okay, i updated the code so i can add to a custom plugin for now.
but it doesn’t seem to work too on the backend, so not preventing conversion to classic block.
// Ensure that the function exists before attempting to remove it
if (function_exists('teckel_init_minify_html')) {
// Remove the original filter hook
remove_filter('template_redirect', 'teckel_init_minify_html');
}
// Define your modified function
function new_teckel_init_minify_html() {
if (is_admin() || (defined('REST_REQUEST') && REST_REQUEST) || (defined('DOING_AJAX') && DOING_AJAX)) {
return;
}
$minify_html_active = get_option('minify_html_active');
if ($minify_html_active != 'no') {
ob_start('teckel_minify_html_output');
}
}
// Add your modified function as a filter hook
add_filter('template_redirect', 'new_teckel_init_minify_html');
Though, the conversion to classic block does happen on every save draft or update. but it doesn’t matter when you refresh the page after updating. It all is back to normal.
@sujaljain007 I modified the code directly in plugin. Plugin doesn’t get many updates and I hope it get’s updated with fix I’ve provided or similar as plugin author was active here.
Hello
Same problem here…
Anybody found a working fix ?
Regards
@jirsbek ok thanks !
Where is this function ? in function.php ?
@byothe Well teckel_init_minify_html() is original function located directly in the plugin’s core file minify-html.php. As it’s definitely not ideal to modify the file directly it’s the only way I made the modification work. I hope author is watching this post and will update the plugin.
I have the same issue for weeks now and it is pain in th***. Any update guys on this fix? Very much appreciated
-
This reply was modified 11 months ago by
gringopost.
Where do you add this?
function teckel_init_minify_html() {
if (is_admin() || (defined(‘REST_REQUEST’) && REST_REQUEST) || (defined(‘DOING_AJAX’) && DOING_AJAX)) {
return;
}
$minify_html_active = get_option(‘minify_html_active’);
if ($minify_html_active != ‘no’) {
ob_start(‘teckel_minify_html_output’);
}
}
add_action(‘template_redirect’, ‘teckel_init_minify_html’);
@gringopost
It’s in the minify-html.php file… in the plugin directory on your site
wp-content > plugins > minify-html-markup > minify-html.php
@gringopost Are you also removing this part of the code in the plugin?
if ( !is_admin() ) {
if ( !( defined( 'WP_CLI' ) && WP_CLI ) ) {
add_action( 'init', 'teckel_init_minify_html', 1 );
}
}
As if you’re not, it’s calling teckel_init_minify_html() twice.
@jirsbek Could you supply the first section of the code you’re using? What I’m unclear about is if you keep the following part or not, as that will also call the teckel_init_minify_html()
function:
if ( !is_admin() ) {
if ( !( defined( 'WP_CLI' ) && WP_CLI ) ) {
add_action( 'init', 'teckel_init_minify_html', 1 );
}
}
@teckel Sure, this part is also removed:
if ( !is_admin() ) {
if ( !( defined( 'WP_CLI' ) && WP_CLI ) ) {
add_action( 'init', 'teckel_init_minify_html', 1 );
}
}
So to sum it up, this part:
function teckel_init_minify_html() {
$minify_html_active = get_option( 'minify_html_active' );
if ( $minify_html_active != 'no' )
ob_start('teckel_minify_html_output');
}
if ( !is_admin() )
if ( !( defined( 'WP_CLI' ) && WP_CLI ) )
add_action( 'init', 'teckel_init_minify_html', 1 );
Is modified to this:
function teckel_init_minify_html() {
if (is_admin() || (defined('REST_REQUEST') && REST_REQUEST) || (defined('DOING_AJAX') && DOING_AJAX)) {
return;
}
$minify_html_active = get_option('minify_html_active');
if ($minify_html_active != 'no') {
ob_start('teckel_minify_html_output');
}
}
add_action('template_redirect', 'teckel_init_minify_html');