A1WOOCOG_FS_ID, 'slug' => 'a1-woocog', 'premium_slug' => 'a1-profit-reports-for-woocommerce-premium', 'type' => 'plugin', 'public_key' => A1WOOCOG_FS_PUBLIC_KEY, 'is_premium' => false, 'premium_suffix' => 'Premium', 'has_addons' => false, 'has_paid_plans' => true, 'is_org_compliant' => true, 'menu' => array( 'slug' => 'a1woocog-account', 'account' => true, 'contact' => false, 'support' => false, 'parent' => array( 'slug' => 'woocommerce', ), ), 'is_live' => true, ) ); // Freemius's default submenu label is just "Account" - not // identifiable as belonging to this plugin among WooCommerce's // own similarly-generic submenu items (Orders, Customers, etc.). $a1woocog_fs->override_i18n( array( 'account' => 'A1 Profit', ) ); } return $a1woocog_fs; } // Only initialize once the placeholder above has been replaced with a // real (numeric) Freemius Plugin ID — avoids the SDK making API calls // with garbage credentials while this is still being wired up. if ( is_numeric( A1WOOCOG_FS_ID ) ) { a1woocog_fs(); do_action( 'a1woocog_fs_loaded' ); // Uninstall cleanup routes through Freemius's own after_uninstall // hook (rather than a standalone uninstall.php) so it runs as part // of the same flow Freemius uses for its own uninstall/license // bookkeeping. a1woocog_fs()->add_action( 'after_uninstall', 'a1woocog_uninstall_cleanup' ); } } /** * Removes only this plugin's own cached meta/options (kept in sync with the * constants in includes/class-a1woocog-product.php and class-a1woocog-order.php). * WooCommerce's native Cost of Goods Sold data (_cogs_value and friends) and * its feature flag are left alone — that's WooCommerce core's data, not this * plugin's, and other code may still depend on it after this plugin is gone. */ function a1woocog_uninstall_cleanup() { delete_post_meta_by_key( '_a1woocog_profit' ); delete_post_meta_by_key( '_a1woocog_margin' ); delete_post_meta_by_key( '_a1woocog_effective_cost' ); // Report cache. The transients themselves carry a 1-day TTL and expire // on their own; only the version counter needs explicit cleanup. delete_option( 'a1woocog_report_cache_version' ); delete_option( 'a1woocog_included_statuses' ); } // Declare HPOS compatibility. add_action( 'before_woocommerce_init', function () { if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); } } ); /** * Boot the plugin after WooCommerce is ready. */ add_action( 'woocommerce_loaded', 'a1woocog_init' ); function a1woocog_init() { require_once A1WOOCOG_PLUGIN_DIR . 'includes/class-a1woocog-license.php'; require_once A1WOOCOG_PLUGIN_DIR . 'includes/class-a1woocog-product.php'; require_once A1WOOCOG_PLUGIN_DIR . 'includes/class-a1woocog-order.php'; require_once A1WOOCOG_PLUGIN_DIR . 'admin/class-a1woocog-admin.php'; A1WooCOG_Product::get_instance(); A1WooCOG_Order::get_instance(); if ( is_admin() ) { A1WooCOG_Admin::get_instance(); } } /** * Activation: this plugin is built on WooCommerce's native Cost of Goods Sold * field, so make sure that feature is switched on. */ register_activation_hook( __FILE__, 'a1woocog_activate' ); function a1woocog_activate() { if ( 'yes' !== get_option( 'woocommerce_feature_cost_of_goods_sold_enabled' ) ) { update_option( 'woocommerce_feature_cost_of_goods_sold_enabled', 'yes' ); } }