| |
| <?php
|
| <?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| add_action( 'wp_head', 'guardedpay_phase1_diagnostic' );
|
|
|
| function guardedpay_phase1_diagnostic() {
|
|
|
| if ( ! is_checkout() || ! current_user_can( 'manage_options' ) ) {
|
| return;
|
| }
|
|
|
| $results = [];
|
|
|
|
|
| $theme = wp_get_theme();
|
| $parent_theme = $theme->parent();
|
|
|
| if ( $parent_theme ) {
|
| $results[] = '✅ CHILD THEME ACTIVE: "' . $theme->get('Name') . '" (parent: "' . $parent_theme->get('Name') . '")';
|
| $results[] = ' → Safe to edit functions.php in: ' . get_stylesheet_directory();
|
| } else {
|
| $results[] = '⚠️ NO CHILD THEME — You are using "' . $theme->get('Name') . '" directly.';
|
| $results[] = ' → DO NOT edit this theme\'s functions.php (updates will overwrite).';
|
| $results[] = ' → Use a Code Snippets plugin instead (WPCode or Code Snippets).';
|
| }
|
|
|
| $results[] = '';
|
|
|
|
|
| $deprecated_strings = [
|
| 'Pay securely with GuardedPay Pro warranty coverage',
|
| 'You will be redirected to complete your payment',
|
| 'Redeem with GuardedPay Pro',
|
| 'I already have a warranty code',
|
| ];
|
|
|
| $results[] = '── DEPRECATED COPY SCAN ──';
|
| $results[] = 'Note: Some strings may be injected via JS after page load.';
|
| $results[] = 'This scan checks PHP-rendered output only.';
|
| $results[] = 'Check browser DevTools (Ctrl+F) on checkout for JS-injected strings.';
|
| $results[] = '';
|
|
|
|
|
| $active_plugins = get_option( 'active_plugins', [] );
|
| $gp_plugins = array_filter( $active_plugins, function( $p ) {
|
| return stripos( $p, 'guard' ) !== false
|
| || stripos( $p, 'bytenft' ) !== false
|
| || stripos( $p, 'guardedpay' ) !== false;
|
| });
|
|
|
| if ( ! empty( $gp_plugins ) ) {
|
| $results[] = '── GUARDEDPAY / BYTENFT PLUGIN(S) FOUND ──';
|
| foreach ( $gp_plugins as $plugin ) {
|
| $results[] = ' → ' . $plugin;
|
| }
|
| } else {
|
| $results[] = '⚠️ No plugin with "guard" or "bytenft" in filename found in active plugins.';
|
| $results[] = ' Check Plugins → Installed for the exact plugin name.';
|
| }
|
|
|
| $results[] = '';
|
|
|
|
|
| $results[] = '── RED BORDER CHECK ──';
|
| $results[] = 'Search your theme CSS and plugin CSS for:';
|
| $results[] = ' border-color: red / border: *red* / #ff0000 / #f00 / rgb(255,0,0)';
|
| $results[] = ' applied to payment method boxes, .wc_payment_method, or GuardedPay containers.';
|
| $results[] = ' The removal snippet (Phase 1b) will override this with CSS.';
|
|
|
| $results[] = '';
|
|
|
|
|
| $child_dir = get_stylesheet_directory();
|
| $template_paths = [
|
| '/woocommerce/checkout/form-checkout.php',
|
| '/woocommerce/checkout/payment.php',
|
| '/woocommerce/checkout/payment-method.php',
|
| '/woocommerce/checkout/form-pay.php',
|
| ];
|
|
|
| $results[] = '── CHECKOUT TEMPLATE OVERRIDES ──';
|
| $found_overrides = false;
|
| foreach ( $template_paths as $tpl ) {
|
| if ( file_exists( $child_dir . $tpl ) ) {
|
| $results[] = ' FOUND: ' . $tpl;
|
| $found_overrides = true;
|
|
|
|
|
| $contents = file_get_contents( $child_dir . $tpl );
|
| foreach ( $deprecated_strings as $str ) {
|
| if ( stripos( $contents, $str ) !== false ) {
|
| $results[] = ' ⛔ CONTAINS DEPRECATED: "' . $str . '"';
|
| }
|
| }
|
| }
|
| }
|
| if ( ! $found_overrides ) {
|
| $results[] = ' None found — checkout uses default WooCommerce templates.';
|
| $results[] = ' Deprecated strings are likely injected by the GuardedPay/ByteNFT plugin.';
|
| }
|
|
|
|
|
| $results[] = '';
|
| $results[] = '── FUNCTIONS.PHP SCAN ──';
|
| $functions_file = $child_dir . '/functions.php';
|
| if ( file_exists( $functions_file ) ) {
|
| $func_contents = file_get_contents( $functions_file );
|
| $found_in_func = false;
|
| foreach ( $deprecated_strings as $str ) {
|
| if ( stripos( $func_contents, $str ) !== false ) {
|
| $results[] = ' ⛔ FOUND IN functions.php: "' . $str . '"';
|
| $found_in_func = true;
|
| }
|
| }
|
| if ( ! $found_in_func ) {
|
| $results[] = ' Clean — no deprecated strings in functions.php.';
|
| }
|
| }
|
|
|
|
|
| echo '<div id="gp-diagnostic" style="
|
| position:fixed; top:0; left:0; right:0; z-index:999999;
|
| background:#fff8e1; border-bottom:3px solid #f9a825;
|
| padding:16px 24px; font-family:monospace; font-size:13px;
|
| line-height:1.6; max-height:50vh; overflow-y:auto;
|
| box-shadow:0 2px 8px rgba(0,0,0,0.15);
|
| ">';
|
| echo '<strong style="font-size:15px;">🔍 GUARDEDPAY PRO — Phase 1 Diagnostic</strong><br>';
|
| echo '<em>Admin-only. Remove this snippet after review.</em><br><br>';
|
| echo '<pre style="margin:0;white-space:pre-wrap;">' . esc_html( implode( "\n", $results ) ) . '</pre>';
|
| echo '<br><button onclick="document.getElementById(\'gp-diagnostic\').style.display=\'none\'" style="
|
| padding:6px 16px; cursor:pointer; border:1px solid #999; background:#fff; border-radius:3px;
|
| ">Dismiss</button>';
|
| echo '</div>';
|
| }
|
| |
| |
Comments