Make WordPress Core

Changeset 15912


Ignore:
Timestamp:
10/22/2010 11:08:35 AM (15 years ago)
Author:
scribu
Message:

Make plugin search & order methods, instead of standalone functions. See #14579

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/default-list-tables.php

    r15904 r15912  
    33273327
    33283328        if ( $s ) {
    3329             function _search_plugins_filter_callback( $plugin ) {
    3330                 static $term;
    3331                 if ( is_null( $term ) )
    3332                     $term = stripslashes( $_REQUEST['s'] );
    3333 
    3334                 foreach ( $plugin as $value )
    3335                     if ( stripos( $value, $term ) !== false )
    3336                         return true;
    3337 
    3338                 return false;
    3339             }
    33403329            $status = 'search';
    3341             $plugins['search'] = array_filter( $plugins['all'], '_search_plugins_filter_callback' );
     3330            $plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
    33423331        }
    33433332
     
    33563345            $order = strtoupper( $order );
    33573346
    3358             function _order_plugins_callback( $plugin_a, $plugin_b ) {
    3359                 global $orderby, $order;
    3360 
    3361                 $a = $plugin_a[$orderby];
    3362                 $b = $plugin_b[$orderby];
    3363 
    3364                 if ( $a == $b )
    3365                     return 0;
    3366 
    3367                 if ( 'DESC' == $order )
    3368                     return ( $a < $b ) ? 1 : -1;
    3369                 else
    3370                     return ( $a < $b ) ? -1 : 1;
    3371             }
    3372             uasort( $this->items, '_order_plugins_callback' );
     3347            uasort( $this->items, array( $this, '_order_callback' ) );
    33733348        }
    33743349
     
    33843359            'per_page' => $plugins_per_page,
    33853360        ) );
     3361    }
     3362
     3363    function _search_callback( $plugin ) {
     3364        static $term;
     3365        if ( is_null( $term ) )
     3366            $term = stripslashes( $_REQUEST['s'] );
     3367
     3368        foreach ( $plugin as $value )
     3369            if ( stripos( $value, $term ) !== false )
     3370                return true;
     3371
     3372        return false;
     3373    }
     3374
     3375    function _order_callback( $plugin_a, $plugin_b ) {
     3376        global $orderby, $order;
     3377
     3378        $a = $plugin_a[$orderby];
     3379        $b = $plugin_b[$orderby];
     3380
     3381        if ( $a == $b )
     3382            return 0;
     3383
     3384        if ( 'DESC' == $order )
     3385            return ( $a < $b ) ? 1 : -1;
     3386        else
     3387            return ( $a < $b ) ? -1 : 1;
    33863388    }
    33873389
Note: See TracChangeset for help on using the changeset viewer.