-
Notifications
You must be signed in to change notification settings - Fork 427
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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:
- The code needs to comply with the WordPress Coding Standards - see the Travis output for the issues.
- TGMPA uses the principle that all plugin options are always set. To comply with this:
- Add the new option to the
$defaults
in theregister()
method:TGM-Plugin-Activation/class-tgm-plugin-activation.php
Lines 1399 to 1409 in 2732e40
$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.
- Add the new option to the
- It may be useful to add an example using this new option to the
example.php
file. - A sister-PR is needed for the
gh-pages
branch to adjust theconfiguration
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.
@GaryJones As this adds a new feature - do you agree that if this is merged in, the next version will need to be called |
@jrfnl on it , going trough suggested changes. |
not sure why travis is failing |
where is that git ? |
@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. |
Checked travis , all the lines mentioned in both files were there before my PR. |
finally :) |
@danyj Thanks for all the changes. I'll try to have another look later today.
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 |
All set. Submitted PR for it. |
There was a problem hiding this 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.
good point , I think only when required is @GaryJones @jrfnl , let me know and I can make changes if you agree |
This PR sets the
has_notice
on plugin level so that we can disable the notices for recommended plugins if we need to. Fixes #748Usage