Automattic\WooCommerce\Blocks\Domain
Bootstrap::init
Init the package - load the blocks library and define constants.
Метод класса: Bootstrap{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->init();
Код Bootstrap::init() Bootstrap::init WC 10.5.2
protected function init() {
$this->register_dependencies();
$this->register_payment_methods();
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
);
// We need to initialize BlockTemplatesController and BlockTemplatesRegistry at the end of `after_setup_theme`
// so themes had the opportunity to declare support for template parts.
add_action(
'after_setup_theme',
function () {
$is_store_api_request = wc()->is_store_api_request();
if ( ! $is_store_api_request && ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) ) {
$this->container->get( BlockTemplatesRegistry::class )->init();
$this->container->get( BlockTemplatesController::class )->init();
}
},
999
);
$is_rest = wc()->is_rest_api_request();
$is_store_api_request = wc()->is_store_api_request();
// Initialize Store API in non-admin context.
if ( ! is_admin() ) {
$this->container->get( StoreApi::class )->init();
}
// Load and init assets.
$this->container->get( PaymentsApi::class )->init();
$this->container->get( DraftOrders::class )->init();
$this->container->get( ShippingController::class )->init();
$this->container->get( CheckoutFields::class )->init();
$this->container->get( CheckoutLink::class )->init();
$this->container->get( AssetDataRegistry::class );
$this->container->get( AssetsController::class );
$this->container->get( DependencyDetection::class );
// Load assets in admin and on the frontend.
if ( ! $is_rest ) {
$this->add_build_notice();
$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( ClassicTemplatesCompatibility::class );
$this->container->get( Notices::class )->init();
if ( is_admin() || $is_rest ) {
$this->container->get( AIPatterns::class );
$this->container->get( PTKPatternsStore::class );
}
if ( is_admin() ) {
$this->container->get( TemplateOptions::class )->init();
}
}
$this->container->get( QueryFilters::class )->init();
}