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.

Built from https://develop.svn.wordpress.org/trunk@29634


git-svn-id: http://core.svn.wordpress.org/trunk@29408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin
2014-08-27 01:32:18 +00:00
parent a32210ef42
commit ac3dd27737
11 changed files with 81 additions and 46 deletions

View File

@@ -27,11 +27,6 @@ if ( ! is_network_admin() ) {
$submenu_file = 'themes.php';
}
$tabs = array(
'upload' => __( 'Upload Theme' ),
'browse-themes' => _x( 'Browse', 'themes' ),
);
$sections = array(
'featured' => __( 'Featured Themes' ),
'popular' => __( 'Popular Themes' ),
@@ -113,22 +108,24 @@ include(ABSPATH . 'wp-admin/admin-header.php');
?>
<div class="wrap">
<h2>
<?php echo esc_html( $title ); ?>
<?php
/**
* Filter the tabs shown on the Install Themes screen.
*
* @since 2.8.0
* @param array $tabs The tabs shown on the Install Themes screen. Defaults are
* 'upload' and 'browse-themes'.
*/
$tabs = apply_filters( 'install_themes_tabs', $tabs );
foreach ( $tabs as $tab_slug => $tab_name ) {
echo '<a href="#" class="' . esc_attr( $tab_slug ) . ' add-new-h2">' . $tab_name . '</a>';
}
?>
</h2>
<h2><?php
echo esc_html( $title );
/**
* Filter the tabs shown on the Add Themes screen.
*
* This filter is for backwards compatibility only,
* for the suppression of the upload tab.
*
* @since 2.8.0
* @param array $tabs The tabs shown on the Add Themes screen. Default is 'upload'.
*/
$tabs = apply_filters( 'install_themes_tabs', array( 'upload' => __( 'Upload Theme' ) ) );
if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ) ) {
echo ' <a href="#" class="upload add-new-h2">' . __( 'Upload Theme' ) . '</a>';
echo ' <a href="#" class="browse-themes add-new-h2">' . _x( 'Browse', 'themes' ) . '</a>';
}
?></h2>
<div class="upload-theme">
<?php install_themes_upload(); ?>