Skip to content

Instantly share code, notes, and snippets.

@seb86
Created February 9, 2023 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seb86/6ba97ea1e6fb09fb3e4bc9f9269c3f38 to your computer and use it in GitHub Desktop.
Save seb86/6ba97ea1e6fb09fb3e4bc9f9269c3f38 to your computer and use it in GitHub Desktop.
Initializes WooCommerce Admin only in the backend.
<?php
/**
* Plugin Name: WooCommerce Admin
* Description: Initializes WooCommerce Admin only in the backend.
* Version: 0.0.1
*/
add_action( 'plugins_loaded', function() {
if ( is_admin() ) {
\Automattic\WooCommerce\Admin\Composer\Package::init();
$activated_plugin = get_transient( 'woocommerce_activated_plugin' );
if ( $activated_plugin ) {
delete_transient( 'woocommerce_activated_plugin' );
/**
* WooCommerce is activated hook.
*
* @since 5.0.0
* @param bool $activated_plugin Activated plugin path,
* generally woocommerce/woocommerce.php.
*/
do_action( 'woocommerce_activated_plugin', $activated_plugin );
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment