Always include buttons and messages components when in editor

This commit is contained in:
Alex P 2023-12-12 10:52:33 +02:00
parent a33d8dea3d
commit 6d450d587f
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 21 additions and 1 deletions

View file

@ -636,6 +636,8 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
case 'shop':
case 'home':
return $messaging_enabled_for_current_location;
case 'block-editor':
return true;
default:
return false;
}

View file

@ -98,6 +98,10 @@ trait ContextTrait {
return 'add-payment-method';
}
if ( $this->is_block_editor() ) {
return 'block-editor';
}
return 'mini-cart';
}
@ -174,4 +178,15 @@ trait ContextTrait {
return $page_id && is_page( $page_id ) && isset( $wp->query_vars['add-payment-method'] );
}
/**
* Checks if it is the block editor page.
*/
private function is_block_editor(): bool {
if ( ! function_exists( 'get_current_screen' ) ) {
return true;
}
$screen = get_current_screen();
return $screen && $screen->is_block_editor();
}
}

View file

@ -43,7 +43,7 @@ export default function Edit( { attributes, clientId, setAttributes } ) {
} : {
...scriptParams.url_params,
...{
components: 'messages',
components: 'messages,buttons,funding-eligibility',
}
}

View file

@ -85,6 +85,9 @@ class SettingsStatus {
* @return bool true if is enabled, otherwise false.
*/
public function is_smart_button_enabled_for_location( string $location ): bool {
if ( $location === 'block-editor' ) {
$location = 'checkout-block';
}
return $this->is_enabled_for_location( 'smart_button_locations', $location );
}