我一直使用upgrader_process_complete
挂钩:
function my_plugins_update_completed( $upgrader_object, $options ) {
// If an update has taken place and the updated type is plugins and the plugins element exists
if ( $options[\'action\'] == \'update\' && $options[\'type\'] == \'plugin\' && isset( $options[\'plugins\'] ) ) {
foreach( $options[\'plugins\'] as $plugin ) {
// Check to ensure it\'s my plugin
if( $plugin == plugin_basename( __FILE__ ) ) {
// do stuff here
}
}
}
}
add_action( \'upgrader_process_complete\', \'my_plugins_update_completed\', 10, 2 );
法典中的更多信息:
https://developer.wordpress.org/reference/hooks/upgrader_process_complete/希望有帮助