load_dependencies(); $this->init_hooks(); } /** * Load required files */ private function load_dependencies() { require_once WP108_CP_PLUGIN_DIR . 'includes/class-router.php'; require_once WP108_CP_PLUGIN_DIR . 'includes/class-admin-controller.php'; } /** * Initialize WordPress hooks */ private function init_hooks() { // Activation/Deactivation register_activation_hook(__FILE__, array($this, 'activate')); register_deactivation_hook(__FILE__, array($this, 'deactivate')); // Admin menu add_action('admin_menu', array($this, 'add_admin_menu')); // Enqueue scripts add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); add_action('wp_enqueue_scripts', array($this, 'enqueue_frontend_scripts')); // AJAX Handlers (Lite - minimal) add_action('wp_ajax_wp108_cp_save_human_settings', array($this, 'ajax_save_human_settings')); add_action('wp_ajax_wp108_cp_get_human_settings', array($this, 'ajax_get_human_settings')); // Load text domain implicitly handled by WordPress since 4.6 // Admin notices for lite version add_action('admin_notices', array($this, 'show_upgrade_notice')); } /** * Plugin activation */ public function activate() { // Set default options - ALL human protection features available in Lite! $defaults = array( 'disable_right_click' => false, 'disable_left_click' => false, 'disable_text_selection' => false, 'disable_copy' => false, 'disable_cut' => false, 'disable_paste' => false, 'disable_print' => false, 'disable_save' => false, 'disable_view_source' => false, 'disable_reader_mode' => false, 'disable_f12' => false, 'disable_ctrl_u' => false, 'disable_ctrl_shift_i' => false, 'disable_ctrl_shift_j' => false, 'disable_ctrl_shift_c' => false, 'disable_image_dragging' => false, 'disable_select_all' => false, 'disable_developer_tools' => false, ); add_option('wp108_cp_options', $defaults); add_option('wp108_cp_version', WP108_CP_VERSION); // Mark as lite version add_option('wp108_cp_is_lite', true); } /** * Plugin deactivation */ public function deactivate() { // Cleanup if needed } /** * Add admin menu */ public function add_admin_menu() { add_menu_page( __('108WP Content Protector Lite', '108wp-content-protector-lite'), __('108WP Protector Lite', '108wp-content-protector-lite'), 'manage_options', '108wp-content-protector-lite', array($this, 'render_admin_page'), 'dashicons-shield', 30 ); } /** * Render admin page */ public function render_admin_page() { $controller = new WP108_CP_Admin_Controller(); $controller->render(); } /** * Enqueue admin scripts */ public function enqueue_admin_scripts($hook) { // Only load on our plugin page if ('toplevel_page_108wp-content-protector-lite' !== $hook) { return; } // Enqueue admin CSS wp_enqueue_style( 'wp108-cp-admin-css', WP108_CP_PLUGIN_URL . 'assets/css/admin.css', array(), WP108_CP_VERSION ); // Enqueue admin JS wp_enqueue_script( 'wp108-cp-admin-js', WP108_CP_PLUGIN_URL . 'assets/js/admin.js', array('jquery'), WP108_CP_VERSION, true ); // Localize script wp_localize_script('wp108-cp-admin-js', 'wp108Admin', array( 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('wp108_cp_nonce'), 'pageUrl' => admin_url('admin.php?page=108wp-content-protector-lite'), 'buyUrl' => WP108_CP_BUY_URL, 'isLite' => true, )); } /** * Enqueue frontend scripts */ public function enqueue_frontend_scripts() { // Don't load on admin pages if (is_admin()) { return; } // Get enabled settings (ALL features available in Lite) $options = get_option('wp108_cp_options', array()); // Check if any protection is enabled $has_protection = false; $enabled_protections = array(); foreach ($options as $key => $value) { if ($value) { $has_protection = true; $enabled_protections[$key] = true; } } if (!$has_protection) { return; // No protections enabled } // Enqueue frontend JS wp_enqueue_script( 'wp108-cp-frontend-js', WP108_CP_PLUGIN_URL . 'assets/js/frontend.js', array('jquery'), WP108_CP_VERSION, true ); // Pass settings to frontend wp_localize_script('wp108-cp-frontend-js', 'wp108Settings', array( 'protections' => $enabled_protections, 'customMessage' => __('Content protection is active on this site.', '108wp-content-protector-lite'), )); } /** * AJAX: Save human protection settings (Lite - ALL human features free!) */ public function ajax_save_human_settings() { check_ajax_referer('wp108_cp_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_error(__('Unauthorized', '108wp-content-protector-lite')); return; } $settings = isset($_POST['settings']) ? json_decode(stripslashes($_POST['settings']), true) : array(); // In Lite, ALL human protection features are available! $allowed = array( 'disable_right_click', 'disable_left_click', 'disable_text_selection', 'disable_copy', 'disable_cut', 'disable_paste', 'disable_print', 'disable_save', 'disable_view_source', 'disable_reader_mode', 'disable_f12', 'disable_ctrl_u', 'disable_ctrl_shift_i', 'disable_ctrl_shift_j', 'disable_ctrl_shift_c', 'disable_image_dragging', 'disable_select_all', 'disable_developer_tools', ); $sanitized = array(); foreach ($allowed as $key) { $sanitized[$key] = isset($settings[$key]) ? (bool) $settings[$key] : false; } update_option('wp108_cp_options', $sanitized); wp_send_json_success(array('message' => __('Protection settings saved!', '108wp-content-protector-lite'))); } /** * AJAX: Get human protection settings */ public function ajax_get_human_settings() { check_ajax_referer('wp108_cp_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_error(__('Unauthorized', '108wp-content-protector-lite')); return; } $options = get_option('wp108_cp_options', array()); wp_send_json_success($options); } /** * Show upgrade notice */ public function show_upgrade_notice() { $screen = get_current_screen(); if ($screen && $screen->id === 'toplevel_page_108wp-content-protector-lite') { ?>

-