Skip to content

Commit

Permalink
fix: re-add subscriptions redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Dec 2, 2024
1 parent 910b30c commit f1f7787
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 10 additions & 4 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1331,10 +1331,16 @@ public static function render_auth_form( $in_modal = true ) {

$referer = \wp_parse_url( \wp_get_referer() );
$labels = self::get_reader_activation_labels( 'signin' );
$auth_callback_url = '#';
// If we are already on the my account page, set the my account URL so the page reloads on submit.
if ( function_exists( 'wc_get_page_permalink' ) && function_exists( 'is_account_page' ) && \is_account_page() ) {
$auth_callback_url = \wc_get_page_permalink( 'myaccount' );
// If there is a redirect parameter, use it as the auth callback URL.
$auth_callback_url = filter_input( INPUT_GET, 'redirect', FILTER_SANITIZE_URL ) ?? '#';
if ( '#' === $auth_callback_url ) {
if ( Renewal::is_subscriptions_page() ) {
// If we are on the subscriptions page, set the auth callback URL to the subscriptions page.
$auth_callback_url = Renewal::get_subscriptions_url();
} elseif ( function_exists( 'wc_get_page_permalink' ) && function_exists( 'is_account_page' ) && \is_account_page() ) {
// If we are already on the my account page, set the my account URL so the page reloads on submit.
$auth_callback_url = \wc_get_page_permalink( 'myaccount' );
}
}
?>
<div class="newspack-ui newspack-reader-auth">
Expand Down
6 changes: 2 additions & 4 deletions src/reader-activation-auth/auth-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,10 @@ window.newspackRAS.push( function ( readerActivation ) {
container.querySelector( '.success-description' ).innerHTML =
labels.success_description || '';
const callbackButton = container.querySelector( '.auth-callback' );
if ( callbackButton ) {
if ( callbackButton && callback ) {
callbackButton.addEventListener( 'click', ev => {
ev.preventDefault();
if ( callback ) {
callback( message, data );
}
callback( message, data );
} );
}

Expand Down

0 comments on commit f1f7787

Please sign in to comment.