Merge pull request #863 from woocommerce/pcp-885-fix-connection-url

Fix links after adding connection tab
This commit is contained in:
Emili Castells 2022-09-26 14:58:14 +02:00 committed by GitHub
commit fd721ddbf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View file

@ -169,6 +169,13 @@ return array(
$section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : ''; $section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '';
$ppcp_tab = isset( $_GET[ SectionsRenderer::KEY ] ) ? sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ) : ''; $ppcp_tab = isset( $_GET[ SectionsRenderer::KEY ] ) ? sanitize_text_field( wp_unslash( $_GET[ SectionsRenderer::KEY ] ) ) : '';
$state = $container->get( 'onboarding.state' );
assert( $state instanceof State );
if ( ! $ppcp_tab && PayPalGateway::ID === $section && $state->current_state() !== State::STATE_ONBOARDED ) {
return Settings::CONNECTION_TAB_ID;
}
return $ppcp_tab ? $ppcp_tab : $section; return $ppcp_tab ? $ppcp_tab : $section;
}, },

View file

@ -60,7 +60,7 @@ class ConnectAdminNotice {
'PayPal Payments is almost ready. To get started, <a href="%1$s">connect your account</a>.', 'PayPal Payments is almost ready. To get started, <a href="%1$s">connect your account</a>.',
'woocommerce-paypal-payments' 'woocommerce-paypal-payments'
), ),
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway' ) admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID )
); );
return new Message( $message, 'warning' ); return new Message( $message, 'warning' );
} }

View file

@ -196,7 +196,7 @@ class SettingsListener {
/** /**
* The URL opened at the end of onboarding after saving the merchant ID/email. * The URL opened at the end of onboarding after saving the merchant ID/email.
*/ */
$redirect_url = apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=ppcp-connection' ) ); $redirect_url = apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID ) );
if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) { if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) {
$redirect_url = add_query_arg( 'ppcp-onboarding-error', '1', $redirect_url ); $redirect_url = add_query_arg( 'ppcp-onboarding-error', '1', $redirect_url );
} }

View file

@ -19,6 +19,8 @@ declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce; namespace WooCommerce\PayPalCommerce;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
define( 'PAYPAL_API_URL', 'https://api.paypal.com' ); define( 'PAYPAL_API_URL', 'https://api.paypal.com' );
define( 'PAYPAL_SANDBOX_API_URL', 'https://api.sandbox.paypal.com' ); define( 'PAYPAL_SANDBOX_API_URL', 'https://api.sandbox.paypal.com' );
define( 'PAYPAL_INTEGRATION_DATE', '2022-04-13' ); define( 'PAYPAL_INTEGRATION_DATE', '2022-04-13' );
@ -134,7 +136,7 @@ define( 'PPCP_FLAG_SEPARATE_APM_BUTTONS', apply_filters( 'woocommerce_paypal_pay
$links, $links,
sprintf( sprintf(
'<a href="%1$s">%2$s</a>', '<a href="%1$s">%2$s</a>',
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID ),
__( 'Settings', 'woocommerce-paypal-payments' ) __( 'Settings', 'woocommerce-paypal-payments' )
) )
); );