Make WordPress Core

Ticket #22400: widgets.2.diff

File widgets.2.diff, 9.4 KB (added by wonderboymusic, 9 years ago)
  • src/wp-includes/default-widgets.php

     
    1919        }
    2020
    2121        function widget( $args, $instance ) {
    22                 extract( $args );
    2322
    2423                /**
    2524                 * Filter the widget title.
     
    5453                        'exclude'     => $exclude
    5554                ) ) );
    5655
    57                 if ( !empty( $out ) ) {
    58                         echo $before_widget;
    59                         if ( $title)
    60                                 echo $before_title . $title . $after_title;
     56                if ( ! empty( $out ) ) {
     57                        echo $args['before_widget'];
     58                        if ( $title ) {
     59                                echo $args['before_title'] . $title . $args['after_title'];
     60                        }
    6161                ?>
    6262                <ul>
    6363                        <?php echo $out; ?>
    6464                </ul>
    6565                <?php
    66                         echo $after_widget;
     66                        echo $args['after_widget'];
    6767                }
    6868        }
    6969
     
    119119        }
    120120
    121121        function widget( $args, $instance ) {
    122                 extract($args, EXTR_SKIP);
    123122
    124123                $show_description = isset($instance['description']) ? $instance['description'] : false;
    125124                $show_name = isset($instance['name']) ? $instance['name'] : false;
     
    130129                $order = $orderby == 'rating' ? 'DESC' : 'ASC';
    131130                $limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
    132131
    133                 $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
     132                $before_widget = preg_replace( '/id="[^"]*"/', 'id="%id"', $args['before_widget'] );
    134133
    135134                /**
    136135                 * Filter the arguments for the Links widget.
     
    142141                 * @param array $args An array of arguments to retrieve the links list.
    143142                 */
    144143                wp_list_bookmarks( apply_filters( 'widget_links_args', array(
    145                         'title_before' => $before_title, 'title_after' => $after_title,
    146                         'category_before' => $before_widget, 'category_after' => $after_widget,
     144                        'title_before' => $args['before_title'], 'title_after' => $args['after_title'],
     145                        'category_before' => $before_widget, 'category_after' => $args['after_widget'],
    147146                        'show_images' => $show_images, 'show_description' => $show_description,
    148147                        'show_name' => $show_name, 'show_rating' => $show_rating,
    149148                        'category' => $category, 'class' => 'linkcat widget',
     
    229228        }
    230229
    231230        function widget( $args, $instance ) {
    232                 extract($args);
    233231
    234232                /** This filter is documented in wp-includes/default-widgets.php */
    235233                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    236234
    237                 echo $before_widget;
    238                 if ( $title )
    239                         echo $before_title . $title . $after_title;
     235                echo $args['before_widget'];
     236                if ( $title ) {
     237                        echo $args['before_title'] . $title . $args['after_title'];
     238                }
    240239
    241240                // Use current theme search form if it exists
    242241                get_search_form();
    243242
    244                 echo $after_widget;
     243                echo $args['after_widget'];
    245244        }
    246245
    247246        function form( $instance ) {
     
    274273        }
    275274
    276275        function widget( $args, $instance ) {
    277                 extract($args);
    278276                $c = ! empty( $instance['count'] ) ? '1' : '0';
    279277                $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    280278
    281279                /** This filter is documented in wp-includes/default-widgets.php */
    282                 $title = apply_filters( 'widget_title', empty($instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
     280                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
    283281
    284                 echo $before_widget;
    285                 if ( $title )
    286                         echo $before_title . $title . $after_title;
     282                echo $args['before_widget'];
     283                if ( $title ) {
     284                        echo $args['before_title'] . $title . $args['after_title'];
     285                }
    287286
    288287                if ( $d ) {
    289288?>
     
    330329<?php
    331330                }
    332331
    333                 echo $after_widget;
     332                echo $args['after_widget'];
    334333        }
    335334
    336335        function update( $new_instance, $old_instance ) {
     
    374373        }
    375374
    376375        function widget( $args, $instance ) {
    377                 extract($args);
    378376
    379377                /** This filter is documented in wp-includes/default-widgets.php */
    380378                $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
    381379
    382                 echo $before_widget;
    383                 if ( $title )
    384                         echo $before_title . $title . $after_title;
     380                echo $args['before_widget'];
     381                if ( $title ) {
     382                        echo $args['before_title'] . $title . $args['after_title'];
     383                }
    385384?>
    386385                        <ul>
    387386                        <?php wp_register(); ?>
     
    406405?>
    407406                        </ul>
    408407<?php
    409                 echo $after_widget;
     408                echo $args['after_widget'];
    410409        }
    411410
    412411        function update( $new_instance, $old_instance ) {
     
    438437        }
    439438
    440439        function widget( $args, $instance ) {
    441                 extract($args);
    442440
    443441                /** This filter is documented in wp-includes/default-widgets.php */
    444442                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    445443
    446                 echo $before_widget;
    447                 if ( $title )
    448                         echo $before_title . $title . $after_title;
     444                echo $args['before_widget'];
     445                if ( $title ) {
     446                        echo $args['before_title'] . $title . $args['after_title'];
     447                }
    449448                echo '<div id="calendar_wrap">';
    450449                get_calendar();
    451450                echo '</div>';
    452                 echo $after_widget;
     451                echo $args['after_widget'];
    453452        }
    454453
    455454        function update( $new_instance, $old_instance ) {
     
    483482        }
    484483
    485484        function widget( $args, $instance ) {
    486                 extract($args);
    487485
    488486                /** This filter is documented in wp-includes/default-widgets.php */
    489487                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     
    497495                 * @param WP_Widget $instance    WP_Widget instance.
    498496                 */
    499497                $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
    500                 echo $before_widget;
    501                 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
     498                echo $args['before_widget'];
     499                if ( ! empty( $title ) ) {
     500                        echo $args['before_title'] . $title . $args['after_title'];
     501                } ?>
    502502                        <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
    503503                <?php
    504                 echo $after_widget;
     504                echo $args['after_widget'];
    505505        }
    506506
    507507        function update( $new_instance, $old_instance ) {
     
    543543        }
    544544
    545545        function widget( $args, $instance ) {
    546                 extract( $args );
    547546
    548547                /** This filter is documented in wp-includes/default-widgets.php */
    549548                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
     
    552551                $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
    553552                $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    554553
    555                 echo $before_widget;
    556                 if ( $title )
    557                         echo $before_title . $title . $after_title;
     554                echo $args['before_widget'];
     555                if ( $title ) {
     556                        echo $args['before_title'] . $title . $args['after_title'];
     557                }
    558558
    559559                $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
    560560
     
    605605<?php
    606606                }
    607607
    608                 echo $after_widget;
     608                echo $args['after_widget'];
    609609        }
    610610
    611611        function update( $new_instance, $old_instance ) {
     
    679679                }
    680680
    681681                ob_start();
    682                 extract($args);
    683682
    684683                $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
    685684
     
    709708
    710709                if ($r->have_posts()) :
    711710?>
    712                 <?php echo $before_widget; ?>
    713                 <?php if ( $title ) echo $before_title . $title . $after_title; ?>
     711                <?php echo $args['before_widget']; ?>
     712                <?php if ( $title ) {
     713                        echo $args['before_title'] . $title . $args['after_title'];
     714                } ?>
    714715                <ul>
    715716                <?php while ( $r->have_posts() ) : $r->the_post(); ?>
    716717                        <li>
     
    721722                        </li>
    722723                <?php endwhile; ?>
    723724                </ul>
    724                 <?php echo $after_widget; ?>
     725                <?php echo $args['after_widget']; ?>
    725726<?php
    726727                // Reset the global $the_post as this query will have stomped on it
    727728                wp_reset_postdata();
     
    832833                        return;
    833834                }
    834835
    835                 extract($args, EXTR_SKIP);
    836836                $output = '';
    837837
    838838                $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
     
    859859                        'post_status' => 'publish'
    860860                ) ) );
    861861
    862                 $output .= $before_widget;
    863                 if ( $title )
    864                         $output .= $before_title . $title . $after_title;
     862                $output .= $args['before_widget'];
     863                if ( $title ) {
     864                        $output .= $args['before_title'] . $title . $args['after_title'];
     865                }
    865866
    866867                $output .= '<ul id="recentcomments">';
    867868                if ( $comments ) {
     
    874875                        }
    875876                }
    876877                $output .= '</ul>';
    877                 $output .= $after_widget;
     878                $output .= $args['after_widget'];
    878879
    879880                echo $output;
    880881
     
    12201221        }
    12211222
    12221223        function widget( $args, $instance ) {
    1223                 extract($args);
    12241224                $current_taxonomy = $this->_get_current_taxonomy($instance);
    12251225                if ( !empty($instance['title']) ) {
    12261226                        $title = $instance['title'];
     
    12361236                /** This filter is documented in wp-includes/default-widgets.php */
    12371237                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    12381238
    1239                 echo $before_widget;
    1240                 if ( $title )
    1241                         echo $before_title . $title . $after_title;
     1239                echo $args['before_widget'];
     1240                if ( $title ) {
     1241                        echo $args['before_title'] . $title . $args['after_title'];
     1242                }
    12421243                echo '<div class="tagcloud">';
    12431244
    12441245                /**
     
    12561257                ) ) );
    12571258
    12581259                echo "</div>\n";
    1259                 echo $after_widget;
     1260                echo $args['after_widget'];
    12601261        }
    12611262
    12621263        function update( $new_instance, $old_instance ) {
     
    13231324        }
    13241325
    13251326        function update( $new_instance, $old_instance ) {
    1326                 $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
    1327                 $instance['nav_menu'] = (int) $new_instance['nav_menu'];
     1327                $instance = array();
     1328                if ( ! empty( $new_instance['title'] ) ) {
     1329                        $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
     1330                }
     1331                if ( ! empty( $new_instance['nav_menu'] ) ) {
     1332                        $instance['nav_menu'] = (int) $new_instance['nav_menu'];
     1333                }
    13281334                return $instance;
    13291335        }
    13301336