3 * Theme Installer List Table class.
6 * @subpackage List_Table
10 class WP_Theme_Install_List_Table extends WP_List_Table {
12 function ajax_user_can() {
13 return current_user_can('install_themes');
16 function prepare_items() {
17 include( ABSPATH . 'wp-admin/includes/theme-install.php' );
19 global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;
21 wp_reset_vars( array( 'tab' ) );
23 $paged = $this->get_pagenum();
27 // These are the tabs which are shown on the page,
29 $tabs['dashboard'] = __( 'Search' );
30 if ( 'search' == $tab )
31 $tabs['search'] = __( 'Search Results' );
32 $tabs['upload'] = __( 'Upload' );
33 $tabs['featured'] = _x( 'Featured','Theme Installer' );
34 //$tabs['popular'] = _x( 'Popular','Theme Installer' );
35 $tabs['new'] = _x( 'Newest','Theme Installer' );
36 $tabs['updated'] = _x( 'Recently Updated','Theme Installer' );
38 $nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item.
40 $tabs = apply_filters( 'install_themes_tabs', $tabs );
41 $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs );
43 // If a non-valid menu tab has been selected, And its not a non-menu action.
44 if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) )
47 $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults );
51 $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
52 $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
56 $terms = explode( ',', $term );
57 $terms = array_map( 'trim', $terms );
58 $terms = array_map( 'sanitize_title_with_dashes', $terms );
59 $args['tag'] = $terms;
62 $args['search'] = $term;
65 $args['author'] = $term;
69 if ( !empty( $_POST['features'] ) ) {
70 $terms = $_POST['features'];
71 $terms = array_map( 'trim', $terms );
72 $terms = array_map( 'sanitize_title_with_dashes', $terms );
73 $args['tag'] = $terms;
74 $_REQUEST['s'] = implode( ',', $terms );
75 $_REQUEST['type'] = 'tag';
78 add_action( 'install_themes_table_header', 'install_theme_search_form' );
85 $args['browse'] = $tab;
95 $api = themes_api( 'query_themes', $args );
97 if ( is_wp_error( $api ) )
98 wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
100 $this->items = $api->themes;
102 $this->set_pagination_args( array(
103 'total_items' => $api->info['results'],
104 'per_page' => $per_page,
108 function no_items() {
109 _e( 'No themes match your request.' );
112 function get_views() {
115 $display_tabs = array();
116 foreach ( (array) $tabs as $action => $text ) {
117 $class = ( $action == $tab ) ? ' class="current"' : '';
118 $href = self_admin_url('theme-install.php?tab=' . $action);
119 $display_tabs['theme-install-'.$action] = "<a href='$href'$class>$text</a>";
122 return $display_tabs;
125 function get_columns() {
131 // wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
133 <div class="tablenav top themes">
134 <div class="alignleft actions">
135 <?php do_action( 'install_themes_table_header' ); ?>
137 <?php $this->pagination( 'top' ); ?>
138 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
142 <div id="availablethemes">
143 <?php $this->display_rows_or_placeholder(); ?>
146 <div class="tablenav bottom themes">
147 <?php $this->pagination( 'bottom' ); ?>
148 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
154 function display_rows() {
155 $themes = $this->items;
156 $theme_names = array_keys( $themes );
158 foreach ( $theme_names as $theme_name ) {
159 $class = array( 'available-theme' );
161 <div class="<?php echo join( ' ', $class ); ?>"><?php
162 if ( isset( $themes[$theme_name] ) )
163 display_theme( $themes[$theme_name] );
165 <?php } // end foreach $theme_names