status = new Status(); $this->connect = new Connect( $this->status ); $this->settings = new Settings( $this->status, $this->connect ); $this->storefront = new Storefront( $this->status ); $this->blocks = new Blocks( $this->storefront ); $this->elementor = new Elementor( $this->storefront ); $this->attribution = new Attribution(); $this->privacy = new Privacy(); $this->review_prompt = new ReviewPrompt(); // Boot each component. $this->status->init(); $this->connect->init(); $this->settings->init(); $this->storefront->init(); $this->blocks->init(); $this->elementor->init(); $this->attribution->init(); $this->privacy->init(); $this->review_prompt->init(); // Plugin action link to the settings page. add_filter( 'plugin_action_links_' . plugin_basename( AISTHETIX_TRYON_FILE ), array( $this, 'plugin_action_links' ) ); } /** * Add a "Settings" link on the Plugins screen. * * @param array $links Existing action links. * @return array */ public function plugin_action_links( $links ) { $settings_link = sprintf( '%s', esc_url( admin_url( 'admin.php?page=aisthetix-tryon' ) ), esc_html__( 'Settings', 'aisthetix-virtual-try-on' ) ); array_unshift( $links, $settings_link ); return $links; } /** * Resolve the brain (central service) base URL, without trailing slash. * * @return string */ public static function brain_url() { $url = AISTHETIX_BRAIN_URL; /** * Filter the aisthetix brain base URL. * * @param string $url Base URL with no trailing slash. */ $url = apply_filters( 'aisthetix_tryon_brain_url', $url ); return untrailingslashit( esc_url_raw( $url ) ); } /** * Get the stored publishable key (safe for the browser). * * @return string */ public static function publishable_key() { return (string) get_option( self::OPTION_PUBLISHABLE_KEY, '' ); } /** * Get the stored secret key. SERVER-ONLY — never enqueue this to the browser. * * @return string */ public static function secret_key() { return (string) get_option( self::OPTION_SECRET_KEY, '' ); } /** * Get the stored store id. * * @return string */ public static function store_id() { return (string) get_option( self::OPTION_STORE_ID, '' ); } /** * Whether the merchant has completed Connect (keys present). * * @return bool */ public static function is_connected() { return '' !== self::publishable_key() && '' !== self::secret_key(); } /** * Read a single plugin setting with a default. * * @param string $key Setting key. * @param mixed $default Default value. * @return mixed */ public static function get_setting( $key, $default = '' ) { $settings = get_option( self::OPTION_SETTINGS, array() ); if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) { return $settings[ $key ]; } return $default; } /** * Whether the merchant has opted into anonymous analytics: the durable * `aisthetix_vid` visitor cookie plus view / add-to-cart / try-on / order * events. Default OFF — nothing tracks passively without this explicit opt-in. * * The shopper-initiated try-on itself is unaffected: it is an explicit action * behind the widget's own consent step, not passive tracking. * * @return bool */ public static function analytics_enabled() { return (bool) self::get_setting( 'enable_analytics', false ); } }