[wp-trac] [WordPress Trac] #35475: New functions: `current_widget` and `current_widget_id`
WordPress Trac
noreply at wordpress.org
Fri Jan 15 16:08:58 UTC 2016
#35475: New functions: `current_widget` and `current_widget_id`
------------------------------+-----------------------------
Reporter: sebastian.pisula | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version:
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
This is alternative for ticket #35456. In widgets we can use different
filters and actions. For example we use the_title filter but in widget we
don't want (this is abstract example). So:
{{{#!php
<?php
if(current_widget() == 'archive'){
return 'test';
}
return 'test2';
}}}
Other example - when can use filter from #35456 ticket:
{{{#!php
<?php
add_filter( 'widget_archives_args', function ( $args ) {
if ( current_widget_id() == 'archives-2' ) {
$args['post_type'] = 'page';
}
return $args;
}, 10 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35475>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list