Automattic\WooCommerce\Admin\Features\Blueprint

RestApi::can_import_blueprintprivateWC 1.0

Check if blueprint imports are allowed based on site status, configuration, and session token.

Метод класса: RestApi{}

Хуков нет.

Возвращает

true|false. Returns true if imports are allowed, false otherwise.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->can_import_blueprint( $session_token );
$session_token(строка|null)
Optional session token for import session.
По умолчанию: null

Код RestApi::can_import_blueprint() WC 11.0.1

private function can_import_blueprint( $session_token = null ) {
	// Allow import if a valid session token is present so when a site is turned into live during the import process, the import can continue.
	if ( $session_token && get_transient( 'blueprint_import_session_' . $session_token ) ) {
		return true;
	}

	// Check if override constant is defined and true.
	if ( defined( 'ALLOW_BLUEPRINT_IMPORT_IN_LIVE_MODE' ) && ALLOW_BLUEPRINT_IMPORT_IN_LIVE_MODE ) {
		return true;
	}

	// Only allow imports in coming soon mode.
	if ( $this->coming_soon_helper->is_site_live() ) {
		return false;
	}

	return true;
}