74 } |
82 } |
75 |
83 |
76 $title = __( 'Update Themes' ); |
84 $title = __( 'Update Themes' ); |
77 $parent_file = 'themes.php'; |
85 $parent_file = 'themes.php'; |
78 |
86 |
79 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
87 require_once ABSPATH . 'wp-admin/admin-header.php'; |
80 |
88 |
81 echo '<div class="wrap">'; |
89 echo '<div class="wrap">'; |
82 echo '<h1>' . esc_html( $title ) . '</h1>'; |
90 echo '<h1>' . esc_html( $title ) . '</h1>'; |
83 |
91 |
84 $url = self_admin_url( 'update.php?action=update-selected-themes&themes=' . urlencode( join( ',', $themes ) ) ); |
92 $url = self_admin_url( 'update.php?action=update-selected-themes&themes=' . urlencode( join( ',', $themes ) ) ); |
85 $url = wp_nonce_url( $url, 'bulk-update-themes' ); |
93 $url = wp_nonce_url( $url, 'bulk-update-themes' ); |
86 |
94 |
87 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; |
95 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; |
88 echo '</div>'; |
96 echo '</div>'; |
89 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
97 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
90 exit; |
98 exit; |
91 case 'delete-selected': |
99 case 'delete-selected': |
92 if ( ! current_user_can( 'delete_themes' ) ) { |
100 if ( ! current_user_can( 'delete_themes' ) ) { |
93 wp_die( __( 'Sorry, you are not allowed to delete themes for this site.' ) ); |
101 wp_die( __( 'Sorry, you are not allowed to delete themes for this site.' ) ); |
94 } |
102 } |
112 $theme_info = array(); |
120 $theme_info = array(); |
113 foreach ( $themes as $key => $theme ) { |
121 foreach ( $themes as $key => $theme ) { |
114 $theme_info[ $theme ] = wp_get_theme( $theme ); |
122 $theme_info[ $theme ] = wp_get_theme( $theme ); |
115 } |
123 } |
116 |
124 |
117 include( ABSPATH . 'wp-admin/update.php' ); |
125 require ABSPATH . 'wp-admin/update.php'; |
118 |
126 |
119 $parent_file = 'themes.php'; |
127 $parent_file = 'themes.php'; |
120 |
128 |
121 if ( ! isset( $_REQUEST['verify-delete'] ) ) { |
129 if ( ! isset( $_REQUEST['verify-delete'] ) ) { |
122 wp_enqueue_script( 'jquery' ); |
130 wp_enqueue_script( 'jquery' ); |
123 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
131 require_once ABSPATH . 'wp-admin/admin-header.php'; |
124 $themes_to_delete = count( $themes ); |
132 $themes_to_delete = count( $themes ); |
125 ?> |
133 ?> |
126 <div class="wrap"> |
134 <div class="wrap"> |
127 <?php if ( 1 == $themes_to_delete ) : ?> |
135 <?php if ( 1 === $themes_to_delete ) : ?> |
128 <h1><?php _e( 'Delete Theme' ); ?></h1> |
136 <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> |
137 <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> |
138 <p><?php _e( 'You are about to remove the following theme:' ); ?></p> |
131 <?php else : ?> |
139 <?php else : ?> |
132 <h1><?php _e( 'Delete Themes' ); ?></h1> |
140 <h1><?php _e( 'Delete Themes' ); ?></h1> |
135 <?php endif; ?> |
143 <?php endif; ?> |
136 <ul class="ul-disc"> |
144 <ul class="ul-disc"> |
137 <?php |
145 <?php |
138 foreach ( $theme_info as $theme ) { |
146 foreach ( $theme_info as $theme ) { |
139 echo '<li>' . sprintf( |
147 echo '<li>' . sprintf( |
140 /* translators: 1: theme name, 2: theme author */ |
148 /* translators: 1: Theme name, 2: Theme author. */ |
141 _x( '%1$s by %2$s', 'theme' ), |
149 _x( '%1$s by %2$s', 'theme' ), |
142 '<strong>' . $theme->display( 'Name' ) . '</strong>', |
150 '<strong>' . $theme->display( 'Name' ) . '</strong>', |
143 '<em>' . $theme->display( 'Author' ) . '</em>' |
151 '<em>' . $theme->display( 'Author' ) . '</em>' |
144 ) . '</li>'; |
152 ) . '</li>'; |
145 } |
153 } |
146 ?> |
154 ?> |
147 </ul> |
155 </ul> |
148 <?php if ( 1 == $themes_to_delete ) : ?> |
156 <?php if ( 1 === $themes_to_delete ) : ?> |
149 <p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p> |
157 <p><?php _e( 'Are you sure you want to delete this theme?' ); ?></p> |
150 <?php else : ?> |
158 <?php else : ?> |
151 <p><?php _e( 'Are you sure you wish to delete these themes?' ); ?></p> |
159 <p><?php _e( 'Are you sure you want to delete these themes?' ); ?></p> |
152 <?php endif; ?> |
160 <?php endif; ?> |
153 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> |
161 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> |
154 <input type="hidden" name="verify-delete" value="1" /> |
162 <input type="hidden" name="verify-delete" value="1" /> |
155 <input type="hidden" name="action" value="delete-selected" /> |
163 <input type="hidden" name="action" value="delete-selected" /> |
156 <?php |
164 <?php |
|
165 |
157 foreach ( (array) $themes as $theme ) { |
166 foreach ( (array) $themes as $theme ) { |
158 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $theme ) . '" />'; |
167 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $theme ) . '" />'; |
159 } |
168 } |
160 |
169 |
161 wp_nonce_field( 'bulk-themes' ); |
170 wp_nonce_field( 'bulk-themes' ); |
162 |
171 |
163 if ( 1 == $themes_to_delete ) { |
172 if ( 1 === $themes_to_delete ) { |
164 submit_button( __( 'Yes, delete this theme' ), '', 'submit', false ); |
173 submit_button( __( 'Yes, delete this theme' ), '', 'submit', false ); |
165 } else { |
174 } else { |
166 submit_button( __( 'Yes, delete these themes' ), '', 'submit', false ); |
175 submit_button( __( 'Yes, delete these themes' ), '', 'submit', false ); |
167 } |
176 } |
|
177 |
168 ?> |
178 ?> |
169 </form> |
179 </form> |
170 <?php |
180 <?php $referer = wp_get_referer(); ?> |
171 $referer = wp_get_referer(); |
|
172 ?> |
|
173 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> |
181 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> |
174 <?php submit_button( __( 'No, return me to the theme list' ), '', 'submit', false ); ?> |
182 <?php submit_button( __( 'No, return me to the theme list' ), '', 'submit', false ); ?> |
175 </form> |
183 </form> |
176 </div> |
184 </div> |
177 <?php |
185 <?php |
178 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
186 |
179 exit; |
187 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
180 } // Endif verify-delete |
188 exit; |
|
189 } // End if verify-delete. |
181 |
190 |
182 foreach ( $themes as $theme ) { |
191 foreach ( $themes as $theme ) { |
183 $delete_result = delete_theme( |
192 $delete_result = delete_theme( |
184 $theme, |
193 $theme, |
185 esc_url( |
194 esc_url( |
206 ), |
215 ), |
207 network_admin_url( 'themes.php' ) |
216 network_admin_url( 'themes.php' ) |
208 ) |
217 ) |
209 ); |
218 ); |
210 exit; |
219 exit; |
|
220 case 'enable-auto-update': |
|
221 case 'disable-auto-update': |
|
222 case 'enable-auto-update-selected': |
|
223 case 'disable-auto-update-selected': |
|
224 if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) { |
|
225 wp_die( __( 'Sorry, you are not allowed to change themes automatic update settings.' ) ); |
|
226 } |
|
227 |
|
228 if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) { |
|
229 check_admin_referer( 'updates' ); |
|
230 } else { |
|
231 if ( empty( $_POST['checked'] ) ) { |
|
232 // Nothing to do. |
|
233 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
|
234 exit; |
|
235 } |
|
236 |
|
237 check_admin_referer( 'bulk-themes' ); |
|
238 } |
|
239 |
|
240 $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
241 |
|
242 if ( 'enable-auto-update' === $action ) { |
|
243 $auto_updates[] = $_GET['theme']; |
|
244 $auto_updates = array_unique( $auto_updates ); |
|
245 $referer = add_query_arg( 'enabled-auto-update', 1, $referer ); |
|
246 } elseif ( 'disable-auto-update' === $action ) { |
|
247 $auto_updates = array_diff( $auto_updates, array( $_GET['theme'] ) ); |
|
248 $referer = add_query_arg( 'disabled-auto-update', 1, $referer ); |
|
249 } else { |
|
250 // Bulk enable/disable. |
|
251 $themes = (array) wp_unslash( $_POST['checked'] ); |
|
252 |
|
253 if ( 'enable-auto-update-selected' === $action ) { |
|
254 $auto_updates = array_merge( $auto_updates, $themes ); |
|
255 $auto_updates = array_unique( $auto_updates ); |
|
256 $referer = add_query_arg( 'enabled-auto-update', count( $themes ), $referer ); |
|
257 } else { |
|
258 $auto_updates = array_diff( $auto_updates, $themes ); |
|
259 $referer = add_query_arg( 'disabled-auto-update', count( $themes ), $referer ); |
|
260 } |
|
261 } |
|
262 |
|
263 $all_items = wp_get_themes(); |
|
264 |
|
265 // Remove themes that don't exist or have been deleted since the option was last updated. |
|
266 $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); |
|
267 |
|
268 update_site_option( 'auto_update_themes', $auto_updates ); |
|
269 |
|
270 wp_safe_redirect( $referer ); |
|
271 exit; |
211 default: |
272 default: |
212 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); |
273 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); |
213 if ( empty( $themes ) ) { |
274 if ( empty( $themes ) ) { |
214 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
275 wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) ); |
215 exit; |
276 exit; |
216 } |
277 } |
217 check_admin_referer( 'bulk-themes' ); |
278 check_admin_referer( 'bulk-themes' ); |
218 |
279 |
219 /** This action is documented in wp-admin/network/site-themes.php */ |
280 /** This action is documented in wp-admin/network/site-themes.php */ |
220 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes ); |
281 $referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
221 |
282 |
222 wp_safe_redirect( $referer ); |
283 wp_safe_redirect( $referer ); |
223 exit; |
284 exit; |
224 } |
285 } |
225 } |
286 } |
239 '<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>' . |
300 '<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>' . |
240 '<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>', |
301 '<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>', |
241 ) |
302 ) |
242 ); |
303 ); |
243 |
304 |
|
305 $help_sidebar_autoupdates = ''; |
|
306 |
|
307 if ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) { |
|
308 get_current_screen()->add_help_tab( |
|
309 array( |
|
310 'id' => 'plugins-themes-auto-updates', |
|
311 'title' => __( 'Auto-updates' ), |
|
312 'content' => |
|
313 '<p>' . __( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' . |
|
314 '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>', |
|
315 ) |
|
316 ); |
|
317 |
|
318 $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>'; |
|
319 } |
|
320 |
244 get_current_screen()->set_help_sidebar( |
321 get_current_screen()->set_help_sidebar( |
245 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
322 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
246 '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>' ) . '</p>' . |
323 '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>' ) . '</p>' . |
|
324 $help_sidebar_autoupdates . |
247 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
325 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
248 ); |
326 ); |
249 |
327 |
250 get_current_screen()->set_screen_reader_content( |
328 get_current_screen()->set_screen_reader_content( |
251 array( |
329 array( |
272 <a href="theme-install.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a> |
350 <a href="theme-install.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a> |
273 <?php endif; ?> |
351 <?php endif; ?> |
274 |
352 |
275 <?php |
353 <?php |
276 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
354 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
277 /* translators: %s: search keywords */ |
355 /* translators: %s: Search query. */ |
278 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
356 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
279 } |
357 } |
280 ?> |
358 ?> |
281 |
359 |
282 <hr class="wp-header-end"> |
360 <hr class="wp-header-end"> |
283 |
361 |
284 <?php |
362 <?php |
285 if ( isset( $_GET['enabled'] ) ) { |
363 if ( isset( $_GET['enabled'] ) ) { |
286 $enabled = absint( $_GET['enabled'] ); |
364 $enabled = absint( $_GET['enabled'] ); |
287 if ( 1 == $enabled ) { |
365 if ( 1 === $enabled ) { |
288 $message = __( 'Theme enabled.' ); |
366 $message = __( 'Theme enabled.' ); |
289 } else { |
367 } else { |
|
368 /* translators: %s: Number of themes. */ |
290 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled ); |
369 $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled ); |
291 } |
370 } |
292 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>'; |
371 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>'; |
293 } elseif ( isset( $_GET['disabled'] ) ) { |
372 } elseif ( isset( $_GET['disabled'] ) ) { |
294 $disabled = absint( $_GET['disabled'] ); |
373 $disabled = absint( $_GET['disabled'] ); |
295 if ( 1 == $disabled ) { |
374 if ( 1 === $disabled ) { |
296 $message = __( 'Theme disabled.' ); |
375 $message = __( 'Theme disabled.' ); |
297 } else { |
376 } else { |
|
377 /* translators: %s: Number of themes. */ |
298 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled ); |
378 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled ); |
299 } |
379 } |
300 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; |
380 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; |
301 } elseif ( isset( $_GET['deleted'] ) ) { |
381 } elseif ( isset( $_GET['deleted'] ) ) { |
302 $deleted = absint( $_GET['deleted'] ); |
382 $deleted = absint( $_GET['deleted'] ); |
303 if ( 1 == $deleted ) { |
383 if ( 1 === $deleted ) { |
304 $message = __( 'Theme deleted.' ); |
384 $message = __( 'Theme deleted.' ); |
305 } else { |
385 } else { |
|
386 /* translators: %s: Number of themes. */ |
306 $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted ); |
387 $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted ); |
307 } |
388 } |
308 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>'; |
389 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>'; |
309 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { |
390 } elseif ( isset( $_GET['enabled-auto-update'] ) ) { |
|
391 $enabled = absint( $_GET['enabled-auto-update'] ); |
|
392 if ( 1 === $enabled ) { |
|
393 $message = __( 'Theme will be auto-updated.' ); |
|
394 } else { |
|
395 /* translators: %s: Number of themes. */ |
|
396 $message = _n( '%s theme will be auto-updated.', '%s themes will be auto-updated.', $enabled ); |
|
397 } |
|
398 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>'; |
|
399 } elseif ( isset( $_GET['disabled-auto-update'] ) ) { |
|
400 $disabled = absint( $_GET['disabled-auto-update'] ); |
|
401 if ( 1 === $disabled ) { |
|
402 $message = __( 'Theme will no longer be auto-updated.' ); |
|
403 } else { |
|
404 /* translators: %s: Number of themes. */ |
|
405 $message = _n( '%s theme will no longer be auto-updated.', '%s themes will no longer be auto-updated.', $disabled ); |
|
406 } |
|
407 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; |
|
408 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) { |
310 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>'; |
409 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>'; |
311 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) { |
410 } elseif ( isset( $_GET['error'] ) && 'main' === $_GET['error'] ) { |
312 echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>'; |
411 echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>'; |
313 } |
412 } |
314 |
413 |
315 ?> |
414 ?> |
316 |
415 |