Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::is_overridden_by_custom_template_content
Checks if the template overriding the page loads the page content or not. Templates by default load the page content, but if that block is deleted the content can get out of sync with the one presented in the page editor.
Метод класса: CartCheckoutUtils{}
Хуков нет.
Возвращает
true|false. true if the template has out of sync content.
Использование
$result = CartCheckoutUtils::is_overridden_by_custom_template_content( $block ): bool;
- $block(строка) (обязательный)
- The block to check.
Список изменений
| С версии 10.9.0 | Введена. |
Код CartCheckoutUtils::is_overridden_by_custom_template_content() CartCheckoutUtils::is overridden by custom template content WC 10.9.1
public static function is_overridden_by_custom_template_content( string $block ): bool {
$block = str_replace( 'woocommerce/', '', $block );
if ( wp_is_block_theme() ) {
$templates_from_db = BlockTemplateUtils::get_block_templates_from_db( array( 'page-' . $block ) );
foreach ( $templates_from_db as $template ) {
if ( ! has_block( 'woocommerce/page-content-wrapper', $template->content ) ) {
// Return true if the template does not load the page content via the woocommerce/page-content-wrapper block.
return true;
}
}
}
return false;
}