mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Always include buttons and messages components when in editor
This commit is contained in:
parent
a33d8dea3d
commit
6d450d587f
4 changed files with 21 additions and 1 deletions
|
@ -636,6 +636,8 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
|
||||||
case 'shop':
|
case 'shop':
|
||||||
case 'home':
|
case 'home':
|
||||||
return $messaging_enabled_for_current_location;
|
return $messaging_enabled_for_current_location;
|
||||||
|
case 'block-editor':
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,10 @@ trait ContextTrait {
|
||||||
return 'add-payment-method';
|
return 'add-payment-method';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $this->is_block_editor() ) {
|
||||||
|
return 'block-editor';
|
||||||
|
}
|
||||||
|
|
||||||
return 'mini-cart';
|
return 'mini-cart';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,4 +178,15 @@ trait ContextTrait {
|
||||||
|
|
||||||
return $page_id && is_page( $page_id ) && isset( $wp->query_vars['add-payment-method'] );
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default function Edit( { attributes, clientId, setAttributes } ) {
|
||||||
} : {
|
} : {
|
||||||
...scriptParams.url_params,
|
...scriptParams.url_params,
|
||||||
...{
|
...{
|
||||||
components: 'messages',
|
components: 'messages,buttons,funding-eligibility',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,9 @@ class SettingsStatus {
|
||||||
* @return bool true if is enabled, otherwise false.
|
* @return bool true if is enabled, otherwise false.
|
||||||
*/
|
*/
|
||||||
public function is_smart_button_enabled_for_location( string $location ): bool {
|
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 );
|
return $this->is_enabled_for_location( 'smart_button_locations', $location );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue