Automattic\WooCommerce\Admin\Features\ProductBlockEditor
ProductFormsController::migrate_templates_when_plugin_updated
Migrate form templates after WooCommerce plugin update.
Method of the class: ProductFormsController{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ProductFormsController = new ProductFormsController(); $ProductFormsController->migrate_templates_when_plugin_updated( $upgrader, $hook_extra );
- $upgrader(WP_Upgrader) (required)
- The WP_Upgrader instance.
- $hook_extra(array) (required)
- Extra arguments passed to hooked filters.
ProductFormsController::migrate_templates_when_plugin_updated() ProductFormsController::migrate templates when plugin updated code WC 10.5.0
public function migrate_templates_when_plugin_updated( \WP_Upgrader $upgrader, array $hook_extra ) {
// If it is not a plugin hook type, bail early.
$type = isset( $hook_extra['type'] ) ? $hook_extra['type'] : '';
if ( 'plugin' !== $type ) {
return;
}
// If it is not the WooCommerce plugin, bail early.
$plugins = isset( $hook_extra['plugins'] ) ? $hook_extra['plugins'] : array();
if (
! in_array( 'woocommerce/woocommerce.php', $plugins, true )
) {
return;
}
// If the action is not install or update, bail early.
$action = isset( $hook_extra['action'] ) ? $hook_extra['action'] : '';
if ( 'install' !== $action && 'update' !== $action ) {
return;
}
// Trigger the migration process.
$this->migrate_product_form_posts( $action );
}