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/includes/class-wp-plugin-install-list-table.php

    r29597 r29634  
    7070            $tabs['beta']      = _x( 'Beta Testing', 'Plugin Installer' );
    7171        }
    72 
    73         $nonmenu_tabs = array( 'upload', 'plugin-information' ); //Valid actions to perform which do not have a Menu item.
     72        if ( current_user_can( 'upload_plugins' ) ) {
     73            // No longer a real tab. Here for filter compatibility.
     74            // Gets juggled into $nonmenu_tabs below.
     75            $tabs['upload'] = __( 'Upload Plugin' );
     76        }
     77
     78        $nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item.
    7479
    7580        /**
     
    9196         */
    9297        $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
     98
     99        if ( isset( $tabs['upload'] ) ) {
     100            unset( $tabs['upload'] );
     101            $nonmenu_tabs[] = 'upload';
     102        }
    93103
    94104        // If a non-valid menu tab has been selected, And it's not a non-menu action.
Note: See TracChangeset for help on using the changeset viewer.