Skip to content

Instantly share code, notes, and snippets.

@tflight
Created January 19, 2024 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tflight/95f7f8f537f422dc649effc294bab473 to your computer and use it in GitHub Desktop.
Save tflight/95f7f8f537f422dc649effc294bab473 to your computer and use it in GitHub Desktop.
ACF Escape HTML Log Check
<?php
/**
* Plugin Name: ACF Escape HTML Log Check
* Description: Checks if the ACF Escape HTML Log has been triggered.
* Version: 1.0.0
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: Tim Flight
* Author URI: https://github.com/tflight
* License: MIT
*
*/
if (! defined('ABSPATH')) {
exit('No direct script access allowed');
}
if (defined('WP_CLI') && WP_CLI) {
WP_CLI::add_command('tflight acf-log-check', 'tflight_acf_log_check', [
'shortdesc' => 'Checks if the ACF Escape HTML Log has been triggered.'
]);
}
function tflight_acf_log_check()
{
$logs = get_option('acf_will_escape_html_log');
if ($logs === false) {
WP_CLI::success('No log entries found.');
return;
}
WP_CLI::warning("ACF Escape HTML Log Check entries found.");
foreach ($logs as $field => $log) {
WP_CLI::log("\n" . '# ' . $field);
$theFields = [$log];
WP_CLI\Utils\format_items('table', $theFields, ['selector', 'function', 'field', 'post_id']);
}
WP_CLI::log("\n" . 'After addressing the issue, reset with `wp option delete acf_will_escape_html_log`');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment