Ticket #29580: 29580.diff
File 29580.diff, 2.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/themes.php
26 26 $theme = wp_get_theme( $_GET['stylesheet'] ); 27 27 if ( !current_user_can('delete_themes') || ! $theme->exists() ) 28 28 wp_die( __( 'Cheatin’ uh?' ) ); 29 delete_theme($_GET['stylesheet']); 30 wp_redirect( admin_url('themes.php?deleted=true') ); 29 $active = wp_get_theme(); 30 if ( $active->get( "Template" ) == $_GET['stylesheet'] ) { 31 wp_redirect( admin_url( 'themes.php?active-child=true' ) ); 32 } else { 33 delete_theme( $_GET['stylesheet'] ); 34 wp_redirect( admin_url( 'themes.php?deleted=true' ) ); 35 } 31 36 exit; 32 37 } 33 38 } … … 133 138 } 134 139 elseif ( isset($_GET['deleted']) ) : ?> 135 140 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div> 141 <?php elseif ( isset( $_GET['active-child'] ) ) : ?> 142 <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div> 136 143 <?php 137 144 endif; 138 145 -
src/wp-admin/includes/theme.php
407 407 408 408 WP_Theme::sort_by_name( $themes ); 409 409 foreach ( $themes as $theme ) { 410 $slug = $theme->get_stylesheet(); 411 $encoded_slug = urlencode( $slug ); 412 410 413 $parent = false; 411 414 if ( $theme->parent() ) { 412 415 $parent = $theme->parent()->display( 'Name' ); 416 $parents[ $slug ] = $theme->parent()->get_stylesheet(); 413 417 } 414 418 415 $slug = $theme->get_stylesheet();416 $encoded_slug = urlencode( $slug );417 418 419 $prepared_themes[ $slug ] = array( 419 420 'id' => $slug, 420 421 'name' => $theme->display( 'Name' ), … … 443 444 ); 444 445 } 445 446 447 // Remove 'delete' action if theme has an active child 448 if ( isset( $parents ) && array_key_exists( $current_theme, $parents ) ) { 449 unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); 450 } 451 446 452 /** 447 453 * Filter the themes prepared for JavaScript, for themes.php. 448 454 *