Automattic\WooCommerce\Blocks\Domain

Bootstrap::init()protectedWC 1.0

Init the package - load the blocks library and define constants.

Method of the class: Bootstrap{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->init();

Bootstrap::init() code WC 9.0.1

protected function init() {
	$this->register_dependencies();
	$this->register_payment_methods();
	$this->load_interactivity_api();

	// This is just a temporary solution to make sure the migrations are run. We have to refactor this. More details: https://github.com/woocommerce/woocommerce-blocks/issues/10196.
	if ( $this->package->get_version() !== $this->package->get_version_stored_on_db() ) {
		$this->migration->run_migrations();
		$this->package->set_version_stored_on_db();
	}

	add_action(
		'admin_init',
		function() {
			// Delete this notification because the blocks are included in WC Core now. This will handle any sites
			// with lingering notices.
			InboxNotifications::delete_surface_cart_checkout_blocks_notification();
		},
		10,
		0
	);

	$is_rest = wc()->is_rest_api_request();
	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	$is_store_api_request = $is_rest && ! empty( $_SERVER['REQUEST_URI'] ) && ( false !== strpos( $_SERVER['REQUEST_URI'], trailingslashit( rest_get_url_prefix() ) . 'wc/store/' ) );

	// Load and init assets.
	$this->container->get( StoreApi::class )->init();
	$this->container->get( PaymentsApi::class )->init();
	$this->container->get( DraftOrders::class )->init();
	$this->container->get( CreateAccount::class )->init();
	$this->container->get( ShippingController::class )->init();
	$this->container->get( TasksController::class )->init();
	$this->container->get( CheckoutFields::class )->init();

	// Load assets in admin and on the frontend.
	if ( ! $is_rest ) {
		$this->add_build_notice();
		$this->container->get( AssetDataRegistry::class );
		$this->container->get( AssetsController::class );
		$this->container->get( Installer::class )->init();
		$this->container->get( GoogleAnalytics::class )->init();
		$this->container->get( is_admin() ? CheckoutFieldsAdmin::class : CheckoutFieldsFrontend::class )->init();
	}

	// Load assets unless this is a request specifically for the store API.
	if ( ! $is_store_api_request ) {
		// Template related functionality. These won't be loaded for store API requests, but may be loaded for
		// regular rest requests to maintain compatibility with the store editor.
		$this->container->get( BlockPatterns::class );
		$this->container->get( BlockTypesController::class );
		$this->container->get( BlockTemplatesRegistry::class )->init();
		$this->container->get( BlockTemplatesController::class )->init();
		$this->container->get( ClassicTemplatesCompatibility::class );
		$this->container->get( ArchiveProductTemplatesCompatibility::class )->init();
		$this->container->get( SingleProductTemplateCompatibility::class )->init();
		$this->container->get( Notices::class )->init();
	}

	$this->container->get( QueryFilters::class )->init();
}