Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#21430 closed defect (bug) (invalid)

Text widget puts a space in <h3> </h3> if title empty

Reported by: rulatir Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: Widgets Keywords:
Focuses: Cc:


If the title of a text widget is left empty, the HTML output contains space in the <h3> </h3> tag. This causes the heading to occupy space if h3 is given margins by the stylesheet (which is normally the case). This in turn fights the intended layout. Fix it please!

Change History (3)

#1 @ocean90
9 years ago

  • Keywords reporter-feedback added

Which theme did you use? Any plugins active?

From default-widgets.php:

class WP_Widget_Text extends WP_Widget {
	function widget( $args, $instance ) {
		$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; } ?>
			<div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
		echo $after_widget;

So, there shouldn't be any title output if the title field is empty.

#2 @rulatir
9 years ago

  • Keywords close added

Thanks for quick response! You were right, ET are the culprit. From DailyNotes/epanel/custom_functions.php:

function et_widget_force_title( $title ){	
	#add an empty title for widgets ( otherwise it might break the sidebar layout )
	if ( $title == '' ) $title = ' ';
	return $title;

Brilliant. Fortunately a filter with priority 20 will undo this. Resolved/invalid.

#3 @helenyhou
9 years ago

  • Keywords reporter-feedback close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.