Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#54941 closed defect (bug) (reported-upstream)

Gutenberg is disabled but Duotone add severals SVG in front and back.

Reported by: deuxparquatre's profile deuxparquatre Owned by:
Milestone: Priority: normal
Severity: major Version: 5.9
Component: Editor Keywords:
Focuses: Cc:

Description

Hi WordPress Team!

Since the version 5.9, Duotone from file /wp-includes/block-supports/duotone.php add multiple SVG tag in the wp_footer and admin_footer.

Is there a way to make sure that when we disable Gutenberg these SVG codes don't show up please?

A big thank you!
Sam

Change History (11)

#1 @sabernhardt
3 years ago

  • Component changed from General to Editor

#2 follow-up: @chesio
3 years ago

I have the same problem. I'm using a custom-made theme with Classic Editor - obviously these SVG tags in footer serve no purpose on my website.

#3 in reply to: ↑ 2 @deuxparquatre
3 years ago

Replying to chesio:

I have the same problem. I'm using a custom-made theme with Classic Editor - obviously these SVG tags in footer serve no purpose on my website.

For now, you can go in /wp-includes/block-supports/duotone.php and remove the wp_footer add_action in line 463.

Note that your edit'll be lost on the next update.

Cheers 🍻

#4 follow-up: @sabernhardt
3 years ago

  • Milestone changed from Awaiting Review to 5.9.1

This is also reported in a support topic, and a Classic Editor issue suggests fixing it in the plugin. However, I would like this to be fixed in Core.

I tried this:

function wp_render_duotone_filter_preset( $preset ) {
	if ( false === apply_filters( 'use_block_editor_for_post', true ) ) {
		return;
	}

That removed the SVGs for me when I used the filter option to disable the block editor, but not when using common plugins (Classic Editor or Disable Gutenberg).

add_filter( 'use_block_editor_for_post', '__return_false', 10 );

#5 in reply to: ↑ 4 @deuxparquatre
3 years ago

Replying to sabernhardt:

This is also reported ...

Thanks for your better waiting solution!

#6 @chesio
3 years ago

I found out that removing global styles gets rid of the SVG markup (and global styles inline CSS that I also don't need in my theme...):

<?php
add_action('after_setup_theme', function () {
    remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles');
    remove_action('wp_footer', 'wp_enqueue_global_styles', 1);
}, 10, 0);

#7 follow-up: @zabatonni
3 years ago

A bit hacky way, but you can remove literally anything added using add_action even Closures:

<?php
add_action('wp_footer',function() {
        global $wp_filter;

        if(empty($wp_filter['wp_footer'][10])) return;

        foreach($wp_filter['wp_footer'][10] as $hook) {
                if(!is_object($hook['function']) || get_class($hook['function']) !== 'Closure') continue;

                $static=(new ReflectionFunction($hook['function']))->getStaticVariables();

                if(empty($static['svg'])) continue;

                if(!str_starts_with($static['svg'],'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 0 0" ')) continue;

                remove_action('wp_footer',$hook['function'],10);
        }
},9);

#8 in reply to: ↑ 7 @deuxparquatre
3 years ago

Replying to zabatonni:

A bit hacky way ...

Bro! My man! Sorry for the delay, you are awesome!

You literally just educated me!

A huge thank you for your help, mission accomplished!

Have a nice day 🍻

Last edited 3 years ago by sabernhardt (previous) (diff)

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


3 years ago

#11 @hellofromTonya
3 years ago

  • Keywords needs-patch removed
  • Milestone 5.9.1 deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

Closing this ticket as it's reported upstream and to centralize the discussions and collaboration in one place. Once a fix is done in Gutenberg, it will be backported to Core.

I invite you to follow its progress and contribute here https://github.com/WordPress/gutenberg/issues/38299.

Note: See TracTickets for help on using tickets.