Make WordPress Core

Ticket #29580: 29580_gowp1.diff

File 29580_gowp1.diff, 3.2 KB (added by karpstrucking, 9 years ago)

updates 29580_gowp.diff for code standards

  • 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..66177c8 100644
    a b require_once( dirname( __FILE__ ) . '/admin.php' ); 
    1212if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
    1313        wp_die( __( 'Cheatin’ uh?' ) );
    1414
    15 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
     15if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {
    1616        if ( 'activate' == $_GET['action'] ) {
    17                 check_admin_referer('switch-theme_' . $_GET['stylesheet']);
     17                check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] );
    1818                $theme = wp_get_theme( $_GET['stylesheet'] );
    1919                if ( ! $theme->exists() || ! $theme->is_allowed() )
    2020                        wp_die( __( 'Cheatin’ uh?' ) );
    2121                switch_theme( $theme->get_stylesheet() );
    22                 wp_redirect( admin_url('themes.php?activated=true') );
     22                wp_redirect( admin_url( 'themes.php?activated=true' ) );
    2323                exit;
    2424        } elseif ( 'delete' == $_GET['action'] ) {
    25                 check_admin_referer('delete-theme_' . $_GET['stylesheet']);
     25                check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] );
    2626                $theme = wp_get_theme( $_GET['stylesheet'] );
    27                 if ( !current_user_can('delete_themes') || ! $theme->exists() )
     27                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