Notify When Update(s) Performed - wordpress

I'm looking to create a tally of the number of core, theme and plugin updates performed on a given WP installation. I envisage that this would involve creating an option into which I store and int value that is incremented every time a core, theme &/or plugin update is successfully performed.
To enable this I was hoping for some hooks are called when each of these update types are performed. However, I can't seem to find any relevant hooks for plugin and theme updates.
For core updates, it looks like I can simply increment the relevant options field whenever the '_core_updated_successfully' hook is called.
Are there any relevant hooks available for plugins and themes?
Can you suggest an alternative methodology?
Thanks in advance.

You can run the upgrader_process_complete action hook. it runs when the download process for a plugin install or update finishes. It takes a type parameter for core, plugin or theme.

Related

What is a good action to use to update the WP database from my plugin?

I need a good trigger to use in my plugin to kick off changes to the website.
I've got a custom plugin that goes on all WordPress sites that I build. I've got it set up to auto-update the plugin.
Occasionally, I need to push out an update across all websites. For instance, there was a plugin that started causing issues across all sites so I wrote code in my function to deactivate it across all sites.
Now I'm writing code to remove some old users that should no longer have access to the site. To deactivate the plugin, I used the action 'plugins_loaded'. Of course the problem there is that it runs EVERY time the plugins are loaded so it runs on EVERY page load. It's pretty fast but still not the right way to do it.
I tried to find some sort of way to kick that one off only when the plugin is updated. Really, I just need these functions to run once ever.
Is there a good action I could use to make sure that happens?

Update hook in wordpress not fired

I want to perform a database operation on plugin update. My current version of plugin doesn't have this hook. I added the following code in the updated version. I am using the following code, but this doesn't work.
add_action( 'upgrader_process_complete', 'init_plugin_update', 10, 2 );
function init_plugin_update( $upgrader_object, $options ) {
error_log('test123');
}
I have seen WooCommerce using the same hook. So is there something i am unaware of ? Won't the new plugin file get loaded before this action ?
The upgrader_process_complete hook, as it's stated in the Codex:
Fires when the upgrader process is complete.
But it's also stated in the Notes:
Use with caution: When you use the upgrader_process_complete action hook in your plugin and your plugin is the one which under upgrade, then this action will run the old version of your plugin.
Effectively it means, if your current version of the plugin is 1.0 and it doesn't have this hook, and you're updating the plugin to version 2.0 which has that hook - it won't get fired.
Further Problems with this and other hooks
To perform a database upgrade (in case your version 2.0 has a different table structure) you obviously can't use this hook.
There is another scenario - when your plugin is updated via FTP and not the admin interface (for example you push some file changes through GIT CI/CD pipelines) - none of the hooks will get fired.
The solution
Manually manage the database version of your plugin.
Save the current plugin version in the database with
add_option.
On init hook (or even better, on
admin_init hook, because it gets triggered only during an admin
request - the Core uses this technique) perform a check if the
current version of the plugin is equal as the saved version in the
database. Use get_option and compare that with the version hardcoded in the plugin itself
If there's a mismatch, that means that the database runs
off of the old codebase and you need to update it

Wordpress Password Expiration - Change value or Create a plugin?

One of our Wordpress websites have hundreds of users...when a new user is created, the link is sent to them that expires within a 24h period.
Now, I see that we can change that by changing the a value within the Core of Wordpress: /wp-includes/users.php
Now, would it be better to change the value directly via FTP or create a plugin?
TLDR;
Never edit core files. Go the plugin route instead.
Every time you update WordPress, all core files are replaced by the new ones so editing its code directly is never a good idea: all changes made to it will be lost. Instead, make use of the many action/filter hooks WordPress offers to alter its behavior - this is the safest way to go as upgrades won't overwrite your modifications.
In your case, the password_reset_expiration filter hook is what you're looking for.

Plugin/Custom Code to email me when a plugin update is available

I've tried 2 or three plugins but none seem to be functional. Is there a custom code piece out there or somewhere I can implement a PHP script that will send me an email when a new plugin update is available? Currently have tried WP Update Notifier and Mail-on-Update with zero success.
You can use Wordfence.
Set Email summary frequency to daily.
Use Scan for out of date plugins, themes and WordPress versions to find plugin updates.

What if you update your version of woocommerce,What happned to our data?

What if you update your version of woocommerce,What happens to our data? Does it remain unchanged?
Your products, orders and customer data is stored in your database, so updating WooCommerce shouldn't affect them, but you should always backup your database before you update anything just in case something goes wrong. You can either use a plugin like WP migrate DB, or else export a copy of the DB via PHPMyAdmin.
If your theme uses custom templates for WooCommerce, these may have to be updated: WooCommerce will flag any templates that need updating.
If you've made any changes to the WooCommerce plugin files themselves you will definitely lose those changes: you should avoid editing plugin files directly.
Finally, it's worth reviewing the WooCommerce changelog to see what changes have been made and how they may impact you.

Resources