Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix: Store Notices block breaks page editors #11165

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/BlockTypes/StoreNotices.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading