X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/38ca813a0e312e2768e5b9519f0415cd0aa84781..596d585e1dc1eb25bccd3781e37210a4e2504179:/wp-admin/includes/class-wp-themes-list-table.php diff --git a/wp-admin/includes/class-wp-themes-list-table.php b/wp-admin/includes/class-wp-themes-list-table.php index 5cb7648e..f6ca8a57 100644 --- a/wp-admin/includes/class-wp-themes-list-table.php +++ b/wp-admin/includes/class-wp-themes-list-table.php @@ -9,59 +9,55 @@ */ class WP_Themes_List_Table extends WP_List_Table { - var $search = array(); + protected $search_terms = array(); var $features = array(); + function __construct() { + parent::__construct( array( + 'ajax' => true, + ) ); + } + function ajax_user_can() { // Do not check edit_theme_options here. AJAX calls for available themes require switch_themes. - return current_user_can('switch_themes'); + return current_user_can( 'switch_themes' ); } function prepare_items() { - global $ct; + $themes = wp_get_themes( array( 'allowed' => true ) ); - $ct = current_theme_info(); - - $themes = get_allowed_themes(); - - if ( ! empty( $_REQUEST['s'] ) ) { - $search = strtolower( stripslashes( $_REQUEST['s'] ) ); - $this->search = array_merge( $this->search, array_filter( array_map( 'trim', explode( ',', $search ) ) ) ); - $this->search = array_unique( $this->search ); - } + if ( ! empty( $_REQUEST['s'] ) ) + $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( stripslashes( $_REQUEST['s'] ) ) ) ) ) ); - if ( !empty( $_REQUEST['features'] ) ) { + if ( ! empty( $_REQUEST['features'] ) ) $this->features = $_REQUEST['features']; - $this->features = array_map( 'trim', $this->features ); - $this->features = array_map( 'sanitize_title_with_dashes', $this->features ); - $this->features = array_unique( $this->features ); - } - if ( $this->search || $this->features ) { + if ( $this->search_terms || $this->features ) { foreach ( $themes as $key => $theme ) { - if ( !$this->search_theme( $theme ) ) + if ( ! $this->search_theme( $theme ) ) unset( $themes[ $key ] ); } } - unset( $themes[$ct->name] ); - uksort( $themes, "strnatcasecmp" ); + unset( $themes[ get_option( 'stylesheet' ) ] ); + WP_Theme::sort_by_name( $themes ); - $per_page = 15; + $per_page = 999; $page = $this->get_pagenum(); $start = ( $page - 1 ) * $per_page; - $this->items = array_slice( $themes, $start, $per_page ); + $this->items = array_slice( $themes, $start, $per_page, true ); $this->set_pagination_args( array( 'total_items' => count( $themes ), 'per_page' => $per_page, + 'infinite_scroll' => true, ) ); } function no_items() { - if ( $this->search || $this->features ) { + if ( $this->search_terms || $this->features ) { _e( 'No items found.' ); return; } @@ -92,7 +88,7 @@ class WP_Themes_List_Table extends WP_List_Table { if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) return; ?> -
%2$s. The stylesheet files are located in %3$s
. %4$s uses templates from %5$s. Changes made to the templates will affect both themes.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme ); ?>
%2$s.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?>
- - -- - - -