{sprintf(__('Let\'s import your %s GBP listing website! Select the items you want to import below', 'product-sync-for-gbp'), wizardLocation.title)}
+
{/* translators: %s is name of the location */ sprintf(__("Let's import your %s GBP listing website! Select the items you want to import below", 'site-import-for-gbp'), wizardLocation.title)}
do_request( self::AUTH_API_URL . 'getlink', [
'request_key' => $nonce,
'post_url' => $return_url,
+ 'success_hook' => $success_hook,
+ 'failure_hook' => $failure_hook,
]);
}
diff --git a/src/php/Plugin.php b/src/php/Plugin.php
index ab17d36..f1edfc6 100644
--- a/src/php/Plugin.php
+++ b/src/php/Plugin.php
@@ -7,7 +7,7 @@
class Plugin {
const DOMAIN = 'site-import-for-gbp';
- const VERSION = '0.1.0';
+ const VERSION = '0.1.1';
const DASHICON = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB3aWR0aD0iMjAiCiAgIGhlaWdodD0iMjAiCiAgIHZpZXdCb3g9IjAgMCAxMDUuMDE2ODUgOTIuNDgyMjE2IgogICB2ZXJzaW9uPSIxLjEiCiAgIGlkPSJzdmczMzUiCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPGRlZnMKICAgICBpZD0iZGVmczMzMiI+CiAgICA8Y2xpcFBhdGgKICAgICAgIGNsaXBQYXRoVW5pdHM9InVzZXJTcGFjZU9uVXNlIgogICAgICAgaWQ9ImNsaXBQYXRoMTAyMzciPgogICAgICA8cmVjdAogICAgICAgICBzdHlsZT0iZmlsbDojMDAwMDAwO2ZpbGwtb3BhY2l0eToxO3N0cm9rZTpub25lO3N0cm9rZS13aWR0aDoxLjU4MzM7c3Ry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k0ODkyIGMgMC43MzI2MiwwLjcxOTIgMS45MDYwNywwLjcxOTIgMi42Mzg2OSwwIGwgNy4xNDA5MywtNy4wNTIgYyAxLjc5Njk0LC0xLjc1NTcgLTAuODQ3NzIsLTQuNDQ3MDIgLTIuNjM0NjQsLTIuNjgxMTQgaCAtMC4wMTAxIGwgLTMuOTExMDQsMy44NjU1NyAwLjA0MTQsLTEzLjQxNjggYyAtMC4wNTE4LC0xLjE5MTEyIC0wLjk1NzAxLC0xLjc5NDM5IC0xLjg2NjU4LC0xLjgwMTkgeiBtIDEzLjE5ODUsMTkuMzAwNTMgYyAtMC45NzQ0MSwtMC4wMDkgLTEuOTU1MTksMC42NDA4IC0xLjg5OTk0LDEuOTYxNTggdiA1LjM5MTU4IGggLTIyLjQwNTExIHYgLTUuMzU1MTkgYyAtMC4wOTk5LC0yLjM4Mjk3IC0zLjYxNTc4LC0yLjQxNjk4IC0zLjc2MTQ3LC0wLjAzNjQgdiA3LjM1ODIyIGggMC4wMjUzIGMgMC4wNDQsMC45OTg5IDAuODYzNzIsMS43ODcwMSAxLjg2MzU2LDEuNzk0ODMgaCAyNi4xNzY2OSBjIDAuOTk4NzgsLTAuMDEgMS44MTYsLTAuNzk3MDggMS44NjI1NCwtMS43OTQ4MyB2IC03LjMyMTgzIGMgMC4wODA3LC0xLjMxOTQ3IC0wLjg4NzEyLC0xLjk4ODYgLTEuODYxNTMsLTEuOTk3OTcgeiIgLz4KCgk8L2c+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K';
diff --git a/src/php/Premium/Admin/ImportPage.php b/src/php/Premium/Admin/ImportPage.php
new file mode 100644
index 0000000..1a99384
--- /dev/null
+++ b/src/php/Premium/Admin/ImportPage.php
@@ -0,0 +1,7 @@
+ 'auth_redirect',
- 'admin_post_pgmb_google_authorized' => 'fetch_tokens',
+ 'admin_post_sifg_auth_success' => 'fetch_tokens',
+ 'admin_post_sifg_auth_failed' => 'auth_failed',
];
}
@@ -46,7 +47,7 @@ public function auth_redirect(){
}
try{
- $response = $this->auth_api->get_authentication_url(esc_url(admin_url('admin-post.php')), wp_create_nonce('sifg_auth_redirect'));
+ $response = $this->auth_api->get_authentication_url(esc_url(admin_url('admin-post.php')), wp_create_nonce('sifg_auth_redirect'), 'sifg_auth_success', 'sifg_auth_failed');
}catch(\Exception $e){
//translators: %s is error message
wp_die(sprintf(__('Could not generate authentication URL: %s', 'site-import-for-gbp'), $e->getMessage()),'', $this->wp_die_args());
@@ -88,4 +89,22 @@ public function fetch_tokens(){
exit;
}
+ /**
+ * When the auth request fails, for example when the user presses the cancel button on the Google dialog
+ */
+ public function auth_failed(){
+ if(!wp_verify_nonce(sanitize_key($_REQUEST['state']), 'sifg_auth_redirect')){ wp_die(__('Invalid nonce', 'site-import-for-gbp'),'', $this->wp_die_args()); }
+
+ $reason = '';
+
+ if(!empty($_REQUEST['error'])){
+ switch($_REQUEST['error']){
+ case 'access_denied':
+ $reason = __('The request was cancelled', 'site-import-for-gbp');
+ }
+ }
+
+ wp_die(sprintf(__('The authorization failed: %s', 'site-import-for-gbp'), $reason),'', $this->wp_die_args());
+ }
+
}