register(); $woo = new OSSEngine_WooCommerce( $options, $tracking ); $woo->register(); $settings = new OSSEngine_Settings( $options, $api, $auth, $byo ); $settings->register(); $auth->register(); $byo->register(); } add_action( 'plugins_loaded', 'ossengine_bootstrap' ); /** * Whether the current PHP/WP versions meet the minimum requirements. * * @return bool */ function ossengine_is_supported_environment() { if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { return false; } if ( function_exists( 'get_bloginfo' ) ) { $wp_version = (string) get_bloginfo( 'version' ); if ( '' !== $wp_version && version_compare( $wp_version, '6.0', '<' ) ) { return false; } } return true; } /** * Controlled notice for unsupported environments (no fatals, no output elsewhere). */ function ossengine_unsupported_notice() { if ( ! current_user_can( 'manage_options' ) ) { return; } echo '

'; echo esc_html__( 'OSSEngine Analytics Connector requires PHP 7.4+ and WordPress 6.0+. Tracking is disabled until the environment is updated.', 'ossengine-analytics-connector' ); echo '

'; } /** * Declare HPOS (custom order tables) compatibility at file scope so it * registers before WooCommerce initializes. Guarded for stores without Woo. */ function ossengine_declare_hpos_compatibility() { if ( class_exists( 'Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); } } add_action( 'before_woocommerce_init', 'ossengine_declare_hpos_compatibility' ); /** * Activation: seed defaults. Never contacts the network. */ function ossengine_activate() { require_once OSSENGINE_PLUGIN_DIR . 'includes/class-ossengine-options.php'; $options = new OSSEngine_Options(); $options->seed_defaults(); if ( ! wp_next_scheduled( 'ossengine_refresh_status' ) ) { wp_schedule_event( time() + WEEK_IN_SECONDS, 'weekly', 'ossengine_refresh_status' ); } } register_activation_hook( __FILE__, 'ossengine_activate' ); /** * Deactivation: stop cron, keep configuration (reconnect without setup). */ function ossengine_deactivate() { $timestamp = wp_next_scheduled( 'ossengine_refresh_status' ); if ( $timestamp ) { wp_unschedule_event( $timestamp, 'ossengine_refresh_status' ); } } register_deactivation_hook( __FILE__, 'ossengine_deactivate' );