• Resolved freemason

    (@freemason)


    Hi,

    After updating to WP 6.4 my right sidebar WPP widget to display most read articles (30 days) only displays a small rolling bar and no posts. I am using Tiles theme.

    Can you help me on this issue?

    Regards

    A Jorge

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 18 total)
  • Chris Ostmo

    (@appideasdotcom)

    This plugin is throwing a javascript error with WP 6.4. We’ll have to wait for the developers to fix it.

    Thread Starter freemason

    (@freemason)

    Thank you Chris. Developer is usually quite fast to react

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @freemason & @appideasdotcom,

    Just tested the plugin with WordPress 6.4 and a stock WordPress theme (Twenty Twenty-Four) and even with a custom theme and I wasn’t able to reproduce the problem. For me the plugin is still working as intended.

    I did notice however that on @freemason’s case the plugin is breaking because its inline <script> tag is being tampered with.

    @freemason this is what’s on your site’s <head> section (truncated for brevity):

    <script type="application/json" id="wpp-json">
    /* <![CDATA[ */
    {"sampling_active":0,"sampling_rate":100, ...}
    /* ]]> */
    </script>

    This is what it’s supposed to look like (truncated for brevity):

    <script id="wpp-json" type="application/json">
    {"sampling_active":0,"sampling_rate":100, ...}
    </script>

    See that extra <![CDATA[ stuff? That’s not supposed to be there, and I have no idea where that’s coming from.

    Please try following these troubleshooting instructions and see if you can figure out what’s going on, then please report back your results.

    • This reply was modified 1 year ago by Hector Cabrera. Reason: Fixed code formatting
    yuzu13

    (@yuzu13)

    Hi @freemason,

    I didn’t do anything specific for the “resources fail to load” issue, but after some time, it seemed to resolve itself naturally. I added some code to the functions.php file of my WordPress theme. This code effectively removes the CDATA section from scripts. Here’s what I added:

    // Remove CDATA section
    function remove_cdata_script_wrapper($script) {
        $script = str_replace("type='text/javascript' id='wpp-json'", "type='application/json' id='wpp-json'", $script);
        $script = str_replace("/* <![CDATA[ */", "", $script);
        $script = str_replace("/* ]]> */", "", $script);
        return $script;
    }
    add_filter('script_loader_tag', 'remove_cdata_script_wrapper');

    You can add this snippet directly to your theme’s functions.php file. Just make sure to back up your site before making any changes, in case you need to revert them.

    Let me know if you need more detailed instructions.

    Best regards,

    Thread Starter freemason

    (@freemason)

    HI @yuzu13

    I added your code via Code Snippets plugin and it seems to be working ok. Thank you very much for your help. Lets hope someone can find the source of the problem, so that it may be properly solved.

    Best regards

    A Jorge

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey everyone,

    @yuzu13 that’s the same workaround I was planning to share but held off to see if we could learn more about the problem. So far though there’s not enough information to know what’s causing this.

    Could someone please follow these instructions to check whether this is being caused by a plugin or by a theme? This way we could determine what’s going on and find a proper solution to this.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Here’s an slightly improved version of @yuzu13’s patch:

    /**
     * Removes CDATA tag from WordPress Popular Posts' inline script.
     */
    add_filter( 'script_loader_tag', function($tag, $handle, $src) {
        if ( 'wpp-js' === $handle ) {
            if ( false !== strpos($tag, '/* <![CDATA[ */') ) {
                $tag = str_replace('/* <![CDATA[ */', '', $tag);
            }
    
            if ( false !== strpos($tag, '/* ]]> */') ) {
                $tag = str_replace('/* ]]> */', '', $tag);
            }
    
            $tag  = str_replace(["\r", "\n"], '', $tag);
        }
    
        return $tag;
    }, 99, 3 );

    It does the same thing basically, only it checks that it’s for WPP’s script only. That way other third-party scripts that do expect to have the CDATA stuff in there will keep working as intended.

    Thread Starter freemason

    (@freemason)

    Hi, Hector,

    Thank you for your help. I moved from @yuzu13 code into yours and it seems to be working OK. Two of the members that posted here (me and FmX) are using Colomag Theme (free and pro version). Maybe this may help.

    Regards

    A Jorge

    • This reply was modified 1 year ago by freemason.
    Thread Starter freemason

    (@freemason)

    • This reply was modified 1 year ago by freemason.
    Plugin Author Hector Cabrera

    (@hcabrera)

    Good news!

    @freemason you’re right, the problem is being caused by your theme.

    So I just found this change from the WordPress team that basically wraps JavaScript code in CDATA blocks for themes that do not enable support for HTML5.

    I was able to replicate this issue on my site by removing these lines of code from my current theme’s functions.php file:

    /**
     * Switch default core markup for search form, comment form, and comments
     * to output valid HTML5.
     */
    add_theme_support(
    	'html5',
    	array(
    		'gallery',
    		'caption',
    		'style',
    		'script',
    	)
    );

    So if you’re having this problem and you don’t see an add_theme_support( ‘html5’, …); code snippet in your theme’s functions.php file then you can fix the problem by adding it yourself like so for example:

    /**
     * Adds support for HTML5 script tags
     */
    add_theme_support( 'html5', array('script') );

    When you’re done, please make sure to reach out to the people who developed your WordPress theme and ask them to update it so it supports HTML5 tags (feel free to link to this comment so they know exactly what needs to be done and why).

    Edit: also, if you’re using a caching plugin (eg. WP Super Cache, W3 Total Cache, etc) make sure to clear its cache after adding this code snippet to your site.

    • This reply was modified 1 year ago by Hector Cabrera. Reason: Added note on caching plugins
    Thread Starter freemason

    (@freemason)

    HI Hector,

    I’ll contact my themes support. Thanks for your help.

    Regards

    A Jorge

    barefootminimalists

    (@barefootminimalists)

    Hi @hcabera which line of code should i add as a code snippet? Or where should I add this code? Thank you!

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @barefootminimalists,

    It’s this one:

    /**
     * Adds support for HTML5 script tags
     */
    add_theme_support( 'html5', array('script') );

    You need to add it to your current theme’s functions.php file.

    Alternatively, you could also use the Code Snippets plugin to do so without having to edit the functions.php file:

    1. Install and activate the Code Snippets plugin.
    2. Go to Snippets > Add New.
    3. Enter a title for the snippet (eg. HTML5 Support).
    4. Make sure that the Functions PHP tab is selected, then paste the code snippet from above in there.
    5. When you’re done, scroll down and click on Save Changes and Activate.

    If everything went well your popular posts list should be working as intended. If that’s not the case though please open a new topic and we’ll take it from there.

    • This reply was modified 1 year ago by Hector Cabrera. Reason: Added a screenshot of the snippet
    barefootminimalists

    (@barefootminimalists)

    @hcabera it worked! Thank you so much!!

    bookofjohn

    (@bookofjohn)

    I’m having similar issues after the WordPress update. Sidebar: “Sorry. No data so far.”

    And I’m still using this in a widget:

    [wpp limit=5 post_type=’post’ range=’last24hours’ thumbnail_width=150 thumbnail_height=150 stats_views=0]

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Popular Posts disapeared after wp6.4 update’ is closed to new replies.