3 * Edit Site Themes Administration Screen
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( ! is_multisite() )
14 wp_die( __( 'Multisite support is not enabled.' ) );
16 if ( ! current_user_can( 'manage_sites' ) )
17 wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) );
19 get_current_screen()->add_help_tab( array(
21 'title' => __('Overview'),
23 '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
24 '<p>' . __('<strong>Info</strong> — The site URL is 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>' .
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>' .
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’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>'
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>'
36 get_current_screen()->set_screen_reader_content( array(
37 'heading_views' => __( 'Filter site themes list' ),
38 'heading_pagination' => __( 'Site themes list navigation' ),
39 'heading_list' => __( 'Site themes list' ),
42 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
44 $action = $wp_list_table->current_action();
46 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
48 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
49 $temp_args = array( 'enabled', 'disabled', 'error' );
50 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
51 $referer = remove_query_arg( $temp_args, wp_get_referer() );
53 if ( ! empty( $_REQUEST['paged'] ) ) {
54 $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
57 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
60 wp_die( __('Invalid site ID.') );
62 $wp_list_table->prepare_items();
64 $details = get_blog_details( $id );
66 wp_die( __( 'The requested site does not exist.' ) );
69 if ( !can_edit_network( $details->site_id ) )
70 wp_die( __( 'You do not have permission to access this page.' ), 403 );
72 $is_main_site = is_main_site( $id );
75 switch_to_blog( $id );
76 $allowed_themes = get_option( 'allowedthemes' );
80 check_admin_referer( 'enable-theme_' . $_GET['theme'] );
81 $theme = $_GET['theme'];
84 if ( !$allowed_themes )
85 $allowed_themes = array( $theme => true );
87 $allowed_themes[$theme] = true;
90 check_admin_referer( 'disable-theme_' . $_GET['theme'] );
91 $theme = $_GET['theme'];
94 if ( !$allowed_themes )
95 $allowed_themes = array();
97 unset( $allowed_themes[$theme] );
99 case 'enable-selected':
100 check_admin_referer( 'bulk-themes' );
101 if ( isset( $_POST['checked'] ) ) {
102 $themes = (array) $_POST['checked'];
104 $n = count( $themes );
105 foreach ( (array) $themes as $theme )
106 $allowed_themes[ $theme ] = true;
112 case 'disable-selected':
113 check_admin_referer( 'bulk-themes' );
114 if ( isset( $_POST['checked'] ) ) {
115 $themes = (array) $_POST['checked'];
116 $action = 'disabled';
117 $n = count( $themes );
118 foreach ( (array) $themes as $theme )
119 unset( $allowed_themes[ $theme ] );
127 update_option( 'allowedthemes', $allowed_themes );
128 restore_current_blog();
130 wp_safe_redirect( add_query_arg( array( 'id' => $id, $action => $n ), $referer ) );
134 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
135 wp_safe_redirect( $referer );
140 add_screen_option( 'per_page' );
142 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
144 $parent_file = 'sites.php';
145 $submenu_file = 'sites.php';
147 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
150 <h1 id="edit-site"><?php echo $title; ?></h1>
151 <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>
152 <h2 class="nav-tab-wrapper nav-tab-small wp-clearfix">
155 'site-info' => array( 'label' => __( 'Info' ), 'url' => 'site-info.php' ),
156 'site-users' => array( 'label' => __( 'Users' ), 'url' => 'site-users.php' ),
157 'site-themes' => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php' ),
158 'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
160 foreach ( $tabs as $tab_id => $tab ) {
161 $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
162 echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
167 if ( isset( $_GET['enabled'] ) ) {
168 $enabled = absint( $_GET['enabled'] );
169 if ( 1 == $enabled ) {
170 $message = __( 'Theme enabled.' );
172 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
174 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
175 } elseif ( isset( $_GET['disabled'] ) ) {
176 $disabled = absint( $_GET['disabled'] );
177 if ( 1 == $disabled ) {
178 $message = __( 'Theme disabled.' );
180 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
182 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
183 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
184 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
187 <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
190 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
191 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
194 <?php $wp_list_table->views(); ?>
196 <form method="post" action="site-themes.php?action=update-site">
197 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
199 <?php $wp_list_table->display(); ?>
204 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>