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 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__('Overlays enabled', 'ad-block-guard') . ''; if (count($overlays_enabled) > 0) { foreach ($overlays_enabled as $usergroup) { echo '' . esc_html__($usergroup, 'ad-block-guard') . ''; } } 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 not compatible and must be deactivated.', 'defer_all_js' => 'The "Defer All JavaScript files" option creates processing delays and must be deactivated.', 'delay_js' => 'The "Delay JavaScript" option creates significant overlay delays and must be deactivated.', ]; 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__('No', 'ad-block-guard') . ''; } echo 'Passed' . esc_html($message) . '
'; } // ------------------------------------------------------------------ // HANDLE FORM SUBMISSION AND EMAIL // ------------------------------------------------------------------ if ( isset($_POST['adblock_guard_request_nonce']) && wp_verify_nonce($_POST['adblock_guard_request_nonce'], 'adblock_guard_request') ) { // Sanitize fields $name = isset($_POST['name']) ? sanitize_text_field($_POST['name']) : ''; $user_email = isset($_POST['user_email']) ? sanitize_email($_POST['user_email']) : ''; $request_type = isset($_POST['request_type']) ? sanitize_text_field($_POST['request_type']) : ''; $request_details = isset($_POST['request_details']) ? sanitize_textarea_field($_POST['request_details']) : ''; $include_site_info = !empty($_POST['include_site_info']); // Build basic details in the email body $domain = $_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']) ? print_r($field['value'], true) : $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 ) { @unlink( $tmp_file ); } } if ($sent) { echo '

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

'; } else { echo '

'; _e( 'Unable to send email! Contact '.ADBLOCKGUARD_EMAIL.' directly.', 'ad-block-guard' ); 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; } $is_overlay = isset($_GET['overlay']) && $_GET['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() { 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'); $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') ); $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 ); } }