2010-10-24 22:57:43 -04:00
< ? php
/**
2010-10-25 00:04:18 -04:00
* Sites List Table class .
2010-10-24 22:57:43 -04:00
*
* @ package WordPress
2010-10-25 00:04:18 -04:00
* @ subpackage List_Table
* @ since 3.1 . 0
2011-01-16 16:47:24 -05:00
* @ access private
2010-10-24 22:57:43 -04:00
*/
2010-11-04 04:07:03 -04:00
class WP_MS_Sites_List_Table extends WP_List_Table {
2010-10-24 22:57:43 -04:00
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
public function __construct ( $args = array () ) {
2011-04-29 16:05:12 -04:00
parent :: __construct ( array (
2010-10-24 22:57:43 -04:00
'plural' => 'sites' ,
2012-09-19 08:43:31 -04:00
'screen' => isset ( $args [ 'screen' ] ) ? $args [ 'screen' ] : null ,
2010-10-24 22:57:43 -04:00
) );
}
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
public function ajax_user_can () {
2010-12-16 04:18:28 -05:00
return current_user_can ( 'manage_sites' );
2010-10-24 22:57:43 -04:00
}
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
public function prepare_items () {
2013-11-12 22:23:10 -05:00
global $s , $mode , $wpdb ;
$current_site = get_current_site ();
2010-10-24 22:57:43 -04:00
$mode = ( empty ( $_REQUEST [ 'mode' ] ) ) ? 'list' : $_REQUEST [ 'mode' ];
$per_page = $this -> get_items_per_page ( 'sites_network_per_page' );
$pagenum = $this -> get_pagenum ();
2013-03-01 12:00:25 -05:00
$s = isset ( $_REQUEST [ 's' ] ) ? wp_unslash ( trim ( $_REQUEST [ 's' ] ) ) : '' ;
2010-11-03 15:26:23 -04:00
$wild = '' ;
if ( false !== strpos ( $s , '*' ) ) {
$wild = '%' ;
$s = trim ( $s , '*' );
}
2014-07-17 05:14:16 -04:00
/*
* If the network is large and a search is not being performed , show only
* the latest blogs with no paging in order to avoid expensive count queries .
*/
2011-10-03 12:30:07 -04:00
if ( ! $s && wp_is_large_network () ) {
2010-11-01 13:53:03 -04:00
if ( ! isset ( $_REQUEST [ 'orderby' ]) )
2010-12-30 13:06:33 -05:00
$_GET [ 'orderby' ] = $_REQUEST [ 'orderby' ] = '' ;
2010-11-01 13:53:03 -04:00
if ( ! isset ( $_REQUEST [ 'order' ]) )
$_GET [ 'order' ] = $_REQUEST [ 'order' ] = 'DESC' ;
}
2010-10-24 22:57:43 -04:00
$query = " SELECT * FROM { $wpdb -> blogs } WHERE site_id = ' { $wpdb -> siteid } ' " ;
2010-11-03 14:28:02 -04:00
if ( empty ( $s ) ) {
// Nothing to do.
2011-07-15 11:42:26 -04:00
} elseif ( preg_match ( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/' , $s ) ||
preg_match ( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/' , $s ) ||
preg_match ( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/' , $s ) ||
preg_match ( '/^[0-9]{1,3}\.$/' , $s ) ) {
// IPv4 address
2014-06-09 20:44:15 -04:00
$sql = $wpdb -> prepare ( " SELECT blog_id FROM { $wpdb -> registration_log } WHERE { $wpdb -> registration_log } .IP LIKE %s " , $wpdb -> esc_like ( $s ) . $wild );
$reg_blog_ids = $wpdb -> get_col ( $sql );
2010-11-19 13:16:03 -05:00
if ( ! $reg_blog_ids )
$reg_blog_ids = array ( 0 );
2010-11-03 14:28:02 -04:00
$query = " SELECT *
2010-11-19 13:16:03 -05:00
FROM { $wpdb -> blogs }
2010-11-03 14:28:02 -04:00
WHERE site_id = '{$wpdb->siteid}'
2010-11-19 13:16:03 -05:00
AND { $wpdb -> blogs } . blog_id IN ( " . implode( ', ', $reg_blog_ids ) . " ) " ;
2010-11-03 14:28:02 -04:00
} else {
2011-07-15 11:42:26 -04:00
if ( is_numeric ( $s ) && empty ( $wild ) ) {
2014-06-09 20:44:15 -04:00
$query .= $wpdb -> prepare ( " AND ( { $wpdb -> blogs } .blog_id = %s ) " , $s );
2010-11-19 13:16:03 -05:00
} elseif ( is_subdomain_install () ) {
2014-06-09 20:44:15 -04:00
$blog_s = str_replace ( '.' . $current_site -> domain , '' , $s );
$blog_s = $wpdb -> esc_like ( $blog_s ) . $wild . $wpdb -> esc_like ( '.' . $current_site -> domain );
$query .= $wpdb -> prepare ( " AND ( { $wpdb -> blogs } .domain LIKE %s ) " , $blog_s );
2010-11-03 14:28:02 -04:00
} else {
2014-06-09 20:44:15 -04:00
if ( $s != trim ( '/' , $current_site -> path ) ) {
$blog_s = $wpdb -> esc_like ( $current_site -> path . $s ) . $wild . $wpdb -> esc_like ( '/' );
} else {
$blog_s = $wpdb -> esc_like ( $s );
}
$query .= $wpdb -> prepare ( " AND ( { $wpdb -> blogs } .path LIKE %s ) " , $blog_s );
2010-10-24 22:57:43 -04:00
}
}
2010-12-30 13:06:33 -05:00
$order_by = isset ( $_REQUEST [ 'orderby' ] ) ? $_REQUEST [ 'orderby' ] : '' ;
2010-10-24 22:57:43 -04:00
if ( $order_by == 'registered' ) {
$query .= ' ORDER BY registered ' ;
} elseif ( $order_by == 'lastupdated' ) {
$query .= ' ORDER BY last_updated ' ;
} elseif ( $order_by == 'blogname' ) {
2010-12-30 13:06:33 -05:00
if ( is_subdomain_install () )
$query .= ' ORDER BY domain ' ;
else
$query .= ' ORDER BY path ' ;
} elseif ( $order_by == 'blog_id' ) {
$query .= ' ORDER BY blog_id ' ;
2010-10-24 22:57:43 -04:00
} else {
2010-11-19 13:16:03 -05:00
$order_by = null ;
2010-10-24 22:57:43 -04:00
}
2010-11-19 13:16:03 -05:00
if ( isset ( $order_by ) ) {
$order = ( isset ( $_REQUEST [ 'order' ] ) && 'DESC' == strtoupper ( $_REQUEST [ 'order' ] ) ) ? " DESC " : " ASC " ;
$query .= $order ;
}
2010-10-24 22:57:43 -04:00
2010-11-01 13:53:03 -04:00
// Don't do an unbounded count on large networks
2011-10-03 12:30:07 -04:00
if ( ! wp_is_large_network () )
2010-11-01 13:53:03 -04:00
$total = $wpdb -> get_var ( str_replace ( 'SELECT *' , 'SELECT COUNT( blog_id )' , $query ) );
2010-10-24 22:57:43 -04:00
$query .= " LIMIT " . intval ( ( $pagenum - 1 ) * $per_page ) . " , " . intval ( $per_page );
$this -> items = $wpdb -> get_results ( $query , ARRAY_A );
2011-10-03 12:30:07 -04:00
if ( wp_is_large_network () )
2010-11-01 13:53:03 -04:00
$total = count ( $this -> items );
2010-10-24 22:57:43 -04:00
$this -> set_pagination_args ( array (
'total_items' => $total ,
'per_page' => $per_page ,
) );
}
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
public function no_items () {
2010-10-24 22:57:43 -04:00
_e ( 'No sites found.' );
}
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
protected function get_bulk_actions () {
2010-10-24 22:57:43 -04:00
$actions = array ();
2010-11-12 11:35:28 -05:00
if ( current_user_can ( 'delete_sites' ) )
$actions [ 'delete' ] = __ ( 'Delete' );
2010-10-24 22:57:43 -04:00
$actions [ 'spam' ] = _x ( 'Mark as Spam' , 'site' );
$actions [ 'notspam' ] = _x ( 'Not Spam' , 'site' );
return $actions ;
}
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
protected function pagination ( $which ) {
2010-10-24 22:57:43 -04:00
global $mode ;
parent :: pagination ( $which );
if ( 'top' == $which )
$this -> view_switcher ( $mode );
}
2014-07-11 23:27:14 -04:00
public function get_columns () {
2010-10-24 22:57:43 -04:00
$blogname_columns = ( is_subdomain_install () ) ? __ ( 'Domain' ) : __ ( 'Path' );
$sites_columns = array (
'cb' => '<input type="checkbox" />' ,
'blogname' => $blogname_columns ,
'lastupdated' => __ ( 'Last Updated' ),
'registered' => _x ( 'Registered' , 'site' ),
'users' => __ ( 'Users' )
);
if ( has_filter ( 'wpmublogsaction' ) )
$sites_columns [ 'plugins' ] = __ ( 'Actions' );
2013-11-23 16:58:10 -05:00
/**
* Filter the displayed site columns in Sites list table .
*
* @ since MU
*
* @ param array $sites_columns An array of displayed site columns . Default 'cb' ,
* 'blogname' , 'lastupdated' , 'registered' , 'users' .
*/
2010-10-24 22:57:43 -04:00
$sites_columns = apply_filters ( 'wpmu_blogs_columns' , $sites_columns );
return $sites_columns ;
}
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
protected function get_sortable_columns () {
2010-10-24 22:57:43 -04:00
return array (
'blogname' => 'blogname' ,
'lastupdated' => 'lastupdated' ,
2010-12-30 13:06:33 -05:00
'registered' => 'blog_id' ,
2010-10-24 22:57:43 -04:00
);
}
2014-07-14 11:42:15 -04:00
public function display_rows () {
2013-11-12 22:23:10 -05:00
global $mode ;
2010-10-24 22:57:43 -04:00
$status_list = array (
'archived' => array ( 'site-archived' , __ ( 'Archived' ) ),
'spam' => array ( 'site-spammed' , _x ( 'Spam' , 'site' ) ),
'deleted' => array ( 'site-deleted' , __ ( 'Deleted' ) ),
'mature' => array ( 'site-mature' , __ ( 'Mature' ) )
);
2014-06-29 14:11:14 -04:00
if ( 'list' == $mode ) {
$date = 'Y/m/d' ;
} else {
$date = 'Y/m/d \<\b\r \/\> g:i:s a' ;
}
2010-10-24 22:57:43 -04:00
$class = '' ;
foreach ( $this -> items as $blog ) {
$class = ( 'alternate' == $class ) ? '' : 'alternate' ;
reset ( $status_list );
$blog_states = array ();
foreach ( $status_list as $status => $col ) {
if ( get_blog_status ( $blog [ 'blog_id' ], $status ) == 1 ) {
$class = $col [ 0 ];
$blog_states [] = $col [ 1 ];
}
}
$blog_state = '' ;
if ( ! empty ( $blog_states ) ) {
$state_count = count ( $blog_states );
$i = 0 ;
$blog_state .= ' - ' ;
foreach ( $blog_states as $state ) {
++ $i ;
( $i == $state_count ) ? $sep = '' : $sep = ', ' ;
$blog_state .= " <span class='post-state'> $state $sep </span> " ;
}
}
echo " <tr class=' $class '> " ;
2013-11-12 22:23:10 -05:00
$blogname = ( is_subdomain_install () ) ? str_replace ( '.' . get_current_site () -> domain , '' , $blog [ 'domain' ] ) : $blog [ 'path' ];
2010-11-17 13:47:34 -05:00
2010-10-24 22:57:43 -04:00
list ( $columns , $hidden ) = $this -> get_column_info ();
foreach ( $columns as $column_name => $column_display_name ) {
2010-11-23 06:39:50 -05:00
$style = '' ;
if ( in_array ( $column_name , $hidden ) )
$style = ' style="display:none;"' ;
2010-10-24 22:57:43 -04:00
switch ( $column_name ) {
case 'cb' : ?>
< th scope = " row " class = " check-column " >
2013-08-26 14:46:08 -04:00
< ? php if ( ! is_main_site ( $blog [ 'blog_id' ] ) ) : ?>
2012-07-25 12:18:14 -04:00
< label class = " screen-reader-text " for = " blog_<?php echo $blog['blog_id'] ; ?> " >< ? php printf ( __ ( 'Select %s' ), $blogname ); ?> </label>
2010-10-24 22:57:43 -04:00
< input type = " checkbox " id = " blog_<?php echo $blog['blog_id'] ?> " name = " allblogs[] " value = " <?php echo esc_attr( $blog['blog_id'] ) ?> " />
2013-08-26 14:46:08 -04:00
< ? php endif ; ?>
2010-10-24 22:57:43 -04:00
</ th >
< ? php
break ;
2010-11-23 06:39:50 -05:00
case 'id' : ?>
2014-01-24 14:06:15 -05:00
< th scope = " row " >
2010-10-24 22:57:43 -04:00
< ? php echo $blog [ 'blog_id' ] ?>
</ th >
< ? php
break ;
2010-11-23 06:39:50 -05:00
case 'blogname' :
echo " <td class='column- $column_name $column_name ' $style > " ; ?>
2010-10-24 22:57:43 -04:00
< a href = " <?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?> " class = " edit " >< ? php echo $blogname . $blog_state ; ?> </a>
< ? php
2012-08-03 13:51:42 -04:00
if ( 'list' != $mode ) {
switch_to_blog ( $blog [ 'blog_id' ] );
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>' ;
restore_current_blog ();
}
2010-10-24 22:57:43 -04:00
// Preordered.
$actions = array (
'edit' => '' , 'backend' => '' ,
'activate' => '' , 'deactivate' => '' ,
'archive' => '' , 'unarchive' => '' ,
'spam' => '' , 'unspam' => '' ,
'delete' => '' ,
'visit' => '' ,
);
$actions [ 'edit' ] = '<span class="edit"><a href="' . esc_url ( network_admin_url ( 'site-info.php?id=' . $blog [ 'blog_id' ] ) ) . '">' . __ ( 'Edit' ) . '</a></span>' ;
$actions [ 'backend' ] = " <span class='backend'><a href=' " . esc_url ( get_admin_url ( $blog [ 'blog_id' ] ) ) . " ' class='edit'> " . __ ( 'Dashboard' ) . '</a></span>' ;
2013-11-12 22:23:10 -05:00
if ( get_current_site () -> blog_id != $blog [ 'blog_id' ] ) {
2010-10-24 22:57:43 -04:00
if ( get_blog_status ( $blog [ 'blog_id' ], 'deleted' ) == '1' )
2011-08-17 22:29:06 -04:00
$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>' ;
2010-10-24 22:57:43 -04:00
else
2011-08-17 22:29:06 -04:00
$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>' ;
2010-10-24 22:57:43 -04:00
if ( get_blog_status ( $blog [ 'blog_id' ], 'archived' ) == '1' )
2011-12-13 18:45:31 -05:00
$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>' ;
2010-10-24 22:57:43 -04:00
else
2011-08-17 22:29:06 -04:00
$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>' ;
2010-10-24 22:57:43 -04:00
if ( get_blog_status ( $blog [ 'blog_id' ], 'spam' ) == '1' )
2011-08-17 22:29:06 -04:00
$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>' ;
2010-10-24 22:57:43 -04:00
else
2011-08-17 22:29:06 -04:00
$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>' ;
2010-10-24 22:57:43 -04:00
2010-11-12 11:35:28 -05:00
if ( current_user_can ( 'delete_site' , $blog [ 'blog_id' ] ) )
2011-08-17 22:29:06 -04:00
$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>' ;
2010-10-24 22:57:43 -04:00
}
2012-10-11 13:48:42 -04:00
$actions [ 'visit' ] = " <span class='view'><a href=' " . esc_url ( get_home_url ( $blog [ 'blog_id' ], '/' ) ) . " ' rel='permalink'> " . __ ( 'Visit' ) . '</a></span>' ;
2010-12-03 07:12:44 -05:00
2013-11-23 16:58:10 -05:00
/**
* Filter the action links displayed for each site in the Sites list table .
*
* The 'Edit' , 'Dashboard' , 'Delete' , and 'Visit' links are displayed by
* default for each site . The site ' s status determines whether to show the
* 'Activate' or 'Deactivate' link , 'Unarchive' or 'Archive' links , and
* 'Not Spam' or 'Spam' link for each site .
*
* @ since 3.1 . 0
*
* @ param array $actions An array of action links to be displayed .
* @ param int $blog_id The site ID .
* @ param string $blogname Site path , formatted depending on whether it is a sub - domain
* or subdirectory multisite install .
*/
2010-12-03 07:12:44 -05:00
$actions = apply_filters ( 'manage_sites_action_links' , array_filter ( $actions ), $blog [ 'blog_id' ], $blogname );
2010-10-24 22:57:43 -04:00
echo $this -> row_actions ( $actions );
?>
</ td >
< ? php
break ;
2010-11-23 06:39:50 -05:00
case 'lastupdated' :
2014-01-24 14:06:15 -05:00
echo " <td class=' $column_name column- $column_name ' $style > " ;
2010-10-24 22:57:43 -04:00
echo ( $blog [ 'last_updated' ] == '0000-00-00 00:00:00' ) ? __ ( 'Never' ) : mysql2date ( $date , $blog [ 'last_updated' ] ); ?>
</ td >
< ? php
break ;
2010-11-23 06:39:50 -05:00
case 'registered' :
2014-01-24 14:06:15 -05:00
echo " <td class=' $column_name column- $column_name ' $style > " ;
2010-10-24 22:57:43 -04:00
if ( $blog [ 'registered' ] == '0000-00-00 00:00:00' )
echo '—' ;
else
echo mysql2date ( $date , $blog [ 'registered' ] );
?>
</ td >
2010-11-01 04:43:24 -04:00
< ? php
break ;
2010-11-23 06:39:50 -05:00
case 'users' :
2014-01-24 14:06:15 -05:00
echo " <td class=' $column_name column- $column_name ' $style > " ;
2010-10-24 22:57:43 -04:00
$blogusers = get_users ( array ( 'blog_id' => $blog [ 'blog_id' ], 'number' => 6 ) );
if ( is_array ( $blogusers ) ) {
$blogusers_warning = '' ;
if ( count ( $blogusers ) > 5 ) {
$blogusers = array_slice ( $blogusers , 0 , 5 );
2011-01-20 17:08:24 -05:00
$blogusers_warning = __ ( 'Only showing first 5 users.' ) . ' <a href="' . esc_url ( network_admin_url ( 'site-users.php?id=' . $blog [ 'blog_id' ] ) ) . '">' . __ ( 'More' ) . '</a>' ;
2010-10-24 22:57:43 -04:00
}
foreach ( $blogusers as $user_object ) {
2011-01-20 17:08:24 -05:00
echo '<a href="' . esc_url ( network_admin_url ( 'user-edit.php?user_id=' . $user_object -> ID ) ) . '">' . esc_html ( $user_object -> user_login ) . '</a> ' ;
2010-10-24 22:57:43 -04:00
if ( 'list' != $mode )
echo '( ' . $user_object -> user_email . ' )' ;
echo '<br />' ;
}
if ( $blogusers_warning != '' )
echo '<strong>' . $blogusers_warning . '</strong><br />' ;
}
?>
</ td >
< ? php
break ;
2010-11-01 04:43:24 -04:00
case 'plugins' : ?>
2010-11-28 12:39:44 -05:00
< ? php if ( has_filter ( 'wpmublogsaction' ) ) {
2014-01-24 14:06:15 -05:00
echo " <td class=' $column_name column- $column_name ' $style > " ;
2013-11-23 16:58:10 -05:00
/**
* Fires inside the auxiliary 'Actions' column of the Sites list table .
*
* By default this column is hidden unless something is hooked to the action .
*
* @ since MU
*
* @ param int $blog_id The site ID .
*/
2010-11-28 12:39:44 -05:00
do_action ( 'wpmublogsaction' , $blog [ 'blog_id' ] ); ?>
</ td >
< ? php }
break ;
2010-12-13 16:21:50 -05:00
2010-11-23 06:39:50 -05:00
default :
echo " <td class=' $column_name column- $column_name ' $style > " ;
2013-11-23 16:58:10 -05:00
/**
* Fires for each registered custom column in the Sites list table .
*
* @ since 3.1 . 0
*
* @ param string $column_name The name of the column to display .
* @ param int $blog_id The site ID .
*/
2010-11-23 08:50:23 -05:00
do_action ( 'manage_sites_custom_column' , $column_name , $blog [ 'blog_id' ] );
2010-11-23 06:39:50 -05:00
echo " </td> " ;
break ;
2010-10-24 22:57:43 -04:00
}
}
?>
</ tr >
< ? php
}
}
}