is_premium = null; $this->plan_name = __( 'Robin image optimizer Premium', 'robin-image-optimizer' ); // Initialize subscribe widget. $this->subscribe_widget = new WRIO_Subscribe_Widget(); add_action( 'admin_menu', [ $this, 'register_page' ], 9 ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); add_action( 'wp_ajax_wrio_license_action', [ $this, 'ajax_handler' ] ); // Register this page in the Factory navigation menu $this->register_in_factory_menu(); } /** * Register this page in the Factory impressive menu system * * This allows the license page to appear in the left navigation bar * alongside other Factory-registered pages. * * @return void */ private function register_in_factory_menu() { global $factory_impressive_page_menu; $page_url = admin_url( 'admin.php?page=' . $this->id ); $factory_impressive_page_menu['robin-image-optimizer'][ $this->id ] = [ 'type' => 'page', 'url' => $page_url, 'title' => __( 'License', 'robin-image-optimizer' ) . ' ', 'short_description' => __( 'Product activation', 'robin-image-optimizer' ), 'position' => 10, 'parent' => 'rio_general', ]; } /** * Initialize premium data * * Called late to ensure WRIO_Plugin is available. * * @return void */ private function init_premium() { if ( null !== $this->premium ) { return; } /** * Initializes the premium provider instance. * * @var WRIO_Premium_Provider $premium */ $premium = WRIO_Plugin::app()->premium; $this->premium = $premium; /** * Gets the license instance from premium provider. * * @var WRIO_License $license */ $license = $premium->get_license(); $this->license = $license; $this->is_premium = $premium->is_activate(); } /** * Register the admin page * * @return void */ public function register_page() { // Parent slug follows Factory pattern: {page_id}-{plugin_name} $parent_slug = 'rio_general-robin-image-optimizer'; $this->page_hook = add_submenu_page( $parent_slug, __( 'License', 'robin-image-optimizer' ), __( 'License', 'robin-image-optimizer' ), 'manage_options', $this->id, [ $this, 'render_page' ], 90 // Position before About Us (which uses 100) ); } /** * Enqueue page assets * * @param string $hook Current admin page hook. * @return void */ public function enqueue_assets( $hook ) { if ( $this->page_hook !== $hook ) { return; } wp_enqueue_script( 'wrio-license-manager', WRIO_PLUGIN_URL . '/admin/assets/js/wrio-license-manager.js', [ 'jquery' ], WRIO_Plugin::app()->getPluginVersion(), true ); // Enqueue the Factory bootstrap core CSS (provides .btn, .form-control, etc.) wp_enqueue_style( 'wrio-bootstrap-core', WRIO_PLUGIN_URL . '/libs/factory/bootstrap/assets/css-min/bootstrap.core.min.css', [], WRIO_Plugin::app()->getPluginVersion() ); // Enqueue the license manager CSS from Factory templates wp_enqueue_style( 'wrio-license-manager', WRIO_PLUGIN_URL . '/libs/factory/templates/assets/css/license-manager.css', [ 'wrio-bootstrap-core' ], WRIO_Plugin::app()->getPluginVersion() ); // Enqueue the impressive page template CSS for full layout wp_enqueue_style( 'wrio-impressive-template', WRIO_PLUGIN_URL . '/libs/factory/templates/pages/templates/impressive/assets/css/impressive.page.template.css', [ 'wrio-bootstrap-core' ], WRIO_Plugin::app()->getPluginVersion() ); // Enqueue subscribe widget CSS. wp_enqueue_style( 'wrio-subscribe-widget', WRIO_PLUGIN_URL . '/admin/assets/css/wrio-subscribe-widget.css', [], WRIO_Plugin::app()->getPluginVersion() ); // Hide internal pages from sidebar (Custom Folders, Nextgen Gallery) wp_add_inline_style( 'wrio-impressive-template', '#io_folders_statistic-robin-image-optimizer-tab, #io_nextgen_gallery_statistic-robin-image-optimizer-tab { display: none !important; }' ); } /** * Handle AJAX license actions * * @return void */ public function ajax_handler() { // Verify nonce if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wrio_license_action' ) ) { wp_send_json_error( [ 'message' => __( 'Security check failed.', 'robin-image-optimizer' ) ] ); } // Check capabilities if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'message' => __( 'You do not have permission to perform this action.', 'robin-image-optimizer' ) ] ); } $this->init_premium(); $action = isset( $_POST['license_action'] ) ? sanitize_text_field( wp_unslash( $_POST['license_action'] ) ) : ''; $license_key = isset( $_POST['licensekey'] ) ? trim( wp_unslash( $_POST['licensekey'] ) ) : ''; $allowed_actions = [ 'activate', 'deactivate', 'unsubscribe' ]; if ( empty( $action ) || ! in_array( $action, $allowed_actions, true ) ) { wp_send_json_error( [ 'message' => __( 'Invalid action.', 'robin-image-optimizer' ) ] ); } try { switch ( $action ) { case 'activate': if ( empty( $license_key ) ) { wp_send_json_error( [ 'message' => __( 'Please enter a license key.', 'robin-image-optimizer' ) ] ); } $this->premium->activate( $license_key ); $message = __( 'Your license has been successfully activated.', 'robin-image-optimizer' ); break; case 'deactivate': $this->premium->deactivate(); $message = __( 'Your license has been deactivated.', 'robin-image-optimizer' ); break; case 'unsubscribe': $this->premium->cancel_paid_subscription(); $message = __( 'Your subscription has been cancelled.', 'robin-image-optimizer' ); break; default: wp_send_json_error( [ 'message' => __( 'Unknown action.', 'robin-image-optimizer' ) ] ); } wp_send_json_success( [ 'message' => $message ] ); } catch ( Exception $e ) { wp_send_json_error( [ 'message' => $e->getMessage() ] ); } } /** * Render the admin page * * @return void */ public function render_page() { $this->init_premium(); $min_height = $this->calculate_menu_height(); ?>
render_header(); ?>
render_page_menu(); ?>
render_license_form(); ?>

:

getPluginName() ); ?>
id; if ( ! isset( $factory_impressive_page_menu[ $menu_scope ] ) ) { return; } $page_menu = $factory_impressive_page_menu[ $menu_scope ]; // Sort by position (descending - higher position = higher in menu) uasort( $page_menu, function ( $a, $b ) { return $b['position'] <=> $a['position']; } ); ?> is_premium || null === $this->license ) { return 'free'; } if ( $this->license->is_lifetime() ) { return 'gift'; } if ( $this->license->get_expiration_time( 'days' ) < 1 ) { return 'trial'; } return 'paid'; } /** * Get hidden license key (first 8 + last 4 characters) * * @return string */ private function get_hidden_license_key() { if ( ! $this->is_premium || null === $this->license ) { return ''; } return $this->license->get_masked_key(); } /** * Get unified expiration display string * * @return string */ private function get_expiration_display() { if ( ! $this->is_premium || null === $this->license ) { return __( 'N/A', 'robin-image-optimizer' ); } return $this->license->get_expiration_display(); } /** * Render the license form * * @return void */ private function render_license_form() { $license_type = $this->get_license_type(); $plan_title = __( 'Free', 'robin-image-optimizer' ); $has_pro = null !== $this->premium && null !== $this->premium->get_plan_id(); if ( $has_pro ) { $plan_title = __( 'Pro', 'robin-image-optimizer' ); } $license_status_label = __( 'License', 'robin-image-optimizer' ); ?>
render_upgrade_banner(); ?>

is_premium ) : ?> get_expiration_display() ); ?>

is_premium ) : ?>

is_premium ) : ?>
render_learnmore_section(); ?>
render_freemius_migration_notice(); ?>
subscribe_widget->render(); ?>
get_support(); $pricing_url = $support->get_pricing_url( true, 'license_banner' ); ?>

get_support(); if ( ! $this->is_premium ) : ?>

[ 'href' => [], 'target' => [], 'rel' => [], ], ] ), '', '' ); ?>

is_premium || null === $this->license || $this->license->get_source() !== WRIO_License::SOURCE_FREEMIUS ) { return; } ?>