Forum Replies Created

Viewing 15 replies - 106 through 120 (of 324 total)
  • Thread Starter wizzud

    (@wizzud)

    Update :

    In wppa_albums() (file wppa-functions.php) there’s a case '#cat': condition (line 352-ish) that

    1. sanitizes the category attribute (capitalizes, separates with comma, and surrounds with commas), so “General” becomes “,General,”/li>
    2. cycles thru all albums
    • exploding the ‘cats’ field on comma
    • checking the resultant array for the sanitized category

    Since the ‘cats’ field was exploded on comma, the in_array() check for string with a leading and trailing comma always fails!

    Either, trim the sanitized category of commas before checking for its existence within the constructed array of each album’s ‘cats’ field
    Or, do a strpos() of the sanitized category within the (string) ‘cats’ fields.

    The advantage of doing the first option is that if you trim immediately after the sanitization, it removes the commas that are otherwise shown on the frontend output as well!
    Eg. line 355-ish…

    $cat = wppa_sanitize_tags( $cat );

    becomes

    $cat = trim( wppa_sanitize_tags( $cat ), ',' );
    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…

    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 wizzud

    (@wizzud)

    ‘Fraid so. CMW is merely a filter : it will remove stuff, but it won’t add stuff in.

    Plugin Author wizzud

    (@wizzud)

    Josh

    Right, I’ve had a look at the example you gave me (the MTA Study… post). The reason you’re not getting a CMW instance when that page is on view is primarily because it isn’t in the main menu (upon which your CMW instance is based). The fallback_ci_parent option won’t help because it falls back to looking for an item that is marked (by WordPress) as current-menu-parent (when no current-menu-item can be found), and there is no item in the main menu that is classed as such. In fact there are no current-menu-* classes anywhere in the menu when that MTA Study… post is being shown, presumably because WordPress can’t say that it is a child item of any particular menu item, even though it can determine (from the post hierarchy) that both Hot Issues and Charter Schools are current-page-ancestor.

    Since the page in question is not in the menu, and WordPress cannot/will not indicate a parent menu item for it, the CMW primary filter of Branch=Current Item fails and there is no output.

    PS : I don’t know whether it would fit into your site plan but I have a tentative suggestion for a possible way around this? Assign the MTA Study… (and maybe other similar posts that are not on the menu) to a suitable Category, such as [Something Relevant] Reference, and add the category as a menu item to a relevant sub-menu. WordPress would mark a category menu item as current-menu-parent when a post in that category was on display, and setting CMW’s fallback_ci_parent option would make CMW pick up that category menu item as the Current Item (given a lack of a more specific alternative).

    Plugin Author wizzud

    (@wizzud)

    I’m sorry, but all your screenshots are giving me “The URL provided does not correspond to a valid shared note. This may be caused by a typo in the link, or the note owner may have made it private.”

    I assume the site is not web-accessible (otherwise there would be no need for the screenshots). I also assume that by “primary sidebar” you mean the CMW widget it contains (as opposed to the sidebar itself)?

    Can you provide the shortcode equivalent of your settings please? And maybe some indication of your menu structure, or at least that part of it that contains the current page (that isn’t showing any output)?
    (Your admin screenshot may well have covered this…)

    Plugin Author wizzud

    (@wizzud)

    No problem. I hope you find what you need.

    Plugin Author wizzud

    (@wizzud)

    Unfortunately I think things are becoming less clear from my point of view.
    By introducing accordion-style menus, I think you are now talking about presentation, not content, and that is beyond CMW’s remit. Any styling and/or interactivity that you wish to place on the menu is down to your theme, and possibly other plugins that can accordion-ise a menu for you. CMW does not provide any styling … at all! It can modify the output HTML slightly if you configure it to, but that’s it.

    Plugin Author wizzud

    (@wizzud)

    Showing just the immediate children of the current menu item is fairly straightforward : Branch = Current Item, Starting at +1 (children), For Depth 1 level.
    Shortcode equivalent:
    [cmwizard menu=NN branch=current start_at="+1" depth=1/]

    If you want to also show the current item, then leave Starting at set to its default value (“the Branch”) and change For Depth to 2 levels.
    If you want to show any ancestors of the current item, then either configure them (under Inclusions), or change Starting at to an absolute level … depends on exactly what you want shown.

    Plugin Author wizzud

    (@wizzud)

    Yes, please refer to this support query

    Plugin Author wizzud

    (@wizzud)

    Would you mind giving me a bit more information please?

    I assume you’re talking about the backend administration of WordPress, so…

    1. Are you using the Widgets page (widgets.php) to configure the CMW instance, or are you using the Customizer (customize.php)?
    2. Which settings don’t collapse? The entire widget form (clicking on the arrow in the widget header)? Or a section with the widget form, such as Filters (clicking on the arrow to the right of “Filters”)? Or do you mean some other “menu settings”? If so, exactly which ones?
    Plugin Author wizzud

    (@wizzud)

    (for ease of reference I’m going to refer to “mobile” and “desktop” modes of your site…)

    You have 2 menu systems, one of which is a CMW instance.
    The CMW instance is in the sidebar, and in desktop mode that sidebar is the primary means of navigation.
    The other menu is hidden (off screen) in desktop mode, and is not a CMW instance.
    In mobile mode, the sidebar is hidden and the off-screen menu takes over … therefore the CMW instance is not available in mobile mode.

    If you need Products on the off-screen menu then I suggest you investigate where and how that particular menu is produced?

    Plugin Author wizzud

    (@wizzud)

    Sorry, but currently, Yes, it’s unavoidable.

    CMW can only cope with one “current item”. At present, it will use the first qualifying item it finds within the menu (it’s actually a bit more complex than that, but essentially it works on a first-found basis). This means that when the menu has category-type items – such as yours – it is quite possible for more than one menu item to marked (by WordPress) as being a possible parent candidate for a particular post. This is perfectly correct : the post does belong to each of those categories.

    For example, given…

    Menu Item A (lists category A items)
    Menu Item B (lists category B items)
    Menu Item C (lists category C items)

    …if Post X belongs to categories A, B and C, WordPress will mark all 3 menu items as a possible parent, and CMW will use Menu Item A as the “current item” (in the absence of a better-qualified candidate).
    In this particular example, it wouldn’t even help if CMW were switched to work on a last-found basis instead … it would simply settle on Menu Item C, which still isn’t the one you’d actually want.

    Plugin Author wizzud

    (@wizzud)

    Under the Fallbacks section, try setting…

    If no Current Item can be found” (checkbox)

    This gets applied right at the start of processing, when determining which of the menu items (if any) should be regarded as the unique “Current Item” by this widget. Under certain conditions, WordPress will mark an item as being the parent of a current item … but there won’t actually be a current item marked! This occurs, for example, when displaying a full post for which there is no specific related menu item, yet there is a menu item for a Category that the displayed post belongs to : WordPress will then mark the related Category as being the parent of the current item (the post) even though it can’t mark the post as being the current item (because there’s no specific item for it within the menu).

    Enabling this fallback will make the widget look for these situations – only as a last resort! – and set (one of) the found “parent” item(s) as the Current Item.

    Plugin Author wizzud

    (@wizzud)

    Looks to me like :
    – if the current item is the menu, show it and its immediate children, plus its siblings, plus all its ancestors and their siblings
    – if the current item is not in the menu, show just the root items

    Set the widget up to get a shortcode equivalent of…

    [cmwizard menu=NNN branch=current depth=2 ancestors=1 ancestor_siblings=1 siblings=1 alternative="no-output,primary"]depth=1[/cmwizard]

Viewing 15 replies - 106 through 120 (of 324 total)