__( 'OK', 'wardpair' ), 'warn' => __( 'Note', 'wardpair' ), 'bad' => __( 'Problem', 'wardpair' ), 'running' => __( 'Checking...', 'wardpair' ), 'copied' => __( 'Copied.', 'wardpair' ), 'copy_manual' => __( 'Press Ctrl+C (or Cmd+C) to copy the selected text.', 'wardpair' ), 'l_css' => __( 'Wardpair styles', 'wardpair' ), 'l_jq' => __( 'jQuery', 'wardpair' ), 'l_js' => __( 'Wardpair script', 'wardpair' ), 'l_cssfile' => __( 'Style file', 'wardpair' ), 'l_jsfile' => __( 'Script file', 'wardpair' ), 'l_err' => __( 'Script errors on this page', 'wardpair' ), 'css_ok' => __( 'loaded and applied.', 'wardpair' ), 'css_missing' => __( 'not on the page as a separate file. A caching or optimisation plugin may have combined or removed it.', 'wardpair' ), 'css_noload' => __( 'the file was found on the page but did not load.', 'wardpair' ), 'css_norules' => __( 'the file loaded but its rules are not applied. Another plugin or the theme may be overriding or blocking them.', 'wardpair' ), 'jq_missing' => __( 'not loaded. Wardpair buttons need it.', 'wardpair' ), 'jq_ok' => __( 'loaded.', 'wardpair' ), 'js_ok' => __( 'loaded and finished running.', 'wardpair' ), 'js_missing' => __( 'not on the page. A caching or optimisation plugin may have removed or delayed it.', 'wardpair' ), 'js_unfinished' => __( 'found on the page but it did not finish running. Check the script errors below.', 'wardpair' ), 'nohash' => __( 'could not be compared with the plugin file (this needs a secure https page).', 'wardpair' ), 'unreachable' => __( 'could not be fetched for comparison (blocked by the browser or a CDN rule).', 'wardpair' ), /* translators: %d: HTTP error code */ 'http' => __( 'the server answered with error %d when the file was requested.', 'wardpair' ), 'gothtml' => __( 'the address returned a web page instead of the file. A cache, firewall or redirect may be in the way.', 'wardpair' ), 'noexpected' => __( 'the plugin file could not be read here, so no comparison was made.', 'wardpair' ), 'same' => __( 'identical to the file in the plugin folder.', 'wardpair' ), 'differs' => __( 'differs from the file in the plugin folder. A cache, minify or CDN setting may have changed it, or an older copy is being served. This alone does not mean something is broken.', 'wardpair' ), 'err_none_collected' => __( 'not recorded on this page load.', 'wardpair' ), 'err_ok' => __( 'none recorded.', 'wardpair' ), ); ?>

jQuery( function ( $ ) { var $msg = $( '#swp-support-msg' ), $box = $( '#swp-support-report' ), $copy = $( '#swp-support-copy' ); function say( t, bad ) { $msg.css( 'color', bad ? '#b32d2e' : '' ).text( t ); } $( '#swp-support-build' ).on( 'click', function () { var $b = $( this ).prop( 'disabled', true ); say( ); $.post( wardpair.ajax_url, { action: 'sentinel_support_report', nonce: wardpair.nonce } ).then( function ( r ) { $b.prop( 'disabled', false ); if ( r && r.success && r.data && r.data.report ) { $box.val( r.data.report ).show(); $copy.show(); say( '' ); } else { say( , true ); } }, function () { $b.prop( 'disabled', false ); say( , true ); } ); } ); $copy.on( 'click', function () { var text = $box.val(); function done() { say( ); } function fallback() { $box.trigger( 'focus' ).trigger( 'select' ); try { if ( document.execCommand( 'copy' ) ) { done(); return; } } catch ( e ) {} say( ); } if ( navigator.clipboard && navigator.clipboard.writeText ) { navigator.clipboard.writeText( text ).then( done, fallback ); } else { fallback(); } } ); } ); ( function () { var D = ; var T = ; var list = document.getElementById( 'swp-dc-list' ); if ( ! list ) { return; } var msg = document.getElementById( 'swp-dc-msg' ), runBtn = document.getElementById( 'swp-dc-run' ), copyBtn = document.getElementById( 'swp-dc-copy' ), box = document.getElementById( 'swp-dc-text' ); var rows = [], COLOR = { ok: '#1a7f37', warn: '#9a6700', bad: '#b32d2e' }; function add( state, label, text ) { rows.push( { state: state, label: label, text: text } ); } function render() { while ( list.firstChild ) { list.removeChild( list.firstChild ); } rows.forEach( function ( r ) { var li = document.createElement( 'li' ), tag = document.createElement( 'strong' ); li.style.margin = '0 0 6px'; tag.style.color = COLOR[ r.state ]; tag.textContent = T[ r.state ] + ' '; li.appendChild( tag ); li.appendChild( document.createTextNode( r.label + ': ' + r.text ) ); list.appendChild( li ); } ); } function reportText() { var out = [ 'Wardpair display check', 'Plugin version: ' + D.version, 'Browser: ' + navigator.userAgent, '' ]; rows.forEach( function ( r ) { out.push( '[' + T[ r.state ] + '] ' + r.label + ': ' + r.text ); } ); return out.join( '\n' ); } function hashOf( url ) { if ( ! window.fetch || ! window.crypto || ! window.crypto.subtle ) { return Promise.resolve( { skip: true } ); } return fetch( url, { credentials: 'same-origin' } ).then( function ( res ) { if ( ! res.ok ) { return { status: res.status }; } var html = /text\/html/i.test( res.headers.get( 'content-type' ) || '' ); return res.arrayBuffer().then( function ( buf ) { return window.crypto.subtle.digest( 'SHA-256', buf ).then( function ( d ) { var hex = Array.prototype.map.call( new Uint8Array( d ), function ( b ) { return ( '0' + b.toString( 16 ) ).slice( -2 ); } ).join( '' ); return { hex: hex, html: html }; } ); } ); } ).catch( function () { return { failed: true }; } ); } function fileRow( label, el, expected ) { var url = ( el && ( el.href || el.src ) ) || expected.url; return hashOf( url ).then( function ( r ) { if ( r.skip ) { add( 'warn', label, T.nohash ); } else if ( r.failed ) { add( 'warn', label, T.unreachable ); } else if ( r.status ) { add( 'bad', label, T.http.replace( '%d', r.status ) ); } else if ( r.html ) { add( 'bad', label, T.gothtml ); } else if ( ! expected.hash ) { add( 'warn', label, T.noexpected ); } else if ( r.hex === expected.hash ) { add( 'ok', label, T.same ); } else { add( 'warn', label, T.differs ); } } ); } function run() { rows = []; if ( runBtn ) { runBtn.disabled = true; } if ( msg ) { msg.textContent = T.running; } // Stylesheet. var link = document.getElementById( 'wardpair-admin-css' ), wrap = document.querySelector( '.swp-wrap' ), mark = ''; try { mark = wrap ? String( window.getComputedStyle( wrap ).getPropertyValue( '--swp-css-loaded' ) ).trim() : ''; } catch ( e ) {} if ( mark === '1' ) { add( 'ok', T.l_css, T.css_ok ); } else if ( ! link ) { add( 'warn', T.l_css, T.css_missing ); } else if ( ! link.sheet ) { add( 'bad', T.l_css, T.css_noload ); } else { add( 'bad', T.l_css, T.css_norules ); } // Script. var script = document.getElementById( 'wardpair-admin-js' ) || document.getElementById( 'wardpair-admin-js-after' ); if ( typeof window.jQuery === 'undefined' ) { add( 'bad', T.l_jq, T.jq_missing ); } else { add( 'ok', T.l_jq, T.jq_ok ); } if ( window.wardpairAssets && window.wardpairAssets.admin ) { add( 'ok', T.l_js, T.js_ok ); } else if ( ! document.getElementById( 'wardpair-admin-js' ) ) { add( 'warn', T.l_js, T.js_missing ); } else { add( 'bad', T.l_js, T.js_unfinished ); } Promise.all( [ fileRow( T.l_cssfile, link, D.css ), fileRow( T.l_jsfile, document.getElementById( 'wardpair-admin-js' ), D.js ) ] ).then( function () { var errs = window.__swpErr; if ( ! errs ) { add( 'warn', T.l_err, T.err_none_collected ); } else if ( errs.length ) { add( 'bad', T.l_err, errs.join( ' | ' ) ); } else { add( 'ok', T.l_err, T.err_ok ); } render(); if ( runBtn ) { runBtn.disabled = false; } if ( copyBtn ) { copyBtn.style.display = ''; } if ( msg ) { msg.textContent = ''; } } ); } if ( runBtn ) { runBtn.addEventListener( 'click', run ); } if ( copyBtn ) { copyBtn.addEventListener( 'click', function () { var text = reportText(); function done() { if ( msg ) { msg.textContent = T.copied; } } function fallback() { if ( ! box ) { return; } box.value = text; box.style.display = ''; box.focus(); box.select(); try { if ( document.execCommand( 'copy' ) ) { done(); return; } } catch ( e ) {} if ( msg ) { msg.textContent = T.copy_manual; } } if ( navigator.clipboard && navigator.clipboard.writeText ) { navigator.clipboard.writeText( text ).then( done, fallback ); } else { fallback(); } } ); } if ( document.readyState === 'complete' ) { run(); } else { window.addEventListener( 'load', run ); } } )();