2010-10-24 22:57:43 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2010-10-25 00:04:18 -04:00
|
|
|
* Theme Installer List Table class.
|
2010-10-24 22:57:43 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
2010-10-25 00:04:18 -04:00
|
|
|
* @subpackage List_Table
|
|
|
|
* @since 3.1.0
|
2011-01-16 16:47:24 -05:00
|
|
|
* @access private
|
2010-10-24 22:57:43 -04:00
|
|
|
*/
|
2010-11-04 04:07:03 -04:00
|
|
|
class WP_Theme_Install_List_Table extends WP_List_Table {
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2012-02-09 12:20:26 -05:00
|
|
|
function __construct() {
|
|
|
|
parent::__construct( array(
|
|
|
|
'ajax' => true,
|
|
|
|
) );
|
|
|
|
}
|
|
|
|
|
2010-12-16 04:18:28 -05:00
|
|
|
function ajax_user_can() {
|
|
|
|
return current_user_can('install_themes');
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function prepare_items() {
|
|
|
|
include( ABSPATH . 'wp-admin/includes/theme-install.php' );
|
|
|
|
|
|
|
|
global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;
|
|
|
|
|
|
|
|
wp_reset_vars( array( 'tab' ) );
|
|
|
|
|
|
|
|
$paged = $this->get_pagenum();
|
|
|
|
|
2011-09-15 00:26:26 -04:00
|
|
|
$per_page = 36;
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
// These are the tabs which are shown on the page,
|
|
|
|
$tabs = array();
|
|
|
|
$tabs['dashboard'] = __( 'Search' );
|
|
|
|
if ( 'search' == $tab )
|
|
|
|
$tabs['search'] = __( 'Search Results' );
|
|
|
|
$tabs['upload'] = __( 'Upload' );
|
|
|
|
$tabs['featured'] = _x( 'Featured','Theme Installer' );
|
|
|
|
//$tabs['popular'] = _x( 'Popular','Theme Installer' );
|
|
|
|
$tabs['new'] = _x( 'Newest','Theme Installer' );
|
|
|
|
$tabs['updated'] = _x( 'Recently Updated','Theme Installer' );
|
|
|
|
|
|
|
|
$nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item.
|
|
|
|
|
|
|
|
$tabs = apply_filters( 'install_themes_tabs', $tabs );
|
|
|
|
$nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs );
|
|
|
|
|
|
|
|
// If a non-valid menu tab has been selected, And its not a non-menu action.
|
|
|
|
if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) )
|
|
|
|
$tab = key( $tabs );
|
|
|
|
|
|
|
|
$args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults );
|
|
|
|
|
|
|
|
switch ( $tab ) {
|
|
|
|
case 'search':
|
|
|
|
$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
|
|
|
|
$term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
|
|
|
|
|
|
|
|
switch ( $type ) {
|
|
|
|
case 'tag':
|
|
|
|
$terms = explode( ',', $term );
|
|
|
|
$terms = array_map( 'trim', $terms );
|
|
|
|
$terms = array_map( 'sanitize_title_with_dashes', $terms );
|
|
|
|
$args['tag'] = $terms;
|
|
|
|
break;
|
|
|
|
case 'term':
|
|
|
|
$args['search'] = $term;
|
|
|
|
break;
|
|
|
|
case 'author':
|
|
|
|
$args['author'] = $term;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-07 16:06:52 -05:00
|
|
|
if ( !empty( $_REQUEST['features'] ) ) {
|
|
|
|
$terms = $_REQUEST['features'];
|
2010-10-24 22:57:43 -04:00
|
|
|
$terms = array_map( 'trim', $terms );
|
|
|
|
$terms = array_map( 'sanitize_title_with_dashes', $terms );
|
|
|
|
$args['tag'] = $terms;
|
|
|
|
$_REQUEST['s'] = implode( ',', $terms );
|
|
|
|
$_REQUEST['type'] = 'tag';
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action( 'install_themes_table_header', 'install_theme_search_form' );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'featured':
|
|
|
|
//case 'popular':
|
|
|
|
case 'new':
|
|
|
|
case 'updated':
|
|
|
|
$args['browse'] = $tab;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$args = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !$args )
|
|
|
|
return;
|
|
|
|
|
|
|
|
$api = themes_api( 'query_themes', $args );
|
|
|
|
|
|
|
|
if ( is_wp_error( $api ) )
|
2011-01-11 19:18:23 -05:00
|
|
|
wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
$this->items = $api->themes;
|
|
|
|
|
|
|
|
$this->set_pagination_args( array(
|
|
|
|
'total_items' => $api->info['results'],
|
|
|
|
'per_page' => $per_page,
|
|
|
|
) );
|
|
|
|
}
|
|
|
|
|
|
|
|
function no_items() {
|
|
|
|
_e( 'No themes match your request.' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_views() {
|
|
|
|
global $tabs, $tab;
|
|
|
|
|
|
|
|
$display_tabs = array();
|
|
|
|
foreach ( (array) $tabs as $action => $text ) {
|
|
|
|
$class = ( $action == $tab ) ? ' class="current"' : '';
|
|
|
|
$href = self_admin_url('theme-install.php?tab=' . $action);
|
2010-12-03 13:51:24 -05:00
|
|
|
$display_tabs['theme-install-'.$action] = "<a href='$href'$class>$text</a>";
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return $display_tabs;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_columns() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2010-12-16 14:05:14 -05:00
|
|
|
function display() {
|
2011-01-11 17:42:22 -05:00
|
|
|
|
2012-02-09 12:20:26 -05:00
|
|
|
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
|
2010-10-24 22:57:43 -04:00
|
|
|
?>
|
2011-09-15 00:26:26 -04:00
|
|
|
<div class="tablenav top themes">
|
2010-10-24 22:57:43 -04:00
|
|
|
<div class="alignleft actions">
|
|
|
|
<?php do_action( 'install_themes_table_header' ); ?>
|
|
|
|
</div>
|
|
|
|
<?php $this->pagination( 'top' ); ?>
|
2010-12-20 13:45:05 -05:00
|
|
|
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
|
2010-10-24 22:57:43 -04:00
|
|
|
<br class="clear" />
|
|
|
|
</div>
|
|
|
|
|
2011-09-15 00:26:26 -04:00
|
|
|
<div id="availablethemes">
|
|
|
|
<?php $this->display_rows_or_placeholder(); ?>
|
|
|
|
</div>
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2011-09-15 00:26:26 -04:00
|
|
|
<div class="tablenav bottom themes">
|
2010-10-24 22:57:43 -04:00
|
|
|
<?php $this->pagination( 'bottom' ); ?>
|
2010-12-20 13:45:05 -05:00
|
|
|
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
|
2010-10-24 22:57:43 -04:00
|
|
|
<br class="clear" />
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function display_rows() {
|
|
|
|
$themes = $this->items;
|
2011-09-15 00:26:26 -04:00
|
|
|
$theme_names = array_keys( $themes );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2011-09-15 00:26:26 -04:00
|
|
|
foreach ( $theme_names as $theme_name ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
$class = array( 'available-theme' );
|
|
|
|
?>
|
2011-09-15 00:26:26 -04:00
|
|
|
<div class="<?php echo join( ' ', $class ); ?>"><?php
|
|
|
|
if ( isset( $themes[$theme_name] ) )
|
|
|
|
display_theme( $themes[$theme_name] );
|
|
|
|
?></div>
|
|
|
|
<?php } // end foreach $theme_names
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
}
|