Changeset 47835 for trunk/src/wp-admin/network/themes.php
- Timestamp:
- 05/20/2020 06:47:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/network/themes.php
r47198 r47835 23 23 24 24 // Clean up request URI from temporary args for screen options/paging uri's to work as expected. 25 $temp_args = array( 'enabled', 'disabled', 'deleted', 'error' ); 25 $temp_args = array( 26 'enabled', 27 'disabled', 28 'deleted', 29 'error', 30 'enabled-auto-update', 31 'disabled-auto-update', 32 ); 33 26 34 $_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); 27 35 $referer = remove_query_arg( $temp_args, wp_get_referer() ); … … 124 132 $themes_to_delete = count( $themes ); 125 133 ?> 126 <div class="wrap">127 <?php if ( 1 == $themes_to_delete ) : ?>134 <div class="wrap"> 135 <?php if ( 1 === $themes_to_delete ) : ?> 128 136 <h1><?php _e( 'Delete Theme' ); ?></h1> 129 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> … … 146 154 ?> 147 155 </ul> 148 <?php if ( 1 == $themes_to_delete ) : ?>156 <?php if ( 1 === $themes_to_delete ) : ?> 149 157 <p><?php _e( 'Are you sure you want to delete this theme?' ); ?></p> 150 158 <?php else : ?> … … 155 163 <input type="hidden" name="action" value="delete-selected" /> 156 164 <?php 165 157 166 foreach ( (array) $themes as $theme ) { 158 167 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $theme ) . '" />'; 159 168 } 160 169 161 162 163 if ( 1 == $themes_to_delete ) {170 wp_nonce_field( 'bulk-themes' ); 171 172 if ( 1 === $themes_to_delete ) { 164 173 submit_button( __( 'Yes, delete this theme' ), '', 'submit', false ); 165 174 } else { 166 175 submit_button( __( 'Yes, delete these themes' ), '', 'submit', false ); 167 176 } 177 168 178 ?> 169 179 </form> 170 <?php 171 $referer = wp_get_referer(); 172 ?> 180 <?php $referer = wp_get_referer(); ?> 173 181 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> 174 182 <?php submit_button( __( 'No, return me to the theme list' ), '', 'submit', false ); ?> 175 183 </form> 176 </div>184 </div> 177 185 <?php 186 178 187 require_once ABSPATH . 'wp-admin/admin-footer.php'; 179 188 exit; … … 209 218 ); 210 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 272 default: 212 273 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); … … 285 346 if ( isset( $_GET['enabled'] ) ) { 286 347 $enabled = absint( $_GET['enabled'] ); 287 if ( 1 == $enabled ) {348 if ( 1 === $enabled ) { 288 349 $message = __( 'Theme enabled.' ); 289 350 } else { … … 294 355 } elseif ( isset( $_GET['disabled'] ) ) { 295 356 $disabled = absint( $_GET['disabled'] ); 296 if ( 1 == $disabled ) {357 if ( 1 === $disabled ) { 297 358 $message = __( 'Theme disabled.' ); 298 359 } else { … … 303 364 } elseif ( isset( $_GET['deleted'] ) ) { 304 365 $deleted = absint( $_GET['deleted'] ); 305 if ( 1 == $deleted ) {366 if ( 1 === $deleted ) { 306 367 $message = __( 'Theme deleted.' ); 307 368 } else { … … 310 371 } 311 372 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>'; 312 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { 373 } elseif ( isset( $_GET['enabled-auto-update'] ) ) { 374 $enabled = absint( $_GET['enabled-auto-update'] ); 375 if ( 1 === $enabled ) { 376 $message = __( 'Theme will be auto-updated.' ); 377 } else { 378 /* translators: %s: Number of themes. */ 379 $message = _n( '%s theme will be auto-updated.', '%s themes will be auto-updated.', $enabled ); 380 } 381 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>'; 382 } elseif ( isset( $_GET['disabled-auto-update'] ) ) { 383 $disabled = absint( $_GET['disabled-auto-update'] ); 384 if ( 1 === $disabled ) { 385 $message = __( 'Theme will no longer be auto-updated.' ); 386 } else { 387 /* translators: %s: Number of themes. */ 388 $message = _n( '%s theme will no longer be auto-updated.', '%s themes will no longer be auto-updated.', $disabled ); 389 } 390 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; 391 } elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) { 313 392 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>'; 314 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {393 } elseif ( isset( $_GET['error'] ) && 'main' === $_GET['error'] ) { 315 394 echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>'; 316 395 } … … 325 404 $wp_list_table->views(); 326 405 327 if ( 'broken' == $status ) {406 if ( 'broken' === $status ) { 328 407 echo '<p class="clear">' . __( 'The following themes are installed but incomplete.' ) . '</p>'; 329 408 }
Note: See TracChangeset
for help on using the changeset viewer.