Files

1 line
7.5 KiB
JSON

{"repo": "behraoui/aicontentpro", "files": {"autocontent-ai-pro.php": {"8f3e78ae28b546bf654b633b9d348036db459dde": {"t": 1785745766.3453314, "n": 7255, "h": "79a8cac6123d74eb", "c": "<?php\n/**\n * Plugin Name: AutoContent AI Pro\n * Plugin URI: https://example.com/autocontent-ai-pro\n * Description: Automatically generate SEO-optimized articles using OpenRouter API with RankMath integration\n * Version: 1.0.0\n * Author: AutoContent AI Pro\n * License: GPL v2 or later\n * Text Domain: autocontent-ai-pro\n */\n\n// Prevent direct access\nif (!defined('ABSPATH')) {\n exit;\n}\n\n// Define plugin constants\ndefine('AUTOCONTENT_AI_PRO_VERSION', '1.0.0');\ndefine('AUTOCONTENT_AI_PRO_PLUGIN_URL', plugin_dir_url(__FILE__));\ndefine('AUTOCONTENT_AI_PRO_PLUGIN_PATH', plugin_dir_path(__FILE__));\n\n// Main plugin class\nclass AutoContentAIPro {\n \n private static $instance = null;\n \n public static function get_instance() {\n if (null === self::$instance) {\n self::$instance = new self();\n }\n return self::$instance;\n }\n \n private function __construct() {\n add_action('plugins_loaded', array($this, 'init'));\n register_activation_hook(__FILE__, array($this, 'activate'));\n register_deactivation_hook(__FILE__, array($this, 'deactivate'));\n }\n \n public function init() {\n // Load plugin textdomain\n load_plugin_textdomain('autocontent-ai-pro', false, dirname(plugin_basename(__FILE__)) . '/languages');\n \n // Include required files\n $this->include_files();\n \n // Initialize components\n $this->init_components();\n }\n \n private function include_files() {\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'includes/class-openrouter-api.php';\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'includes/class-content-generator.php';\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'includes/class-image-handler.php';\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'includes/class-seo-optimizer.php';\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'includes/class-logger.php';\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'admin/class-admin.php';\n require_once AUTOCONTENT_AI_PRO_PLUGIN_PATH . 'admin/class-settings.php';\n }\n \n private function init_components() {\n // Initialize admin interface\n if (is_admin()) {\n new AutoContentAIPro_Admin();\n new AutoContentAIPro_Settings();\n }\n \n // Initialize AJAX handlers\n add_action('wp_ajax_generate_content', array($this, 'ajax_generate_content'));\n add_action('wp_ajax_batch_generate_content', array($this, 'ajax_batch_generate_content'));\n add_action('wp_ajax_test_api_connection', array($this, 'ajax_test_api_connection'));\n add_action('wp_ajax_check_api_status', array($this, 'ajax_check_api_status'));\n }\n \n public function activate() {\n // Create database tables if needed\n $this->create_tables();\n \n // Set default options\n $this->set_default_options();\n \n // Flush rewrite rules\n flush_rewrite_rules();\n }\n \n public function deactivate() {\n // Clean up scheduled events\n wp_clear_scheduled_hook('autocontent_ai_pro_cleanup');\n }\n \n private function create_tables() {\n global $wpdb;\n \n $table_name = $wpdb->prefix . 'autocontent_ai_pro_logs';\n \n $charset_collate = $wpdb->get_charset_collate();\n \n $sql = \"CREATE TABLE $table_name (\n id mediumint(9) NOT NULL AUTO_INCREMENT,\n timestamp datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,\n action varchar(100) NOT NULL,\n message text NOT NULL,\n data longtext,\n status varchar(20) NOT NULL,\n PRIMARY KEY (id)\n ) $charset_collate;\";\n \n require_once(ABSPATH . 'wp-admin/includes/upgrade.php');\n dbDelta($sql);\n }\n \n private function set_default_options() {\n $default_options = array(\n 'openrouter_api_key' => '',\n 'openai_api_key' => '',\n 'claude_api_key' => '',\n 'deepseek_api_key' => '',\n 'default_model' => 'gpt-4',\n 'default_publish_status' => 'draft',\n 'enable_images' => 1,\n 'enable_seo' => 1,\n 'internal_links_count' => 2,\n 'external_links_count' => 3\n );\n \n foreach ($default_options as $option => $value) {\n if (!get_option('autocontent_ai_pro_' . $option)) {\n add_option('autocontent_ai_pro_' . $option, $value);\n }\n }\n }\n \n public function ajax_generate_content() {\n check_ajax_referer('autocontent_ai_pro_nonce', 'nonce');\n \n if (!current_user_can('edit_posts')) {\n wp_die(__('You do not have sufficient permissions to access this page.'));\n }\n \n $topic = sanitize_text_field($_POST['topic']);\n $focus_keyword = sanitize_text_field($_POST['focus_keyword']);\n $publish_status = sanitize_text_field($_POST['publish_status']);\n \n $generator = new AutoContentAIPro_ContentGenerator();\n $result = $generator->generate_single_article($topic, $focus_keyword, $publish_status);\n \n wp_send_json($result);\n }\n \n public function ajax_batch_generate_content() {\n check_ajax_referer('autocontent_ai_pro_nonce', 'nonce');\n \n if (!current_user_can('edit_posts')) {\n wp_die(__('You do not have sufficient permissions to access this page.'));\n }\n \n $keywords = array_map('sanitize_text_field', $_POST['keywords']);\n $publish_status = sanitize_text_field($_POST['publish_status']);\n \n $generator = new AutoContentAIPro_ContentGenerator();\n $results = array();\n \n foreach ($keywords as $keyword) {\n $result = $generator->generate_single_article($keyword, $keyword, $publish_status);\n $results[] = $result;\n }\n \n wp_send_json($results);\n }\n \n public function ajax_test_api_connection() {\n check_ajax_referer('autocontent_ai_pro_nonce', 'nonce');\n \n if (!current_user_can('manage_options')) {\n wp_die(__('You do not have sufficient permissions to access this page.'));\n }\n \n $api = new AutoContentAIPro_OpenRouterAPI();\n $result = $api->test_connection();\n \n wp_send_json($result);\n }\n \n public function ajax_check_api_status() {\n check_ajax_referer('autocontent_ai_pro_nonce', 'nonce');\n \n if (!current_user_can('manage_options')) {\n wp_die(__('You do not have sufficient permissions to access this page.'));\n }\n \n $status = array(\n 'openrouter_configured' => !empty(get_option('autocontent_ai_pro_openrouter_api_key', '')),\n 'openai_configured' => !empty(get_option('autocontent_ai_pro_openai_api_key', '')),\n 'claude_configured' => !empty(get_option('autocontent_ai_pro_claude_api_key', '')),\n 'deepseek_configured' => !empty(get_option('autocontent_ai_pro_deepseek_api_key', ''))\n );\n \n wp_send_json($status);\n }\n}\n\n// Initialize the plugin\nAutoContentAIPro::get_instance();\n"}}}}