plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles( $hook ) { if ( 'toplevel_page_ai-post-summarizer-lite' !== $hook && 'ai-summarizer_page_aips-lite-our-plugins' !== $hook ) { return; } // Use the same CSS file name structure but in the lite directory wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/ai-post-summarizer-lite-admin.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 * @param string $hook The current admin page. */ public function enqueue_scripts( $hook ) { if ( 'toplevel_page_ai-post-summarizer-lite' !== $hook && 'ai-summarizer_page_aips-lite-our-plugins' !== $hook ) { return; } // Use the same JS file name structure but in the lite directory. wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/ai-post-summarizer-lite-admin.js', array( 'jquery', 'updates' ), $this->version, true ); // Pass options to JS. $saved_options = get_option( 'aips_lite_options', array() ); wp_localize_script( $this->plugin_name, 'aips_admin_data', array( 'options' => $saved_options, 'is_lite' => true, // Flag for JS to know it's Lite. ) ); // Toast Notification - Handle via inline script to ensure it triggers correctly. // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['settings-updated'] ) && 'true' === $_GET['settings-updated'] ) { $toast_script = ' jQuery(document).ready(function($) { var toast = $("#aips-admin-toast"); if (toast.length) { toast.css("display", "flex"); setTimeout(function() { toast.addClass("show"); }, 100); setTimeout(function() { toast.removeClass("show"); }, 3000); } }); '; wp_add_inline_script( $this->plugin_name, $toast_script ); // Clean URL history. $clean_url_script = ' if (window.history.replaceState) { var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search.replace(/&?settings-updated=[^&]+/, ""); window.history.replaceState({path: newUrl}, "", newUrl); } '; wp_add_inline_script( $this->plugin_name, $clean_url_script ); } } /** * Enqueue scripts and styles for admin notices on Dashboard and Plugins pages. * * @since 1.0.0 * @param string $hook The current admin page hook. */ public function enqueue_notice_scripts( $hook ) { // Only enqueue on Dashboard (index.php) and Plugins (plugins.php). if ( ! in_array( $hook, array( 'index.php', 'plugins.php' ), true ) ) { return; } // Enqueue CSS for notice styling. wp_enqueue_style( $this->plugin_name . '-notice', plugin_dir_url( __FILE__ ) . 'css/ai-post-summarizer-lite-admin.css', array(), $this->version, 'all' ); // Enqueue JS for notice interactions. wp_enqueue_script( $this->plugin_name . '-notice', plugin_dir_url( __FILE__ ) . 'js/ai-post-summarizer-lite-admin.js', array( 'jquery' ), $this->version, true ); // Pass nonce to JS for AJAX requests. wp_localize_script( $this->plugin_name . '-notice', 'aips_notice_data', array( 'nonce' => wp_create_nonce( 'aips_lite_dismiss_notice_nonce' ), ) ); } /** * Register the administration menu. * * @since 1.0.0 */ public function add_plugin_admin_menu() { // Sparkles icon as data URI (Same as Pro) $icon_svg = 'data:image/svg+xml;base64,' . base64_encode( '' ); add_menu_page( 'AI Post Summarizer Lite for WordPress', 'AI Summarizer', 'manage_options', 'ai-post-summarizer-lite', array( $this, 'display_plugin_setup_page' ), $icon_svg, 6 ); add_submenu_page( 'ai-post-summarizer-lite', 'Our Plugins', '' . __( 'Our Plugins', 'ai-post-summarizer-lite' ) . '', 'manage_options', 'aips-lite-our-plugins', array( $this, 'display_our_plugins_page' ) ); } /** * Add settings link to plugin row. * * @since 1.0.0 */ public function add_plugin_action_links( $links ) { $settings_link = '' . __( 'Settings', 'ai-post-summarizer-lite' ) . ''; array_unshift( $links, $settings_link ); $links['go_pro'] = '' . __( 'Upgrade to Pro', 'ai-post-summarizer-lite' ) . ''; return $links; } /** * Modify plugin row meta links. * * @since 1.0.0 */ public function modify_plugin_row_meta( $links, $file ) { if ( strpos( $file, 'ai-post-summarizer-lite.php' ) !== false ) { foreach ( $links as $key => $link ) { if ( strpos( $link, 'Visit plugin site' ) !== false ) { $links[ $key ] = str_replace( 'Visit plugin site', __( 'View details', 'ai-post-summarizer-lite' ), $link ); } } // Add rate link after View details $links[] = '' . __( 'Rate Us ★★★★★', 'ai-post-summarizer-lite' ) . ''; } return $links; } /** * Display the review notice. * * @since 1.0.0 */ public function display_review_notice() { // Only show on Dashboard and Plugins page (NOT on settings page) $screen = get_current_screen(); if ( ! $screen || ! in_array( $screen->id, array( 'dashboard', 'plugins' ), true ) ) { return; } $user_id = get_current_user_id(); $dismissed_until = get_user_meta( $user_id, 'aips_lite_review_notice_dismissed', true ); // Check if dismissed (unless forced via URL) // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $_GET['aips_force_notice'] ) && $dismissed_until && time() < $dismissed_until ) { return; } ?>
id, array( 'dashboard', 'plugins' ), true ) ) { return; } $user_id = get_current_user_id(); $dismissed_until = get_user_meta( $user_id, 'aips_lite_pro_notice_dismissed', true ); // Check if dismissed if ( $dismissed_until && time() < $dismissed_until ) { return; } $pro_url = 'https://rsabbir.gumroad.com/l/ai-post-summarizer'; ?>

Version version ); ?>
render_general_tab( $options ); ?>
array( $this, 'sanitize_options' ), ) ); } /** * Display admin notices including our toast trigger. * * @since 1.0.0 */ public function display_admin_notices() { // Show review notice $this->display_review_notice(); // Show Pro promotion notice $this->display_pro_notice(); // Note: Toast notification is handled by external JS file (ai-post-summarizer-lite-admin.js) // which detects 'settings-updated' URL parameter and shows the toast automatically. } public function sanitize_options( $input ) { $new_input = array(); $existing_options = get_option( 'aips_lite_options', array() ); if ( isset( $input['display_position'] ) ) { $new_input['display_position'] = sanitize_text_field( $input['display_position'] ); } elseif ( isset( $existing_options['display_position'] ) ) { $new_input['display_position'] = $existing_options['display_position']; } if ( isset( $input['button_style'] ) ) { $new_input['button_style'] = sanitize_text_field( $input['button_style'] ); } elseif ( isset( $existing_options['button_style'] ) ) { $new_input['button_style'] = $existing_options['button_style']; } if ( isset( $input['button_size'] ) ) { $new_input['button_size'] = sanitize_text_field( $input['button_size'] ); } elseif ( isset( $existing_options['button_size'] ) ) { $new_input['button_size'] = $existing_options['button_size']; } else { $new_input['button_size'] = 'small'; } // Force ChatGPT and Google AI enabled, others disabled $new_input['platforms'] = array( 'googleai' => array( 'enabled' => true, 'label' => 'Google AI', 'weight' => 0, ), 'chatgpt' => array( 'enabled' => true, 'label' => 'ChatGPT', 'weight' => 1, ), 'gemini' => array( 'enabled' => false, 'label' => 'Gemini', 'weight' => 2, ), 'perplexity' => array( 'enabled' => false, 'label' => 'Perplexity', 'weight' => 3, ), 'claude' => array( 'enabled' => false, 'label' => 'Claude', 'weight' => 4, ), 'grok' => array( 'enabled' => false, 'label' => 'Grok', 'weight' => 5, ), 'deepseek' => array( 'enabled' => false, 'label' => 'DeepSeek', 'weight' => 6, ), ); // Floating button settings — fully functional in Lite. $new_input['floating_button_enabled'] = isset( $input['floating_button_enabled'] ) && '1' === $input['floating_button_enabled']; $allowed_float_positions = array( 'bottom-right', 'bottom-left' ); $new_input['floating_button_position'] = isset( $input['floating_button_position'] ) && in_array( $input['floating_button_position'], $allowed_float_positions, true ) ? sanitize_key( $input['floating_button_position'] ) : ( isset( $existing_options['floating_button_position'] ) ? $existing_options['floating_button_position'] : 'bottom-right' ); $new_input['floating_widget'] = $new_input['floating_button_enabled']; // backward-compat alias. return $new_input; } public function reset_defaults() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( 'Unauthorized user' ); } check_admin_referer( 'aips_lite_reset_defaults_nonce', 'aips_lite_reset_nonce' ); delete_option( 'aips_lite_options' ); AIPS_Lite_Activator::activate(); // Re-set defaults wp_safe_redirect( admin_url( 'admin.php?page=ai-post-summarizer-lite&settings-updated=true' ) ); exit; } /** * Render the General Settings tab. */ private function render_general_tab( $options ) { $position = isset( $options['display_position'] ) ? $options['display_position'] : 'before'; $style = isset( $options['button_style'] ) ? $options['button_style'] : 'square'; $button_size = isset( $options['button_size'] ) ? $options['button_size'] : 'small'; $floating_btn_enabled = isset( $options['floating_button_enabled'] ) ? (bool) $options['floating_button_enabled'] : false; $floating_btn_position = isset( $options['floating_button_position'] ) ? $options['floating_button_position'] : 'bottom-right'; // Hardcoded platforms for display $platforms = array( 'googleai' => array( 'label' => 'Google AI', 'enabled' => true, 'pro' => false, ), 'chatgpt' => array( 'label' => 'ChatGPT', 'enabled' => true, 'pro' => false, ), 'gemini' => array( 'label' => 'Gemini', 'enabled' => false, 'pro' => true, ), 'perplexity' => array( 'label' => 'Perplexity', 'enabled' => false, 'pro' => true, ), 'claude' => array( 'label' => 'Claude', 'enabled' => false, 'pro' => true, ), 'grok' => array( 'label' => 'Grok', 'enabled' => false, 'pro' => true, ), 'deepseek' => array( 'label' => 'DeepSeek', 'enabled' => false, 'pro' => true, ), ); ?>

$data ) : ?>
>
PRO
get_plugin_status( 'botshield-captcha' ); $geoshield_status = $this->get_plugin_status( 'geoshield-country-restrictions-lite' ); $securegate_status = $this->get_plugin_status( 'securegate-captcha-lite' ); require_once AIPS_LITE_PATH . 'admin/partials/aips-lite-admin-our-plugins.php'; } /** * AJAX handler for activating a plugin. * * @since 1.0.5 */ public function ajax_activate_plugin() { check_ajax_referer( 'aips_lite_plugin_action', 'nonce' ); if ( ! current_user_can( 'activate_plugins' ) ) { wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'ai-post-summarizer-lite' ) ) ); } $slug = isset( $_POST['slug'] ) ? sanitize_key( $_POST['slug'] ) : ''; if ( ! $slug ) { wp_send_json_error( array( 'message' => __( 'Invalid plugin slug.', 'ai-post-summarizer-lite' ) ) ); } // Most plugins have a main file named after the slug // This is a common pattern for the user's plugins $plugin_path = $slug . '/' . $slug . '.php'; // Some exceptions if needed if ( 'geoshield-country-restrictions-lite' === $slug ) { $plugin_path = 'geoshield-country-restrictions-lite/geoshield-country-restrictions-lite.php'; } $result = activate_plugin( $plugin_path ); if ( is_wp_error( $result ) ) { wp_send_json_error( array( 'message' => $result->get_error_message() ) ); } wp_send_json_success( array( 'message' => __( 'Plugin activated.', 'ai-post-summarizer-lite' ) ) ); } }