wp/wp-admin/includes/class-wp-ms-themes-list-table.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * MS Themes List Table class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage List_Table
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
class WP_MS_Themes_List_Table extends WP_List_Table {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    12
	public $site_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    13
	public $is_site_themes;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    14
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    15
	private $has_items;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    18
	 * Constructor.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
	 * @access public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
	 * @see WP_List_Table::__construct() for more information on default arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
	 * @param array $args An associative array of arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
	public function __construct( $args = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
		global $status, $page;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		parent::__construct( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
			'plural' => 'themes',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
		$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
		if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
			$status = 'all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
		$page = $this->get_pagenum();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
		$this->is_site_themes = ( 'site-themes-network' == $this->screen->id ) ? true : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
		if ( $this->is_site_themes )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
	protected function get_table_classes() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    48
		// todo: remove and add CSS for .themes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    49
		return array( 'widefat', 'plugins' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    52
	public function ajax_user_can() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		if ( $this->is_site_themes )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
			return current_user_can( 'manage_sites' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
			return current_user_can( 'manage_network_themes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
	public function prepare_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
		global $status, $totals, $page, $orderby, $order, $s;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		wp_reset_vars( array( 'orderby', 'order', 's' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		$themes = array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
			 * Filter the full array of WP_Theme objects to list in the Multisite
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    67
			 * themes list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    68
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
			 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    70
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
			 * @param array $all An array of WP_Theme objects to display in the list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
			'all' => apply_filters( 'all_themes', wp_get_themes() ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
			'search' => array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
			'enabled' => array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
			'disabled' => array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
			'upgrade' => array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		if ( $this->is_site_themes ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
			$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
			$allowed_where = 'site';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
			$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
			$allowed_where = 'network';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
		foreach ( (array) $themes['all'] as $key => $theme ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
			if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
				unset( $themes['all'][ $key ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			if ( $maybe_update && isset( $current->response[ $key ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
				$themes['all'][ $key ]->update = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
				$themes['upgrade'][ $key ] = $themes['all'][ $key ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
			$themes[ $filter ][ $key ] = $themes['all'][ $key ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
		if ( $s ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
			$status = 'search';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
			$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
		$totals = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
		foreach ( $themes as $type => $list )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			$totals[ $type ] = count( $list );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
		if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
			$status = 'all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
		$this->items = $themes[ $status ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
		WP_Theme::sort_by_name( $this->items );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
		$this->has_items = ! empty( $themes['all'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		$total_this_page = $totals[ $status ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
		if ( $orderby ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
			$orderby = ucfirst( $orderby );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
			$order = strtoupper( $order );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
			if ( $orderby == 'Name' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
				if ( 'ASC' == $order )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
					$this->items = array_reverse( $this->items );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
				uasort( $this->items, array( $this, '_order_callback' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		$start = ( $page - 1 ) * $themes_per_page;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
		if ( $total_this_page > $themes_per_page )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
			$this->items = array_slice( $this->items, $start, $themes_per_page, true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
		$this->set_pagination_args( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			'total_items' => $total_this_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			'per_page' => $themes_per_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   147
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   148
	 * @staticvar string $term
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
	 * @param WP_Theme $theme
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   150
	 * @return bool
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
	public function _search_callback( $theme ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
		static $term;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
		if ( is_null( $term ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
			$term = wp_unslash( $_REQUEST['s'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
			// Don't mark up; Do translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
			if ( false !== stripos( $theme->display( $field, false, true ), $term ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
				return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		if ( false !== stripos( $theme->get_stylesheet(), $term ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
			return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		if ( false !== stripos( $theme->get_template(), $term ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
			return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	// Not used by any core columns.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   173
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   174
	 * @global string $orderby
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   175
	 * @global string $order
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
	 * @param array $theme_a
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
	 * @param array $theme_b
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   178
	 * @return int
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   179
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   180
	public function _order_callback( $theme_a, $theme_b ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		global $orderby, $order;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		$a = $theme_a[ $orderby ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		$b = $theme_b[ $orderby ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
		if ( $a == $b )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
			return 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
		if ( 'DESC' == $order )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
			return ( $a < $b ) ? 1 : -1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
			return ( $a < $b ) ? -1 : 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   195
	public function no_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
		if ( ! $this->has_items )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
			_e( 'No themes found.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
			_e( 'You do not appear to have any themes available at this time.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
	public function get_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		global $status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
		return array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
			'cb'          => '<input type="checkbox" />',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
			'name'        => __( 'Theme' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
			'description' => __( 'Description' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
	protected function get_sortable_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
		return array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
			'name'         => 'name',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
	protected function get_views() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
		global $totals, $status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		$status_links = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		foreach ( $totals as $type => $count ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
			if ( !$count )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
			switch ( $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
				case 'all':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
				case 'enabled':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
					$text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
				case 'disabled':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
					$text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
				case 'upgrade':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
				case 'broken' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
					$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
			if ( $this->is_site_themes )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
				$url = 'site-themes.php?id=' . $this->site_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
				$url = 'themes.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
			if ( 'search' != $type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
					esc_url( add_query_arg('theme_status', $type, $url) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
					( $type == $status ) ? ' class="current"' : '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
					sprintf( $text, number_format_i18n( $count ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
				);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
		return $status_links;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   261
	protected function get_bulk_actions() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
		global $status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
		$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
		if ( 'enabled' != $status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
			$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
		if ( 'disabled' != $status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
			$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
		if ( ! $this->is_site_themes ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
			if ( current_user_can( 'update_themes' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
				$actions['update-selected'] = __( 'Update' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
			if ( current_user_can( 'delete_themes' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
				$actions['delete-selected'] = __( 'Delete' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		return $actions;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   278
	public function display_rows() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
		foreach ( $this->items as $theme )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
			$this->single_row( $theme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   283
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
	 * @global string $status
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   285
	 * @global int $page
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   286
	 * @global string $s
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
	 * @global array $totals
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
	 * @param WP_Theme $theme
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   289
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   290
	public function single_row( $theme ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
		global $status, $page, $s, $totals;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
		$context = $status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
		if ( $this->is_site_themes ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
			$url = "site-themes.php?id={$this->site_id}&amp;";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
			$allowed = $theme->is_allowed( 'site', $this->site_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
			$url = 'themes.php?';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
			$allowed = $theme->is_allowed( 'network' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
		// Pre-order.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
		$actions = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
			'enable' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
			'disable' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
			'edit' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
			'delete' => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
		$stylesheet = $theme->get_stylesheet();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
		$theme_key = urlencode( $stylesheet );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
		if ( ! $allowed ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
			if ( ! $theme->errors() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
				$actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
			$actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
		if ( current_user_can('edit_themes') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
			$actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
		if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;checked[]=' . $theme_key . '&amp;theme_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   327
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   328
		 * Filter the action links displayed for each theme in the Multisite
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   329
		 * themes list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   330
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   331
		 * The action links displayed are determined by the theme's status, and
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   332
		 * which Multisite themes list table is being displayed - the Network
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   333
		 * themes list table (themes.php), which displays all installed themes,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   334
		 * or the Site themes list table (site-themes.php), which displays the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   335
		 * non-network enabled themes when editing a site in the Network admin.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   336
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   337
		 * The default action links for the Network themes list table include
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   338
		 * 'Network Enable', 'Network Disable', 'Edit', and 'Delete'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   340
		 * The default action links for the Site themes list table include
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   341
		 * 'Enable', 'Disable', and 'Edit'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   342
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   343
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
		 * @param array    $actions An array of action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
		 * @param WP_Theme $theme   The current WP_Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
		 * @param string   $context Status of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
		$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
		 * Filter the action links of a specific theme in the Multisite themes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   353
		 * list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   355
		 * The dynamic portion of the hook name, `$stylesheet`, refers to the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   356
		 * directory name of the theme, which in most cases is synonymous
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
		 * with the template name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   358
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   359
		 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   360
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   361
		 * @param array    $actions An array of action links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   362
		 * @param WP_Theme $theme   The current WP_Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   363
		 * @param string   $context Status of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
		$actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
		$class = ! $allowed ? 'inactive' : 'active';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
		$checkbox_id = "checkbox_" . md5( $theme->get('Name') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
		$id = sanitize_html_class( $theme->get_stylesheet() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
			$class .= ' update';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
		echo "<tr id='$id' class='$class'>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
		list( $columns, $hidden ) = $this->get_column_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		foreach ( $columns as $column_name => $column_display_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
			$style = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
			if ( in_array( $column_name, $hidden ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
				$style = ' style="display:none;"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
			switch ( $column_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
				case 'cb':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
					echo "<th scope='row' class='check-column'>$checkbox</th>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
				case 'name':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
					echo "<td class='theme-title'$style><strong>" . $theme->display('Name') . "</strong>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
					echo $this->row_actions( $actions, true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
					echo "</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
				case 'description':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
					echo "<td class='column-description desc'$style>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
					if ( $theme->errors() ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
						$pre = $status == 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
						echo '<p><strong class="attention">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
					echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
						<div class='$class second theme-version-author-uri'>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
					$theme_meta = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
					if ( $theme->get('Version') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
						$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
					$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
					if ( $theme->get('ThemeURI') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
						$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
					/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   414
					 * Filter the array of row meta for each theme in the Multisite themes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
					 * list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
					 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   417
					 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   418
					 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   419
					 * @param array    $theme_meta An array of the theme's metadata,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   420
					 *                             including the version, author, and
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   421
					 *                             theme URI.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   422
					 * @param string   $stylesheet Directory name of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   423
					 * @param WP_Theme $theme      WP_Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
					 * @param string   $status     Status of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
					 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
					$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
					echo implode( ' | ', $theme_meta );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
					echo "</div></td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
				default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
					echo "<td class='$column_name column-$column_name'$style>";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   434
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   435
					/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   436
					 * Fires inside each custom column of the Multisite themes list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   437
					 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   438
					 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   439
					 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   440
					 * @param string   $column_name Name of the column.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   441
					 * @param string   $stylesheet  Directory name of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   442
					 * @param WP_Theme $theme       Current WP_Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
					 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
					do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
					echo "</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
		echo "</tr>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
		if ( $this->is_site_themes )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
			remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   453
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   454
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   455
		 * Fires after each row in the Multisite themes list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   456
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   457
		 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   458
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   459
		 * @param string   $stylesheet Directory name of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   460
		 * @param WP_Theme $theme      Current WP_Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   461
		 * @param string   $status     Status of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   462
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
		do_action( 'after_theme_row', $stylesheet, $theme, $status );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   464
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   465
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   466
		 * Fires after each specific row in the Multisite themes list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   467
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   468
		 * The dynamic portion of the hook name, `$stylesheet`, refers to the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   469
		 * directory name of the theme, most often synonymous with the template
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
		 * name of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   472
		 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   473
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   474
		 * @param string   $stylesheet Directory name of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   475
		 * @param WP_Theme $theme      Current WP_Theme object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   476
		 * @param string   $status     Status of the theme.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   477
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
}