Ticket #32470: 32470.4.diff
| File 32470.4.diff, 5.8 KB (added by , 11 years ago) |
|---|
-
wp-includes/default-widgets.php
254 254 * @param array $args 255 255 * @param array $instance 256 256 */ 257 public function widget( $args, $instance ) { 258 /** This filter is documented in wp-includes/default-widgets.php */ 259 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 260 261 echo $args['before_widget']; 262 if ( $title ) { 263 echo $args['before_title'] . $title . $args['after_title']; 264 } 265 257 public function widget_markup( $args, $instance ) { 266 258 // Use current theme search form if it exists 267 259 get_search_form(); 268 269 echo $args['after_widget'];270 260 } 271 261 272 262 /** … … 444 434 * @param array $args 445 435 * @param array $instance 446 436 */ 447 public function widget( $args, $instance ) { 448 /** This filter is documented in wp-includes/default-widgets.php */ 449 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base ); 450 451 echo $args['before_widget']; 452 if ( $title ) { 453 echo $args['before_title'] . $title . $args['after_title']; 454 } 437 public function widget_markup( $args, $instance ) { 455 438 ?> 456 439 <ul> 457 440 <?php wp_register(); ?> … … 476 459 ?> 477 460 </ul> 478 461 <?php 479 echo $args['after_widget'];480 462 } 481 463 482 464 /** … … 519 501 * @param array $args 520 502 * @param array $instance 521 503 */ 522 public function widget( $args, $instance ) { 523 /** This filter is documented in wp-includes/default-widgets.php */ 524 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 525 526 echo $args['before_widget']; 527 if ( $title ) { 528 echo $args['before_title'] . $title . $args['after_title']; 529 } 504 public function widget_markup( $args, $instance ) { 530 505 echo '<div id="calendar_wrap">'; 531 506 get_calendar(); 532 507 echo '</div>'; 533 echo $args['after_widget'];534 508 } 535 509 536 510 /** … … 575 549 * @param array $args 576 550 * @param array $instance 577 551 */ 578 public function widget( $args, $instance ) { 579 /** This filter is documented in wp-includes/default-widgets.php */ 580 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 552 public function widget_markup( $args, $instance ) { 581 553 582 554 /** 583 555 * Filter the content of the Text widget. … … 588 560 * @param WP_Widget $instance WP_Widget instance. 589 561 */ 590 562 $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); 591 echo $args['before_widget']; 592 if ( ! empty( $title ) ) { 593 echo $args['before_title'] . $title . $args['after_title']; 594 } ?> 563 ?> 595 564 <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 596 565 <?php 597 echo $args['after_widget'];598 566 } 599 567 600 568 /** … … 1392 1360 * @param array $args 1393 1361 * @param array $instance 1394 1362 */ 1395 public function widget ( $args, $instance ) {1363 public function widget_markup( $args, $instance ) { 1396 1364 $current_taxonomy = $this->_get_current_taxonomy($instance); 1397 1365 if ( !empty($instance['title']) ) { 1398 1366 $title = $instance['title']; … … 1405 1373 } 1406 1374 } 1407 1375 1408 /** This filter is documented in wp-includes/default-widgets.php */1409 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );1410 1411 echo $args['before_widget'];1412 if ( $title ) {1413 echo $args['before_title'] . $title . $args['after_title'];1414 }1415 1376 echo '<div class="tagcloud">'; 1416 1377 1417 1378 /** … … 1429 1390 ) ) ); 1430 1391 1431 1392 echo "</div>\n"; 1432 echo $args['after_widget'];1433 1393 } 1434 1394 1435 1395 /** -
wp-includes/widgets.php
104 104 * @param array $instance The settings for the particular instance of the widget. 105 105 */ 106 106 public function widget( $args, $instance ) { 107 die('function WP_Widget::widget() must be over-ridden in a sub-class.'); 107 //verify that we should be showing the widget 108 if ( ! $this->verify_settings( $instance ) ) { 109 return; 110 } 111 112 $this->before_widget( $args, $instance ); 113 $this->widget_markup( $args, $instance ); 114 $this->after_widget( $args, $instance ); 108 115 } 109 116 110 117 /** 118 * Verify settings 119 * 120 * Used to determine whether we should render the widget or not. Props @jdgrimes {link} https://core.trac.wordpress.org/ticket/32470#comment:15 121 * @param array $instance 122 * @return bool 123 */ 124 public function verify_settings( $instance ) { 125 return true; 126 } 127 128 /** 129 * Default treatment of before widget markup 130 * 131 * @param $args 132 * @param $instance 133 */ 134 public function before_widget( $args, $instance ) { 135 $title = $this->widget_title( $instance ); 136 echo $args['before_widget']; 137 if ( $title ) { 138 echo $args['before_title'] . $title . $args['after_title']; 139 } 140 } 141 142 /** 143 * Output the custom markup content for the widget 144 * 145 * Subclasses will override this to create their output 146 */ 147 public function widget_markup( $args, $instance ) {} 148 149 /** 150 * Default treatment of after widget markup 151 * 152 * @param $args 153 * @param $instance 154 */ 155 public function after_widget( $args, $instance ) { 156 echo $args['after_widget']; 157 } 158 159 /** 160 * Return the title of the widget 161 * 162 * @param $instance 163 * 164 * @return mixed|void 165 */ 166 public function widget_title( $instance ) { 167 return apply_filters( 'widget_title', ! isset($instance['title'] ) || empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); 168 } 169 170 /** 111 171 * Update a particular instance. 112 172 * 113 173 * This function should check that $new_instance is set correctly. The newly-calculated