'prod', 'authority' => $public_authority, 'audience' => 'aha-connect-prod' ); } if ( 'prod' !== $environment && class_exists( 'Aha_Is_Woocommerce_Connect_Dev_Profiles', false ) ) { $profile = Aha_Is_Woocommerce_Connect_Dev_Profiles::resolve( $environment, $local_port, $local_authority ); if ( null !== $public_authority && $public_authority !== $profile['authority'] ) { throw new InvalidArgumentException( 'invalid_connect_profile' ); } return $profile; } throw new InvalidArgumentException( 'invalid_connect_profile' ); } /** * Read only operator-controlled wp-config constants, not WordPress options or POST fields. * * @return array */ public static function from_operator_config() { if ( class_exists( 'Aha_Is_Woocommerce_Connect_Dev_Profiles', false ) ) { return Aha_Is_Woocommerce_Connect_Dev_Profiles::from_operator_config(); } // Prod build: any other AHA_IS_WOOCOMMERCE_CONNECT_ constant is a stray non-prod setting; fail closed. foreach ( array_keys( get_defined_constants( true )['user'] ?? array() ) as $name ) { if ( 0 === strpos( $name, 'AHA_IS_WOOCOMMERCE_CONNECT_' ) && ! in_array( $name, array( 'AHA_IS_WOOCOMMERCE_CONNECT_ENVIRONMENT', 'AHA_IS_WOOCOMMERCE_CONNECT_PUBLIC_AUTHORITY' ), true ) ) { throw new InvalidArgumentException( 'invalid_connect_profile' ); } } return self::resolve( defined( 'AHA_IS_WOOCOMMERCE_CONNECT_ENVIRONMENT' ) ? AHA_IS_WOOCOMMERCE_CONNECT_ENVIRONMENT : 'prod', null, null, self::operator_authority() ); } /** * Read only operator-controlled public authority configuration. * * @return mixed Null means the selected profile default. */ public static function operator_authority() { if ( defined( 'AHA_IS_WOOCOMMERCE_CONNECT_PUBLIC_AUTHORITY' ) ) { return AHA_IS_WOOCOMMERCE_CONNECT_PUBLIC_AUTHORITY; } $authority = getenv( 'AHA_IS_WOOCOMMERCE_CONNECT_PUBLIC_AUTHORITY' ); return false === $authority ? null : $authority; } }