skip to Main Content

I have recently set up a wordpress page and the plugin Email Adress Encode.

I have set up the encoder with shortcodes at 3 locations using:
[encode link="..."]...[/encode].

It worked fine for some time but only now I’ve realized that one instance of the shortcode is not working anymore (without chaning the block at all).

I can’t make out the specific timing but it was working until about a week ago.

  • The plugin is installed.
  • The shortcode is working in the footer and the impressum but not in home.html

WordPress version: 6.2.1.

Homepage: https://www.ff-schleissheim.at
Impressum: https://www.ff-schleissheim.at/Impressum

The telephone numbers are exactly the same shortcode and are working in Impressum but not on Homepage.

My guess would be it has something to do with the filters but as I haven’t changed anything I don’t really know where to start.
(It also might’ve been an WordPress update that changed the behaviour but I honestly don’t like the idea of forcing a downgrade to an older version of wordpress so I’m searching for other options before trying the downgrade).

As the Shortcodes are included in a <p> tag I tried using the actualy shortcode block. Outcome was the same. I also tried the default wordpress shortcodes (provided by wordpress) and they are working everywhere except the Homepage.

On Hompage it just plain prints out the shortcode text.

I also looked at the other forums and questions here but none of them worked and none of them are up-to-date as well.

2

Answers


  1. Chosen as BEST ANSWER

    As @Aldevisign pointed out in his answer this is intended behaviour with the newest wordpress update to version 6.2.1.

    It is a security issue with the Shortcode block that should only affect pages, where non-trusted people can upload/post anything therefore on most or at least some pages this is not an issue for security. (If you want to know more look at the links in @Aldevisign's answer.

    Here is a fix/workaround I found in one of the links provided in the answer:

    Either create a plugin or just put a function.php in the root of the theme with the following code:

    <?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);
    

    Credits for the code: https://core.trac.wordpress.org/ticket/58333#comment:72

    It made the ShortCodes on my page work again. (Only tested the theme/funciton.php version though.


  2. This is normal, I invite you to this conversation:
    https://core.trac.wordpress.org/ticket/58333

    But the ShortCodes have been disabled in the 6.1 with block themes for a security vulnerability. From what I read it can still be working in template parts. And I manage to make them working in a page without the site editor.

    I’ve seen this in the WordPress reddit this morning: https://www.reddit.com/r/Wordpress/comments/13lka7s/how_much_trouble_did_wordpress_621_update_cause/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search