[wp-trac] [WordPress Trac] #38614: Text widget markup is not removable
WordPress Trac
noreply at wordpress.org
Wed Apr 19 14:48:36 UTC 2017
#38614: Text widget markup is not removable
--------------------------+------------------------------
Reporter: henry.wright | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 4.6.1
Severity: normal | Resolution:
Keywords: close | Focuses:
--------------------------+------------------------------
Comment (by SergeyBiryukov):
This can be done using the existing `widget_display_callback` filter:
{{{
function wp38614_replace_text_widget_wrapper( $instance, $widget, $args )
{
// Bail if not displaying the widget to be filtered
if ( 'text-2' !== $widget->id ) {
return $instance;
}
$title = apply_filters( 'widget_title', $instance['title'],
$instance, $widget->id_base );
$text = apply_filters( 'widget_text', $instance['text'],
$instance, $widget );
echo $args['before_widget'];
if ( $title ) {
echo $args['before_title'] . $title .
$args['after_title'];
}
echo '<div class="custom stuff">[';
echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text;
echo ']</div>';
echo $args['after_widget'];
return false;
}
add_filter( 'widget_display_callback',
'wp38614_replace_text_widget_wrapper', 10, 3 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38614#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list