get_route(), '/wp/v2/' ) === 0 ) {\n return new WP_Error( 'rest_forbidden', 'Not available', [ 'status' => 401 ] );\n }\n return $res;\n}, 10, 3 );\n\n/* ---------- Render ---------- */\nadd_action( 'template_redirect', function () {\n if ( ! is_page() ) return;\n $id = get_queried_object_id();\n if ( get_page_template_slug( $id ) !== KW_LEGACY_TEMPLATE ) return;\n $html = get_post_meta( $id, 'kw_legacy_html', true );\n if ( ! $html ) return;\n header( 'X-Robots-Tag: noindex, nofollow', true ); /* 2026-11-03: archived former site under /www9/, never indexed */\n if ( strpos( $html, '' ) !== false ) {\n $fid = (int) get_option( 'kw_legacy_form_id' );\n $form = $fid ? do_shortcode( '[contact-form-7 id="' . $fid . '" html_class="kw-legacy-form"]' ) : '';\n $html = str_replace( '', $form, $html );\n }\n status_header( 200 );\n header( 'Content-Type: text/html; charset=UTF-8' );\n echo $html; // stored, already processed HTML of the former site\n exit;\n}, 5 );\n\n/* ---------- Build helpers (used once by the import script) ---------- */\nfunction kw_legacy_local_base() {\n $u = wp_upload_dir();\n return [ $u['basedir'] . '/kw-legacy/', '/wp-content/uploads/kw-legacy/' ];\n}\n\n/** Download one old-site path (e.g. wp-content/themes/Divi/style.css) into uploads/kw-legacy/. CSS refs are followed. */\nfunction kw_legacy_mirror( $path, &$done = [] ) {\n $path = ltrim( preg_replace( '/[?#].*$/', '', $path ), '/' );\n if ( $path === '' || isset( $done[ $path ] ) ) return;\n $done[ $path ] = 1;\n if ( ! preg_match( '/\.[a-z0-9]{2,5}$/i', $path ) ) return; // directory-like\n [ $dir ] = kw_legacy_local_base();\n $dest = $dir . $path;\n if ( ! file_exists( $dest ) ) {\n $r = wp_remote_get( KW_LEGACY_SRC . '/' . $path, [ 'timeout' => 30 ] );\n if ( is_wp_error( $r ) || wp_remote_retrieve_response_code( $r ) !== 200 ) { $done[ $path ] = 'ERR'; return; }\n wp_mkdir_p( dirname( $dest ) );\n file_put_contents( $dest, wp_remote_retrieve_body( $r ) );\n }\n if ( preg_match( '/\.css$/i', $path ) ) {\n $css = file_get_contents( $dest );\n preg_match_all( '/url\(\s*[\'"]?([^\'")]+)[\'"]?\s*\)|@import\s+[\'"]([^\'"]+)[\'"]/i', $css, $m );\n foreach ( array_merge( $m[1], $m[2] ) as $ref ) {\n if ( ! $ref || strpos( $ref, 'data:' ) === 0 ) continue;\n if ( preg_match( '#^(https?:)?//#', $ref ) ) {\n if ( ! preg_match( '#^(https?:)?//(www\.)?kersonwallaw\.com/(.+)$#', $ref, $mm ) ) continue;\n $p = $mm[3];\n } elseif ( strpos( $ref, '/' ) === 0 ) {\n $p = substr( $ref, 1 );\n } else {\n $p = kw_legacy_resolve( dirname( $path ), $ref );\n }\n kw_legacy_mirror( $p, $done );\n }\n // make absolute old-host refs inside CSS local\n [ , $web ] = kw_legacy_local_base();\n $css2 = preg_replace( '#(https?:)?//(www\.)?kersonwallaw\.com/(wp-content|wp-includes)/#', $web . '$3/', $css );\n $css2 = preg_replace( '#url\(\s*([\'"]?)/(wp-content|wp-includes)/#', 'url($1' . $web . '$2/', $css2 );\n if ( $css2 !== $css ) file_put_contents( $dest, $css2 );\n }\n}\n\nfunction kw_legacy_resolve( $base, $rel ) {\n $rel = preg_replace( '/[?#].*$/', '', $rel );\n $parts = $base === '.' ? [] : explode( '/', $base );\n foreach ( explode( '/', $rel ) as $seg ) {\n if ( $seg === '' || $seg === '.' ) continue;\n if ( $seg === '..' ) array_pop( $parts ); else $parts[] = $seg;\n }\n return implode( '/', $parts );\n}\n\n/** Decode a Cloudflare-obfuscated e-mail. */\nfunction kw_legacy_cfdecode( $hex ) {\n $k = hexdec( substr( $hex, 0, 2 ) ); $o = '';\n for ( $i = 2; $i < strlen( $hex ); $i += 2 ) $o .= chr( hexdec( substr( $hex, $i, 2 ) ) ^ $k );\n return $o;\n}\n\n/** Turn an old page's HTML into the bridge copy. $pages = [old path => new path]. */\nfunction kw_legacy_process( $html, $pages ) {\n [ , $web ] = kw_legacy_local_base();\n $src = preg_quote( 'www.kersonwallaw.com', '#' );\n\n // 1. Contact form → placeholder\n $p = strpos( $html, '
', $p );\n $e = strpos( $html, '
', $e ) + 6;\n $html = substr( $html, 0, $p ) . '' . substr( $html, $e );\n }\n\n // 2. Scripts to drop: cookie banner, reCAPTCHA, Google tag, old CF7 JS, Cloudflare helpers\n $drop = '(complianz|cmplz|recaptcha|googletagmanager|gtag\(|contact-form-7|wpcf7|/swv/|cdn-cgi|challenge-platform)';\n $html = preg_replace_callback( '##is', function ( $m ) use ( $drop ) {\n return preg_match( '#' . $drop . '#i', $m[0] ) ? '' : $m[0];\n }, $html );\n $html = preg_replace( '#]*(complianz|cmplz)[^>]*>#i', '', $html );\n $html = preg_replace( '#]*rel=["\'](alternate|EditURI|pingback|https://api\.w\.org/|shortlink)["\'][^>]*(feed|xmlrpc|wp-json|oembed|\?p=)[^>]*>#i', '', $html );\n $html = str_replace( '', "\n", $html );\n\n // 3. Cloudflare e-mail obfuscation\n $html = preg_replace_callback( '#href="/cdn-cgi/l/email-protection\#([0-9a-f]+)"#i', fn( $m ) => 'href="mailto:' . esc_attr( kw_legacy_cfdecode( $m[1] ) ) . '"', $html );\n $html = preg_replace_callback( '#<(span|a)\b[^>]*data-cfemail="([0-9a-f]+)"[^>]*>.*?\1>#is', fn( $m ) => esc_html( kw_legacy_cfdecode( $m[2] ) ), $html );\n\n // 4. Assets → local mirror (plain and JSON-escaped)\n $html = preg_replace( '#(https?:)?//' . $src . '/(wp-content|wp-includes)/#', $web . '$2/', $html );\n $html = preg_replace( '#(https?:)?\\\\/\\\\/' . $src . '\\\\/(wp-content|wp-includes)\\\\/#', str_replace( '/', '\\/', $web ) . '$2\\/', $html );\n $html = preg_replace( '#(["\'(])/(wp-content|wp-includes)/(?!uploads/kw-legacy/)#', '$1' . $web . '$2/', $html );\n $html = str_replace( $web . 'wp-content/uploads/kw-legacy/', $web, $html ); // guard against double rewrite\n\n // 5. Page links → bridge pages\n $html = preg_replace_callback( '#(https?:)?//(www\.)?kersonwallaw\.com(/[^"\'\s<>]*)?#i', function ( $m ) use ( $pages ) {\n $full = $m[3] ?? '/';\n if ( $full === '' ) $full = '/';\n $path = preg_replace( '/[?#].*$/', '', $full );\n $tail = substr( $full, strlen( $path ) );\n $key = '/' . trim( $path, '/' ) . '/';\n if ( $key === '//' ) $key = '/';\n if ( isset( $pages[ $key ] ) ) return $pages[ $key ] . $tail;\n return $full; // other same-site paths (e.g. /ubitrak_grc/) stay relative\n }, $html );\n $html = preg_replace( '#(action|href)="/fr/\##', '$1="/www9/fr/#', $html );\n\n return $html;\n}\n
Insights - Kerson Wallaw
Skip to content
Practical notes on PCI DSS, privacy law, security testing and audit, written by the team that does the work. Filter by topic, month or keyword.
Governance and risk ·
ISO 27001 or SOC 2? Choosing the right proof for Canadian SaaS and service providers
ISO 27001 certifies a management system; SOC 2 reports on controls. How Canadian SaaS and service providers can decide which one customers will actually accept.
ISO 27001SOC 2 Read the insight →
PCI DSS ·
Targeted risk analysis under PCI DSS 4.x: what it is and how to write one
PCI DSS 4.x lets organizations set some control frequencies themselves if they justify them in a targeted risk analysis. Here is when you need one and how to…
PCI DSS Read the insight →
Governance and risk ·
SOC 1 vs SOC 2 in Canada: CSAE 3416, CSAE 3000 and what your clients actually need
SOC 1 supports your clients' financial statement audits; SOC 2 addresses security and related criteria. How CSAE 3416 and CSAE 3000 fit, and how to pick.
SOC 2 Read the insight →
Privacy and Law 25 ·
Cookies and tracking under Law 25: privacy by default in practice (ss. 8.1 and 9.1)
Section 8.1 governs tracking and profiling technologies; section 9.1 sets privacy by default but excludes cookie settings. Here is how the two fit together on a real website.
GDPRQuébec Law 25 Read the insight →
Governance and risk ·
The EU’s Digital Omnibus: what proposed GDPR changes could mean for Canadian businesses
The European Commission's Digital Omnibus proposes major GDPR changes, from the definition of personal data to breach deadlines. It is not law yet. Here is what Canadian businesses…
GDPRPIPEDAQuébec Law 25 Read the insight →
Governance and risk ·
Answering client security questionnaires without starting from zero every time
Security questionnaires eat sales and security time. A practical method to build a reusable answer library, back it with evidence and keep it current.
ISO 27001PCI DSSPIPEDA Read the insight →
Governance and risk ·
Reporting a breach to the Privacy Commissioner: the “real risk of significant harm” test explained
Under PIPEDA, a breach must be reported when it creates a real risk of significant harm. Here is how to weigh sensitivity and probability of misuse, and what…
Bill C-36PIPEDAQuébec Law 25 Read the insight →
Governance and risk ·
OSFI Guideline B-10: what third-party risk management means for suppliers to Canadian banks and insurers
OSFI's Guideline B-10 has applied since 2024-05-01. What federally regulated banks and insurers now expect from their suppliers, and how vendors can prepare.
ISO 27001PCI DSSSOC 2 Read the insight →
PCI DSS ·
Unattended payments: PCI and device security risks for parking, fuel, EV charging and kiosks
Fuel pumps, parking stations, EV chargers and kiosks face skimming, tampering and network risks. Here is what PCI PTS and PCI DSS require, and practical steps for operators.
InteracPCI DSS Read the insight →
Webinars, conference talks and private sessions on PCI DSS, privacy law and cybersecurity, in English and French.