Widgets: Move empty title checks out of the apply_filters( 'widget_title' )
calls for clarity.
See #42226. git-svn-id: https://develop.svn.wordpress.org/trunk@41867 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2885001d30
commit
e0598057c8
@ -42,16 +42,20 @@ class WP_Nav_Menu_Widget extends WP_Widget {
|
||||
// Get menu
|
||||
$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
|
||||
|
||||
if ( !$nav_menu )
|
||||
if ( ! $nav_menu ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
echo $args['before_widget'];
|
||||
|
||||
if ( !empty($instance['title']) )
|
||||
echo $args['before_title'] . $instance['title'] . $args['after_title'];
|
||||
if ( $title ) {
|
||||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
}
|
||||
|
||||
$nav_menu_args = array(
|
||||
'fallback_cb' => '',
|
||||
|
@ -40,13 +40,16 @@ class WP_Widget_Archives extends WP_Widget {
|
||||
* @param array $instance Settings for the current Archives widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Archives' );
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
$c = ! empty( $instance['count'] ) ? '1' : '0';
|
||||
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
|
||||
|
||||
echo $args['before_widget'];
|
||||
|
||||
if ( $title ) {
|
||||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
}
|
||||
|
@ -49,8 +49,10 @@ class WP_Widget_Calendar extends WP_Widget {
|
||||
* @param array $instance The settings for the particular instance of the widget.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
echo $args['before_widget'];
|
||||
if ( $title ) {
|
||||
|
@ -44,14 +44,17 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
public function widget( $args, $instance ) {
|
||||
static $first_dropdown = true;
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Categories' );
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
$c = ! empty( $instance['count'] ) ? '1' : '0';
|
||||
$h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
|
||||
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
|
||||
|
||||
echo $args['before_widget'];
|
||||
|
||||
if ( $title ) {
|
||||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
}
|
||||
|
@ -42,10 +42,13 @@ class WP_Widget_Meta extends WP_Widget {
|
||||
* @param array $instance Settings for the current Meta widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Meta' );
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
echo $args['before_widget'];
|
||||
|
||||
if ( $title ) {
|
||||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
}
|
||||
@ -75,6 +78,7 @@ class WP_Widget_Meta extends WP_Widget {
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ class WP_Widget_Pages extends WP_Widget {
|
||||
* @param array $instance Settings for the current Pages widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Pages' );
|
||||
|
||||
/**
|
||||
* Filters the widget title.
|
||||
@ -50,7 +51,7 @@ class WP_Widget_Pages extends WP_Widget {
|
||||
* @param array $instance Array of settings for the current widget.
|
||||
* @param mixed $id_base The widget ID.
|
||||
*/
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
$sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
|
||||
$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
|
||||
|
@ -68,8 +68,9 @@ class WP_Widget_RSS extends WP_Widget {
|
||||
$link = substr($link, 1);
|
||||
}
|
||||
|
||||
if ( empty($title) )
|
||||
$title = empty($desc) ? __('Unknown Feed') : $desc;
|
||||
if ( empty( $title ) ) {
|
||||
$title = ! empty( $desc ) ? $desc : __( 'Unknown Feed' );
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
@ -40,8 +40,10 @@ class WP_Widget_Search extends WP_Widget {
|
||||
* @param array $instance Settings for the current Search widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
echo $args['before_widget'];
|
||||
if ( $title ) {
|
||||
|
@ -39,14 +39,15 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
||||
* @param array $instance Settings for the current Tag Cloud widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$current_taxonomy = $this->_get_current_taxonomy($instance);
|
||||
if ( !empty($instance['title']) ) {
|
||||
$current_taxonomy = $this->_get_current_taxonomy( $instance );
|
||||
|
||||
if ( ! empty( $instance['title'] ) ) {
|
||||
$title = $instance['title'];
|
||||
} else {
|
||||
if ( 'post_tag' == $current_taxonomy ) {
|
||||
$title = __('Tags');
|
||||
if ( 'post_tag' === $current_taxonomy ) {
|
||||
$title = __( 'Tags' );
|
||||
} else {
|
||||
$tax = get_taxonomy($current_taxonomy);
|
||||
$tax = get_taxonomy( $current_taxonomy );
|
||||
$title = $tax->labels->name;
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +192,10 @@ class WP_Widget_Text extends WP_Widget {
|
||||
public function widget( $args, $instance ) {
|
||||
global $post;
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
|
||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
|
||||
$text = ! empty( $instance['text'] ) ? $instance['text'] : '';
|
||||
$is_visual_text_widget = ( ! empty( $instance['visual'] ) && ! empty( $instance['filter'] ) );
|
||||
|
Loading…
Reference in New Issue
Block a user