Make WordPress Core

Ticket #29580: 29580_gowp.diff

File 29580_gowp.diff, 2.2 KB (added by karpstrucking, 11 years ago)

removes link and blocks delete when theme has an active child

  • wp-admin/includes/theme.php

    diff --git wp-admin/includes/theme.php wp-admin/includes/theme.php
    index eaef0bc..e8b4ef4 100644
    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        if ( $parents && array_key_exists( $current_theme, $parents ) )
     448                unset( $prepared_themes[$parents[$current_theme]]['actions']['delete'] );
     449
    446450        /**
    447451         * Filter the themes prepared for JavaScript, for themes.php.
    448452         *
  • wp-admin/themes.php

    diff --git wp-admin/themes.php wp-admin/themes.php
    index 9457fe3..c0208b4 100644
    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