mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Create a filter to switch the UI if the flag is enabled
This commit is contained in:
parent
5917ddae53
commit
a2375ba94a
2 changed files with 27 additions and 1 deletions
|
@ -13,6 +13,7 @@ use WooCommerce\PayPalCommerce\Onboarding\Endpoint\UpdateSignupLinksEndpoint;
|
|||
use WooCommerce\PayPalCommerce\Onboarding\Assets\OnboardingAssets;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
|
||||
use WooCommerce\PayPalCommerce\Settings\SettingsModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
|
||||
|
@ -48,7 +49,8 @@ class OnboardingModule implements ServiceModule, ExtendingModule, ExecutableModu
|
|||
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
'woocommerce.feature-flags.woocommerce_paypal_payments.settings_enabled',
|
||||
getenv( 'PCP_SETTINGS_ENABLED' ) === '1'
|
||||
) ) {
|
||||
) || SettingsModule::should_use_the_old_ui()
|
||||
) {
|
||||
|
||||
$asset_loader = $c->get( 'onboarding.assets' );
|
||||
/**
|
||||
|
|
|
@ -22,10 +22,20 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|||
class SettingsModule implements ServiceModule, ExecutableModule {
|
||||
use ModuleClassNameIdTrait;
|
||||
|
||||
/**
|
||||
* Returns whether the old settings UI should be loaded.
|
||||
*/
|
||||
public static function should_use_the_old_ui(): bool {
|
||||
return apply_filters( 'woocommerce_paypal_payments_should_use_the_old_ui', false );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function services() : array {
|
||||
if ( self::should_use_the_old_ui() ) {
|
||||
return array();
|
||||
}
|
||||
return require __DIR__ . '/../services.php';
|
||||
}
|
||||
|
||||
|
@ -33,6 +43,20 @@ class SettingsModule implements ServiceModule, ExecutableModule {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
public function run( ContainerInterface $container ) : bool {
|
||||
if ( self::should_use_the_old_ui() ) {
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_inside_settings_page_header',
|
||||
static function () : void {
|
||||
echo sprintf(
|
||||
'<a href="#" class="button" onclick="javascript:void(0);">%s</a>',
|
||||
esc_html__( 'Switch to new settings UI', 'woocommerce-paypal-payments' )
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
add_action(
|
||||
'admin_enqueue_scripts',
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue