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_network_themes') ) |
13 if ( !current_user_can('manage_network_themes') ) |
17 wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) ); |
14 wp_die( __( 'Sorry, you are not allowed to manage network themes.' ) ); |
18 |
15 |
19 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
16 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
20 $pagenum = $wp_list_table->get_pagenum(); |
17 $pagenum = $wp_list_table->get_pagenum(); |
21 |
18 |
22 $action = $wp_list_table->current_action(); |
19 $action = $wp_list_table->current_action(); |
27 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error' ); |
24 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error' ); |
28 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); |
25 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); |
29 $referer = remove_query_arg( $temp_args, wp_get_referer() ); |
26 $referer = remove_query_arg( $temp_args, wp_get_referer() ); |
30 |
27 |
31 if ( $action ) { |
28 if ( $action ) { |
32 $allowed_themes = get_site_option( 'allowedthemes' ); |
|
33 switch ( $action ) { |
29 switch ( $action ) { |
34 case 'enable': |
30 case 'enable': |
35 check_admin_referer('enable-theme_' . $_GET['theme']); |
31 check_admin_referer('enable-theme_' . $_GET['theme']); |
36 $allowed_themes[ $_GET['theme'] ] = true; |
32 WP_Theme::network_enable_theme( $_GET['theme'] ); |
37 update_site_option( 'allowedthemes', $allowed_themes ); |
|
38 if ( false === strpos( $referer, '/network/themes.php' ) ) |
33 if ( false === strpos( $referer, '/network/themes.php' ) ) |
39 wp_redirect( network_admin_url( 'themes.php?enabled=1' ) ); |
34 wp_redirect( network_admin_url( 'themes.php?enabled=1' ) ); |
40 else |
35 else |
41 wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) ); |
36 wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) ); |
42 exit; |
37 exit; |
43 case 'disable': |
38 case 'disable': |
44 check_admin_referer('disable-theme_' . $_GET['theme']); |
39 check_admin_referer('disable-theme_' . $_GET['theme']); |
45 unset( $allowed_themes[ $_GET['theme'] ] ); |
40 WP_Theme::network_disable_theme( $_GET['theme'] ); |
46 update_site_option( 'allowedthemes', $allowed_themes ); |
|
47 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) ); |
41 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) ); |
48 exit; |
42 exit; |
49 case 'enable-selected': |
43 case 'enable-selected': |
50 check_admin_referer('bulk-themes'); |
44 check_admin_referer('bulk-themes'); |
51 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); |
45 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); |
52 if ( empty($themes) ) { |
46 if ( empty($themes) ) { |
53 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
47 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
54 exit; |
48 exit; |
55 } |
49 } |
56 foreach( (array) $themes as $theme ) |
50 WP_Theme::network_enable_theme( (array) $themes ); |
57 $allowed_themes[ $theme ] = true; |
|
58 update_site_option( 'allowedthemes', $allowed_themes ); |
|
59 wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) ); |
51 wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) ); |
60 exit; |
52 exit; |
61 case 'disable-selected': |
53 case 'disable-selected': |
62 check_admin_referer('bulk-themes'); |
54 check_admin_referer('bulk-themes'); |
63 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); |
55 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); |
64 if ( empty($themes) ) { |
56 if ( empty($themes) ) { |
65 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
57 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
66 exit; |
58 exit; |
67 } |
59 } |
68 foreach( (array) $themes as $theme ) |
60 WP_Theme::network_disable_theme( (array) $themes ); |
69 unset( $allowed_themes[ $theme ] ); |
|
70 update_site_option( 'allowedthemes', $allowed_themes ); |
|
71 wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) ); |
61 wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) ); |
72 exit; |
62 exit; |
73 case 'update-selected' : |
63 case 'update-selected' : |
74 check_admin_referer( 'bulk-themes' ); |
64 check_admin_referer( 'bulk-themes' ); |
75 |
65 |
84 $parent_file = 'themes.php'; |
74 $parent_file = 'themes.php'; |
85 |
75 |
86 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
76 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
87 |
77 |
88 echo '<div class="wrap">'; |
78 echo '<div class="wrap">'; |
89 echo '<h2>' . esc_html( $title ) . '</h2>'; |
79 echo '<h1>' . esc_html( $title ) . '</h1>'; |
90 |
80 |
91 $url = self_admin_url('update.php?action=update-selected-themes&themes=' . urlencode( join(',', $themes) )); |
81 $url = self_admin_url('update.php?action=update-selected-themes&themes=' . urlencode( join(',', $themes) )); |
92 $url = wp_nonce_url($url, 'bulk-update-themes'); |
82 $url = wp_nonce_url($url, 'bulk-update-themes'); |
93 |
83 |
94 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; |
84 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; |
95 echo '</div>'; |
85 echo '</div>'; |
96 require_once(ABSPATH . 'wp-admin/admin-footer.php'); |
86 require_once(ABSPATH . 'wp-admin/admin-footer.php'); |
97 exit; |
87 exit; |
98 case 'delete-selected': |
88 case 'delete-selected': |
99 if ( ! current_user_can( 'delete_themes' ) ) { |
89 if ( ! current_user_can( 'delete_themes' ) ) { |
100 wp_die( __('You do not have sufficient permissions to delete themes for this site.') ); |
90 wp_die( __('Sorry, you are not allowed to delete themes for this site.') ); |
101 } |
91 } |
102 |
92 |
103 check_admin_referer( 'bulk-themes' ); |
93 check_admin_referer( 'bulk-themes' ); |
104 |
94 |
105 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); |
95 $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); |
114 if ( empty( $themes ) ) { |
104 if ( empty( $themes ) ) { |
115 wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) ); |
105 wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) ); |
116 exit; |
106 exit; |
117 } |
107 } |
118 |
108 |
119 $files_to_delete = $theme_info = array(); |
109 $theme_info = array(); |
120 $theme_translations = wp_get_installed_translations( 'themes' ); |
|
121 foreach ( $themes as $key => $theme ) { |
110 foreach ( $themes as $key => $theme ) { |
122 $theme_info[ $theme ] = wp_get_theme( $theme ); |
111 $theme_info[ $theme ] = wp_get_theme( $theme ); |
123 |
|
124 // Locate all the files in that folder. |
|
125 $files = list_files( $theme_info[ $theme ]->get_stylesheet_directory() ); |
|
126 if ( $files ) { |
|
127 $files_to_delete = array_merge( $files_to_delete, $files ); |
|
128 } |
|
129 |
|
130 // Add translation files. |
|
131 $theme_slug = $theme_info[ $theme ]->get_stylesheet(); |
|
132 if ( ! empty( $theme_translations[ $theme_slug ] ) ) { |
|
133 $translations = $theme_translations[ $theme_slug ]; |
|
134 |
|
135 foreach ( $translations as $translation => $data ) { |
|
136 $files_to_delete[] = $theme_slug . '-' . $translation . '.po'; |
|
137 $files_to_delete[] = $theme_slug . '-' . $translation . '.mo'; |
|
138 } |
|
139 } |
|
140 } |
112 } |
141 |
113 |
142 include(ABSPATH . 'wp-admin/update.php'); |
114 include(ABSPATH . 'wp-admin/update.php'); |
143 |
115 |
144 $parent_file = 'themes.php'; |
116 $parent_file = 'themes.php'; |
148 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
120 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
149 $themes_to_delete = count( $themes ); |
121 $themes_to_delete = count( $themes ); |
150 ?> |
122 ?> |
151 <div class="wrap"> |
123 <div class="wrap"> |
152 <?php if ( 1 == $themes_to_delete ) : ?> |
124 <?php if ( 1 == $themes_to_delete ) : ?> |
153 <h2><?php _e( 'Delete Theme' ); ?></h2> |
125 <h1><?php _e( 'Delete Theme' ); ?></h1> |
154 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div> |
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> |
155 <p><?php _e( 'You are about to remove the following theme:' ); ?></p> |
127 <p><?php _e( 'You are about to remove the following theme:' ); ?></p> |
156 <?php else : ?> |
128 <?php else : ?> |
157 <h2><?php _e( 'Delete Themes' ); ?></h2> |
129 <h1><?php _e( 'Delete Themes' ); ?></h1> |
158 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div> |
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> |
159 <p><?php _e( 'You are about to remove the following themes:' ); ?></p> |
131 <p><?php _e( 'You are about to remove the following themes:' ); ?></p> |
160 <?php endif; ?> |
132 <?php endif; ?> |
161 <ul class="ul-disc"> |
133 <ul class="ul-disc"> |
162 <?php |
134 <?php |
163 foreach ( $theme_info as $theme ) { |
135 foreach ( $theme_info as $theme ) { |
164 /* translators: 1: theme name, 2: theme author */ |
136 echo '<li>' . sprintf( |
165 echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>'; |
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>' |
|
141 ) . '</li>'; |
166 } |
142 } |
167 ?> |
143 ?> |
168 </ul> |
144 </ul> |
169 <?php if ( 1 == $themes_to_delete ) : ?> |
145 <?php if ( 1 == $themes_to_delete ) : ?> |
170 <p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p> |
146 <p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p> |
180 } |
156 } |
181 |
157 |
182 wp_nonce_field( 'bulk-themes' ); |
158 wp_nonce_field( 'bulk-themes' ); |
183 |
159 |
184 if ( 1 == $themes_to_delete ) { |
160 if ( 1 == $themes_to_delete ) { |
185 submit_button( __( 'Yes, Delete this theme' ), 'button', 'submit', false ); |
161 submit_button( __( 'Yes, delete this theme' ), '', 'submit', false ); |
186 } else { |
162 } else { |
187 submit_button( __( 'Yes, Delete these themes' ), 'button', 'submit', false ); |
163 submit_button( __( 'Yes, delete these themes' ), '', 'submit', false ); |
188 } |
164 } |
189 ?> |
165 ?> |
190 </form> |
166 </form> |
191 <?php |
167 <?php |
192 $referer = wp_get_referer(); |
168 $referer = wp_get_referer(); |
193 ?> |
169 ?> |
194 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> |
170 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> |
195 <?php submit_button( __( 'No, Return me to the theme list' ), 'button', 'submit', false ); ?> |
171 <?php submit_button( __( 'No, return me to the theme list' ), '', 'submit', false ); ?> |
196 </form> |
172 </form> |
197 |
|
198 <p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p> |
|
199 <div id="files-list" style="display:none;"> |
|
200 <ul class="code"> |
|
201 <?php |
|
202 foreach ( (array) $files_to_delete as $file ) { |
|
203 echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . '/themes', '', $file ) ) . '</li>'; |
|
204 } |
|
205 ?> |
|
206 </ul> |
|
207 </div> |
|
208 </div> |
173 </div> |
209 <?php |
174 <?php |
210 require_once(ABSPATH . 'wp-admin/admin-footer.php'); |
175 require_once(ABSPATH . 'wp-admin/admin-footer.php'); |
211 exit; |
176 exit; |
212 } // Endif verify-delete |
177 } // Endif verify-delete |
245 '<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>' |
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>' |
246 ) ); |
225 ) ); |
247 |
226 |
248 get_current_screen()->set_help_sidebar( |
227 get_current_screen()->set_help_sidebar( |
249 '<p><strong>' . __('For more information:') . '</strong></p>' . |
228 '<p><strong>' . __('For more information:') . '</strong></p>' . |
250 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>') . '</p>' . |
229 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>') . '</p>' . |
251 '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
230 '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
252 ); |
231 ); |
|
232 |
|
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' ), |
|
237 ) ); |
253 |
238 |
254 $title = __('Themes'); |
239 $title = __('Themes'); |
255 $parent_file = 'themes.php'; |
240 $parent_file = 'themes.php'; |
256 |
241 |
|
242 wp_enqueue_script( 'updates' ); |
257 wp_enqueue_script( 'theme-preview' ); |
243 wp_enqueue_script( 'theme-preview' ); |
258 |
244 |
259 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
245 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
260 |
246 |
261 ?> |
247 ?> |
262 |
248 |
263 <div class="wrap"> |
249 <div class="wrap"> |
264 <h2><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php } |
250 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
265 if ( $s ) |
251 |
266 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> |
252 <?php if ( current_user_can( 'install_themes' ) ) : ?> |
267 </h2> |
253 <a href="theme-install.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a> |
|
254 <?php endif; ?> |
|
255 |
|
256 <?php |
|
257 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
|
258 /* translators: %s: search keywords */ |
|
259 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
|
260 } |
|
261 ?> |
|
262 |
|
263 <hr class="wp-header-end"> |
268 |
264 |
269 <?php |
265 <?php |
270 if ( isset( $_GET['enabled'] ) ) { |
266 if ( isset( $_GET['enabled'] ) ) { |
271 $enabled = absint( $_GET['enabled'] ); |
267 $enabled = absint( $_GET['enabled'] ); |
272 if ( 1 == $enabled ) { |
268 if ( 1 == $enabled ) { |
305 |
301 |
306 <?php |
302 <?php |
307 $wp_list_table->views(); |
303 $wp_list_table->views(); |
308 |
304 |
309 if ( 'broken' == $status ) |
305 if ( 'broken' == $status ) |
310 echo '<p class="clear">' . __('The following themes are installed but incomplete. Themes must have a stylesheet and a template.') . '</p>'; |
306 echo '<p class="clear">' . __( 'The following themes are installed but incomplete.' ) . '</p>'; |
311 ?> |
307 ?> |
312 |
308 |
313 <form method="post"> |
309 <form id="bulk-action-form" method="post"> |
314 <input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" /> |
310 <input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" /> |
315 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" /> |
311 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" /> |
316 |
312 |
317 <?php $wp_list_table->display(); ?> |
313 <?php $wp_list_table->display(); ?> |
318 </form> |
314 </form> |
319 |
315 |
320 </div> |
316 </div> |
321 |
317 |
322 <?php |
318 <?php |
|
319 wp_print_request_filesystem_credentials_modal(); |
|
320 wp_print_admin_notice_templates(); |
|
321 wp_print_update_row_templates(); |
|
322 |
323 include(ABSPATH . 'wp-admin/admin-footer.php'); |
323 include(ABSPATH . 'wp-admin/admin-footer.php'); |