• Resolved Bryan Willis

    (@codecandid)


    Hey I posted this on your blog, but thought this might be a better place for it:

    I’m wondering if it’s possible to add support for the sidebar id to be included for filtering. I know id is a paramater of dynamic_sidebar_params, but I can’t figure out how to integrate it.

    This is what I’d like be able to do:

    function my_widget_output_filter( $widget_output, $widget_type, $widget_id, $sidebar_id ) {
        if ( 'categories' == $widget_type && 'primary-sidebar' == $sidebar_id ) {
            $widget_output = str_replace('before', 'after', $widget_output);
        }
        return $widget_output;
    }
    add_filter( 'widget_output', 'my_widget_output_filter', 10, 3 );

    This would allow filtering on only specific widgets of specific sidebars instead of executing on every sidebar on the site.

    https://www.ads-software.com/plugins/widget-output-filters/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Bryan Willis

    (@codecandid)

    Thanks for the feedback on my other support question! That definitely cleared things up for me.

    After looking over dynamic_sidebar_params it seems like we should be able to add either name and/or id as an option. I think I’m starting to figure this out, but I’m a little shortsighted with how to incorporate the php…

    Name::

    $sidebar_name = $sidebar_params[0]['name'];

    Then we could do this:

    if ( 'categories' == $widget_type && 'Primary Sidebar' == $sidebar_name ) {
    // regex
    }

    ID

    $sidebar_name = $sidebar_params[0]['id'];
    Then we could do this:

    if ( 'categories' == $widget_type && 'primary-sidebar' == $sidebar_id ) {
    // regex
    }

    I don’t see why this wouldn’t work, any ideas how we could add this to the plugin??

    Thread Starter Bryan Willis

    (@codecandid)

    Here’s a small little plugin I made that adds Bootstrap markup to all built in widgets.

    Have you had a chance to look at into the sidebar feature yet??

    Plugin Author Philip Newcomer

    (@philipnewcomer)

    Hey Bryan, I’ve just released version 1.1 of Widget Output Filters which now includes the sidebar ID in the parameters it passes to the filter. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add option for sidebar paramater’ is closed to new replies.