Skip to content

Instantly share code, notes, and snippets.

@ironprogrammer
Last active March 9, 2023 17:37
Show Gist options
  • Save ironprogrammer/62151bd5ca3f5a97051f641c3d7410d7 to your computer and use it in GitHub Desktop.
Save ironprogrammer/62151bd5ca3f5a97051f641c3d7410d7 to your computer and use it in GitHub Desktop.
<?php
/*
* Test mu-plugin for https://core.trac.wordpress.org/ticket/57780
*
* Tests CSS URL data type support for `filter`, from this PR https://github.com/WordPress/wordpress-develop/pull/4108.
* This update supports https://github.com/WordPress/gutenberg/pull/48281 directly in core. This plugin:
* - adds a border to the image <- supported by default
* - adds a blur filter to the image <- this should not be passed
* - adds a duotone effect to the image <- confirms the patch ✅
*
* Installation/Removal:
* Copy this gist into a PHP file located in your test site's `wp-content/mu-plugins/` directory. Create directory if needed.
* When testing is complete, delete this file from `wp-content/mu-plugins/`.
*
* Before patch:
* Image should be displayed in full color, with only a 4px black border.
*
* After patch:
* Image should be displayed in purple/yellow duotone, with a 4px purple border. Image should not be blurred.
*/
add_action( 'after_setup_theme', 'trac_57780' );
function trac_57780() {
if ( ! ( is_admin() || wp_is_json_request() ) ) {
$html = '<img src="https://placekitten.com/408/287" style="border: 4px solid #000; filter: blur(5px); filter: url(\'#wp-duotone-purple-yellow\') !important;">';
$allowed_html = array(
'img' => array(
'src' => array(),
'style' => array(),
),
);
echo wp_kses( $html, $allowed_html );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment