This commit is contained in:
Tung Du 2023-10-09 14:15:57 +07:00 committed by GitHub
parent df2a3d72d2
commit 1f049de16b
1 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,17 @@ class StoreNotices extends AbstractBlock {
* @return string | void Rendered block output.
*/
protected function render( $attributes, $content, $block ) {
/**
* This block should be rendered only on the frontend. Woo loads notice
* functions on the front end requests only. So it's safe and handy to
* check for the print notice function existence to short circuit the
* render process on the admin side.
* See WooCommerce::is_request() for the frontend request definition.
*/
if ( ! function_exists( 'wc_print_notices' ) ) {
return $content;
}
ob_start();
woocommerce_output_all_notices();
$notices = ob_get_clean();