Automattic\WooCommerce\Internal\ComingSoon
ComingSoonRequestHandler::handle_template_include()
Replaces the page template with a 'coming soon' when the site is in coming soon mode.
Метод класса: ComingSoonRequestHandler{}
Хуков нет.
Возвращает
Строку
. The path to the 'coming soon' template or any empty string to prevent further template loading in FSE themes.
Использование
$ComingSoonRequestHandler = new ComingSoonRequestHandler(); $ComingSoonRequestHandler->handle_template_include( $template );
- $template(строка) (обязательный)
- The path to the previously determined template.
Код ComingSoonRequestHandler::handle_template_include() ComingSoonRequestHandler::handle template include WC 9.7.1
public function handle_template_include( $template ) { global $wp; if ( ! $this->should_show_coming_soon( $wp ) ) { return $template; } // A coming soon page needs to be displayed. Set a short cache duration to prevents ddos attacks. header( 'Cache-Control: max-age=60' ); $is_fse_theme = wc_current_theme_is_fse_theme(); $is_store_coming_soon = $this->coming_soon_helper->is_store_coming_soon(); if ( ! $is_fse_theme && ! current_theme_supports( 'block-template-parts' ) ) { // Initialize block templates for use in classic theme. BlocksPackage::init(); $container = BlocksPackage::container(); $container->get( BlockTemplatesRegistry::class )->init(); $container->get( BlockTemplatesController::class )->init(); } add_theme_support( 'block-templates' ); $coming_soon_template = get_query_template( 'coming-soon' ); if ( ! $is_fse_theme && $is_store_coming_soon ) { get_header(); } add_action( 'wp_head', function () { echo "<meta name='woo-coming-soon-page' content='yes'>"; } ); if ( ! empty( $coming_soon_template ) && file_exists( $coming_soon_template ) ) { if ( ! $is_fse_theme && $is_store_coming_soon && function_exists( 'get_the_block_template_html' ) ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo get_the_block_template_html(); } else { include $coming_soon_template; } } if ( ! $is_fse_theme && $is_store_coming_soon ) { get_footer(); } if ( $is_fse_theme ) { // Since we've already rendered a template, return empty string to ensure no other template is rendered. return ''; } else { // In non-FSE themes, other templates will still be rendered. // We need to exit to prevent further processing. exit(); } }