/* * Plugin Name: ScamDetect * Plugin URI: https://example.com/scam-detect * Description: A WordPress plugin for detecting and reporting scams * Version: 1.0.1 * Author: Your Name * Author URI: https://example.com * Text Domain: scam-detect * Domain Path: /languages * License: GPL v2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html */ // Prevent direct access to this file if (!defined('ABSPATH')) { exit; } // Define plugin constants define('SCAM_DETECT_VERSION', '1.0.1'); define('SCAM_DETECT_PLUGIN_DIR', plugin_dir_path(__FILE__)); define('SCAM_DETECT_PLUGIN_URL', plugin_dir_url(__FILE__)); // Include required files require_once SCAM_DETECT_PLUGIN_DIR . 'includes/class-scam-detect.php'; require_once SCAM_DETECT_PLUGIN_DIR . 'includes/class-scam-detect-activator.php'; require_once SCAM_DETECT_PLUGIN_DIR . 'includes/class-scam-detect-deactivator.php'; require_once SCAM_DETECT_PLUGIN_DIR . 'includes/class-scam-detect-api.php'; require_once SCAM_DETECT_PLUGIN_DIR . 'includes/post-types.php'; require_once SCAM_DETECT_PLUGIN_DIR . 'includes/shortcodes.php'; // Register activation and deactivation hooks register_activation_hook(__FILE__, array('ScamDetectActivator', 'activate')); register_deactivation_hook(__FILE__, array('ScamDetectDeactivator', 'deactivate')); // Initialize the plugin function scam_detect_init() { $plugin = new ScamDetect(); $plugin->init(); } add_action('plugins_loaded', 'scam_detect_init'); // Add admin menu function scam_detect_admin_menu() { add_menu_page( __('ScamDetect', 'scam-detect'), __('ScamDetect', 'scam-detect'), 'manage_options', 'scam-detect', 'scam_detect_dashboard_page', 'dashicons-shield', 30 ); add_submenu_page( 'scam-detect', __('Dashboard', 'scam-detect'), __('Dashboard', 'scam-detect'), 'manage_options', 'scam-detect', 'scam_detect_dashboard_page' ); add_submenu_page( 'scam-detect', __('Reports', 'scam-detect'), __('Reports', 'scam-detect'), 'manage_options', 'scam-detect-reports', 'scam_detect_reports_page' ); add_submenu_page( 'scam-detect', __('Statistics', 'scam-detect'), __('Statistics', 'scam-detect'), 'manage_options', 'scam-detect-stats', 'scam_detect_stats_page' ); add_submenu_page( 'scam-detect', __('Settings', 'scam-detect'), __('Settings', 'scam-detect'), 'manage_options', 'scam-detect-settings', 'scam_detect_settings_page' ); } add_action('admin_menu', 'scam_detect_admin_menu'); // Load admin pages function scam_detect_dashboard_page() { require_once SCAM_DETECT_PLUGIN_DIR . 'admin/dashboard-page.php'; } function scam_detect_reports_page() { require_once SCAM_DETECT_PLUGIN_DIR . 'admin/reports-page.php'; } function scam_detect_stats_page() { require_once SCAM_DETECT_PLUGIN_DIR . 'admin/stats-page.php'; } function scam_detect_settings_page() { require_once SCAM_DETECT_PLUGIN_DIR . 'admin/settings-page.php'; } // Enqueue admin scripts and styles function scam_detect_admin_enqueue_scripts($hook) { // Only load on plugin pages if (strpos($hook, 'scam-detect') === false) { return; } wp_enqueue_style( 'scam-detect-admin', SCAM_DETECT_PLUGIN_URL . 'assets/css/admin.css', array(), SCAM_DETECT_VERSION ); wp_enqueue_script( 'scam-detect-admin', SCAM_DETECT_PLUGIN_URL . 'assets/js/admin.js', array('jquery'), SCAM_DETECT_VERSION, true ); wp_localize_script('scam-detect-admin', 'scamDetectAdmin', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('scam_detect_admin'), 'i18n' => array( 'confirmDelete' => __('Are you sure you want to delete this item?', 'scam-detect'), 'confirmBulkAction' => __('Are you sure you want to perform this action?', 'scam-detect'), 'error' => __('An error occurred. Please try again.', 'scam-detect'), 'success' => __('Operation completed successfully.', 'scam-detect') ) )); } add_action('admin_enqueue_scripts', 'scam_detect_admin_enqueue_scripts'); // Enqueue frontend scripts and styles function scam_detect_enqueue_scripts() { wp_enqueue_style( 'scam-detect', SCAM_DETECT_PLUGIN_URL . 'assets/css/public.css', array(), SCAM_DETECT_VERSION ); wp_enqueue_script( 'scam-detect', SCAM_DETECT_PLUGIN_URL . 'assets/js/public.js', array('jquery'), SCAM_DETECT_VERSION, true ); wp_localize_script('scam-detect', 'scamDetect', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('scam_detect_public'), 'i18n' => array( 'checking' => __('Checking...', 'scam-detect'), 'submitting' => __('Submitting...', 'scam-detect'), 'error' => __('An error occurred. Please try again.', 'scam-detect'), 'success' => __('Thank you for your submission.', 'scam-detect') ) )); } add_action('wp_enqueue_scripts', 'scam_detect_enqueue_scripts'); // Add settings link on plugin page function scam_detect_plugin_action_links($links) { $settings_link = sprintf( '%s', esc_url(admin_url('admin.php?page=scam-detect-settings')), esc_html__('Settings', 'scam-detect') ); array_unshift($links, $settings_link); return $links; } add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'scam_detect_plugin_action_links'); // Load plugin textdomain function scam_detect_load_textdomain() { load_plugin_textdomain('scam-detect', false, dirname(plugin_basename(__FILE__)) . '/languages'); } add_action('init', 'scam_detect_load_textdomain'); XML-RPC server accepts POST requests only.