• I have a Weaver Slider Post that contains just a URL to a YouTube video.
    The post is in a Group.
    The Group is Filtered, with “Native Theme Support” set.
    The Filter is used for a Slider, with “Slider contains Video” set.

    Using v1.3 of Weaver Show Posts, the video gets embedded.
    Using v1.3.1, it does not : just the plain URL gets shown.

    [ NB I have also just tried v1.3.1.1 : no change from v1.3.1, in fact it appears that v1.3.1.1 is exactly the same as v.1.3.1 bar the version number? ]

    v1.3.1 introduced modification of the ‘the_content’ filters (in includes/atw-showposts-sc.php), which knocks out all the ‘the_content’ filters bar capital_P_dangit and do_shortcode before loading my content.php template part. As a result, my the_content() call only runs do_shortcode filters! Hence no embedded video (among other things).

    PS. I have tried turning Native Theme Support off – to use your template – but that appears to have the same problem.

    https://wordpress.org/plugins/show-posts/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author wpweaver

    (@wpweaver)

    1.3.1.1 was needed due to an update mistake for 1.3.1 – failed to update the latest version field.

    The the_content filters were changed, and what you described was not supposed to be a side-effect. There did seem to be an issue with the_content filters, however, when some plugins added filters at lower priorities.

    The low priority filter issue affected only one plugin as far as I know, while the existing show posts code has worked for years with no other reported issues.

    Let me look into this, and I may have to add an option to add the new the_content low priority filtering as an option.

    The whole thing with the_content filtering is quite a mess – one that I literally would use as a case example of how not to do something if I were writing a book. It is clear that logically the_content() should be recursive, but it isn’t, and in some cases, things get “broken” – low priority filters.

    I will see if I can reproduce the plain just a YouTube URL issue, and if I can, then I will try to find a workaround for this mess.

    Plugin Author wpweaver

    (@wpweaver)

    Follow up:

    I cannot duplicate this issue.

    I have a URL-only video as the only content of a post.

    That post in a slider by defining a slider that uses a post filter that includes the video url only post. It displays fine. It works fine with Twenty Eleven using both native support and Show Posts display support.

    Do be sure you have Show Sliders 1.3.1 and Show Posts 1.3.1.1.

    What theme are you using?

    Thread Starter wizzud

    (@wizzud)

    Thanks for looking so quickly, and I’m sorry I haven’t responded sooner but I’ve been playing…

    You’re absolutely right, putting a shortcode into a page on its own displays the slider fine. Unfortunately that’s not what I’m doing – and here I apologise for not giving the full information from the start!

    I have a home page that has 3 distinct sliders on it, so they are templated (in my page-home.php) and called using

    echo atw_slider_sc( array('name'=>'SLIDER NAME') );

    Slider-A : uses atw posts containing HTML and images, but no shortcodes or videos
    Slider-B : filters a certain category of custom post type, displaying thumbnail, title, and excerpt from each retrieved post (ie. doesn’t use atw posts)
    Slider-C (the problem one!) : uses atw posts, each containing either a shortcode or an embedded video

    The order down the page is :

    1. Slider-A (functioned)
    2. Page content
    3. Slider-B (functioned)
    4. Slider-C (functioned)

    The Slider-A and Slider-B always display perfectly.
    Slider-C resolves the shortcodes, but not the embedded video.

    If I add the shortcode equivalent of Slider-C into the page’s content…

    1. Slider-A (functioned)
    2. Page content, containing Slider-C (shortcoded)
    3. Slider-B (functioned)
    4. Slider-C (functioned)

    …then Slider-C (shortcoded) exhibits the same problem as Slider-C (functioned), ie. shortcodes resolved but not the embedded video.

    If I then remove Slider-A …

    1. Page content, containing Slider-C (shortcoded)
    2. Slider-B (functioned)
    3. Slider-C (functioned)

    …then Slider-C (shortcoded) displays perfectly, resolving both the shortocdes and video, but Slider-C (functioned) switches from resolved shortcodes/unresolved video to unresolved shortcodes/resolved video.

    Removing Slider-B…

    1. Page content, containing Slider-C (shortcoded)
    2. Slider-C (functioned)

    …makes no difference.

    Swapping the order around…

    1. Slider-C (functioned)
    2. Page content, containing Slider-C (shortcoded)

    …results in both sliders resolving their shortcodes but not the video.

    Removing the functioned slider, leaving just…

    1. Page content, containing Slider-C (shortcoded)

    …shows the Slider-c (shortcoded) perfectly, with shortcodes and video being resolved. And adding more shortcoded sliders into the content still runs everything perfectly.

    I then took all shortcodes out of the content, and put Slider-B (functioned) and Slider-C (functioned) back in…

    1. Page content (no shortcode)
    2. Slider-B (functioned)
    3. Slider-C (functioned)

    ..and Slider-C (functioned) shows unresolved shortcodes/resolved video.

    Likewise, swapping Slider-B out for Slider-A…

    1. Page content (no shortcode)
    2. Slider-A (functioned)
    3. Slider-C (functioned)

    …makes Slider-C (functioned) still show unresolved shortcodes/resolved video.

    However, moving Slider-A (functioned) above the page content…

    1. Slider-A (functioned)
    2. Page content (no shortcode)
    3. Slider-C (functioned)

    …reverts Slider-C (functioned) back to resolved shortcodes and unresolved video!

    So, my conclusion is … confusion!
    I think there is definitely something amiss when calling the slider via the atw_slider_sc() function, and it also seems to affect slider(s) that come after it (shortcoded or functioned). I’m not at all sure how the position of the page content processing can have any effect, but it does appear to.
    There doesn’t seem to be a problem when using multiple sliders that are just shortcoded.

    My next step : put some logging in the code. I’ll let you know what (if anything) I find… it’ll probably turn out to by misuse of your plugin!

    [ PS : Using Weaver Show Posts v1.3.1.1 and Weaver Show Sliders v1.3.1, in WordPress v4.3.
    All the above tests were done on my theme, which is a heavily-modified child of devdmbootstrap3, but I also added echo atw_slider_sc(...); directly to TwentyFifteen’s page.php : immediately before the loop and the embedded video was not resolved; within, or immediately after, the loop and the video was resolved. I also appended it to the header.php : video not resolved. ]

    Plugin Author wpweaver

    (@wpweaver)

    This is getting pretty complicated for a forum-type discussion.

    This whole issue is related to this discussion on my forum:

    http://forum.weavertheme.com/discussion/comment/59800#Comment_59800

    It might give some insight.

    It is indeed likely that the direct call to atw_slider_sc is the issue as the fixes added as a result of the referenced discussion would involve order of execution, and more important, end-of-the-loop adjustments due to calls the do_shortcode. Could also have something to do with the echo as that would tend to bypass nested filtering on the shortcode.

    There is little overhead in shortcode processing, so perhaps you could simply replace your direct call with a do_shortcode().

    Thread Starter wizzud

    (@wizzud)

    I’m sorry but I fail to see how
    do_shortcode( $content, $ignore_html );
    is a suitable replacement for
    atw_slider_sc( array( 'name' => 'fred' ) );
    I don’t have the $content because it’s all hidden behind the ‘fred’ slider group!

    I’m sorry (again!) but this is quite long…

    I’ve looked at your code, and the pull request that it’s based on, and the WordPress code, and the problem as stated by the developer of the Simple Lightbox plugin. Unfortunately I think the solution you have put in place – and I fully understand that it’s lifted from the pull request – is incorrect : you should not be modifying the filters that you (or somebody else, like me) is subsequently going to be using and depending on!

    The Simple Lightbox developer (correctly) stated that what was needed is to store the current state of the filters, and then restore that saved state. What the code you’ve used is actually doing is saving a copy of all the global filters, then stripping out some of those filters such that any interim call to the_content() will only get a partial set of filters run on it!
    Added to which, you’re doing this save/restore regardless of whether you need to or not : you only need to do it if ‘the_content’ filters are being processed at the time!
    The consequence of not checking whether ‘the_content’ filters are currently running is that if atw_slider_sc() is run before the main page content is processed – which you advise for placing a slider in the page header, for example – then ‘the_content’ filters have not yet been run, and the $wp_filter['the_content'] array has not been key-sorted … which means that instead of knocking out low priority filters (those with a bigger $priority number) you’re actually knocking out the high ones (the ones with a lower $priority value) because they have been physically added to the array later! And even a subsequent run of the ‘the_content’ filters won’t correct it because WordPress only key-sorts on the first run and you restore the entire ‘the_content’ filter array with the original unsorted version.

    As for when atw_slider_sc() is only run after the loop, well, the key of $wp_content['the_content'] is set to the first element, which is the highest priority (lowest $priority value) because they’ve been sorted, which means that you’re knocking out all the texturising/formatting/shortcode/etc filters. So any shortcodes in the slides don’t get resolved!

    Why do (just) shortcodes in the main content work? Because the $wp_filter['the_content'] has been key-sorted, and ‘do_shortcodes’ just happens to be the lowest priority of all the ‘the_content’ filters. If someone were to add an even lower priority filter, then it would not get run.

    I have a solution that works for me (mixing shortcodes and function calls) – you might like to test/consider it.

    Change the save/restore functions to …

    function atw_save_the_content_filters() {
        global $wp_filter, $wp_current_filter;
        $tag = 'the_content';
        if( empty( $wp_filter ) || empty( $wp_current_filter ) || !in_array( $tag, $wp_current_filter ) ){
            return false;
        }
        return key( $wp_filter[ $tag ] );
    }
    function atw_restore_the_content_filters( $key = false ){
        global $wp_filter;
        $tag = 'the_content';
        if( $key !== false ){
            reset( $wp_filter[ $tag ] );
            while( key( $wp_filter[ $tag ] ) !== $key ){
                if( next( $wp_filter[ $tag ] ) === false ){
                    break;
                }
            }
        }
    }

    Where you call atw_save_the_content_filters()…

    $saved_the_content_filter_key = atw_save_the_content_filters();

    Where you call atw_restore_the_content_filters()…

    atw_restore_the_content_filters( $saved_the_content_filter_key );

    This solution does not modify the filters, and only runs when ‘the_content’ filters are actually being applied. Whether it still resolves your original poster’s problem with Simple Lightbox I can’t say, but it does conform with what that plugin’s developer suggested was the problem. What you choose to do with it is up to you.

    Regards…

    Plugin Author wpweaver

    (@wpweaver)

    Thank you!

    As you suspected, I simply added the code from the previous pull request. That did fix the issue with the light box, but your solution seems to still fix that, too.

    I will post updated versions of Show Posts and Show Sliders soon with your fix to the fix.

    Let me know if that fixes your issues.

    If you have other issues or suggestions for these plugins, do let me know and I will consider incorporating them into these plugins.

    Thread Starter wizzud

    (@wizzud)

    Many thanks for the fast response, but…

    The just-released v1.3.2 of Show Posts has the main fix, however you’ve only changed 1 of the calls to the atw_restore_the_content_filters() function : there are 4 more that also need to pass in the $saved_the_content_filter_key variable!

    Sorry to be a pain.

    Plugin Author wpweaver

    (@wpweaver)

    My bad – must have incorrectly typed the search string because I only found the first one.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘v1.3.1 breaks embedded video’ is closed to new replies.