-
Notifications
You must be signed in to change notification settings - Fork 16
Added a filter so users can not enable auto updates via action if plugin has disabled auto-updates. #10
base: master
Are you sure you want to change the base?
Conversation
Hi, thank you! This feature already exists today in WordPress Core and already works fine with this Feature Plugin. For example, you can use:
Cheers, |
@audrasjb Yes but it does not prevent the actions in the column to hide. The action is still there even if the plugin allows auto-updates or not. That's the purpose of this filter. |
Updated title of issue. |
@audrasjb It's really a UI filter than actually preventing auto-updates. |
Ah ok. Thank you for clarifying. |
wp-autoupdates.php
Outdated
@@ -9,7 +9,7 @@ | |||
Tested up to: 5.3 | |||
Author: The WordPress Team | |||
Author URI: https://wordpress.org | |||
Contributors: wordpressdotorg, audrasjb, whodunitagency, desrosj, xkon, karmatosed | |||
Contributors: wordpressdotorg, audrasjb, whodunitagency, desrosj, xkon, karmatosed, sebd86 |
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.
Please don’t directly add your name to the contributors on the plugin header.
You can add your name on the readme.md file and I will take care your name is added to the props list of WordPress 5.5, but the plugin’s list of contributors is updated manually.
Thanks for your comprehension :)
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.
Understood @audrasjb
@audrasjb Pull request updated. |
@seb86 thanx for raising this. It makes me wonder whether the UI (i.e., the presence of the enable/disable links) should be keyed on the return value from core's That is, something like:
|
Related: #16 |
I did at first think about this but then plugins that sell like me would require requirements to be filled such:
|
Can you expand on the above please? I'm not sure I understand what you're saying, since the example code you have above doesn't test either of those things. If you'd need to test them in a callback hooked to |
For me personally, I don't want the user option to enable or disable plugin updates automatically which is why with the example above, I then hook into So when my plugin has an update available, it fetches the data and passes the parameters I require to check against. If the requirement is good then I enable the plugin to auto update. /**
* Enable auto updates for CoCart Pro if latest release supports
* the current installed version of WooCommerce.
*
* @access public
* @param bool $should_update Should this plugin auto update.
* @param object $plugin Plugin being checked.
* @return bool $should_update Returns the new status if plugin should auto update.
*/
public function auto_update_plugin( $should_update, $plugin ) {
if ( ! isset( $plugin->slug ) ) {
return $should_update;
}
// If the plugin is not CoCart Pro then just return original status.
if ( $this->config['file'] !== $plugin->plugin ) {
return $should_update;
}
/**
* Check to see if the current installed WooCommerce version
* is less than a version required or more than a tested up to.
*/
if (
version_compare( WC_VERSION, $this->config['wc_requires'], '<' ) ||
version_compare( WC_VERSION, $this->config['wc_tested_up_to'], '>' )
) {
return false;
}
return $should_update;
} // END auto_update_plugin() Hope that helps. |
That's what I thought you meant. And that's why in the sample code I added the comment:
so that when the existing core filter were applied to decide whether to display the UI you'd have all the info you'd get when it is applied by So, in the case where your callback returns Note that I'm not completely sold on the idea of using the existing core filter to decide whether to display the UI, I'm just trying to figure out how that would be any different than a new filter whose only purpose were to control whether the UI displays or not. |
This PR allows plugins to remove the option for users to enable auto updates for a specific plugin on the plugins table.
Since the table columns can not be filtered and only allows you to add content, this allows the action to have a condition for a specific plugin.
Example of use in a plugin