remove from text-widget

OK, attempting to remove the with jQuery is counter intuitive.

Modifying it via output buffering is inefficient.

And we shouldn’t edit the actual widget code itself, since this will revert back next time we update WordPress.

I would suggest either creating your own text widget, or simply extend and modify the existing WordPress widget as follows (put the following code in your functions.php file):

add_action( 'widgets_init', 'register_my_widgets' );


function register_my_widgets() {
    ...
    register_widget( 'My_Text_Widget' );
}

class My_Text_Widget extends WP_Widget_Text {
    function widget( $args, $instance ) {
        extract($args);
        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
        $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
        echo $before_widget;
        if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
            <?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?>
        <?php
        echo $after_widget;
    }
}

Leave a Comment