Make WordPress Core


Ignore:
Timestamp:
08/27/2014 01:31:05 AM (9 years ago)
Author:
nacin
Message:

Plugin/Theme Uploads: New capabilities; unify UIs; ensure compatibility with old filters.

Introduce upload_plugins and upload_themes capabilities to allow blocking of plugin and theme uploads, versus the old hacky (and not secure) ways of just hiding UI tabs. These are simply meta capabilities that map to install_plugins and install_themes.

Also:

  • Use the same nice design for the plugin upload screen as the theme upload screen.
  • Better compatibility for the old install_themes_tabs filter added in [29002]. see #28578.
  • Ensure using the install_plugins_tabs filter to remove the upload tab removes the new button.
  • Use 'Add Plugins' instead of 'Install Plugins' to match 'Add Themes'.

fixes #29236.

File:
1 edited

Legend:

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

    r29596 r29634  
    2727    $submenu_file = 'themes.php';
    2828}
    29 
    30 $tabs = array(
    31     'upload'        => __( 'Upload Theme' ),
    32     'browse-themes' => _x( 'Browse', 'themes' ),
    33 );
    3429
    3530$sections = array(
     
    114109?>
    115110<div class="wrap">
    116     <h2>
    117         <?php echo esc_html( $title ); ?>
    118         <?php
    119         /**
    120          * Filter the tabs shown on the Install Themes screen.
    121          *
    122          * @since 2.8.0
    123          * @param array $tabs The tabs shown on the Install Themes screen. Defaults are
    124          *                    'upload' and 'browse-themes'.
    125          */
    126         $tabs = apply_filters( 'install_themes_tabs', $tabs );
    127         foreach ( $tabs as $tab_slug => $tab_name ) {
    128             echo '<a href="#" class="' . esc_attr( $tab_slug ) . ' add-new-h2">' . $tab_name . '</a>';
    129         }
    130         ?>
    131     </h2>
     111    <h2><?php
     112    echo esc_html( $title );
     113
     114    /**
     115     * Filter the tabs shown on the Add Themes screen.
     116     *
     117     * This filter is for backwards compatibility only,
     118     * for the suppression of the upload tab.
     119     *
     120     * @since 2.8.0
     121     * @param array $tabs The tabs shown on the Add Themes screen. Default is 'upload'.
     122     */
     123    $tabs = apply_filters( 'install_themes_tabs', array( 'upload' => __( 'Upload Theme' ) ) );
     124    if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ) ) {
     125        echo ' <a href="#" class="upload add-new-h2">' . __( 'Upload Theme' ) . '</a>';
     126        echo ' <a href="#" class="browse-themes add-new-h2">' . _x( 'Browse', 'themes' ) . '</a>';
     127    }
     128    ?></h2>
    132129
    133130    <div class="upload-theme">
Note: See TracChangeset for help on using the changeset viewer.