Automattic\WooCommerce\Internal\ComingSoon

ComingSoonRequestHandler::should_show_coming_soon()privateWC 1.0

Determines whether the coming soon screen should be shown.

Method of the class: ComingSoonRequestHandler{}

Hooks from the method

Return

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->should_show_coming_soon( $wp );
$wp(\WP) (required)
Current WordPress environment instance.

ComingSoonRequestHandler::should_show_coming_soon() code WC 9.3.3

private function should_show_coming_soon( \WP &$wp ) {
	// Early exit if LYS feature is disabled.
	if ( ! Features::is_enabled( 'launch-your-store' ) ) {
		return false;
	}

	// Early exit if the user is logged in as administrator / shop manager.
	if ( current_user_can( 'manage_woocommerce' ) ) {
		return false;
	}

	// Do not show coming soon on 404 pages when applied to store pages only.
	if ( $this->coming_soon_helper->is_store_coming_soon() && is_404() ) {
		return false;
	}

	// Early exit if the URL doesn't need a coming soon screen.
	$url = $this->coming_soon_helper->get_url_from_wp( $wp );

	if ( ! $this->coming_soon_helper->is_url_coming_soon( $url ) ) {
		return false;
	}

	/**
	 * Check if there is an exclusion.
	 *
	 * @since 9.1.0
	 *
	 * @param bool $is_excluded If the request should be excluded from Coming soon mode. Defaults to false.
	 */
	if ( apply_filters( 'woocommerce_coming_soon_exclude', false ) ) {
		return false;
	}

	// Check if the private link option is enabled.
	if ( get_option( 'woocommerce_private_link' ) === 'yes' ) {
		// Exclude users with a private link.
		if ( isset( $_GET['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_GET['woo-share'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
			// Persist the share link with a cookie for 90 days.
			setcookie( 'woo-share', sanitize_text_field( wp_unslash( $_GET['woo-share'] ) ), time() + 60 * 60 * 24 * 90, '/' ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
			return false;
		}
		if ( isset( $_COOKIE['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_COOKIE['woo-share'] ) {
			return false;
		}
	}
	return true;
}