Open POS — sends the admin to POS with this store's URL. * Connecting (the WooCommerce OAuth handshake) is driven from POS/LM2 from * here on, not from wp-admin — see the plan for the full flow. This plugin * has nothing left to do for that beyond getting the admin to POS in the * first place. */ class OpenPosLink { public const SLUG = 'akantio-pos-open'; private PosUrl $posUrl; public function __construct( PosUrl $posUrl ) { $this->posUrl = $posUrl; } public function register(): void { add_action( 'admin_menu', [ $this, 'registerMenu' ] ); } public function registerMenu(): void { // null parent = hidden admin page: reachable at admin.php?page= // (which is exactly how SettingsPage's "Open POS" button links to // it — see renderHeader()) without its own entry in the admin menu. add_submenu_page( null, __( 'Open POS', 'akantio-pos' ), '', 'manage_woocommerce', self::SLUG, [ $this, 'render' ] ); } public function render(): void { if ( ! current_user_can( 'manage_woocommerce' ) ) { wp_die( esc_html__( 'You do not have permission to do this.', 'akantio-pos' ) ); } $posUrl = $this->posUrl->get(); // wp_safe_redirect() only allows same-host targets by default, and // the POS URL is intentionally a different host — so explicitly // allow just that one host rather than dropping down to the // unguarded wp_redirect(). $posHost = wp_parse_url( $posUrl, PHP_URL_HOST ); add_filter( 'allowed_redirect_hosts', static function ( array $hosts ) use ( $posHost ) { $hosts[] = $posHost; return $hosts; } ); wp_safe_redirect( rtrim( $posUrl, '/' ) . '/sso/woo?store=' . rawurlencode( site_url() ) ); exit; } }