3 * Edit Site Themes Administration Screen
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( ! current_user_can( 'manage_sites' ) )
14 wp_die( __( 'Sorry, you are not allowed to manage themes for this site.' ) );
16 get_current_screen()->add_help_tab( array(
18 'title' => __('Overview'),
20 '<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
21 '<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>' .
22 '<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>' .
23 '<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>' .
24 '<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>'
27 get_current_screen()->set_help_sidebar(
28 '<p><strong>' . __('For more information:') . '</strong></p>' .
29 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' .
30 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>'
33 get_current_screen()->set_screen_reader_content( array(
34 'heading_views' => __( 'Filter site themes list' ),
35 'heading_pagination' => __( 'Site themes list navigation' ),
36 'heading_list' => __( 'Site themes list' ),
39 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
41 $action = $wp_list_table->current_action();
43 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
45 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
46 $temp_args = array( 'enabled', 'disabled', 'error' );
47 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
48 $referer = remove_query_arg( $temp_args, wp_get_referer() );
50 if ( ! empty( $_REQUEST['paged'] ) ) {
51 $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
54 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
57 wp_die( __('Invalid site ID.') );
59 $wp_list_table->prepare_items();
61 $details = get_site( $id );
63 wp_die( __( 'The requested site does not exist.' ) );
66 if ( !can_edit_network( $details->site_id ) )
67 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
69 $is_main_site = is_main_site( $id );
72 switch_to_blog( $id );
73 $allowed_themes = get_option( 'allowedthemes' );
77 check_admin_referer( 'enable-theme_' . $_GET['theme'] );
78 $theme = $_GET['theme'];
81 if ( !$allowed_themes )
82 $allowed_themes = array( $theme => true );
84 $allowed_themes[$theme] = true;
87 check_admin_referer( 'disable-theme_' . $_GET['theme'] );
88 $theme = $_GET['theme'];
91 if ( !$allowed_themes )
92 $allowed_themes = array();
94 unset( $allowed_themes[$theme] );
96 case 'enable-selected':
97 check_admin_referer( 'bulk-themes' );
98 if ( isset( $_POST['checked'] ) ) {
99 $themes = (array) $_POST['checked'];
101 $n = count( $themes );
102 foreach ( (array) $themes as $theme )
103 $allowed_themes[ $theme ] = true;
109 case 'disable-selected':
110 check_admin_referer( 'bulk-themes' );
111 if ( isset( $_POST['checked'] ) ) {
112 $themes = (array) $_POST['checked'];
113 $action = 'disabled';
114 $n = count( $themes );
115 foreach ( (array) $themes as $theme )
116 unset( $allowed_themes[ $theme ] );
123 if ( isset( $_POST['checked'] ) ) {
124 check_admin_referer( 'bulk-themes' );
125 $themes = (array) $_POST['checked'];
126 $n = count( $themes );
128 * Fires when a custom bulk action should be handled.
130 * The redirect link should be modified with success or failure feedback
131 * from the action to be used to display feedback to the user.
135 * @param string $redirect_url The redirect URL.
136 * @param string $action The action being taken.
137 * @param array $items The items to take the action on.
138 * @param int $site_id The site id.
140 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes, $id );
147 update_option( 'allowedthemes', $allowed_themes );
148 restore_current_blog();
150 wp_safe_redirect( add_query_arg( array( 'id' => $id, $action => $n ), $referer ) );
154 if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
155 wp_safe_redirect( $referer );
160 add_screen_option( 'per_page' );
162 /* translators: %s: site name */
163 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
165 $parent_file = 'sites.php';
166 $submenu_file = 'sites.php';
168 require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
171 <h1 id="edit-site"><?php echo $title; ?></h1>
172 <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>
175 network_edit_site_nav( array(
177 'selected' => 'site-themes'
180 if ( isset( $_GET['enabled'] ) ) {
181 $enabled = absint( $_GET['enabled'] );
182 if ( 1 == $enabled ) {
183 $message = __( 'Theme enabled.' );
185 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
187 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
188 } elseif ( isset( $_GET['disabled'] ) ) {
189 $disabled = absint( $_GET['disabled'] );
190 if ( 1 == $disabled ) {
191 $message = __( 'Theme disabled.' );
193 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
195 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
196 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
197 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
200 <p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
203 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
204 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
207 <?php $wp_list_table->views(); ?>
209 <form method="post" action="site-themes.php?action=update-site">
210 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
212 <?php $wp_list_table->display(); ?>
217 <?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>