TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.76k stars 429 forks source link

Variable admin notices based on user level. #507

Closed jrfnl closed 8 years ago

jrfnl commented 8 years ago

By default the following logic will be used: User < 'publish_posts' (=Author): no admin notices User < install/update/activate: "contact administrator notice" without disclosing information about the plugins involved and only if there are required plugins which require action. User = install/update/activate: "normal" notices

The minimum user level for which admin notices are shown at all can be adjusted by using the newly introduced tgmpa_show_admin_notice_capability filter. The default capability is set to 'publish_posts'.

Example:

add_filter( 'tgmpa_show_admin_notice_capability', create_function( '$cap', 'return \'edit_pages\';' ) );

To only show the admin notices to network admins on multisite, set it to a super admin capability like 'manage_network_plugins'.

Note: the notices() function is ugly and in desperate need of refactoring, that is not handled in this PR (which only makes it worse).

Fixes #190, #414 Supersedes: INN/Largo#740 Partially fixes #479, #489 - notice will now only show for required updates for non-admin users with level author or editor. Possibly fixes #492, though more information is needed on the actual case.

GaryJones commented 8 years ago

The PR now has conflicts.

jrfnl commented 8 years ago

Rebased.

jrfnl commented 8 years ago

@GaryJones re: both your remarks - for this bit, all I really did was abstract a block of code out to a new method as what with the other extra if's and indents, the notices() function became even more unwieldy than it already was. I didn't actually change the code within the block (other than adding a return). So variable names, conditions etc are all as they were.

FYI: this whole block of functionality will be removed in my current plan for 3.0 as it won't be needed anymore.