wp/wp-admin/network/site-themes.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     8  */
     8  */
     9 
     9 
    10 /** Load WordPress Administration Bootstrap */
    10 /** Load WordPress Administration Bootstrap */
    11 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 require_once( dirname( __FILE__ ) . '/admin.php' );
    12 
    12 
    13 if ( ! is_multisite() )
       
    14 	wp_die( __( 'Multisite support is not enabled.' ) );
       
    15 
       
    16 if ( ! current_user_can( 'manage_sites' ) )
    13 if ( ! current_user_can( 'manage_sites' ) )
    17 	wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) );
    14 	wp_die( __( 'Sorry, you are not allowed to manage themes for this site.' ) );
    18 
    15 
    19 get_current_screen()->add_help_tab( array(
    16 get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
    20 	'id'      => 'overview',
    17 get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
    21 	'title'   => __('Overview'),
    18 
    22 	'content' =>
    19 get_current_screen()->set_screen_reader_content( array(
    23 		'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
    20 	'heading_views'      => __( 'Filter site themes list' ),
    24 		'<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
    21 	'heading_pagination' => __( 'Site themes list navigation' ),
    25 		'<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
    22 	'heading_list'       => __( 'Site themes list' ),
    26 		'<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
       
    27 		'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
       
    28 ) );
    23 ) );
    29 
       
    30 get_current_screen()->set_help_sidebar(
       
    31 	'<p><strong>' . __('For more information:') . '</strong></p>' .
       
    32 	'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
       
    33 	'<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
       
    34 );
       
    35 
    24 
    36 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
    25 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
    37 
    26 
    38 $action = $wp_list_table->current_action();
    27 $action = $wp_list_table->current_action();
    39 
    28 
    53 if ( ! $id )
    42 if ( ! $id )
    54 	wp_die( __('Invalid site ID.') );
    43 	wp_die( __('Invalid site ID.') );
    55 
    44 
    56 $wp_list_table->prepare_items();
    45 $wp_list_table->prepare_items();
    57 
    46 
    58 $details = get_blog_details( $id );
    47 $details = get_site( $id );
       
    48 if ( ! $details ) {
       
    49 	wp_die( __( 'The requested site does not exist.' ) );
       
    50 }
       
    51 
    59 if ( !can_edit_network( $details->site_id ) )
    52 if ( !can_edit_network( $details->site_id ) )
    60 	wp_die( __( 'You do not have permission to access this page.' ), 403 );
    53 	wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
    61 
    54 
    62 $is_main_site = is_main_site( $id );
    55 $is_main_site = is_main_site( $id );
    63 
    56 
    64 if ( $action ) {
    57 if ( $action ) {
    65 	switch_to_blog( $id );
    58 	switch_to_blog( $id );
    90 			check_admin_referer( 'bulk-themes' );
    83 			check_admin_referer( 'bulk-themes' );
    91 			if ( isset( $_POST['checked'] ) ) {
    84 			if ( isset( $_POST['checked'] ) ) {
    92 				$themes = (array) $_POST['checked'];
    85 				$themes = (array) $_POST['checked'];
    93 				$action = 'enabled';
    86 				$action = 'enabled';
    94 				$n = count( $themes );
    87 				$n = count( $themes );
    95 				foreach( (array) $themes as $theme )
    88 				foreach ( (array) $themes as $theme )
    96 					$allowed_themes[ $theme ] = true;
    89 					$allowed_themes[ $theme ] = true;
    97 			} else {
    90 			} else {
    98 				$action = 'error';
    91 				$action = 'error';
    99 				$n = 'none';
    92 				$n = 'none';
   100 			}
    93 			}
   103 			check_admin_referer( 'bulk-themes' );
    96 			check_admin_referer( 'bulk-themes' );
   104 			if ( isset( $_POST['checked'] ) ) {
    97 			if ( isset( $_POST['checked'] ) ) {
   105 				$themes = (array) $_POST['checked'];
    98 				$themes = (array) $_POST['checked'];
   106 				$action = 'disabled';
    99 				$action = 'disabled';
   107 				$n = count( $themes );
   100 				$n = count( $themes );
   108 				foreach( (array) $themes as $theme )
   101 				foreach ( (array) $themes as $theme )
   109 					unset( $allowed_themes[ $theme ] );
   102 					unset( $allowed_themes[ $theme ] );
   110 			} else {
   103 			} else {
   111 				$action = 'error';
   104 				$action = 'error';
   112 				$n = 'none';
   105 				$n = 'none';
   113 			}
   106 			}
   114 			break;
   107 			break;
       
   108 		default:
       
   109 			if ( isset( $_POST['checked'] ) ) {
       
   110 				check_admin_referer( 'bulk-themes' );
       
   111 				$themes = (array) $_POST['checked'];
       
   112 				$n = count( $themes );
       
   113 				$screen = get_current_screen()->id;
       
   114 
       
   115 				/**
       
   116 				 * Fires when a custom bulk action should be handled.
       
   117 				 *
       
   118 				 * The redirect link should be modified with success or failure feedback
       
   119 				 * from the action to be used to display feedback to the user.
       
   120 				 *
       
   121 				 * The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
       
   122 				 *
       
   123 				 * @since 4.7.0
       
   124 				 *
       
   125 				 * @param string $redirect_url The redirect URL.
       
   126 				 * @param string $action       The action being taken.
       
   127 				 * @param array  $items        The items to take the action on.
       
   128 				 * @param int    $site_id      The site ID.
       
   129 				 */
       
   130 				$referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id );
       
   131 			} else {
       
   132 				$action = 'error';
       
   133 				$n = 'none';
       
   134 			}
   115 	}
   135 	}
   116 
   136 
   117 	update_option( 'allowedthemes', $allowed_themes );
   137 	update_option( 'allowedthemes', $allowed_themes );
   118 	restore_current_blog();
   138 	restore_current_blog();
   119 
   139 
   127 }
   147 }
   128 
   148 
   129 add_thickbox();
   149 add_thickbox();
   130 add_screen_option( 'per_page' );
   150 add_screen_option( 'per_page' );
   131 
   151 
   132 $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
   152 /* translators: %s: site name */
   133 $title_site_url_linked = sprintf( __( 'Edit Site: %s' ), '<a href="' . get_blogaddress_by_id( $id ) . '">' . $site_url_no_http . '</a>' );
   153 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
   134 $title = sprintf( __( 'Edit Site: %s' ), $site_url_no_http );
       
   135 
   154 
   136 $parent_file = 'sites.php';
   155 $parent_file = 'sites.php';
   137 $submenu_file = 'sites.php';
   156 $submenu_file = 'sites.php';
   138 
   157 
   139 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
   158 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
   140 
   159 
   141 <div class="wrap">
   160 <div class="wrap">
   142 <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
   161 <h1 id="edit-site"><?php echo $title; ?></h1>
   143 <h3 class="nav-tab-wrapper">
   162 <p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
   144 <?php
   163 <?php
   145 $tabs = array(
   164 
   146 	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
   165 network_edit_site_nav( array(
   147 	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
   166 	'blog_id'  => $id,
   148 	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
   167 	'selected' => 'site-themes'
   149 	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
   168 ) );
   150 );
       
   151 foreach ( $tabs as $tab_id => $tab ) {
       
   152 	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
       
   153 	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
       
   154 }
       
   155 ?>
       
   156 </h3><?php
       
   157 
   169 
   158 if ( isset( $_GET['enabled'] ) ) {
   170 if ( isset( $_GET['enabled'] ) ) {
   159 	$enabled = absint( $_GET['enabled'] );
   171 	$enabled = absint( $_GET['enabled'] );
   160 	if ( 1 == $enabled ) {
   172 	if ( 1 == $enabled ) {
   161 		$message = __( 'Theme enabled.' );
   173 		$message = __( 'Theme enabled.' );