236
* Handles the checkbox column output.
241
* @param array $blog Current site.
243
public function column_cb( $blog ) {
244
if ( ! is_main_site( $blog['blog_id'] ) ) :
245
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
247
<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php
248
printf( __( 'Select %s' ), $blogname );
250
<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
255
* Handles the blogname column output.
260
* @global string $mode
262
* @param array $blog Current blog.
264
public function column_blogname( $blog ) {
267
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
268
$blog_states = array();
269
reset( $this->status_list );
271
foreach ( $this->status_list as $status => $col ) {
272
if ( $blog[ $status ] == 1 ) {
273
$blog_states[] = $col[1];
277
if ( ! empty( $blog_states ) ) {
278
$state_count = count( $blog_states );
280
$blog_state .= ' - ';
281
foreach ( $blog_states as $state ) {
283
$sep = ( $i == $state_count ) ? '' : ', ';
284
$blog_state .= "<span class='post-state'>$state$sep</span>";
289
<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
291
if ( 'list' !== $mode ) {
292
switch_to_blog( $blog['blog_id'] );
293
/* translators: 1: site name, 2: site tagline. */
294
echo '<p>' . sprintf( __( '%1$s – <em>%2$s</em>' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>';
295
restore_current_blog();
300
* Handles the lastupdated column output.
305
* @param array $blog Current site.
307
public function column_lastupdated( $blog ) {
310
if ( 'list' == $mode ) {
311
$date = __( 'Y/m/d' );
313
$date = __( 'Y/m/d g:i:s a' );
316
echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
320
* Handles the registered column output.
325
* @param array $blog Current site.
327
public function column_registered( $blog ) {
330
if ( 'list' == $mode ) {
331
$date = __( 'Y/m/d' );
333
$date = __( 'Y/m/d g:i:s a' );
336
if ( $blog['registered'] == '0000-00-00 00:00:00' ) {
339
echo mysql2date( $date, $blog['registered'] );
344
* Handles the users column output.
349
* @param array $blog Current site.
351
public function column_users( $blog ) {
352
$user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
353
if ( ! $user_count ) {
354
$blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) );
355
$user_count = count( $blog_users );
356
unset( $blog_users );
357
wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
361
'<a href="%s">%s</a>',
362
esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
363
number_format_i18n( $user_count )
368
* Handles the plugins column output.
373
* @param array $blog Current site.
375
public function column_plugins( $blog ) {
376
if ( has_filter( 'wpmublogsaction' ) ) {
378
* Fires inside the auxiliary 'Actions' column of the Sites list table.
380
* By default this column is hidden unless something is hooked to the action.
384
* @param int $blog_id The site ID.
386
do_action( 'wpmublogsaction', $blog['blog_id'] );
391
* Handles output for the default column.
396
* @param array $blog Current site.
397
* @param string $column_name Current column name.
399
public function column_default( $blog, $column_name ) {
401
* Fires for each registered custom column in the Sites list table.
405
* @param string $column_name The name of the column to display.
406
* @param int $blog_id The site ID.
408
do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
413
* @global string $mode
195
415
public function display_rows() {
198
$status_list = array(
199
'archived' => array( 'site-archived', __( 'Archived' ) ),
200
'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ),
201
'deleted' => array( 'site-deleted', __( 'Deleted' ) ),
202
'mature' => array( 'site-mature', __( 'Mature' ) )
205
if ( 'list' == $mode ) {
206
$date = __( 'Y/m/d' );
208
$date = __( 'Y/m/d g:i:s a' );
211
416
foreach ( $this->items as $blog ) {
213
reset( $status_list );
418
reset( $this->status_list );
215
$blog_states = array();
216
foreach ( $status_list as $status => $col ) {
217
if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
420
foreach ( $this->status_list as $status => $col ) {
421
if ( $blog[ $status ] == 1 ) {
218
422
$class = " class='{$col[0]}'";
219
$blog_states[] = $col[1];
223
if ( ! empty( $blog_states ) ) {
224
$state_count = count( $blog_states );
226
$blog_state .= ' - ';
227
foreach ( $blog_states as $state ) {
229
( $i == $state_count ) ? $sep = '' : $sep = ', ';
230
$blog_state .= "<span class='post-state'>$state$sep</span>";
233
426
echo "<tr{$class}>";
235
$blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
237
list( $columns, $hidden ) = $this->get_column_info();
239
foreach ( $columns as $column_name => $column_display_name ) {
241
if ( in_array( $column_name, $hidden ) )
242
$style = ' style="display:none;"';
244
switch ( $column_name ) {
246
<th scope="row" class="check-column">
247
<?php if ( ! is_main_site( $blog['blog_id'] ) ) : ?>
248
<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php printf( __( 'Select %s' ), $blogname ); ?></label>
249
<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
257
<?php echo $blog['blog_id'] ?>
263
echo "<td class='column-$column_name $column_name'$style>"; ?>
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>
266
if ( 'list' != $mode ) {
267
switch_to_blog( $blog['blog_id'] );
268
echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_option( 'blogname' ), get_option( 'blogdescription ' ) ) . '</p>';
269
restore_current_blog();
274
'edit' => '', 'backend' => '',
275
'activate' => '', 'deactivate' => '',
276
'archive' => '', 'unarchive' => '',
277
'spam' => '', 'unspam' => '',
282
$actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
283
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
284
if ( get_current_site()->blog_id != $blog['blog_id'] ) {
285
if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
286
$actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
288
$actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
290
if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
291
$actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
293
$actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
295
if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
296
$actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
298
$actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
300
if ( current_user_can( 'delete_site', $blog['blog_id'] ) )
301
$actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
304
$actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
307
* Filter the action links displayed for each site in the Sites list table.
309
* The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
310
* default for each site. The site's status determines whether to show the
311
* 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
312
* 'Not Spam' or 'Spam' link for each site.
316
* @param array $actions An array of action links to be displayed.
317
* @param int $blog_id The site ID.
318
* @param string $blogname Site path, formatted depending on whether it is a sub-domain
319
* or subdirectory multisite install.
321
$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
322
echo $this->row_actions( $actions );
329
echo "<td class='$column_name column-$column_name'$style>";
330
echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?>
335
echo "<td class='$column_name column-$column_name'$style>";
336
if ( $blog['registered'] == '0000-00-00 00:00:00' )
339
echo mysql2date( $date, $blog['registered'] );
345
echo "<td class='$column_name column-$column_name'$style>";
346
$blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
347
if ( is_array( $blogusers ) ) {
348
$blogusers_warning = '';
349
if ( count( $blogusers ) > 5 ) {
350
$blogusers = array_slice( $blogusers, 0, 5 );
351
$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'More' ) . '</a>';
353
foreach ( $blogusers as $user_object ) {
354
echo '<a href="' . esc_url( network_admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
355
if ( 'list' != $mode )
356
echo '( ' . $user_object->user_email . ' )';
359
if ( $blogusers_warning != '' )
360
echo '<strong>' . $blogusers_warning . '</strong><br />';
368
<?php if ( has_filter( 'wpmublogsaction' ) ) {
369
echo "<td class='$column_name column-$column_name'$style>";
371
* Fires inside the auxiliary 'Actions' column of the Sites list table.
373
* By default this column is hidden unless something is hooked to the action.
377
* @param int $blog_id The site ID.
379
do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
385
echo "<td class='$column_name column-$column_name'$style>";
387
* Fires for each registered custom column in the Sites list table.
391
* @param string $column_name The name of the column to display.
392
* @param int $blog_id The site ID.
394
do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
428
$this->single_row_columns( $blog );
435
* Gets the name of the default primary column.
440
* @return string Name of the default primary column, in this case, 'blogname'.
442
protected function get_default_primary_column_name() {
447
* Generates and displays row action links.
452
* @param object $blog Blog being acted upon.
453
* @param string $column_name Current column name.
454
* @param string $primary Primary column name.
455
* @return string Row actions output.
457
protected function handle_row_actions( $blog, $column_name, $primary ) {
458
if ( $primary !== $column_name ) {
462
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
466
'edit' => '', 'backend' => '',
467
'activate' => '', 'deactivate' => '',
468
'archive' => '', 'unarchive' => '',
469
'spam' => '', 'unspam' => '',
474
$actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
475
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
476
if ( get_current_site()->blog_id != $blog['blog_id'] ) {
477
if ( $blog['deleted'] == '1' ) {
478
$actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a></span>';
480
$actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
483
if ( $blog['archived'] == '1' ) {
484
$actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
486
$actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
489
if ( $blog['spam'] == '1' ) {
490
$actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
492
$actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
495
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
496
$actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a></span>';
500
$actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
503
* Filter the action links displayed for each site in the Sites list table.
505
* The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
506
* default for each site. The site's status determines whether to show the
507
* 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
508
* 'Not Spam' or 'Spam' link for each site.
512
* @param array $actions An array of action links to be displayed.
513
* @param int $blog_id The site ID.
514
* @param string $blogname Site path, formatted depending on whether it is a sub-domain
515
* or subdirectory multisite install.
517
$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
518
return $this->row_actions( $actions );