WordPress.org

Make WordPress Core

Changeset 11041


Ignore:
Timestamp:
04/22/2009 01:06:15 AM (11 years ago)
Author:
azaozz
Message:

Remove remnants from widgets search, see #9511

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/widgets.php

    r11009 r11041  
    1717 * @param string $_search Optional. Search for widgets. Should be unsanitized.
    1818 */
    19 function wp_list_widgets( $show = 'all', $_search = false ) {
     19function wp_list_widgets() {
    2020    global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
    2121
    22     if ( $_search ) {
    23         // sanitize
    24         $search = preg_replace( '/[^\w\s]/', '', $_search );
    25         // array of terms
    26         $search_terms = preg_split( '/[\s]/', $search, -1, PREG_SPLIT_NO_EMPTY );
    27     } else {
    28         $search_terms = array();
    29     }
    30 
    31     if ( !in_array( $show, array( 'all', 'unused', 'used' ) ) )
    32         $show = 'all';
    33 ?>
     22    $no_widgets_shown = true;
     23    $already_shown = array(); ?>
    3424
    3525    <ul id="widget-list">
    3626<?php
    37         $no_widgets_shown = true;
    38         $already_shown = array();
    39         foreach ( $wp_registered_widgets as $name => $widget ) {
    40             if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
    41                 continue;
    42 
    43             if ( $search_terms ) {
    44                 $hit = false;
    45                 // Simple case-insensitive search.  Boolean OR.
    46                 $search_text = preg_replace( '/[^\w]/', '', $widget['name'] );
    47                 if ( isset($widget['description']) )
    48                     $search_text .= preg_replace( '/[^\w]/', '', $widget['description'] );
    49 
    50                 foreach ( $search_terms as $search_term ) {
    51                     if ( stristr( $search_text, $search_term ) ) {
    52                         $hit = true;
    53                         break;
    54                     }
    55                 }
    56                 if ( !$hit )
    57                     continue;
    58             }
    59 
    60             $sidebar = is_active_widget( $widget['callback'], $widget['id'] );
    61 
    62             if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) )
    63                 continue;
    64 
    65             if ( ! isset( $widget['params'][0] ) )
    66                 $widget['params'][0] = array();
    67 
    68             $already_shown[] = $widget['callback'];
    69             $no_widgets_shown = false;
    70 
    71             $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
    72 
    73             if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) {
    74                 $id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
    75                 $args['_temp_id'] = "$id_base-__i__";
    76                 $args['_multi_num'] = next_widget_id_number($id_base);
    77                 $args['_add'] = 'multi';
    78             } else {
    79                 $args['_add'] = 'single';
    80                 if ( $sidebar )
    81                     $args['_hide'] = '1';
    82             }
    83 
    84             $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
    85             call_user_func_array( 'wp_widget_control', $args );
     27    foreach ( $wp_registered_widgets as $name => $widget ) {
     28        if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
     29            continue;
     30
     31        $sidebar = is_active_widget( $widget['callback'], $widget['id'] );
     32
     33        if ( ! isset( $widget['params'][0] ) )
     34            $widget['params'][0] = array();
     35
     36        $already_shown[] = $widget['callback'];
     37        $no_widgets_shown = false;
     38
     39        $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
     40
     41        if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) {
     42            $id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
     43            $args['_temp_id'] = "$id_base-__i__";
     44            $args['_multi_num'] = next_widget_id_number($id_base);
     45            $args['_add'] = 'multi';
     46        } else {
     47            $args['_add'] = 'single';
     48            if ( $sidebar )
     49                $args['_hide'] = '1';
    8650        }
    8751
    88         if ( $no_widgets_shown )
    89           echo '<li>' . __( 'No matching widgets' ) . "</li>\n";
    90 ?>
     52        $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
     53        call_user_func_array( 'wp_widget_control', $args );
     54    }
     55
     56    if ( $no_widgets_shown )
     57      echo '<li>' . __( 'No matching widgets' ) . "</li>\n"; ?>
    9158    </ul>
    9259<?php
  • trunk/wp-admin/widgets.php

    r11009 r11041  
    312312}
    313313
    314 /*
    315 // Unsanitized!
    316 $widget_search = isset($_GET['s']) ? $_GET['s'] : false;
    317 
    318 // Not entirely sure what all should be here
    319 $show_values = array(
    320     ''      => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ),
    321     'unused' => __( 'Show unused widgets' ),
    322     'used'  => __( 'Show used widgets' )
    323 );
    324 
    325 $show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false;
    326 */
    327 
    328314$messages = array(
    329315    __('Changes saved.')
Note: See TracChangeset for help on using the changeset viewer.