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

@@ -26,7 +26,7 @@ $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items();
$title = __('Install Plugins');
$title = __( 'Add Plugins' );
$parent_file = 'plugins.php';
wp_enqueue_script( 'plugin-install' );
@@ -75,16 +75,26 @@ include(ABSPATH . 'wp-admin/admin-header.php');
<div class="wrap">
<h2>
<?php
echo esc_html( $title );
$href = self_admin_url( 'plugin-install.php?tab=upload' );
echo esc_html( $title );
if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
if ( $tab === 'upload' ) {
$href = self_admin_url( 'plugin-install.php' );
$text = _x( 'Browse', 'plugins' );
} else {
$href = self_admin_url( 'plugin-install.php?tab=upload' );
$text = __( 'Upload Plugin' );
}
echo ' <a href="' . $href . '" class="upload add-new-h2">' . $text . '</a>';
}
?>
<a href="<?php echo $href; ?>" class="upload add-new-h2"><?php _e( 'Upload Plugin' ); ?></a>
</h2>
<?php $wp_list_table->views(); ?>
<br class="clear" />
<?php
if ( $tab !== 'upload' ) {
$wp_list_table->views();
echo '<br class="clear" />';
}
/**
* Fires after the plugins list table in each tab of the Install Plugins screen.
*