Skip to content

Commit

Permalink
Trigger oauth process from suggest to login page.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Sep 4, 2024
1 parent f7411a8 commit 7c3664a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
// Finish OAuth connection and save token.
$.post(params.ajax_url, finishData, function (finishResponse) {
if (finishResponse.success) {
// Token is saved in the database, reload the page to reflect the changes.
window.location.reload();
// Token is saved in the database, redirect to the settings page to reflect the changes.
window.location.href = params.admin_settings_url;
} else {
console.log(
'Error calling OAuth finish endpoint. Data:',
Expand Down
14 changes: 13 additions & 1 deletion includes/admin/templates/suggest-to-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
?>
</p>

<a href="<?php echo esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ); ?>" class="button mailchimp-sf-button"><?php esc_html_e( 'Connect account', 'mailchimp' ); ?></a>
<button id="mailchimp_sf_oauth_connect" class="button mailchimp-sf-button">
<span class="mailchimp-sf-loading hidden">
<svg class="animate-spin" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</span>
<?php esc_html_e( 'Connect account', 'mailchimp' ); ?>
</button>
<p class="mailchimp-sf-oauth-error error-field" style="display:none;"></p>
<div id="mailchimp-sf-popup-blocked-modal" style="display:none;">
<p><?php esc_html_e( 'Please allow your browser to show popups for this page.', 'mailchimp' ); ?></p>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions includes/class-mailchimp-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ public function enqueue_admin_page_scripts( $hook_suffix ) {
'modal_title' => esc_html__( 'Login Popup is blocked!', 'mailchimp' ),
'modal_button_try_again' => esc_html__( 'Try again', 'mailchimp' ),
'modal_button_cancel' => esc_html__( 'No, cancel!', 'mailchimp' ),
'admin_settings_url' => esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ),
);

// Create account page specific data.
Expand Down

0 comments on commit 7c3664a

Please sign in to comment.