2010-01-05 23:02:57 -05:00
< ? php
2010-04-04 09:29:35 -04:00
/**
* Multisite sites administration panel .
*
* @ package WordPress
* @ subpackage Multisite
* @ since 3.0 . 0
*/
2010-04-01 17:21:27 -04:00
require_once ( './admin.php' );
2010-01-05 23:02:57 -05:00
2010-04-16 09:35:44 -04:00
if ( ! is_multisite () )
2010-04-01 17:21:27 -04:00
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-01-06 15:19:35 -05:00
2010-04-02 20:10:44 -04:00
if ( ! current_user_can ( 'manage_sites' ) )
wp_die ( __ ( 'You do not have permission to access this page.' ) );
2010-04-01 17:21:27 -04:00
$title = __ ( 'Sites' );
2010-01-06 19:30:53 -05:00
$parent_file = 'ms-admin.php' ;
2010-01-05 23:02:57 -05:00
wp_enqueue_script ( 'admin-forms' );
2010-04-01 17:21:27 -04:00
require_once ( './admin-header.php' );
2010-01-07 10:52:22 -05:00
2010-04-01 17:21:27 -04:00
$id = isset ( $_GET [ 'id' ] ) ? intval ( $_GET [ 'id' ] ) : 0 ;
2010-01-05 23:02:57 -05:00
2010-04-01 17:21:27 -04:00
if ( isset ( $_GET [ 'updated' ] ) && $_GET [ 'updated' ] == 'true' && ! empty ( $_GET [ 'action' ] ) ) {
2010-01-05 23:02:57 -05:00
?>
2010-04-07 23:36:52 -04:00
< div id = " message " class = " updated " >< p >
2010-01-05 23:02:57 -05:00
< ? php
2010-04-01 17:21:27 -04:00
switch ( $_GET [ 'action' ] ) {
2010-01-05 23:02:57 -05:00
case 'all_notspam' :
2010-04-02 20:10:44 -04:00
_e ( 'Sites removed from spam.' );
2010-01-05 23:02:57 -05:00
break ;
case 'all_spam' :
2010-04-02 20:10:44 -04:00
_e ( 'Sites marked as spam.' );
2010-01-05 23:02:57 -05:00
break ;
case 'all_delete' :
2010-04-01 17:21:27 -04:00
_e ( 'Sites deleted.' );
2010-01-05 23:02:57 -05:00
break ;
case 'delete' :
2010-04-01 17:21:27 -04:00
_e ( 'Site deleted.' );
2010-01-05 23:02:57 -05:00
break ;
case 'add-blog' :
2010-04-01 17:21:27 -04:00
_e ( 'Site added.' );
2010-01-05 23:02:57 -05:00
break ;
case 'archive' :
2010-04-01 17:21:27 -04:00
_e ( 'Site archived.' );
2010-01-05 23:02:57 -05:00
break ;
case 'unarchive' :
2010-04-01 17:21:27 -04:00
_e ( 'Site unarchived.' );
2010-01-05 23:02:57 -05:00
break ;
case 'activate' :
2010-04-01 17:21:27 -04:00
_e ( 'Site activated.' );
2010-01-05 23:02:57 -05:00
break ;
case 'deactivate' :
2010-04-01 17:21:27 -04:00
_e ( 'Site deactivated.' );
2010-01-05 23:02:57 -05:00
break ;
case 'unspam' :
2010-04-02 20:10:44 -04:00
_e ( 'Site removed from spam.' );
2010-01-05 23:02:57 -05:00
break ;
case 'spam' :
2010-04-02 20:10:44 -04:00
_e ( 'Site marked as spam.' );
2010-01-05 23:02:57 -05:00
break ;
default :
2010-04-01 17:21:27 -04:00
_e ( 'Settings saved.' );
2010-01-05 23:02:57 -05:00
break ;
}
?>
</ p ></ div >
< ? php
}
2010-04-01 17:21:27 -04:00
$action = isset ( $_GET [ 'action' ] ) ? $_GET [ 'action' ] : 'list' ;
2010-01-20 18:01:09 -05:00
switch ( $action ) {
2010-04-01 17:21:27 -04:00
// Edit site
case 'editblog' :
2010-01-05 23:02:57 -05:00
$blog_prefix = $wpdb -> get_blog_prefix ( $id );
2010-01-29 12:36:57 -05:00
$options = $wpdb -> get_results ( " SELECT * FROM { $blog_prefix } options WHERE option_name NOT LIKE ' \ _%' AND option_name NOT LIKE '%user_roles' " );
2010-04-01 17:21:27 -04:00
$details = get_blog_details ( $id );
2010-01-05 23:02:57 -05:00
$editblog_roles = get_blog_option ( $id , " { $blog_prefix } user_roles " );
2010-02-09 13:03:46 -05:00
$is_main_site = is_main_site ( $id );
2010-01-05 23:02:57 -05:00
?>
< div class = " wrap " >
2010-01-20 17:35:21 -05:00
< ? php screen_icon (); ?>
2010-04-01 17:21:27 -04:00
< h2 >< ? php _e ( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2>
2010-01-06 19:24:03 -05:00
< form method = " post " action = " ms-edit.php?action=updateblog " >
2010-04-01 17:21:27 -04:00
< ? php wp_nonce_field ( 'editblog' ); ?>
< input type = " hidden " name = " id " value = " <?php echo esc_attr( $id ) ?> " />
< div class = " metabox-holder " style = " width:49%;float:left; " >
< div id = " blogedit_bloginfo " class = " postbox " >
< h3 class = " hndle " >< span >< ? php _e ( 'Site info (wp_blogs)' ); ?> </span></h3>
< div class = " inside " >
< table class = " form-table " >
< tr class = " form-field form-required " >
< th scope = " row " >< ? php _e ( 'Domain' ) ?> </th>
2010-01-05 23:02:57 -05:00
< ? php
2010-04-01 17:21:27 -04:00
$protocol = is_ssl () ? 'https://' : 'http://' ;
if ( $is_main_site ) { ?>
< td >< code >< ? php echo $protocol ; echo esc_attr ( $details -> domain ) ?> </code></td>
< ? php } else { ?>
< td >< ? php echo $protocol ; ?> <input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td>
< ? php } ?>
</ tr >
< tr class = " form-field form-required " >
< th scope = " row " >< ? php _e ( 'Path' ) ?> </th>
< ? php if ( $is_main_site ) { ?>
< td >< code >< ? php echo esc_attr ( $details -> path ) ?> </code></td>
< ? php } else { ?>
< td >< input name = " blog[path] " type = " text " id = " path " value = " <?php echo esc_attr( $details->path ) ?> " size = " 40 " style = 'margin-bottom:5px;' />
< br />< input type = " checkbox " style = " width:20px; " name = " update_home_url " value = " update " < ? php if ( get_blog_option ( $id , 'siteurl' ) == untrailingslashit ( get_blogaddress_by_id ( $id ) ) || get_blog_option ( $id , 'home' ) == untrailingslashit ( get_blogaddress_by_id ( $id ) ) ) echo 'checked="checked"' ; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td>
< ? php } ?>
</ tr >
< tr class = " form-field " >
< th scope = " row " >< ? php _e ( 'Registered' ) ?> </th>
< td >< input name = " blog[registered] " type = " text " id = " blog_registered " value = " <?php echo esc_attr( $details->registered ) ?> " size = " 40 " /></ td >
</ tr >
< tr class = " form-field " >
< th scope = " row " >< ? php _e ( 'Last Updated' ) ?> </th>
< td >< input name = " blog[last_updated] " type = " text " id = " blog_last_updated " value = " <?php echo esc_attr( $details->last_updated ) ?> " size = " 40 " /></ td >
</ tr >
2010-04-06 19:13:44 -04:00
< tr >
< th scope = " row " >< ? php _e ( 'Site Settings' ); ?> </th>
< td >
2010-04-03 07:15:51 -04:00
< ? php
2010-04-16 09:35:44 -04:00
$checked_fields = array ( 'public' => __ ( 'Public' ) );
2010-04-16 09:45:56 -04:00
if ( ! $is_main_site ) {
$checked_fields [ 'archived' ] = __ ( 'Archived' );
$checked_fields [ 'spam' ] = __ ( 'Spam' );
$checked_fields [ 'deleted' ] = __ ( 'Deleted' );
}
2010-04-06 19:13:44 -04:00
$checked_fields [ 'mature' ] = __ ( 'Mature' );
2010-04-03 07:15:51 -04:00
foreach ( $checked_fields as $field_key => $field_label ) {
?>
2010-04-16 09:35:44 -04:00
< input type = " checkbox " name = " blog[<?php echo $field_key ; ?>] " id = " blog_<?php echo $field_key ; ?> " value = " 1 " < ? php checked ( $details -> $field_key ); ?> />
2010-04-06 19:13:44 -04:00
< label for = " blog_<?php echo $field_key ; ?> " >< ? php echo $field_label ; ?> </label><br/>
2010-04-02 20:10:44 -04:00
< ? php } ?>
2010-04-06 19:13:44 -04:00
</ td >
</ tr >
2010-04-01 17:21:27 -04:00
</ table >
< p class = " submit " style = " text-align:center; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e( 'Update Options' ) ?> " /></ p >
</ div >
</ div >
< div id = " blogedit_blogoptions " class = " postbox " >
< h3 class = " hndle " >< span >< ? php printf ( __ ( 'Site options (%soptions)' ), $blog_prefix ); ?> </span></h3>
< div class = " inside " >
< table class = " form-table " >
< ? php
$editblog_default_role = 'subscriber' ;
foreach ( $options as $option ) {
if ( $option -> option_name == 'default_role' )
$editblog_default_role = $option -> option_value ;
$disabled = false ;
$class = 'all-options' ;
if ( is_serialized ( $option -> option_value ) ) {
if ( is_serialized_string ( $option -> option_value ) ) {
$option -> option_value = esc_html ( maybe_unserialize ( $option -> option_value ), 'single' );
2010-01-05 23:02:57 -05:00
} else {
2010-04-01 17:21:27 -04:00
$option -> option_value = 'SERIALIZED DATA' ;
$disabled = true ;
$class = 'all-options disabled' ;
2010-01-05 23:02:57 -05:00
}
2010-04-01 17:21:27 -04:00
}
if ( strpos ( $option -> option_value , " \n " ) !== false ) {
2010-01-05 23:02:57 -05:00
?>
2010-04-01 17:21:27 -04:00
< tr class = " form-field " >
< th scope = " row " >< ? php echo ucwords ( str_replace ( " _ " , " " , $option -> option_name ) ) ?> </th>
< td >< textarea class = " <?php echo $class ; ?> " rows = " 5 " cols = " 40 " name = " option[<?php echo esc_attr( $option->option_name ) ?>] " id = " <?php echo esc_attr( $option->option_name ) ?> " < ? php disabled ( $disabled ) ?> ><?php wp_htmledit_pre( $option->option_value ) ?></textarea></td>
</ tr >
< ? php
} else {
?>
< tr class = " form-field " >
< th scope = " row " >< ? php esc_html_e ( ucwords ( str_replace ( " _ " , " " , $option -> option_name ) ) ); ?> </th>
< ? php if ( $is_main_site && in_array ( $option -> option_name , array ( 'siteurl' , 'home' ) ) ) { ?>
< td >< code >< ? php esc_html_e ( $option -> option_value ) ?> </code></td>
< ? php } else { ?>
< td >< input class = " <?php echo $class ; ?> " name = " option[<?php echo esc_attr( $option->option_name ) ?>] " type = " text " id = " <?php echo esc_attr( $option->option_name ) ?> " value = " <?php echo esc_attr( $option->option_value ) ?> " size = " 40 " < ? php disabled ( $disabled ) ?> /></td>
< ? php } ?>
</ tr >
< ? php
}
} // End foreach
?>
</ table >
< p class = " submit " style = " text-align:center; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e( 'Update Options' ) ?> " /></ p >
</ div >
</ div >
2010-01-05 23:02:57 -05:00
</ div >
2010-01-06 23:27:46 -05:00
2010-04-01 17:21:27 -04:00
< div class = " metabox-holder " style = " width:49%;float:right; " >
< ? php
// Site Themes
$themes = get_themes ();
$blog_allowed_themes = wpmu_get_blog_allowedthemes ( $id );
$allowed_themes = get_site_option ( 'allowedthemes' );
if ( ! $allowed_themes )
$allowed_themes = array_keys ( $themes );
$out = '' ;
foreach ( $themes as $key => $theme ) {
$theme_key = esc_html ( $theme [ 'Stylesheet' ] );
if ( ! isset ( $allowed_themes [ $theme_key ] ) ) {
$checked = isset ( $blog_allowed_themes [ $theme_key ] ) ? 'checked="checked"' : '' ;
$out .= ' < tr class = " form-field form-required " >
< th title = " ' . esc_attr( $theme["Description"] ).' " scope = " row " > ' . esc_html( $key ) . ' </ th >
< td >< label >< input name = " theme[' . esc_attr( $theme_key ) . '] " type = " checkbox " style = " width:20px; " value = " on " '.$checked.' /> ' . __( ' Active ' ) . ' </ label ></ td >
</ tr > ' ;
2010-01-05 23:02:57 -05:00
}
2010-04-01 17:21:27 -04:00
}
2010-01-06 23:27:46 -05:00
2010-04-01 17:21:27 -04:00
if ( $out != '' ) {
?>
< div id = " blogedit_blogthemes " class = " postbox " >
< h3 class = " hndle " >< span >< ? php esc_html_e ( 'Site Themes' ); ?> </span></h3>
< div class = " inside " >
< p class = " description " >< ? php _e ( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?> </p>
< table class = " form-table " >
< ? php echo $out ; ?>
</ table >
< p class = " submit " style = " text-align:center; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e( 'Update Options' ) ?> " /></ p >
</ div ></ div >
< ? php }
// Site users
$blogusers = get_users_of_blog ( $id );
if ( is_array ( $blogusers ) ) {
echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __ ( 'Site Users' ) . '</span></h3><div class="inside">' ;
echo '<table class="form-table">' ;
echo " <tr><th> " . __ ( 'User' ) . " </th><th> " . __ ( 'Role' ) . " </th><th> " . __ ( 'Password' ) . " </th><th> " . __ ( 'Remove' ) . " </th></tr> " ;
reset ( $blogusers );
foreach ( ( array ) $blogusers as $key => $val ) {
if ( isset ( $val -> meta_value ) && ! $val -> meta_value )
continue ;
$t = @ unserialize ( $val -> meta_value );
if ( is_array ( $t ) ) {
reset ( $t );
$existing_role = key ( $t );
2010-01-05 23:02:57 -05:00
}
2010-04-01 17:21:27 -04:00
echo '<tr><td><a href="user-edit.php?user_id=' . $val -> user_id . '">' . $val -> user_login . '</a></td>' ;
if ( $val -> user_id != $current_user -> data -> ID ) {
?>
2010-01-05 23:02:57 -05:00
< td >
2010-04-01 17:21:27 -04:00
< select name = " role[<?php echo $val->user_id ?>] " id = " new_role " >< ? php
foreach ( $editblog_roles as $role => $role_assoc ){
$name = translate_user_role ( $role_assoc [ 'name' ] );
echo '<option ' . selected ( $role , $existing_role ) . ' value="' . esc_attr ( $role ) . '">' . esc_html ( $name ) . '</option>' ;
}
?>
2010-01-05 23:02:57 -05:00
</ select >
</ td >
2010-04-01 17:21:27 -04:00
< td >
< input type = " text " name = " user_password[<?php echo esc_attr( $val->user_id ) ?>] " />
</ td >
< ? php
echo '<td><input title="' . __ ( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr ( $val -> user_id ) . ']" /></td>' ;
} else {
echo " <td><strong> " . __ ( 'N/A' ) . " </strong></td><td><strong> " . __ ( 'N/A' ) . " </strong></td><td><strong> " . __ ( 'N/A' ) . " </strong></td> " ;
}
echo '</tr>' ;
}
echo " </table> " ;
echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__ ( 'Update Options' ) . '" /></p>' ;
echo " </div></div> " ;
}
?>
2010-01-06 23:27:46 -05:00
2010-04-01 17:21:27 -04:00
< div id = " blogedit_blogadduser " class = " postbox " >
< h3 class = " hndle " >< span >< ? php _e ( 'Add a new user' ); ?> </span></h3>
< div class = " inside " >
2010-04-11 06:41:54 -04:00
< p class = " description " >< ? php _e ( 'Enter the username of an existing user and hit “Update Options” to add the user.' ) ?> </p>
2010-04-01 17:21:27 -04:00
< table class = " form-table " >
< tr >
< th scope = " row " >< ? php _e ( 'User Login:' ) ?> </th>
< td >< input type = " text " name = " newuser " id = " newuser " /></ td >
</ tr >
< tr >
< th scope = " row " >< ? php _e ( 'Role:' ) ?> </th>
< td >
< select name = " new_role " id = " new_role " >
< ? php
reset ( $editblog_roles );
foreach ( $editblog_roles as $role => $role_assoc ){
$name = translate_user_role ( $role_assoc [ 'name' ] );
$selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '' ;
echo '<option ' . $selected . ' value="' . esc_attr ( $role ) . '">' . esc_html ( $name ) . '</option>' ;
}
?>
</ select >
</ td >
</ tr >
</ table >
< p class = " submit " style = " text-align:center; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e( 'Update Options' ) ?> " /></ p >
</ div >
</ div >
< div id = " blogedit_miscoptions " class = " postbox " >
< h3 class = " hndle " >< span >< ? php _e ( 'Misc Site Actions' ) ?> </span></h3>
< div class = " inside " >
< table class = " form-table " >
< ? php do_action ( 'wpmueditblogaction' , $id ); ?>
</ table >
< p class = " submit " style = " text-align:center; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e( 'Update Options' ) ?> " /></ p >
</ div >
</ div >
2010-01-05 23:02:57 -05:00
</ div >
2010-01-06 23:27:46 -05:00
2010-01-05 23:02:57 -05:00
< div style = " clear:both; " ></ div >
</ form >
</ div >
< ? php
break ;
2010-04-01 17:21:27 -04:00
// List sites
2010-01-20 18:01:09 -05:00
case 'list' :
2010-01-05 23:02:57 -05:00
default :
2010-03-06 13:31:10 -05:00
$pagenum = isset ( $_GET [ 'paged' ] ) ? absint ( $_GET [ 'paged' ] ) : 0 ;
if ( empty ( $pagenum ) )
$pagenum = 1 ;
$per_page = ( int ) get_user_option ( 'ms_sites_per_page' );
if ( empty ( $per_page ) || $per_page < 1 )
$per_page = 15 ;
$per_page = apply_filters ( 'ms_sites_per_page' , $per_page );
2010-04-01 17:21:27 -04:00
$s = isset ( $_GET [ 's' ] ) ? stripslashes ( trim ( $_GET [ 's' ] ) ) : '' ;
2010-03-17 12:27:25 -04:00
$like_s = esc_sql ( like_escape ( $s ) );
2010-01-15 17:11:12 -05:00
2010-01-05 23:02:57 -05:00
$query = " SELECT * FROM { $wpdb -> blogs } WHERE site_id = ' { $wpdb -> siteid } ' " ;
2010-03-06 13:31:10 -05:00
if ( isset ( $_GET [ 'searchaction' ] ) ) {
if ( 'name' == $_GET [ 'searchaction' ] ) {
$query .= " AND ( { $wpdb -> blogs } .domain LIKE '% { $like_s } %' OR { $wpdb -> blogs } .path LIKE '% { $like_s } %' ) " ;
} elseif ( 'id' == $_GET [ 'searchaction' ] ) {
$query .= " AND { $wpdb -> blogs } .blog_id = ' { $like_s } ' " ;
} elseif ( 'ip' == $_GET [ 'searchaction' ] ) {
$query = " SELECT *
FROM { $wpdb -> blogs }, { $wpdb -> registration_log }
WHERE site_id = '{$wpdb->siteid}'
AND { $wpdb -> blogs } . blog_id = { $wpdb -> registration_log } . blog_id
AND { $wpdb -> registration_log } . IP LIKE ( '%{$like_s}%' ) " ;
}
}
2010-01-05 23:02:57 -05:00
2010-03-06 13:31:10 -05:00
$order_by = isset ( $_GET [ 'sortby' ] ) ? $_GET [ 'sortby' ] : 'id' ;
2010-01-22 17:14:22 -05:00
if ( $order_by == 'registered' ) {
2010-01-05 23:02:57 -05:00
$query .= ' ORDER BY registered ' ;
2010-01-22 17:14:22 -05:00
} elseif ( $order_by == 'lastupdated' ) {
2010-01-05 23:02:57 -05:00
$query .= ' ORDER BY last_updated ' ;
2010-01-22 17:14:22 -05:00
} elseif ( $order_by == 'blogname' ) {
2010-01-05 23:02:57 -05:00
$query .= ' ORDER BY domain ' ;
2010-01-22 17:14:22 -05:00
} else {
$order_by = 'id' ;
2010-03-06 13:31:10 -05:00
$query .= " ORDER BY { $wpdb -> blogs } .blog_id " ;
2010-01-05 23:02:57 -05:00
}
2010-03-06 13:31:10 -05:00
$order = ( isset ( $_GET [ 'order' ] ) && 'DESC' == $_GET [ 'order' ] ) ? " DESC " : " ASC " ;
2010-01-22 17:14:22 -05:00
$query .= $order ;
2010-01-05 23:02:57 -05:00
2010-04-01 17:21:27 -04:00
$total = $wpdb -> get_var ( str_replace ( 'SELECT *' , 'SELECT COUNT(blog_id)' , $query ) );
2010-01-05 23:02:57 -05:00
2010-04-01 17:21:27 -04:00
$query .= " LIMIT " . intval ( ( $pagenum - 1 ) * $per_page ) . " , " . intval ( $per_page );
2010-01-05 23:02:57 -05:00
$blog_list = $wpdb -> get_results ( $query , ARRAY_A );
2010-03-06 13:31:10 -05:00
$num_pages = ceil ( $total / $per_page );
$page_links = paginate_links ( array (
'base' => add_query_arg ( 'paged' , '%#%' ),
2010-01-05 23:02:57 -05:00
'format' => '' ,
2010-04-01 17:21:27 -04:00
'prev_text' => __ ( '«' ),
'next_text' => __ ( '»' ),
2010-03-06 13:31:10 -05:00
'total' => $num_pages ,
'current' => $pagenum
2010-01-05 23:02:57 -05:00
));
2010-03-06 13:31:10 -05:00
2010-04-01 17:21:27 -04:00
if ( empty ( $_GET [ 'mode' ] ) )
2010-03-06 13:31:10 -05:00
$mode = 'list' ;
else
$mode = esc_attr ( $_GET [ 'mode' ] );
2010-01-05 23:02:57 -05:00
?>
2010-03-06 13:31:10 -05:00
< div class = " wrap " >
2010-01-20 17:35:21 -05:00
< ? php screen_icon (); ?>
2010-03-06 13:31:10 -05:00
< h2 >< ? php _e ( 'Sites' ) ?>
2010-04-01 17:21:27 -04:00
< a href = " #form-add-site " class = " button add-new-h2 " >< ? php echo esc_html_x ( 'Add New' , 'sites' ); ?> </a>
2010-03-06 13:31:10 -05:00
< ? php
2010-04-01 17:21:27 -04:00
if ( isset ( $_GET [ 's' ] ) && $_GET [ 's' ] )
printf ( '<span class="subtitle">' . __ ( 'Search results for “%s”' ) . '</span>' , esc_html ( $s ) );
2010-03-06 13:31:10 -05:00
?>
</ h2 >
2010-01-14 14:42:55 -05:00
< form action = " ms-sites.php " method = " get " id = " ms-search " >
2010-03-06 13:31:10 -05:00
< p class = " search-box " >
< input type = " hidden " name = " action " value = " blogs " />
2010-04-01 17:21:27 -04:00
< input type = " text " name = " s " value = " <?php echo esc_attr( $s ); ?> " />
< input type = " submit " class = " button " value = " <?php esc_attr_e( 'Search Site by' ) ?> " />
2010-03-06 13:31:10 -05:00
< select name = " searchaction " >
2010-04-01 17:21:27 -04:00
< option value = " name " selected = " selected " >< ? php _e ( 'Name' ); ?> </option>
< option value = " id " >< ? php _e ( 'ID' ); ?> </option>
< option value = " ip " >< ? php _e ( 'IP address' ); ?> </option>
2010-03-06 13:31:10 -05:00
</ select >
</ p >
2010-01-05 23:02:57 -05:00
</ form >
2010-03-06 13:31:10 -05:00
< form id = " form-site-list " action = " ms-edit.php?action=allblogs " method = " post " >
2010-04-01 17:21:27 -04:00
< input type = " hidden " name = " mode " value = " <?php echo esc_attr( $mode ); ?> " />
2010-01-05 23:02:57 -05:00
< div class = " tablenav " >
2010-03-06 13:31:10 -05:00
< div class = " alignleft actions " >
< select name = " action " >
2010-04-01 17:21:27 -04:00
< option value = " -1 " selected = " selected " >< ? php _e ( 'Bulk Actions' ); ?> </option>
< option value = " delete " >< ? php _e ( 'Delete' ); ?> </option>
< option value = " spam " >< ? php _e ( 'Mark as Spam' ); ?> </option>
< option value = " notspam " >< ? php _e ( 'Not Spam' ); ?> </option>
2010-03-06 13:31:10 -05:00
</ select >
2010-04-01 17:21:27 -04:00
< input type = " submit " value = " <?php esc_attr_e( 'Apply' ); ?> " name = " doaction " id = " doaction " class = " button-secondary action " />
< ? php wp_nonce_field ( 'bulk-ms-sites' ); ?>
2010-03-06 13:31:10 -05:00
</ div >
< ? php if ( $page_links ) { ?>
< div class = " tablenav-pages " >
< ? php $page_links_text = sprintf ( '<span class="displaying-num">' . __ ( 'Displaying %s–%s of %s' ) . '</span>%s' ,
number_format_i18n ( ( $pagenum - 1 ) * $per_page + 1 ),
2010-04-22 13:59:21 -04:00
number_format_i18n ( min ( $pagenum * $per_page , $total ) ),
number_format_i18n ( $total ),
2010-03-06 13:31:10 -05:00
$page_links
); echo $page_links_text ; ?>
</ div >
< ? php } ?>
2010-03-17 12:27:25 -04:00
2010-03-06 13:31:10 -05:00
< div class = " view-switch " >
2010-04-01 17:21:27 -04:00
< a href = " <?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?> " >< img < ? php if ( 'list' == $mode ) echo 'class="current"' ; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
< a href = " <?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?> " >< img < ? php if ( 'excerpt' == $mode ) echo 'class="current"' ; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
2010-01-05 23:02:57 -05:00
</ div >
2010-03-06 13:31:10 -05:00
</ div >
2010-01-05 23:02:57 -05:00
2010-03-17 12:27:25 -04:00
< div class = " clear " ></ div >
2010-01-05 23:02:57 -05:00
< ? php
// define the columns to display, the syntax is 'internal name' => 'display name'
2010-04-01 17:21:27 -04:00
$blogname_columns = ( is_subdomain_install () ) ? __ ( 'Domain' ) : __ ( 'Path' );
$sites_columns = array (
'id' => __ ( 'ID' ),
2010-01-05 23:02:57 -05:00
'blogname' => $blogname_columns ,
2010-04-01 17:21:27 -04:00
'lastupdated' => __ ( 'Last Updated' ),
'registered' => __ ( 'Registered' ),
'users' => __ ( 'Users' )
2010-01-05 23:02:57 -05:00
);
2010-01-06 23:27:46 -05:00
2010-01-18 15:34:48 -05:00
if ( has_filter ( 'wpmublogsaction' ) )
2010-04-01 17:21:27 -04:00
$sites_columns [ 'plugins' ] = __ ( 'Actions' );
2010-01-06 23:27:46 -05:00
2010-04-01 17:21:27 -04:00
$sites_columns = apply_filters ( 'wpmu_blogs_columns' , $sites_columns );
2010-01-05 23:02:57 -05:00
?>
2010-03-06 13:31:10 -05:00
< table class = " widefat " >
2010-01-05 23:02:57 -05:00
< thead >
< tr >
2010-04-01 17:21:27 -04:00
< th class = " manage-column column-cb check-column " id = " cb " scope = " col " >
2010-03-06 13:31:10 -05:00
< input type = " checkbox " />
</ th >
< ? php
2010-04-01 17:21:27 -04:00
$col_url = '' ;
foreach ( $sites_columns as $column_id => $column_display_name ) {
2010-03-06 13:31:10 -05:00
$column_link = " <a href=' " ;
$order2 = '' ;
if ( $order_by == $column_id )
2010-04-01 17:21:27 -04:00
$order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC' ;
2010-03-06 13:31:10 -05:00
2010-04-01 17:21:27 -04:00
$column_link .= esc_url ( add_query_arg ( array ( 'order' => $order2 , 'paged' => $pagenum , 'sortby' => $column_id ), remove_query_arg ( array ( 'action' , 'updated' ), $_SERVER [ 'REQUEST_URI' ] ) ) );
2010-03-06 13:31:10 -05:00
$column_link .= " '> { $column_display_name } </a> " ;
2010-04-01 17:21:27 -04:00
$col_url .= '<th scope="col">' . ( ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ) . '</th>' ;
}
echo $col_url ?>
2010-01-05 23:02:57 -05:00
</ tr >
</ thead >
2010-03-06 13:31:10 -05:00
< tfoot >
< tr >
2010-04-01 17:21:27 -04:00
< th class = " manage-column column-cb check-column " id = " cb1 " scope = " col " >
2010-03-06 13:31:10 -05:00
< input type = " checkbox " />
</ th >
< ? php echo $col_url ?>
</ tr >
</ tfoot >
2010-04-01 17:21:27 -04:00
< tbody id = " the-site-list " class = " list:site " >
2010-01-05 23:02:57 -05:00
< ? php
2010-04-01 17:21:27 -04:00
$status_list = array ( 'archived' => array ( 'site-archived' , __ ( 'Archived' ) ), 'spam' => array ( 'site-spammed' , __ ( 'Spam' ) ), 'deleted' => array ( 'site-deleted' , __ ( 'Deleted' ) ), 'mature' => array ( 'site-mature' , __ ( 'Mature' ) ) );
2010-01-19 12:01:39 -05:00
if ( $blog_list ) {
2010-02-05 16:49:19 -05:00
$class = '' ;
2010-01-19 12:01:39 -05:00
foreach ( $blog_list as $blog ) {
2010-04-01 17:21:27 -04:00
$class = ( 'alternate' == $class ) ? '' : 'alternate' ;
2010-01-05 23:02:57 -05:00
reset ( $status_list );
2010-01-29 12:36:57 -05:00
$blog_states = array ();
2010-01-05 23:02:57 -05:00
foreach ( $status_list as $status => $col ) {
2010-01-18 15:34:48 -05:00
if ( get_blog_status ( $blog [ 'blog_id' ], $status ) == 1 ) {
2010-02-04 14:03:08 -05:00
$class = $col [ 0 ];
2010-01-29 12:36:57 -05:00
$blog_states [] = $col [ 1 ];
}
}
$blog_state = '' ;
2010-04-01 17:21:27 -04:00
if ( ! empty ( $blog_states ) ) {
$state_count = count ( $blog_states );
2010-01-29 12:36:57 -05:00
$i = 0 ;
$blog_state .= ' - ' ;
foreach ( $blog_states as $state ) {
++ $i ;
( $i == $state_count ) ? $sep = '' : $sep = ', ' ;
$blog_state .= " <span class='post-state'> $state $sep </span> " ;
2010-01-05 23:02:57 -05:00
}
}
2010-02-04 14:03:08 -05:00
echo " <tr class=' $class '> " ;
2010-01-05 23:02:57 -05:00
2010-04-01 17:21:27 -04:00
$blogname = ( is_subdomain_install () ) ? str_replace ( '.' . $current_site -> domain , '' , $blog [ 'domain' ] ) : $blog [ 'path' ];
foreach ( $sites_columns as $column_name => $column_display_name ) {
2010-01-29 12:36:57 -05:00
switch ( $column_name ) {
2010-01-05 23:02:57 -05:00
case 'id' : ?>
< th scope = " row " class = " check-column " >
2010-04-01 17:21:27 -04:00
< input type = " checkbox " id = " blog_<?php echo $blog['blog_id'] ?> " name = " allblogs[] " value = " <?php echo esc_attr( $blog['blog_id'] ) ?> " />
2010-01-05 23:02:57 -05:00
</ th >
2010-03-11 13:16:26 -05:00
< th valign = " top " scope = " row " >
2010-01-05 23:02:57 -05:00
< ? php echo $blog [ 'blog_id' ] ?>
</ th >
< ? php
break ;
2010-01-06 23:27:46 -05:00
2010-01-05 23:02:57 -05:00
case 'blogname' : ?>
2010-03-06 13:31:10 -05:00
< td class = " column-title " >
2010-04-01 17:21:27 -04:00
< a href = " <?php echo esc_url( admin_url( 'ms-sites.php?action=editblog&id=' . $blog['blog_id'] ) ); ?> " class = " edit " >< ? php echo $blogname . $blog_state ; ?> </a>
2010-01-05 23:02:57 -05:00
< ? php
2010-03-06 13:31:10 -05:00
if ( 'list' != $mode )
2010-03-11 13:16:26 -05:00
echo '<p>' . sprintf ( _x ( '%1$s – <em>%2$s' , '%1$s: site name. %2$s: site tagline.' ), get_blog_option ( $blog [ 'blog_id' ], 'blogname' ), get_blog_option ( $blog [ 'blog_id' ], 'blogdescription ' ) ) . '</em></p>' ;
2010-03-06 13:31:10 -05:00
2010-04-02 20:10:44 -04:00
// Preordered.
$actions = array (
'edit' => '' , 'backend' => '' ,
'activate' => '' , 'deactivate' => '' ,
'archive' => '' , 'unarchive' => '' ,
'spam' => '' , 'unspam' => '' ,
'delete' => '' ,
'visit' => '' ,
);
$actions [ 'edit' ] = '<span class="edit"><a href="' . esc_url ( admin_url ( 'ms-sites.php?action=editblog&id=' . $blog [ 'blog_id' ] ) ) . '">' . __ ( 'Edit' ) . '</a><span>' ;
$actions [ 'backend' ] = " <span class='backend'><a href=' " . esc_url ( get_admin_url ( $blog [ 'blog_id' ]) ) . " ' class='edit'> " . __ ( 'Backend' ) . '</a></span>' ;
2010-04-01 17:21:27 -04:00
if ( $current_site -> blog_id != $blog [ 'blog_id' ] ) {
if ( get_blog_status ( $blog [ 'blog_id' ], 'deleted' ) == '1' )
2010-04-11 06:41:54 -04:00
$actions [ 'activate' ] = '<span class="activate"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=activateblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to activate the site %s' ), $blogname ) ) ) ) . '">' . __ ( 'Activate' ) . '</a></span>' ;
2010-04-01 17:21:27 -04:00
else
2010-04-11 06:41:54 -04:00
$actions [ 'deactivate' ] = '<span class="activate"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=deactivateblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to deactivate the site %s' ), $blogname ) ) ) ) . '">' . __ ( 'Deactivate' ) . '</a></span>' ;
2010-04-02 20:10:44 -04:00
2010-04-01 17:21:27 -04:00
if ( get_blog_status ( $blog [ 'blog_id' ], 'archived' ) == '1' )
2010-04-11 06:41:54 -04:00
$actions [ 'unarchive' ] = '<span class="archive"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=unarchiveblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to unarchive the site %s.' ), $blogname ) ) ) ) . '">' . __ ( 'Unarchive' ) . '</a></span>' ;
2010-04-01 17:21:27 -04:00
else
2010-04-11 06:41:54 -04:00
$actions [ 'archive' ] = '<span class="archive"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=archiveblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to archive the site %s.' ), $blogname ) ) ) ) . '">' . __ ( 'Archive' ) . '</a></span>' ;
2010-04-02 20:10:44 -04:00
2010-04-01 17:21:27 -04:00
if ( get_blog_status ( $blog [ 'blog_id' ], 'spam' ) == '1' )
2010-04-11 06:41:54 -04:00
$actions [ 'unspam' ] = '<span class="spam"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=unspamblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to unspam the site %s.' ), $blogname ) ) ) ) . '">' . __ ( 'Not Spam' ) . '</a></span>' ;
2010-04-01 17:21:27 -04:00
else
2010-04-11 06:41:54 -04:00
$actions [ 'spam' ] = '<span class="spam"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=spamblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to mark the site %s as spam.' ), $blogname ) ) ) ) . '">' . __ ( 'Spam' ) . '</a></span>' ;
2010-01-06 23:27:46 -05:00
2010-04-11 06:41:54 -04:00
$actions [ 'delete' ] = '<span class="delete"><a href="' . esc_url ( admin_url ( 'ms-edit.php?action=confirm&action2=deleteblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( 'You are about to delete the site %s.' ), $blogname ) ) ) ) . '">' . __ ( 'Delete' ) . '</a></span>' ;
2010-04-02 20:10:44 -04:00
}
2010-01-06 23:27:46 -05:00
2010-04-02 20:10:44 -04:00
$actions [ 'visit' ] = " <span class='view'><a href=' " . esc_url ( get_home_url ( $blog [ 'blog_id' ] ) ) . " ' rel='permalink'> " . __ ( 'Visit' ) . '</a>' ;
$actions = array_filter ( $actions );
2010-04-01 17:21:27 -04:00
if ( count ( $actions ) ) : ?>
2010-01-05 23:02:57 -05:00
< div class = " row-actions " >
2010-04-01 17:21:27 -04:00
< ? php echo implode ( ' | ' , $actions ); ?>
2010-01-05 23:02:57 -05:00
</ div >
< ? php endif ; ?>
</ td >
< ? php
break ;
2010-01-06 23:27:46 -05:00
2010-01-05 23:02:57 -05:00
case 'lastupdated' : ?>
< td valign = " top " >
2010-03-06 13:31:10 -05:00
< ? php
if ( 'list' == $mode )
$date = 'Y/m/d' ;
else
$date = 'Y/m/d \<\b\r \/\> g:i:s a' ;
2010-04-01 17:21:27 -04:00
echo ( $blog [ 'last_updated' ] == '0000-00-00 00:00:00' ) ? __ ( 'Never' ) : mysql2date ( __ ( $date ), $blog [ 'last_updated' ] ); ?>
2010-03-17 12:27:25 -04:00
</ td >
2010-01-05 23:02:57 -05:00
< ? php
break ;
2010-03-06 13:31:10 -05:00
case 'registered' : ?>
2010-01-05 23:02:57 -05:00
< td valign = " top " >
2010-04-02 20:10:44 -04:00
< ? php
2010-04-01 17:21:27 -04:00
if ( $blog [ 'registered' ] == '0000-00-00 00:00:00' )
echo '—' ;
else
echo mysql2date ( __ ( $date ), $blog [ 'registered' ] );
?>
2010-01-05 23:02:57 -05:00
</ td >
2010-03-06 13:31:10 -05:00
< ? php
break ;
2010-01-05 23:02:57 -05:00
case 'users' : ?>
< td valign = " top " >
< ? php
2010-01-06 23:27:46 -05:00
$blogusers = get_users_of_blog ( $blog [ 'blog_id' ] );
2010-01-05 23:02:57 -05:00
if ( is_array ( $blogusers ) ) {
$blogusers_warning = '' ;
if ( count ( $blogusers ) > 5 ) {
$blogusers = array_slice ( $blogusers , 0 , 5 );
2010-04-01 17:21:27 -04:00
$blogusers_warning = __ ( 'Only showing first 5 users.' ) . ' <a href="' . esc_url ( get_admin_url ( $blog [ 'blog_id' ], 'users.php' ) ) . '">' . __ ( 'More' ) . '</a>' ;
2010-01-05 23:02:57 -05:00
}
2010-03-06 13:31:10 -05:00
foreach ( $blogusers as $key => $val ) {
2010-04-01 17:21:27 -04:00
echo '<a href="' . esc_url ( admin_url ( 'user-edit.php?user_id=' . $val -> user_id ) ) . '">' . esc_html ( $val -> user_login ) . '</a> ' ;
2010-03-06 13:31:10 -05:00
if ( 'list' != $mode )
echo '(' . $val -> user_email . ')' ;
echo '<br />' ;
}
2010-01-29 12:36:57 -05:00
if ( $blogusers_warning != '' )
2010-01-05 23:02:57 -05:00
echo '<strong>' . $blogusers_warning . '</strong><br />' ;
}
?>
</ td >
< ? php
break ;
case 'plugins' : ?>
2010-01-18 15:34:48 -05:00
< ? php if ( has_filter ( 'wpmublogsaction' ) ) { ?>
2010-01-05 23:02:57 -05:00
< td valign = " top " >
2010-04-01 17:21:27 -04:00
< ? php do_action ( 'wpmublogsaction' , $blog [ 'blog_id' ] ); ?>
2010-01-05 23:02:57 -05:00
</ td >
< ? php } ?>
< ? php break ;
2010-01-06 23:27:46 -05:00
2010-01-05 23:02:57 -05:00
default : ?>
2010-01-18 15:34:48 -05:00
< ? php if ( has_filter ( 'manage_blogs_custom_column' ) ) { ?>
2010-01-05 23:02:57 -05:00
< td valign = " top " >
2010-04-01 17:21:27 -04:00
< ? php do_action ( 'manage_blogs_custom_column' , $column_name , $blog [ 'blog_id' ] ); ?>
2010-01-05 23:02:57 -05:00
</ td >
< ? php } ?>
< ? php break ;
}
}
?>
</ tr >
< ? php
}
} else { ?>
2010-03-06 13:31:10 -05:00
< tr >
2010-04-01 17:21:27 -04:00
< td colspan = " <?php echo (int) count( $sites_columns ); ?> " >< ? php _e ( 'No blogs found.' ) ?> </td>
2010-01-06 23:27:46 -05:00
</ tr >
2010-01-05 23:02:57 -05:00
< ? php
} // end if ($blogs)
?>
</ tbody >
</ table >
2010-03-06 13:31:10 -05:00
< div class = " tablenav " >
< ? php
if ( $page_links )
echo " <div class='tablenav-pages'> $page_links_text </div> " ;
?>
< div class = " alignleft actions " >
< select name = " action2 " >
2010-04-01 17:21:27 -04:00
< option value = " -1 " selected = " selected " >< ? php _e ( 'Bulk Actions' ); ?> </option>
< option value = " delete " >< ? php _e ( 'Delete' ); ?> </option>
< option value = " spam " >< ? php _e ( 'Mark as Spam' ); ?> </option>
< option value = " notspam " >< ? php _e ( 'Not Spam' ); ?> </option>
2010-03-06 13:31:10 -05:00
</ select >
2010-04-01 17:21:27 -04:00
< input type = " submit " value = " <?php esc_attr_e( 'Apply' ); ?> " name = " doaction2 " id = " doaction2 " class = " button-secondary action " />
2010-03-06 13:31:10 -05:00
</ div >
< br class = " clear " />
</ div >
2010-01-05 23:02:57 -05:00
</ form >
</ div >
2010-04-03 07:15:51 -04:00
< div id = " form-add-site " class = " wrap " >
< h3 >< ? php _e ( 'Add Site' ) ?> </h3>
2010-01-06 19:24:03 -05:00
< form method = " post " action = " ms-edit.php?action=addblog " >
2010-04-01 17:21:27 -04:00
< ? php wp_nonce_field ( 'add-blog' ) ?>
2010-01-05 23:02:57 -05:00
< table class = " form-table " >
< tr class = " form-field form-required " >
2010-04-01 17:21:27 -04:00
< th scope = " row " >< ? php _e ( 'Site Address' ) ?> </th>
2010-01-05 23:02:57 -05:00
< td >
2010-01-08 16:25:01 -05:00
< ? php if ( is_subdomain_install () ) { ?>
2010-04-01 17:21:27 -04:00
< input name = " blog[domain] " type = " text " class = " regular-text " title = " <?php _e( 'Domain' ) ?> " />.< ? php echo $current_site -> domain ; ?>
2010-01-05 23:02:57 -05:00
< ? php } else {
2010-04-01 17:21:27 -04:00
echo $current_site -> domain . $current_site -> path ?> <input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>
2010-01-06 23:27:46 -05:00
< ? php }
2010-04-01 17:21:27 -04:00
echo '<p>' . __ ( 'Only the characters a-z and 0-9 recommended.' ) . '</p>' ;
2010-01-05 23:02:57 -05:00
?>
</ td >
</ tr >
< tr class = " form-field form-required " >
2010-04-01 17:21:27 -04:00
< th scope = " row " >< ? php _e ( 'Site Title' ) ?> </th>
< td >< input name = " blog[title] " type = " text " class = " regular-text " title = " <?php _e( 'Title' ) ?> " /></ td >
2010-01-05 23:02:57 -05:00
</ tr >
< tr class = " form-field form-required " >
2010-04-01 17:21:27 -04:00
< th scope = " row " >< ? php _e ( 'Admin Email' ) ?> </th>
< td >< input name = " blog[email] " type = " text " class = " regular-text " title = " <?php _e( 'Email' ) ?> " /></ td >
2010-01-05 23:02:57 -05:00
</ tr >
< tr class = " form-field " >
2010-04-01 17:21:27 -04:00
< td colspan = " 2 " >< ? php _e ( 'A new user will be created if the above email address is not in the database.' ) ?> <br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>
2010-01-05 23:02:57 -05:00
</ tr >
</ table >
< p class = " submit " >
2010-04-01 17:21:27 -04:00
< input class = " button " type = " submit " name = " go " value = " <?php esc_attr_e( 'Add Site' ) ?> " /></ p >
2010-01-05 23:02:57 -05:00
</ form >
</ div >
< ? php
break ;
} // end switch( $action )
2010-04-01 17:21:27 -04:00
include ( './admin-footer.php' ); ?>