3 * Multisite themes administration panel.
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( !current_user_can('manage_network_themes') )
14 wp_die( __( 'Sorry, you are not allowed to manage network themes.' ) );
16 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
17 $pagenum = $wp_list_table->get_pagenum();
19 $action = $wp_list_table->current_action();
21 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
23 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
24 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error' );
25 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
26 $referer = remove_query_arg( $temp_args, wp_get_referer() );
31 check_admin_referer('enable-theme_' . $_GET['theme']);
32 WP_Theme::network_enable_theme( $_GET['theme'] );
33 if ( false === strpos( $referer, '/network/themes.php' ) )
34 wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
36 wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
39 check_admin_referer('disable-theme_' . $_GET['theme']);
40 WP_Theme::network_disable_theme( $_GET['theme'] );
41 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
43 case 'enable-selected':
44 check_admin_referer('bulk-themes');
45 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
46 if ( empty($themes) ) {
47 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
50 WP_Theme::network_enable_theme( (array) $themes );
51 wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
53 case 'disable-selected':
54 check_admin_referer('bulk-themes');
55 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
56 if ( empty($themes) ) {
57 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
60 WP_Theme::network_disable_theme( (array) $themes );
61 wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
63 case 'update-selected' :
64 check_admin_referer( 'bulk-themes' );
66 if ( isset( $_GET['themes'] ) )
67 $themes = explode( ',', $_GET['themes'] );
68 elseif ( isset( $_POST['checked'] ) )
69 $themes = (array) $_POST['checked'];
73 $title = __( 'Update Themes' );
74 $parent_file = 'themes.php';
76 require_once(ABSPATH . 'wp-admin/admin-header.php');
78 echo '<div class="wrap">';
79 echo '<h1>' . esc_html( $title ) . '</h1>';
81 $url = self_admin_url('update.php?action=update-selected-themes&themes=' . urlencode( join(',', $themes) ));
82 $url = wp_nonce_url($url, 'bulk-update-themes');
84 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
86 require_once(ABSPATH . 'wp-admin/admin-footer.php');
88 case 'delete-selected':
89 if ( ! current_user_can( 'delete_themes' ) ) {
90 wp_die( __('Sorry, you are not allowed to delete themes for this site.') );
93 check_admin_referer( 'bulk-themes' );
95 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
97 if ( empty( $themes ) ) {
98 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
102 $themes = array_diff( $themes, array( get_option( 'stylesheet' ), get_option( 'template' ) ) );
104 if ( empty( $themes ) ) {
105 wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) );
109 $theme_info = array();
110 foreach ( $themes as $key => $theme ) {
111 $theme_info[ $theme ] = wp_get_theme( $theme );
114 include(ABSPATH . 'wp-admin/update.php');
116 $parent_file = 'themes.php';
118 if ( ! isset( $_REQUEST['verify-delete'] ) ) {
119 wp_enqueue_script( 'jquery' );
120 require_once( ABSPATH . 'wp-admin/admin-header.php' );
121 $themes_to_delete = count( $themes );
124 <?php if ( 1 == $themes_to_delete ) : ?>
125 <h1><?php _e( 'Delete Theme' ); ?></h1>
126 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div>
127 <p><?php _e( 'You are about to remove the following theme:' ); ?></p>
129 <h1><?php _e( 'Delete Themes' ); ?></h1>
130 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div>
131 <p><?php _e( 'You are about to remove the following themes:' ); ?></p>
135 foreach ( $theme_info as $theme ) {
136 echo '<li>' . sprintf(
137 /* translators: 1: theme name, 2: theme author */
138 _x( '%1$s by %2$s', 'theme' ),
139 '<strong>' . $theme->display( 'Name' ) . '</strong>',
140 '<em>' . $theme->display( 'Author' ) . '</em>'
145 <?php if ( 1 == $themes_to_delete ) : ?>
146 <p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p>
148 <p><?php _e( 'Are you sure you wish to delete these themes?' ); ?></p>
150 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
151 <input type="hidden" name="verify-delete" value="1" />
152 <input type="hidden" name="action" value="delete-selected" />
154 foreach ( (array) $themes as $theme ) {
155 echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
158 wp_nonce_field( 'bulk-themes' );
160 if ( 1 == $themes_to_delete ) {
161 submit_button( __( 'Yes, delete this theme' ), '', 'submit', false );
163 submit_button( __( 'Yes, delete these themes' ), '', 'submit', false );
168 $referer = wp_get_referer();
170 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
171 <?php submit_button( __( 'No, return me to the theme list' ), '', 'submit', false ); ?>
175 require_once(ABSPATH . 'wp-admin/admin-footer.php');
177 } // Endif verify-delete
179 foreach ( $themes as $theme ) {
180 $delete_result = delete_theme( $theme, esc_url( add_query_arg( array(
181 'verify-delete' => 1,
182 'action' => 'delete-selected',
183 'checked' => $_REQUEST['checked'],
184 '_wpnonce' => $_REQUEST['_wpnonce']
185 ), network_admin_url( 'themes.php' ) ) ) );
188 $paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
189 wp_redirect( add_query_arg( array(
190 'deleted' => count( $themes ),
193 ), network_admin_url( 'themes.php' ) ) );
196 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
197 if ( empty( $themes ) ) {
198 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
201 check_admin_referer( 'bulk-themes' );
203 /** This action is documented in wp-admin/network/site-themes.php */
204 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes );
206 wp_safe_redirect( $referer );
212 $wp_list_table->prepare_items();
216 add_screen_option( 'per_page' );
218 get_current_screen()->add_help_tab( array(
220 'title' => __('Overview'),
222 '<p>' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '</p>' .
223 '<p>' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site’s Appearance > Themes screen.') . '</p>' .
224 '<p>' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen (which has a Themes tab); get there via the Edit action link on the All Sites screen. Only network admins are able to install or edit themes.') . '</p>'
227 get_current_screen()->set_help_sidebar(
228 '<p><strong>' . __('For more information:') . '</strong></p>' .
229 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>') . '</p>' .
230 '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
233 get_current_screen()->set_screen_reader_content( array(
234 'heading_views' => __( 'Filter themes list' ),
235 'heading_pagination' => __( 'Themes list navigation' ),
236 'heading_list' => __( 'Themes list' ),
239 $title = __('Themes');
240 $parent_file = 'themes.php';
242 wp_enqueue_script( 'updates' );
243 wp_enqueue_script( 'theme-preview' );
245 require_once(ABSPATH . 'wp-admin/admin-header.php');
250 <h1><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="page-title-action"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
251 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
252 /* translators: %s: search keywords */
253 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
259 if ( isset( $_GET['enabled'] ) ) {
260 $enabled = absint( $_GET['enabled'] );
261 if ( 1 == $enabled ) {
262 $message = __( 'Theme enabled.' );
264 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
266 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
267 } elseif ( isset( $_GET['disabled'] ) ) {
268 $disabled = absint( $_GET['disabled'] );
269 if ( 1 == $disabled ) {
270 $message = __( 'Theme disabled.' );
272 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
274 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
275 } elseif ( isset( $_GET['deleted'] ) ) {
276 $deleted = absint( $_GET['deleted'] );
277 if ( 1 == $deleted ) {
278 $message = __( 'Theme deleted.' );
280 $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
282 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
283 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
284 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
285 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
286 echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
292 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
296 $wp_list_table->views();
298 if ( 'broken' == $status )
299 echo '<p class="clear">' . __( 'The following themes are installed but incomplete.' ) . '</p>';
302 <form id="bulk-action-form" method="post">
303 <input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />
304 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
306 <?php $wp_list_table->display(); ?>
312 wp_print_request_filesystem_credentials_modal();
313 wp_print_admin_notice_templates();
314 wp_print_update_row_templates();
316 include(ABSPATH . 'wp-admin/admin-footer.php');