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/plugin-install.php

    r29218 r29634  
    2727$wp_list_table->prepare_items();
    2828
    29 $title = __('Install Plugins');
     29$title = __( 'Add Plugins' );
    3030$parent_file = 'plugins.php';
    3131
     
    7676<h2>
    7777    <?php
    78         echo esc_html( $title );
    79         $href = self_admin_url( 'plugin-install.php?tab=upload' );
     78    echo esc_html( $title );
     79    if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
     80        if ( $tab === 'upload' ) {
     81            $href = self_admin_url( 'plugin-install.php' );
     82            $text = _x( 'Browse', 'plugins' );
     83        } else {
     84            $href = self_admin_url( 'plugin-install.php?tab=upload' );
     85            $text = __( 'Upload Plugin' );
     86        }
     87        echo ' <a href="' . $href . '" class="upload add-new-h2">' . $text . '</a>';
     88    }
    8089    ?>
    81     <a href="<?php echo $href; ?>" class="upload add-new-h2"><?php _e( 'Upload Plugin' ); ?></a>
    8290</h2>
    8391
    84 <?php $wp_list_table->views(); ?>
     92<?php
     93if ( $tab !== 'upload' ) {
     94    $wp_list_table->views();
     95    echo '<br class="clear" />';
     96}
    8597
    86 <br class="clear" />
    87 <?php
    8898/**
    8999 * Fires after the plugins list table in each tab of the Install Plugins screen.
Note: See TracChangeset for help on using the changeset viewer.