Review refactor.
This commit is contained in:
parent
ca3cd5fd7e
commit
d5babd800a
|
@ -62,14 +62,14 @@ class WC_Blocks_Utils {
|
|||
/**
|
||||
* Check if a given page contains a particular block.
|
||||
*
|
||||
* @param int|WP_Post $page Page post ID or post object.
|
||||
* @param string $block_name The name (id) of a block, e.g. `woocommerce/cart`.
|
||||
* @return bool|null Boolean value if the page contains the block or not. Null in case the page does not exist.
|
||||
* @param int|WP_Post $page Page post ID or post object.
|
||||
* @param string $block_name The name (id) of a block, e.g. `woocommerce/cart`.
|
||||
* @return bool Boolean value if the page contains the block or not. Null in case the page does not exist.
|
||||
*/
|
||||
public static function has_block_in_page( $page, $block_name ) {
|
||||
$page_to_check = get_post( $page );
|
||||
if ( null === $page_to_check ) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
$blocks = parse_blocks( $page_to_check->post_content );
|
||||
|
|
|
@ -1230,7 +1230,7 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
|
|||
// Block checks.
|
||||
if ( $values['block'] && get_post( $page_id ) ) {
|
||||
$block_required = true;
|
||||
if ( WC_Blocks_Utils::does_page_contains_block( $page_id, $values['block'] ) ) {
|
||||
if ( WC_Blocks_Utils::has_block_in_page( $page_id, $values['block'] ) ) {
|
||||
$block_present = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue