id === 'adblock-guard_page_ad_block_guard_demo_page') { if (!current_user_can('manage_options')) { return; } $is_overlay = isset($_GET['overlay']) && $_GET['overlay'] == '1'; if ($is_overlay) { if ( isset($_GET['ad_block_guard_demo_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['ad_block_guard_demo_nonce'])), 'ad_block_guard_demo_action') ) { // Nonce is valid, enqueue the CSS wp_enqueue_style( 'demo-overlay-admin-css', AD_BLOCK_GUARD_PLUGIN_URL . 'assets/css/admin-demo-overlay.css', [], AD_BLOCK_GUARD_VERSION ); } else { wp_die(esc_html__('Nonce verification failed. Please try again.', 'ad-block-guard')); } } } } function edd_sample_license_page() { add_settings_section( 'edd_sample_license', __( 'Plugin License', 'ad-block-guard' ), 'edd_sample_license_key_settings_section', EDD_SAMPLE_PLUGIN_LICENSE_PAGE ); add_settings_field( 'edd_sample_license_key', '', 'edd_sample_license_key_settings_field', EDD_SAMPLE_PLUGIN_LICENSE_PAGE, 'edd_sample_license', ); ?>

render_overlay_demo_page(); } // Add other submenu callback functions as needed... public function system_review_page_callback() { include AD_BLOCK_GUARD_PLUGIN_DIR . 'templates/admin/system-review-page.php'; } public function help_page_callback() { include AD_BLOCK_GUARD_PLUGIN_DIR . 'templates/admin/help-page.php'; } // Function to render the Overlay Demo Page private function render_overlay_demo_page() { // Check user capabilities if (!current_user_can('manage_options')) { return; } // Check if the system is enabled $system_enabled = carbon_get_theme_option('ad_block_guard_enable'); // Check the status of the detection methods $remote_detection_enabled = carbon_get_theme_option('ad_block_guard_remote_detection'); $network_detection_enabled = carbon_get_theme_option('ad_block_guard_network_detection'); $fast_detection_enabled = carbon_get_theme_option('ad_block_guard_fast_detection'); // Display warnings if necessary $this->render_warning_table(!$system_enabled, __('WARNING: You have the system disabled in "General Settings".', 'ad-block-guard')); $this->render_warning_table(!$remote_detection_enabled && !$network_detection_enabled && !$fast_detection_enabled, __('ERROR: All detection methods are disabled. The system will NOT work with all methods disabled.', 'ad-block-guard')); // Get the serialized data from the wp_options table $usergroup_settings = get_option('_ad_block_guard_usergroup_settings', []); // Process overlays into enabled and disabled arrays list($enabled_overlays, $disabled_overlays) = $this->process_overlays($usergroup_settings); echo '
'; echo '

' . esc_html__('Demo Overlay', 'ad-block-guard') . '

'; // Render messages echo '

' . esc_html__('REMINDER: The overlay close button will ALWAYS be available on overlays during demo mode.', 'ad-block-guard') . '

'; // Render the tables $this->render_overlays_table(__('Enabled Overlays', 'ad-block-guard'), $enabled_overlays, true); $this->render_overlays_table(__('Disabled Overlays', 'ad-block-guard'), $disabled_overlays, false); echo '
'; echo '





'; } private function render_warning_table($condition, $message) { if ($condition) { echo '

' . esc_html($message) . '

'; } } private function process_overlays($usergroup_settings) { $enabled_overlays = []; $disabled_overlays = []; if (!empty($usergroup_settings)) { foreach ($usergroup_settings as $group) { if (isset($group['overlay_enabled']) && $group['overlay_enabled']) { $enabled_overlays[] = $group; } else { $disabled_overlays[] = $group; } } } return [$enabled_overlays, $disabled_overlays]; } private function render_overlays_table($title, $overlays, $enabled) { echo '

' . esc_html($title) . '

'; if (empty($overlays)) { $message = $enabled ? __('No enabled overlays found. Please check your settings.', 'ad-block-guard') : __('No disabled overlays', 'ad-block-guard'); $this->render_warning_table(true, esc_html($message)); } else { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($overlays as $overlay) { $this->render_overlay_row($overlay, $enabled); } echo '
' . esc_html__('Edit', 'ad-block-guard') . '' . esc_html__('Role', 'ad-block-guard') . '' . esc_html__('Enabled', 'ad-block-guard') . '' . esc_html__('Theme', 'ad-block-guard') . '' . esc_html__('Can Close', 'ad-block-guard') . '' . esc_html__('Delay', 'ad-block-guard') . '' . esc_html__('Launch', 'ad-block-guard') . '
'; } } private function render_overlay_row($overlay, $enabled) { $usergroup = ucfirst($overlay['usergroup']); $link = add_query_arg( 'tab', urlencode($usergroup), admin_url('admin.php?page=ad_block_guard_settings') ); $overlay['theme'] = isset($overlay['theme']) ? $overlay['theme'] : 'Compact'; echo ''; echo '' . ' '; echo '' . esc_html($usergroup) . ''; echo ''; echo '' . esc_html($enabled ? __('Yes', 'ad-block-guard') : __('No', 'ad-block-guard')) . ''; echo ''; echo '' . esc_html($overlay['theme']) . ''; echo '' . esc_html($overlay['allow_close'] ? __('Yes', 'ad-block-guard') : __('No', 'ad-block-guard')) . ''; echo '' . esc_html($overlay['overlay_delay']) . 's'; echo ''; echo '
'; wp_nonce_field('ad_block_guard_demo_action', 'ad_block_guard_demo_nonce'); echo ''; echo ''; echo ''; echo '
'; echo ''; echo ''; } }