[wp-trac] [WordPress Trac] #57351: Escaped Shortcodes don't work in Block themes

WordPress Trac noreply at wordpress.org
Fri Feb 10 17:52:13 UTC 2023


#57351: Escaped Shortcodes don't work in Block themes
------------------------------+---------------------
 Reporter:  TobiasBg          |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  6.2
Component:  Themes            |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-testing-info  |     Focuses:
------------------------------+---------------------

Comment (by costdev):

 Looking into this more, it appears that when using a block theme,
 `do_shortcode()` is hooked to `the_content` twice. The first run renders a
 literal `[test]`, and the second run evaluates it.

 Adding this to the top of `do_shortcode()` shows that when limited to only
 one run on `the_content`, the shortcode is correctly escaped:

 {{{#!php
 <?php
 if ( doing_filter( 'the_content' ) && wp_get_theme()->is_block_theme() ) {
         static $did_block_theme_the_content = false;

         if ( $did_block_theme_the_content ) {
                 return $content;
         }

         $did_block_theme_the_content = true;
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57351#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list