' . "\n"; echo '' . "\n"; } } public static function head( $title ) { header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); echo '' . esc_html( $title ) . ''; wp_enqueue_style( 'wacc-shop', plugins_url( 'assets/shop.css', WACC_FILE ), array(), WACC_VERSION ); // Print only our registered handle: confirmation pages must not load theme analytics. wp_styles()->do_items( array( 'wacc-shop' ) ); echo ''; } public function route() { // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Public GET routing/review only; Handoff::page verifies the browser-bound nonce before POST mutations. if ( isset( $_GET['wacc_checkout'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reject malformed bearer secrets below; never transform credentials into a different valid token. $token = is_string( $_GET['wacc_checkout'] ) ? wp_unslash( $_GET['wacc_checkout'] ) : ''; $token = preg_match( '/^[a-f0-9]{64}$/D', $token ) ? $token : ''; ( new Handoff() )->page( $token ); } if ( isset( $_GET['wacc_shop'] ) ) { nocache_headers(); header( 'X-Robots-Tag: noindex' ); self::head( 'Shop with your AI agent | Agentomise' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- markup() contains fixed HTML and contextually escapes every dynamic value. echo $this->markup(); wp_enqueue_script( 'wacc-shop', plugins_url( 'assets/shop.js', WACC_FILE ), array(), WACC_VERSION, false ); wp_scripts()->do_items( array( 'wacc-shop' ) ); echo ''; exit; } // phpcs:enable WordPress.Security.NonceVerification.Recommended } public function shortcode() { wp_enqueue_style( 'wacc-shop', plugins_url( 'assets/shop.css', WACC_FILE ), array(), WACC_VERSION ); wp_enqueue_script( 'wacc-shop', plugins_url( 'assets/shop.js', WACC_FILE ), array(), WACC_VERSION, true ); return $this->markup(); } public function markup() { $available = Api::available(); if ( is_wp_error( $available ) ) { return '

Agent shopping

' . esc_html( $available->get_error_message() ) . '

'; } $mode_notice = \AgentCommerceCompanion\Settings::status() === 'browse' ? '

Browse only: explore products here. Agent cart changes and purchases are currently unavailable.

' : ''; return '

' . esc_html( get_bloginfo( 'name' ) ) . '

Find your next purchase

Search the catalogue, choose an exact size or variant, and review your selection before paying securely at checkout.

' . $mode_notice . '

'; } }