Make WordPress Core

Ticket #31365: 31365.diff

File 31365.diff, 4.0 KB (added by MikeHansenMe, 10 years ago)
  • src/wp-admin/themes.php

     
    158158        // Pretend you didn't see this.
    159159        $current_theme_actions = array();
    160160        if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
    161                 foreach ( (array) $submenu['themes.php'] as $item) {
     161                foreach ( (array) $submenu['themes.php'] as $item ) {
    162162                        $class = '';
    163                         if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) )
     163                        if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
    164164                                continue;
     165                        }
    165166                        // 0 = name, 1 = capability, 2 = file
    166                         if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) )
     167                        if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) {
    167168                                $class = ' current';
    168                         if ( !empty($submenu[$item[2]]) ) {
    169                                 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
    170                                 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
    171                                 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
    172                                         $current_theme_actions[] = "<a class='button button-secondary$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
    173                                 else
    174                                         $current_theme_actions[] = "<a class='button button-secondary$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
     169                        }
     170                        if ( ! empty( $submenu[ $item[2] ] ) ) {
     171                                $submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
     172                                $menu_hook = get_plugin_page_hook( $submenu[ $item[2] ][0][2], $item[2] );
     173                                if ( file_exists( WP_PLUGIN_DIR . "/" . $submenu[ $item[2] ][0][2] ) || ! empty( $menu_hook ) ) {
     174                                        $current_theme_actions[] = "<a class='button button-secondary" . $class . "' href='" . esc_url( add_query_arg( array( 'page' => $submenu[ $item[2] ][0][2] ), 'admin.php' ) ) . "'>" . $item[0] . "</a>";
     175                                } else {
     176                                        $current_theme_actions[] = "<a class='button button-secondary" . $class . "' href='" . esc_url( $submenu[ $item[2] ][0][2] ) . "'>" . $item[0] ."</a>";
     177                                }
    175178                        } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
    176179                                $menu_file = $item[2];
    177180
    178181                                if ( current_user_can( 'customize' ) ) {
    179182                                        if ( 'custom-header' === $menu_file ) {
    180                                                 $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
     183                                                $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize" . $class . "' href='customize.php?autofocus[control]=header_image'>" . $item[0] . "</a>";
    181184                                        } elseif ( 'custom-background' === $menu_file ) {
    182                                                 $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
     185                                                $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize" . $class . "' href='customize.php?autofocus[control]=background_image'>" . $item[0] . "</a>";
    183186                                        }
    184187                                }
    185188
     
    187190                                        $menu_file = substr( $menu_file, 0, $pos );
    188191                                }
    189192
    190                                 if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
    191                                         $current_theme_actions[] = "<a class='button button-secondary$class' href='{$item[2]}'>{$item[0]}</a>";
     193                                if ( file_exists( ABSPATH . "wp-admin/" . $menu_file ) ) {
     194                                        $current_theme_actions[] = "<a class='button button-secondary" . $class . "' href='" . esc_url( $item[2] ) . "'>" . $item[0] . "</a>";
    192195                                } else {
    193                                         $current_theme_actions[] = "<a class='button button-secondary$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
     196                                        $current_theme_actions[] = "<a class='button button-secondary" . $class . "' href='" . esc_url( add_query_arg( array( 'page' => $item[2] ), 'themes.php' ) ) . "'>" . $item[0] . "</a>";
    194197                                }
    195198                        }
    196199                }