includes/class-connect.php. * * @param string $class Fully-qualified class name being loaded. * @return void */ spl_autoload_register( function ( $class ) { $prefix = 'Aisthetix\\TryOn\\'; $len = strlen( $prefix ); if ( 0 !== strncmp( $prefix, $class, $len ) ) { return; } $relative = substr( $class, $len ); // Convert namespace separators, CamelCase, and underscores to kebab-case. $relative = str_replace( '\\', '/', $relative ); $relative = preg_replace( '/([a-z0-9])([A-Z])/', '$1-$2', $relative ); $relative = str_replace( '_', '-', $relative ); $file = AISTHETIX_TRYON_PATH . 'includes/class-' . strtolower( $relative ) . '.php'; if ( is_readable( $file ) ) { require_once $file; } } ); /** * Declare HPOS (High-Performance Order Storage) compatibility. The plugin does * not read or write order tables directly in this pass, so it is compatible. */ add_action( 'before_woocommerce_init', function () { if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', AISTHETIX_TRYON_FILE, true ); } } ); /** * Bootstrap the plugin once all plugins are loaded. * * We require WooCommerce to be active. `Requires Plugins` enforces this on * modern WordPress, but we keep a defensive runtime check + admin notice for * older installs and edge cases. * * @return void */ function aisthetix_tryon_bootstrap() { if ( ! class_exists( 'WooCommerce' ) ) { add_action( 'admin_notices', 'aisthetix_tryon_missing_woocommerce_notice' ); return; } \Aisthetix\TryOn\Plugin::instance()->init(); } add_action( 'plugins_loaded', 'aisthetix_tryon_bootstrap' ); /** * Admin notice shown when WooCommerce is not active. * * @return void */ function aisthetix_tryon_missing_woocommerce_notice() { if ( ! current_user_can( 'activate_plugins' ) ) { return; } ?>

true ) ); } // Seed default options without overwriting existing values. if ( false === get_option( 'aisthetix_tryon_settings', false ) ) { add_option( 'aisthetix_tryon_settings', array( 'placement' => 'after_add_to_cart', 'button_text' => '', ) ); } } register_activation_hook( AISTHETIX_TRYON_FILE, 'aisthetix_tryon_activate' ); /** * Deactivation hook: clear cached status transient. Keys/options are kept so * the merchant stays connected across deactivate/reactivate. * * @return void */ function aisthetix_tryon_deactivate() { delete_transient( 'aisthetix_tryon_status' ); } register_deactivation_hook( AISTHETIX_TRYON_FILE, 'aisthetix_tryon_deactivate' );