Make WordPress Core

Changeset 26470


Ignore:
Timestamp:
11/29/2013 09:00:23 AM (11 years ago)
Author:
dd32
Message:

Themes: Do extra Cap checks before outputting links, and use full URI's. See #25948

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

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

    r26469 r26470  
    143143        $theme_name = $theme->display('Name');
    144144        $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
    145         $update_url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
     145        $update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet );
    146146        $update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update.") ) . '\') ) {return true;}return false;"';
    147147
     
    415415            'update'       => get_theme_update_available( $theme ),
    416416            'actions'      => array(
    417                 'activate' => wp_nonce_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug, 'switch-theme_' . $slug ),
    418                 'customize'=> admin_url( 'customize.php?theme=' . $encoded_slug ),
    419                 'delete'   => wp_nonce_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug, 'delete-theme_' . $slug ),
     417                'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
     418                'customize'=> current_user_can( 'edit_theme_options' ) ? admin_url( 'customize.php?theme=' . $encoded_slug ) : null,
     419                'delete'   => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
    420420            ),
    421421        );
  • trunk/src/wp-admin/themes.php

    r26462 r26470  
    9393    'settings' => array(
    9494        'canInstall'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
    95         'installURI'    => admin_url( 'theme-install.php' ),
    96         'customizeURI'  => ( current_user_can( 'edit_theme_options' ) ) ? wp_customize_url() : null,
     95        'installURI'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
    9796        'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
    98         'root'          => '/wp-admin/themes.php',
     97        'root'          => admin_url( 'themes.php' ),
    9998        'extraRoutes'   => '',
    10099    ),
     
    221220    <div class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.author }}}' ); ?></div>
    222221    <h3 class="theme-name">{{ data.name }}</h3>
     222
    223223    <div class="theme-actions">
    224224
    225225    <# if ( data.active ) { #>
    226         <span class="current-label"><?php _e( 'Current Theme' ); ?></span>
    227         <# if ( wp.themes.data.settings['customizeURI'] ) { #>
    228             <a class="button button-primary hide-if-no-customize" href="{{ wp.themes.data.settings['customizeURI'] }}"><?php _e( 'Customize' ); ?></a>
     226        <# if ( data.actions['customize'] ) { #>
     227            <a class="button button-primary hide-if-no-customize" href="{{ data.actions['customize'] }}"><?php _e( 'Customize' ); ?></a>
    229228        <# } #>
    230229    <# } else { #>
     
    293292        <div class="active-theme">
    294293            <a href="{{{ wp.themes.data.settings.customizeURI }}}" class="button button-primary hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
    295             <?php if( current_theme_supports( 'menus' ) ) { ?>
     294            <?php if ( current_theme_supports( 'menus' ) ) { ?>
    296295            <a class="button button-secondary" href="<?php echo admin_url( 'nav-menus.php' ); ?>"><?php _e( 'Menus' ); ?></a>
    297296            <?php } ?>
     
    301300        </div>
    302301        <div class="inactive-theme">
    303             <a href="{{{ data.actions.activate }}}" class="button button-primary"><?php _e( 'Activate' ); ?></a>
     302            <# if ( data.actions.activate ) { #>
     303                <a href="{{{ data.actions.activate }}}" class="button button-primary"><?php _e( 'Activate' ); ?></a>
     304            <# } #>
    304305            <a href="{{{ data.actions.customize }}}" class="button button-secondary"><?php _e( 'Live Preview' ); ?></a>
    305306        </div>
    306307
    307         <# if ( ! data.active ) { #>
     308        <# if ( ! data.active && data.actions.delete ) { #>
    308309            <a href="{{{ data.actions.delete }}}" class="delete-theme"><?php _e( 'Delete' ); ?></a>
    309310        <# } #>
Note: See TracChangeset for help on using the changeset viewer.