WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/02/2014 02:20:14 AM (5 years ago)
Author:
johnbillion
Message:

Prevent the deletion of a theme while it has an active child theme.

Fixes #29580
Props karpstrucking, jesin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/theme.php

    r30680 r30697  
    425425    WP_Theme::sort_by_name( $themes );
    426426    foreach ( $themes as $theme ) {
     427        $slug = $theme->get_stylesheet();
     428        $encoded_slug = urlencode( $slug );
     429
    427430        $parent = false;
    428431        if ( $theme->parent() ) {
    429432            $parent = $theme->parent()->display( 'Name' );
    430         }
    431 
    432         $slug = $theme->get_stylesheet();
    433         $encoded_slug = urlencode( $slug );
     433            $parents[ $slug ] = $theme->parent()->get_stylesheet();
     434        }
    434435
    435436        $prepared_themes[ $slug ] = array(
     
    461462    }
    462463
     464    // Remove 'delete' action if theme has an active child
     465    if ( isset( $parents ) && array_key_exists( $current_theme, $parents ) ) {
     466        unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
     467    }
     468
    463469    /**
    464470     * Filter the themes prepared for JavaScript, for themes.php.
Note: See TracChangeset for help on using the changeset viewer.