3 * Multisite themes administration panel.
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_network_themes') )
17 wp_die( __( 'Sorry, you are not allowed to manage network themes.' ) );
19 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
20 $pagenum = $wp_list_table->get_pagenum();
22 $action = $wp_list_table->current_action();
24 $s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
26 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
27 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error' );
28 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
29 $referer = remove_query_arg( $temp_args, wp_get_referer() );
34 check_admin_referer('enable-theme_' . $_GET['theme']);
35 WP_Theme::network_enable_theme( $_GET['theme'] );
36 if ( false === strpos( $referer, '/network/themes.php' ) )
37 wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
39 wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
42 check_admin_referer('disable-theme_' . $_GET['theme']);
43 WP_Theme::network_disable_theme( $_GET['theme'] );
44 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
46 case 'enable-selected':
47 check_admin_referer('bulk-themes');
48 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
49 if ( empty($themes) ) {
50 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
53 WP_Theme::network_enable_theme( (array) $themes );
54 wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
56 case 'disable-selected':
57 check_admin_referer('bulk-themes');
58 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
59 if ( empty($themes) ) {
60 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
63 WP_Theme::network_disable_theme( (array) $themes );
64 wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
66 case 'update-selected' :
67 check_admin_referer( 'bulk-themes' );
69 if ( isset( $_GET['themes'] ) )
70 $themes = explode( ',', $_GET['themes'] );
71 elseif ( isset( $_POST['checked'] ) )
72 $themes = (array) $_POST['checked'];
76 $title = __( 'Update Themes' );
77 $parent_file = 'themes.php';
79 require_once(ABSPATH . 'wp-admin/admin-header.php');
81 echo '<div class="wrap">';
82 echo '<h1>' . esc_html( $title ) . '</h1>';
84 $url = self_admin_url('update.php?action=update-selected-themes&themes=' . urlencode( join(',', $themes) ));
85 $url = wp_nonce_url($url, 'bulk-update-themes');
87 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
89 require_once(ABSPATH . 'wp-admin/admin-footer.php');
91 case 'delete-selected':
92 if ( ! current_user_can( 'delete_themes' ) ) {
93 wp_die( __('Sorry, you are not allowed to delete themes for this site.') );
96 check_admin_referer( 'bulk-themes' );
98 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
100 if ( empty( $themes ) ) {
101 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
105 $themes = array_diff( $themes, array( get_option( 'stylesheet' ), get_option( 'template' ) ) );
107 if ( empty( $themes ) ) {
108 wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) );
112 $theme_info = array();
113 foreach ( $themes as $key => $theme ) {
114 $theme_info[ $theme ] = wp_get_theme( $theme );
117 include(ABSPATH . 'wp-admin/update.php');
119 $parent_file = 'themes.php';
121 if ( ! isset( $_REQUEST['verify-delete'] ) ) {
122 wp_enqueue_script( 'jquery' );
123 require_once( ABSPATH . 'wp-admin/admin-header.php' );
124 $themes_to_delete = count( $themes );
127 <?php if ( 1 == $themes_to_delete ) : ?>
128 <h1><?php _e( 'Delete Theme' ); ?></h1>
129 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div>
130 <p><?php _e( 'You are about to remove the following theme:' ); ?></p>
132 <h1><?php _e( 'Delete Themes' ); ?></h1>
133 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div>
134 <p><?php _e( 'You are about to remove the following themes:' ); ?></p>
138 foreach ( $theme_info as $theme ) {
139 echo '<li>' . sprintf(
140 /* translators: 1: theme name, 2: theme author */
141 _x( '%1$s by %2$s', 'theme' ),
142 '<strong>' . $theme->display( 'Name' ) . '</strong>',
143 '<em>' . $theme->display( 'Author' ) . '</em>'
148 <?php if ( 1 == $themes_to_delete ) : ?>
149 <p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p>
151 <p><?php _e( 'Are you sure you wish to delete these themes?' ); ?></p>
153 <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
154 <input type="hidden" name="verify-delete" value="1" />
155 <input type="hidden" name="action" value="delete-selected" />
157 foreach ( (array) $themes as $theme ) {
158 echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
161 wp_nonce_field( 'bulk-themes' );
163 if ( 1 == $themes_to_delete ) {
164 submit_button( __( 'Yes, delete this theme' ), 'button', 'submit', false );
166 submit_button( __( 'Yes, delete these themes' ), 'button', 'submit', false );
171 $referer = wp_get_referer();
173 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
174 <?php submit_button( __( 'No, return me to the theme list' ), 'button', 'submit', false ); ?>
178 require_once(ABSPATH . 'wp-admin/admin-footer.php');
180 } // Endif verify-delete
182 foreach ( $themes as $theme ) {
183 $delete_result = delete_theme( $theme, esc_url( add_query_arg( array(
184 'verify-delete' => 1,
185 'action' => 'delete-selected',
186 'checked' => $_REQUEST['checked'],
187 '_wpnonce' => $_REQUEST['_wpnonce']
188 ), network_admin_url( 'themes.php' ) ) ) );
191 $paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
192 wp_redirect( add_query_arg( array(
193 'deleted' => count( $themes ),
196 ), network_admin_url( 'themes.php' ) ) );
201 $wp_list_table->prepare_items();
205 add_screen_option( 'per_page' );
207 get_current_screen()->add_help_tab( array(
209 'title' => __('Overview'),
211 '<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>' .
212 '<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>' .
213 '<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>'
216 get_current_screen()->set_help_sidebar(
217 '<p><strong>' . __('For more information:') . '</strong></p>' .
218 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>') . '</p>' .
219 '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
222 get_current_screen()->set_screen_reader_content( array(
223 'heading_views' => __( 'Filter themes list' ),
224 'heading_pagination' => __( 'Themes list navigation' ),
225 'heading_list' => __( 'Themes list' ),
228 $title = __('Themes');
229 $parent_file = 'themes.php';
231 wp_enqueue_script( 'updates' );
232 wp_enqueue_script( 'theme-preview' );
234 require_once(ABSPATH . 'wp-admin/admin-header.php');
239 <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 }
240 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
241 /* translators: %s: search keywords */
242 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
248 if ( isset( $_GET['enabled'] ) ) {
249 $enabled = absint( $_GET['enabled'] );
250 if ( 1 == $enabled ) {
251 $message = __( 'Theme enabled.' );
253 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
255 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
256 } elseif ( isset( $_GET['disabled'] ) ) {
257 $disabled = absint( $_GET['disabled'] );
258 if ( 1 == $disabled ) {
259 $message = __( 'Theme disabled.' );
261 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
263 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
264 } elseif ( isset( $_GET['deleted'] ) ) {
265 $deleted = absint( $_GET['deleted'] );
266 if ( 1 == $deleted ) {
267 $message = __( 'Theme deleted.' );
269 $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
271 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
272 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
273 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
274 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
275 echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
281 <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
285 $wp_list_table->views();
287 if ( 'broken' == $status )
288 echo '<p class="clear">' . __( 'The following themes are installed but incomplete.' ) . '</p>';
291 <form id="bulk-action-form" method="post">
292 <input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />
293 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
295 <?php $wp_list_table->display(); ?>
301 wp_print_request_filesystem_credentials_modal();
302 wp_print_admin_notice_templates();
303 wp_print_update_row_templates();
305 include(ABSPATH . 'wp-admin/admin-footer.php');