Fix context check

This commit is contained in:
Alex P 2023-12-20 08:59:47 +02:00
parent 16fbb5b4d1
commit 22e908ff25
No known key found for this signature in database
GPG key ID: 54487A734A204D71
2 changed files with 5 additions and 3 deletions

View file

@ -624,6 +624,8 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
$messaging_enabled_for_current_location = $this->settings_status->is_pay_later_messaging_enabled_for_location( $location );
$has_paylater_block = has_block( 'woocommerce-paypal-payments/paylater-messages' );
switch ( $location ) {
case 'checkout':
case 'cart':
@ -636,9 +638,9 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
return true;
case 'checkout-block':
case 'cart-block':
return has_block( 'woocommerce-paypal-payments/paylater-messages' ) || $this->is_block_editor();
return $has_paylater_block || $this->is_block_editor();
default:
return false;
return $has_paylater_block;
}
}

View file

@ -184,7 +184,7 @@ trait ContextTrait {
*/
protected function is_block_editor(): bool {
if ( ! function_exists( 'get_current_screen' ) ) {
return true;
return false;
}
$screen = get_current_screen();
return $screen && $screen->is_block_editor();