Merge pull request woocommerce/woocommerce-admin#747 from woocommerce/add/run-dbdelta-on-init

Run dbdelta on init, at least as long as this is a separate plugin
This commit is contained in:
Allen Snook 2018-11-02 08:35:49 -07:00 committed by GitHub
commit a0d96c07f4
1 changed files with 13 additions and 0 deletions

View File

@ -92,6 +92,19 @@ function deactivate_wc_admin_plugin() {
}
register_deactivation_hook( WC_ADMIN_PLUGIN_FILE, 'deactivate_wc_admin_plugin' );
/**
* Update the database tables if needed. This hooked function does NOT need to
* be ported to WooCommerce's code base - WC_Install will do this on plugin
* update automatically.
*/
function wc_admin_init() {
// Only create/update tables on init if WP_DEBUG is true.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
WC_Admin_Api_Init::create_db_tables();
}
}
add_action( 'init', 'wc_admin_init' );
/**
* Set up the plugin, only if we can detect both Gutenberg and WooCommerce
*/