wp/wp-admin/includes/class-wp-ms-sites-list-table.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 11:14:17 +0000
changeset 6 490d5cc509ed
parent 5 5e2f62d02dcd
child 7 cf61fcea0001
permissions -rw-r--r--
update portfolio
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
 * Sites 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_Sites_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
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    13
	 * Constructor.
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
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
	 * @access public
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
	 * @see WP_List_Table::__construct() for more information on default arguments.
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
	 * @param array $args An associative array of arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
	public function __construct( $args = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		parent::__construct( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
			'plural' => 'sites',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	public function ajax_user_can() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		return current_user_can( 'manage_sites' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
	public function prepare_items() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
		global $s, $mode, $wpdb;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
		$current_site = get_current_site();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
		$mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
		$per_page = $this->get_items_per_page( 'sites_network_per_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
		$pagenum = $this->get_pagenum();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
		$s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
		$wild = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		if ( false !== strpos($s, '*') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
			$wild = '%';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
			$s = trim($s, '*');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
		/*
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    52
		 * If the network is large and a search is not being performed, show only
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
		 * the latest blogs with no paging in order to avoid expensive count queries.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
		if ( !$s && wp_is_large_network() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
			if ( !isset($_REQUEST['orderby']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
				$_GET['orderby'] = $_REQUEST['orderby'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
			if ( !isset($_REQUEST['order']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
				$_GET['order'] = $_REQUEST['order'] = 'DESC';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		if ( empty($s) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
			// Nothing to do.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
		} elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
					preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
					preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
					preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
			// IPv4 address
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
			$sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . $wild );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
			$reg_blog_ids = $wpdb->get_col( $sql );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
			if ( !$reg_blog_ids )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
				$reg_blog_ids = array( 0 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
			$query = "SELECT *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
				FROM {$wpdb->blogs}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				WHERE site_id = '{$wpdb->siteid}'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
				AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
			if ( is_numeric($s) && empty( $wild ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    83
				$query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.blog_id = %s )", $s );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			} elseif ( is_subdomain_install() ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    85
				$blog_s = str_replace( '.' . $current_site->domain, '', $s );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    86
				$blog_s = $wpdb->esc_like( $blog_s ) . $wild . $wpdb->esc_like( '.' . $current_site->domain );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    87
				$query .= $wpdb->prepare( " AND ( {$wpdb->blogs}.domain LIKE %s ) ", $blog_s );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
			} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    89
				if ( $s != trim('/', $current_site->path) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    90
					$blog_s = $wpdb->esc_like( $current_site->path . $s ) . $wild . $wpdb->esc_like( '/' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    91
				} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    92
					$blog_s = $wpdb->esc_like( $s );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    93
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
				$query .= $wpdb->prepare( " AND  ( {$wpdb->blogs}.path LIKE %s )", $blog_s );
0
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
		$order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		if ( $order_by == 'registered' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			$query .= ' ORDER BY registered ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
		} elseif ( $order_by == 'lastupdated' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			$query .= ' ORDER BY last_updated ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		} elseif ( $order_by == 'blogname' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
			if ( is_subdomain_install() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
				$query .= ' ORDER BY domain ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
				$query .= ' ORDER BY path ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		} elseif ( $order_by == 'blog_id' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
			$query .= ' ORDER BY blog_id ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
			$order_by = null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
		if ( isset( $order_by ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			$order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
			$query .= $order;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
		// Don't do an unbounded count on large networks
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		if ( ! wp_is_large_network() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
			$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
		$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
		$this->items = $wpdb->get_results( $query, ARRAY_A );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		if ( wp_is_large_network() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
			$total = count($this->items);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
		$this->set_pagination_args( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
			'total_items' => $total,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
			'per_page' => $per_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
	public function no_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		_e( 'No sites found.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
	protected function get_bulk_actions() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
		$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
		if ( current_user_can( 'delete_sites' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			$actions['delete'] = __( 'Delete' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
		$actions['spam'] = _x( 'Mark as Spam', 'site' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
		$actions['notspam'] = _x( 'Not Spam', 'site' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
		return $actions;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   150
	 * @param string $which
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
	protected function pagination( $which ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
		global $mode;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
		parent::pagination( $which );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		if ( 'top' == $which )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
			$this->view_switcher( $mode );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   161
	public function get_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
		$blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		$sites_columns = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
			'cb'          => '<input type="checkbox" />',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
			'blogname'    => $blogname_columns,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
			'lastupdated' => __( 'Last Updated' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
			'registered'  => _x( 'Registered', 'site' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
			'users'       => __( 'Users' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
		if ( has_filter( 'wpmublogsaction' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
			$sites_columns['plugins'] = __( 'Actions' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   174
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   175
		 * Filter the displayed site columns in Sites list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
		 * @since MU
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   178
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   179
		 * @param array $sites_columns An array of displayed site columns. Default 'cb',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   180
		 *                             'blogname', 'lastupdated', 'registered', 'users'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   181
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
		$sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		return $sites_columns;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
	protected function get_sortable_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
		return array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
			'blogname'    => 'blogname',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
			'lastupdated' => 'lastupdated',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
			'registered'  => 'blog_id',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
		);
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 display_rows() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   196
		global $mode;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
		$status_list = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
			'archived' => array( 'site-archived', __( 'Archived' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
			'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
			'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
			'mature'   => array( 'site-mature', __( 'Mature' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
		if ( 'list' == $mode ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
			$date = __( 'Y/m/d' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
			$date = __( 'Y/m/d g:i:s a' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		foreach ( $this->items as $blog ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
			$class = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
			reset( $status_list );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
			$blog_states = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
			foreach ( $status_list as $status => $col ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
				if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
					$class = " class='{$col[0]}'";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
					$blog_states[] = $col[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
			$blog_state = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
			if ( ! empty( $blog_states ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
				$state_count = count( $blog_states );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
				$i = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
				$blog_state .= ' - ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
				foreach ( $blog_states as $state ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
					++$i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
					( $i == $state_count ) ? $sep = '' : $sep = ', ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
					$blog_state .= "<span class='post-state'>$state$sep</span>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
			echo "<tr{$class}>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   235
			$blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
			list( $columns, $hidden ) = $this->get_column_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
			foreach ( $columns as $column_name => $column_display_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
				$style = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
				if ( in_array( $column_name, $hidden ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
					$style = ' style="display:none;"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
				switch ( $column_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
					case 'cb': ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
						<th scope="row" class="check-column">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
							<?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
							<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
							<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
							<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
						</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
					case 'id':?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
						<th scope="row">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
							<?php echo $blog['blog_id'] ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
						</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
					case 'blogname':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
						echo "<td class='column-$column_name $column_name'$style>"; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
							<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
							<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
							if ( 'list' != $mode ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
								switch_to_blog( $blog['blog_id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
								echo '<p>' . sprintf( _x( '%1$s &#8211; <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
								restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
							}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
							// Preordered.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
							$actions = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
								'edit' => '', 'backend' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
								'activate' => '', 'deactivate' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
								'archive' => '', 'unarchive' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
								'spam' => '', 'unspam' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
								'delete' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
								'visit' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
							);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
							$actions['edit']	= '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
							$actions['backend']	= "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
							if ( get_current_site()->blog_id != $blog['blog_id'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
								if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
									$actions['activate']	= '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
								else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
									$actions['deactivate']	= '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
								if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
									$actions['unarchive']	= '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
								else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
									$actions['archive']	= '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
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 ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
									$actions['unspam']	= '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
								else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
									$actions['spam']	= '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
								if ( current_user_can( 'delete_site', $blog['blog_id'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
									$actions['delete']	= '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
							}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
							$actions['visit']	= "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
							/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
							 * Filter the action links displayed for each site in the Sites list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   308
							 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   309
							 * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   310
							 * default for each site. The site's status determines whether to show the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
							 * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
							 * 'Not Spam' or 'Spam' link for each site.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
							 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
							 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
							 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
							 * @param array  $actions  An array of action links to be displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
							 * @param int    $blog_id  The site ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   318
							 * @param string $blogname Site path, formatted depending on whether it is a sub-domain
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
							 *                         or subdirectory multisite install.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
							 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
							$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
							echo $this->row_actions( $actions );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
					?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
						</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
					case 'lastupdated':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   329
						echo "<td class='$column_name column-$column_name'$style>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
							echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
						</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
				case 'registered':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   335
						echo "<td class='$column_name column-$column_name'$style>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
						if ( $blog['registered'] == '0000-00-00 00:00:00' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
							echo '&#x2014;';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
						else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
							echo mysql2date( $date, $blog['registered'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
						?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
						</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
				case 'users':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
						echo "<td class='$column_name column-$column_name'$style>";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
							$blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
							if ( is_array( $blogusers ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
								$blogusers_warning = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
								if ( count( $blogusers ) > 5 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
									$blogusers = array_slice( $blogusers, 0, 5 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
									$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'More' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
								}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
								foreach ( $blogusers as $user_object ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
									echo '<a href="' . esc_url( network_admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
									if ( 'list' != $mode )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
										echo '( ' . $user_object->user_email . ' )';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
									echo '<br />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
								}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
								if ( $blogusers_warning != '' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
									echo '<strong>' . $blogusers_warning . '</strong><br />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
							}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
							?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
						</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
				case 'plugins': ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
					<?php if ( has_filter( 'wpmublogsaction' ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   369
					echo "<td class='$column_name column-$column_name'$style>";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   370
						/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
						 * Fires inside the auxiliary 'Actions' column of the Sites list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   372
						 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
						 * By default this column is hidden unless something is hooked to the action.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
						 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   375
						 * @since MU
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   376
						 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   377
						 * @param int $blog_id The site ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
						 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
						do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
					</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
					<?php }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
				default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
					echo "<td class='$column_name column-$column_name'$style>";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   386
					/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   387
					 * Fires for each registered custom column in the Sites list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   388
					 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
					 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   390
					 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   391
					 * @param string $column_name The name of the column to display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
					 * @param int    $blog_id     The site ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
					 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
					do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
					echo "</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
			?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
}