Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add has_notices on plugin level #749

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Add has_notices on plugin level #749

wants to merge 4 commits into from

Conversation

danyj
Copy link

@danyj danyj commented Jul 8, 2018

This PR sets the has_notice on plugin level so that we can disable the notices for recommended plugins if we need to. Fixes #748

Usage

	'bbpress'=> array(
		'name'      => 'bbPress',
		'slug'      => 'bbpress',
		'required'  => false,
		'force_activation'   => false,
		'has_notices' => false // This plugin will not be visible in the TGMPA notice
	),

@jrfnl jrfnl changed the base branch from master to develop July 8, 2018 16:13
Copy link
Contributor

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danyj Welcome and thanks for your first PR!

I realy like the idea of this change.

As we try to make sure the code in TGMPA is high-quality, for this PR to be acceptable a couple of changes are needed:

  1. The code needs to comply with the WordPress Coding Standards - see the Travis output for the issues.
  2. TGMPA uses the principle that all plugin options are always set. To comply with this:
    • Add the new option to the $defaults in the register() method:
      $defaults = array(
      'name' => '', // String.
      'slug' => '', // String.
      'source' => 'repo', // String.
      'required' => false, // Boolean.
      'version' => '', // String.
      'force_activation' => false, // Boolean.
      'force_deactivation' => false, // Boolean.
      'external_url' => '', // String.
      'is_callable' => '', // String|Array.
      );
    • Add validation for the input in the same method - see line1421 for an example:
      $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] );
    • You can now remove the isset($plugin['has_notices']) from the condition you added.
  3. It may be useful to add an example using this new option to the example.php file.
  4. A sister-PR is needed for the gh-pages branch to adjust the configuration documentation: http://tgmpluginactivation.com/configuration/

Please let me know if you need help with any of this and I look forward to seeing this get into TGMPA.

@jrfnl
Copy link
Contributor

jrfnl commented Jul 8, 2018

@GaryJones As this adds a new feature - do you agree that if this is merged in, the next version will need to be called 2.7.0 (instead of 2.6.2) ?

@danyj
Copy link
Author

danyj commented Jul 8, 2018

@jrfnl on it , going trough suggested changes.

@danyj
Copy link
Author

danyj commented Jul 8, 2018

not sure why travis is failing

@danyj
Copy link
Author

danyj commented Jul 8, 2018

A sister-PR is needed f

where is that git ?

@danyj
Copy link
Author

danyj commented Jul 8, 2018

@jrfnl please check the travis , all those lines were there and are untouched. I simply pulled the git and changed 4 lines and they do not seem to be failing.

@danyj
Copy link
Author

danyj commented Jul 8, 2018

Checked travis , all the lines mentioned in both files were there before my PR.

@danyj
Copy link
Author

danyj commented Jul 8, 2018

finally :)

@jrfnl
Copy link
Contributor

jrfnl commented Jul 8, 2018

@danyj Thanks for all the changes. I'll try to have another look later today.

where is that git ?

Regarding the sister-PR, it is in this same repo, just on another (orphan) branch: https://github.com/TGMPA/TGM-Plugin-Activation/tree/gh-pages

@danyj
Copy link
Author

danyj commented Jul 8, 2018

All set. Submitted PR for it.

Copy link
Contributor

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danyj All looks good to me.

There's just one thing I'm wondering: should has_notices always be allowed/respected or only when required is false ?

If a plugin is required and not active, not showing the notice could easily cause the fact that the plugin is deactivated to go unnoticed, which - depending on the quality of the theme/plugin which requires it - could break sites with a WSOD.

What do you think ?

@GaryJones Have you got an opinion on this ?

If we would only allow it for recommended plugins, the if() within the notices() method would need to check the required setting as well + the explanation text in example.php would need to mention this too.

@danyj
Copy link
Author

danyj commented Jul 10, 2018

or only when required is false

good point , I think only when required is false because required true should always show notice.

@GaryJones @jrfnl , let me know and I can make changes if you agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants