get_col_charset($wpdb->options, 'option_value'); } $is_utf8mb4 = ($charset_result === 'utf8mb4'); echo '
'; echo '

' . esc_html__('System Check', 'ad-block-guard') . '

'; /** * ============================================= * "System Settings" * ============================================= */ echo '

' . esc_html__('AdBlock Guard Settings', 'ad-block-guard') . '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // Row for adblock enabled echo ''; echo ''; echo ''; if ($adblockguard_enable) { echo ''; } else { echo ''; } echo ''; // Row for detection enabled echo ''; echo ''; echo ''; if ($adblockguard_enable && $has_detection) { echo ''; } else { $error_message = !$adblockguard_enable ? __('AdBlock Guard System is globally disabled in the detection options', 'ad-block-guard') : __('No detection methods are enabled. At least one detection method must be selected', 'ad-block-guard'); echo ''; } echo ''; // Row for overlays enabled echo ''; echo ''; echo ''; if (count($overlays_enabled) > 0) { echo ''; } else { echo ''; } echo ''; echo ''; echo '
' . esc_html__('Check', 'ad-block-guard') . '' . esc_html__('Status', 'ad-block-guard') . '' . esc_html__('Message', 'ad-block-guard') . '
' . esc_html__('AdBlock system enabled', 'ad-block-guard') . ''; if ($adblockguard_enable) { echo '' . esc_html__('Yes', 'ad-block-guard') . ''; } else { echo '' . esc_html__('No', 'ad-block-guard') . ''; } echo '' . esc_html__('Passed', 'ad-block-guard') . '' . esc_html__('AdBlock Guard System is globally disabled in the detection options', 'ad-block-guard') . '
' . esc_html__('AdBlock detection enabled', 'ad-block-guard') . ''; // Check if at least one detection method is enabled $has_detection = ( !empty(get_option('_wuadblockguard_fast_detection')) || !empty(get_option('_wuadblockguard_custom_load_js_enable')) || !empty(get_option('_wuadblockguard_network_detection')) || !empty(get_option('_wuadblockguard_remote_detection')) ); if ($adblockguard_enable && $has_detection) { echo '' . esc_html__('Yes', 'ad-block-guard') . ''; } else { echo '' . esc_html__('No', 'ad-block-guard') . ''; } echo '' . esc_html__('Passed', 'ad-block-guard') . '' . esc_html($error_message) . '
' . esc_html__('Overlays enabled', 'ad-block-guard') . ''; if (count($overlays_enabled) > 0) { foreach ($overlays_enabled as $usergroup) { echo '' . esc_html($usergroup) . ''; } } else { echo '' . esc_html__('No', 'ad-block-guard') . ''; } echo '' . esc_html__('Passed', 'ad-block-guard') . '' . esc_html__('AdBlock Guard System has zero overlays enabled', 'ad-block-guard') . '
'; /** * ============================================= * "PHP Settings" TABLE (with table-width) * ============================================= */ echo '

' . esc_html__('PHP Settings', 'ad-block-guard') . '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // Row for charset echo ''; echo ''; echo ''; if ($is_utf8mb4) { echo ''; } else { echo ''; } echo ''; echo ''; echo '
' . esc_html__('Check', 'ad-block-guard') . '' . esc_html__('Status', 'ad-block-guard') . '' . esc_html__('Message', 'ad-block-guard') . '
' . esc_html__('charset is utf8mb4', 'ad-block-guard') . ''; if ($is_utf8mb4) { echo '' . esc_html__('Yes', 'ad-block-guard') . ''; } else { echo '' . esc_html__('No', 'ad-block-guard') . ''; } echo '' . esc_html__('Passed', 'ad-block-guard') . '' . esc_html__('Requires attention', 'ad-block-guard') . '
'; /** * ============================================================= * "WP Rocket - Cache System" TABLE (only if WP_ROCKET_VERSION) * ============================================================= */ if (defined('WP_ROCKET_VERSION')) { $wp_rocket_settings = get_option('wp_rocket_settings', []); $conflicting_settings = [ //'minify_concatenate_js' => 'The "Combine JavaScript files" option is not compatible and must be deactivated.', 'manual_preload' => 'The "Activate Preloading" option is enabled in WP Rocket. Your pages are automatically cached. Please ensure you clear caches if you make changes to display or exclusions.', 'defer_all_js' => 'The "Defer All JavaScript files" option creates processing delays for the AdBlock overlay. If these delays are unsatisfactory please disable this option in WP Rocket.', 'delay_js' => 'The "Delay JavaScript" option is enabled in WP Rocket and will cause significant overlay loading delays. If these delays are unsatisfactory please disable this option in WP Rocket.', ]; echo '

' . esc_html__('WP Rocket - Cache System', 'ad-block-guard') . '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($conflicting_settings as $setting_key => $message) { $is_disabled = empty($wp_rocket_settings[$setting_key]); echo ''; echo ''; echo ''; if ($is_disabled) { echo ''; } else { echo ''; } echo ''; } echo ''; echo '
' . esc_html__('Setting', 'ad-block-guard') . '' . esc_html__('Disabled?', 'ad-block-guard') . '' . esc_html__('Message', 'ad-block-guard') . '
' . esc_html($setting_key) . ''; if ($is_disabled) { echo '' . esc_html__('Yes', 'ad-block-guard') . ''; } else { echo '' . esc_html__('Warning', 'ad-block-guard') . ''; } echo 'Passed' . esc_html($message) . '
'; } // ------------------------------------------------------------------ // HANDLE FORM SUBMISSION AND EMAIL // ------------------------------------------------------------------ if ( isset($_POST['adblock_guard_request_nonce']) && wp_verify_nonce( sanitize_text_field(wp_unslash($_POST['adblock_guard_request_nonce'])), 'adblock_guard_request' ) ) { // Sanitize fields $name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : ''; $user_email = isset($_POST['user_email']) ? sanitize_email(wp_unslash($_POST['user_email'])) : ''; $request_type = isset($_POST['request_type']) ? sanitize_text_field(wp_unslash($_POST['request_type'])) : ''; $request_details = isset($_POST['request_details']) ? sanitize_textarea_field(wp_unslash($_POST['request_details'])) : ''; $include_site_info = isset($_POST['include_site_info']) && sanitize_text_field(wp_unslash($_POST['include_site_info'])) === '1'; // Build basic details in the email body $domain = isset($_SERVER['SERVER_NAME']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME'])) : 'unknown-domain'; $subject = "AdBlock Guard Request: {$domain}"; // We'll build an HTML email body $body = '

Name: ' . esc_html($name) . '

'; $body .= '

Email: ' . esc_html($user_email) . '

'; $body .= '

Type of Request: ' . esc_html($request_type) . '

'; if (!empty($request_details)) { // nl2br so line breaks show in HTML $body .= '

Request Details:
' . nl2br(esc_html($request_details)) . '

'; } // If you want to ensure directory sizes are computed: if (!class_exists('\WP_Site_Health')) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; } if (class_exists('\WP_Site_Health')) { $site_health = \WP_Site_Health::get_instance(); if (method_exists($site_health, 'perform_async_tests')) { $site_health->perform_async_tests(); } } // Then fetch the debug data if (!class_exists('\WP_Debug_Data')) { require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php'; } if (class_exists('\WP_Debug_Data')) { // true => include sensitive data in the output $debug_data = \WP_Debug_Data::debug_data(true); // If any data is returned, convert it into an HTML table if (!empty($debug_data) && is_array($debug_data)) { $body .= '

Site Health Debug Info (WP_Debug_Data):

'; $body .= ''; foreach ($debug_data as $section_key => $section) { // Each $section has 'label' and 'fields' keys $section_label = !empty($section['label']) ? $section['label'] : ucfirst($section_key); $body .= ''; // The 'fields' array typically contains key => value if (!empty($section['fields']) && is_array($section['fields'])) { foreach ($section['fields'] as $field_key => $field) { $field_label = $field['label'] ?? $field_key; $field_value = is_array($field['value']) || is_object($field['value']) ? wp_json_encode($field['value'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $field['value']; $field_value = is_string($field_value) ? $field_value : ''; // Escape or format as needed $body .= ''; $body .= ''; $body .= ''; $body .= ''; } } } $body .= '
' . esc_html($section_label) . '
' . esc_html($field_label) . '' . nl2br(esc_html($field_value)) . '
'; } else { $body .= '

No debug data found or site health is not available.

'; } } else { $body .= '

No \WP_Debug_Data data not found or site health is not available.

'; } // Path to your plugin's log file $log_path = ADBLOCKGUARD_PLUGIN_DIR . 'ad-block-guard.log'; // Build attachments array $attachments = array(); // If the log exists, load the last 5k lines & store in a temp file if (file_exists($log_path)) { $log_tail = self::get_last_lines($log_path, 5000); if ($log_tail) { // Build a custom-named temp file in system temp directory $timestamp = time(); $named_tmp = sys_get_temp_dir() . "/ad-block-guard-tail-{$timestamp}.log"; // Write the tail file_put_contents($named_tmp, $log_tail); // Add to attachments $attachments[] = $named_tmp; } } // Prepare HTML headers for wp_mail $headers = ['Content-Type: text/html; charset=UTF-8']; // Attempt to send $sent = wp_mail(ADBLOCKGUARD_EMAIL, $subject, $body, $headers, $attachments); // Clean up the temp file(s) if ($sent && !empty($attachments)) { foreach ($attachments as $tmp_file) { wp_delete_file($tmp_file); } } if ($sent) { echo '

'; esc_html_e('Your request has been sent successfully!', 'ad-block-guard'); echo '

'; } else { /* translators: %s: Support email link. */ $email_notice = sprintf( /* translators: %s: Support email link. */ __('Unable to send email! Contact %s directly.', 'ad-block-guard'), '' . esc_html(ADBLOCKGUARD_EMAIL) . '' ); echo '

'; echo wp_kses($email_notice, ['a' => ['href' => []]]); echo '

'; } } // ------------------------------------------------------------------ // DISPLAY THE FORM (ONLY ONCE) // ------------------------------------------------------------------ $current_user = wp_get_current_user(); $default_email = $current_user ? $current_user->user_email : ''; ?>



'; // end wrap } public function enqueue_demo_overlay_styles($hook_suffix) { $screen = get_current_screen(); if ($screen && $screen->id === 'adblock-guard_page_wuadblockguard_demo_page') { if (!current_user_can('manage_options')) { return; } $overlay = isset($_GET['overlay']) ? sanitize_text_field(wp_unslash($_GET['overlay'])) : ''; $is_overlay = $overlay === '1'; if ($is_overlay) { if ( isset($_GET['wuadblockguard_demo_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['wuadblockguard_demo_nonce'])), 'wuadblockguard_demo_action') ) { wp_enqueue_style( 'demo-overlay-admin-css', ADBLOCKGUARD_PLUGIN_URL . 'assets/css/admin-demo-overlay.css', [], ADBLOCKGUARD_VERSION ); } else { wp_die(esc_html__('Nonce verification failed. Please try again.', 'ad-block-guard')); } } } } public function license_key_page_callback() { if (!current_user_can('manage_options')) { return; } include ADBLOCKGUARD_PLUGIN_DIR . 'templates/admin/license-key-page.php'; } public function demo_page_callback() { $this->render_overlay_demo_page(); } private function render_overlay_demo_page() { if (!current_user_can('manage_options')) { return; } $system_enabled = carbon_get_theme_option('wuadblockguard_enable'); $remote_detection_enabled = carbon_get_theme_option('wuadblockguard_remote_detection'); $network_detection_enabled = carbon_get_theme_option('wuadblockguard_network_detection'); $fast_detection_enabled = carbon_get_theme_option('wuadblockguard_fast_detection'); $usergroup_settings = carbon_get_theme_option('wuadblockguard_usergroup_settings', []); list($enabled_overlays, $disabled_overlays) = $this->process_overlays($usergroup_settings); echo '
'; echo '

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

'; echo '

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

'; echo '
'; $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') : null; if ($message) $this->render_warning_table(true, esc_html($message)); } else { echo '
'; 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') . '
'; echo '
'; } } private function render_overlay_row($overlay, $enabled) { $usergroup = ucfirst($overlay['usergroup']); $link = add_query_arg('tab', urlencode($usergroup), admin_url('admin.php?page=wuadblockguard_settings')); $overlay['theme'] = $overlay['theme'] ?? 'Compact'; echo ''; echo ''; echo '' . esc_html($usergroup) . ''; echo '' . esc_html($enabled ? __('Yes', 'ad-block-guard') : __('No', 'ad-block-guard')) . ''; 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('wuadblockguard_demo_action', 'wuadblockguard_demo_nonce'); echo ''; echo ''; // Add the data-allow-close attribute to the button echo ''; echo '
'; echo ''; echo ''; } /** * Safely read only the last $maxLines lines from a file * and return them as a single string. */ private static function get_last_lines( $file_path, $max_lines = 5000 ) { if ( ! file_exists( $file_path ) ) { return ''; } // Read entire file into array, ignoring newlines // (Simple approach — if your log is extremely large, you might need a more efficient method) $lines = @file( $file_path, FILE_IGNORE_NEW_LINES ); if ( ! is_array( $lines ) ) { return ''; } // Slice the last $max_lines lines $total = count( $lines ); if ( $total > $max_lines ) { $lines = array_slice( $lines, -$max_lines ); } // Re-join into one string return implode( "\n", $lines ); } }