Make WordPress Core

Ticket #29580: 29580.diff

File 29580.diff, 2.1 KB (added by jesin, 9 years ago)

Fixes undefined variable notice on 29580_gowp2.diff

  • src/wp-admin/themes.php

     
    2626                $theme = wp_get_theme( $_GET['stylesheet'] );
    2727                if ( !current_user_can('delete_themes') || ! $theme->exists() )
    2828                        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                }
    3136                exit;
    3237        }
    3338}
     
    133138                }
    134139        elseif ( isset($_GET['deleted']) ) : ?>
    135140<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>
    136143<?php
    137144endif;
    138145
  • src/wp-admin/includes/theme.php

     
    407407
    408408        WP_Theme::sort_by_name( $themes );
    409409        foreach ( $themes as $theme ) {
     410                $slug = $theme->get_stylesheet();
     411                $encoded_slug = urlencode( $slug );
     412
    410413                $parent = false;
    411414                if ( $theme->parent() ) {
    412415                        $parent = $theme->parent()->display( 'Name' );
     416                        $parents[ $slug ] = $theme->parent()->get_stylesheet();
    413417                }
    414418
    415                 $slug = $theme->get_stylesheet();
    416                 $encoded_slug = urlencode( $slug );
    417 
    418419                $prepared_themes[ $slug ] = array(
    419420                        'id'           => $slug,
    420421                        'name'         => $theme->display( 'Name' ),
     
    443444                );
    444445        }
    445446
     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
    446452        /**
    447453         * Filter the themes prepared for JavaScript, for themes.php.
    448454         *