[wp-trac] [WordPress Trac] #58333: WordPress 6.2.1 Shortcodes some shortcode no longer works!

WordPress Trac noreply at wordpress.org
Thu May 18 20:09:05 UTC 2023


#58333: WordPress 6.2.1 Shortcodes some shortcode no longer works!
--------------------------+-------------------------
 Reporter:  jorcus        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  6.2.2
Component:  Shortcodes    |     Version:  6.2.1
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |     Focuses:
--------------------------+-------------------------
Changes (by vanko):

 * status:  reopened => closed
 * resolution:   => worksforme


Comment:

 This v2 of the fix code working thank you!

 Replying to [comment:72 gmariani405]:
 > Replying to [comment:7 andergmartins]:
 > > For those who want to stay on 6.2.1 and need to restore the support
 for shortcodes on templates, you can try this workaround.
 > >
 > > Add the following code as a plugin in a PHP file in the plugins
 folder:
 > >
 > > {{{#!php
 > > <?php
 > > /*
 > > Plugin Name: Fix shortcode
 > > Plugin URI:
 > > Description: Restore shortcode support on block templates
 > > Author: Anderson Martins
 > > Version: 0.1.0
 > > */
 > >
 > > add_filter('render_block_data', function($parsed_block) {
 > >     if (isset($parsed_block['innerContent'])) {
 > >         foreach ($parsed_block['innerContent'] as &$innerContent) {
 > >             if (empty($innerContent)) {
 > >                 continue;
 > >             }
 > >
 > >             $innerContent = do_shortcode($innerContent);
 > >         }
 > >     }
 > >
 > >     if (isset($parsed_block['innerBlocks'])) {
 > >         foreach ($parsed_block['innerBlocks'] as $key => &$innerBlock)
 {
 > >             if (! empty($innerBlock['innerContent'])) {
 > >                 foreach ($innerBlock['innerContent'] as
 &$innerContent) {
 > >                     if (empty($innerContent)) {
 > >                         continue;
 > >                     }
 > >
 > >                     $innerContent = do_shortcode($innerContent);
 > >                 }
 > >             }
 > >         }
 > >     }
 > >
 > >     return $parsed_block;
 > > }, 10, 1);
 > >
 > >
 > > }}}
 > >
 > >
 > > But be aware that support was removed for fixing a security issue, and
 restoring shortcode support you are probably bringing back the security
 issue.
 >
 > Fixed it, this looks to be working now.
 >
 > {{{#!php
 > <?php
 > /*
 > Plugin Name: Fix shortcode
 > Plugin URI:
 > Description: Restore shortcode support on block templates
 https://core.trac.wordpress.org/ticket/58333
 > Author: Anderson Martins, Gabriel Mariani
 > Version: 0.2.0
 > */
 >
 > function parse_inner_blocks(&$parsed_block)
 > {
 >     if (isset($parsed_block['innerBlocks'])) {
 >         foreach ($parsed_block['innerBlocks'] as $key => &$inner_block)
 {
 >             if (!empty($inner_block['innerContent'])) {
 >                 foreach ($inner_block['innerContent'] as
 &$inner_content) {
 >                     if (empty($inner_content)) {
 >                         continue;
 >                     }
 >
 >                     $inner_content = do_shortcode($inner_content);
 >                 }
 >             }
 >             if (isset($inner_block['innerBlocks'])) {
 >                 $inner_block = parse_inner_blocks($inner_block);
 >             }
 >         }
 >     }
 >
 >     return $parsed_block;
 > }
 >
 > add_filter('render_block_data', function ($parsed_block) {
 >
 >     if (isset($parsed_block['innerContent'])) {
 >         foreach ($parsed_block['innerContent'] as &$inner_content) {
 >             if (empty($inner_content)) {
 >                 continue;
 >             }
 >
 >             $inner_content = do_shortcode($inner_content);
 >         }
 >     }
 >
 >     $parsed_block = parse_inner_blocks($parsed_block);
 >
 >     return $parsed_block;
 > }, 10, 1);
 >
 > }}}

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


More information about the wp-trac mailing list