Make WordPress Core

Ticket #29580: 29580_gowp2.diff

File 29580_gowp2.diff, 2.3 KB (added by karpstrucking, 10 years ago)

reverts unrelated format changes in 29580_gowp1.diff

  • wp-admin/includes/theme.php

    diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
    index eaef0bc..02c150d 100644
    a b function wp_prepare_themes_for_js( $themes = null ) { 
    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' ),
    function wp_prepare_themes_for_js( $themes = null ) { 
    443444                );
    444445        }
    445446
     447        // Remove 'delete' action if theme has an active child
     448        if ( $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         *
  • wp-admin/themes.php

    diff --git a/wp-admin/themes.php b/wp-admin/themes.php
    index 9457fe3..2726eea 100644
    a b if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { 
    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}
    if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?> 
    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