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.


git-svn-id: https://develop.svn.wordpress.org/trunk@29634 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-08-27 01:31:05 +00:00
parent 8ee417d4f4
commit 322991024f
7 changed files with 70 additions and 39 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.
*