diff --git a/.distignore b/.distignore index 13f498c..20e4a9b 100644 --- a/.distignore +++ b/.distignore @@ -44,3 +44,4 @@ node_modules *.zip src/js assets +src/php/Premium diff --git a/languages/site-import-for-gbp.pot b/languages/site-import-for-gbp.pot index 2936bbe..57caa32 100644 --- a/languages/site-import-for-gbp.pot +++ b/languages/site-import-for-gbp.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-02-10T14:40:08+00:00\n" +"POT-Creation-Date: 2024-02-12T14:46:16+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.9.0\n" "X-Domain: site-import-for-gbp\n" @@ -50,7 +50,7 @@ msgstr "" #. translators: %1$s is the Google internal image ID, %2$s is the error message #: src/php/BackgroundProcessing/BackgroundProcess.php:71 -#: src/php/BackgroundProcessing/BackgroundProcess.php:332 +#: src/php/BackgroundProcessing/BackgroundProcess.php:338 msgid "Failed to import image %1$s: %2$s" msgstr "" @@ -67,40 +67,45 @@ msgstr "" msgid "Did not find any posts to import" msgstr "" +#. translators: %1$s is Google Location identifier, %2$s is the error message +#: src/php/BackgroundProcessing/BackgroundProcess.php:214 +msgid "Failed to import post into %1$s WordPress: %2$s" +msgstr "" + #. translators: %1$d is WordPress post ID, %2$s is the error message -#: src/php/BackgroundProcessing/BackgroundProcess.php:231 +#: src/php/BackgroundProcessing/BackgroundProcess.php:237 msgid "Updated already imported post %1$d: %2$s" msgstr "" #. translators: %1$d is WordPress post ID, %2$s is the title of the imported post -#: src/php/BackgroundProcessing/BackgroundProcess.php:234 +#: src/php/BackgroundProcessing/BackgroundProcess.php:240 msgid "Imported post %1$d: %2$s" msgstr "" -#: src/php/BackgroundProcessing/BackgroundProcess.php:242 +#: src/php/BackgroundProcessing/BackgroundProcess.php:248 msgid "-- 50 post limit reached --" msgstr "" #. translators: %1$s is the Google internal location ID, %2$s is the error message -#: src/php/BackgroundProcessing/BackgroundProcess.php:259 +#: src/php/BackgroundProcessing/BackgroundProcess.php:265 msgid "Failed to load Gallery images from %1$s: %2$s" msgstr "" -#: src/php/BackgroundProcessing/BackgroundProcess.php:284 +#: src/php/BackgroundProcessing/BackgroundProcess.php:290 msgid "Did not find any gallery images to import" msgstr "" -#: src/php/BackgroundProcessing/BackgroundProcess.php:301 +#: src/php/BackgroundProcessing/BackgroundProcess.php:307 msgid "-- 100 image limit reached --" msgstr "" #. translators: %s is the Google internal image ID -#: src/php/BackgroundProcessing/BackgroundProcess.php:323 +#: src/php/BackgroundProcessing/BackgroundProcess.php:329 msgid "Skipping image %s, already imported before" msgstr "" #. translators: %s is Google Image ID -#: src/php/BackgroundProcessing/BackgroundProcess.php:339 +#: src/php/BackgroundProcessing/BackgroundProcess.php:345 msgid "Imported gallery image %s into Media library" msgstr "" @@ -186,6 +191,11 @@ msgstr "" msgid "Connect to Google Business Profile" msgstr "" +#. translators: %s is name of the location +#: build/index.js:1 +msgid "Let's import your %s GBP listing website! Select the items you want to import below" +msgstr "" + #: build/index.js:1 msgid "Import posts" msgstr "" @@ -222,6 +232,14 @@ msgstr "" msgid "Import is currently in progress, and running in the background. You may stay here and wait for it to complete or leave this page. Up to you!" msgstr "" +#: build/index.js:1 +msgid "Could not cancel import" +msgstr "" + +#: build/index.js:1 +msgid "Cancelling..." +msgstr "" + #: build/index.js:1 msgid "Cancel import" msgstr "" diff --git a/readme.txt b/readme.txt index 16d9ef0..a73ba17 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: google my business, google business profile, gbp, gmb, import Requires at least: 5.0 Tested up to: 6.4.3 Requires PHP: 7.2 -Stable tag: 0.1.0 +Stable tag: 0.1.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -58,6 +58,12 @@ The plugin is capped at importing your most recent 100 gallery images and 50 pos == Changelog == += 0.1.1 = + +* Fix: conflict with Post to Google My Business authorization when both plugins are activated +* Fix: Some small textdomain and string issues +* Added: Error page for failed authentication + = 0.1.0 = * Initial release diff --git a/site-import-for-gbp.php b/site-import-for-gbp.php index 2450eed..0abc739 100644 --- a/site-import-for-gbp.php +++ b/site-import-for-gbp.php @@ -7,7 +7,8 @@ * Author URI: https://koenreus.com * Text Domain: site-import-for-gbp * Domain Path: /languages - * Version: 0.1.0 + * Version: 0.1.1 + * Network: true * * @package Site_Import_For_Gbp */ diff --git a/src/js/Components/GoogleLocationSelector.js b/src/js/Components/GoogleLocationSelector.js index 550b23a..97a4880 100644 --- a/src/js/Components/GoogleLocationSelector.js +++ b/src/js/Components/GoogleLocationSelector.js @@ -69,7 +69,7 @@ export default function GoogleLocationSelector({ isGoogleConfigured, startWizard onChange={ ( newGroup ) => getGroup( newGroup ) } __nextHasNoMarginBottom /> - + @@ -98,8 +98,8 @@ function Pagination({hasResolved, locations, getGroup, currentGroup}){ } return (
- {prevPages.length > 1 && } - {locations.nextPageToken && } + {prevPages.length > 1 && } + {locations.nextPageToken && }
); } diff --git a/src/js/Components/Wizard.js b/src/js/Components/Wizard.js index 2887a16..47ad1ff 100644 --- a/src/js/Components/Wizard.js +++ b/src/js/Components/Wizard.js @@ -172,7 +172,7 @@ export default function Wizard(){ }else if(wizardStep === 'start'){ return ( -

{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 =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k0LDEuOTYxNTggdiA1LjM5MTU4IGggLTIyLjQwNTExIHYgLTUuMzU1MTkgYyAtMC4wOTk5LC0yLjM4Mjk3IC0zLjYxNTc4LC0yLjQxNjk4IC0zLjc2MTQ3LC0wLjAzNjQgdiA3LjM1ODIyIGggMC4wMjUzIGMgMC4wNDQsMC45OTg5IDAuODYzNzIsMS43ODcwMSAxLjg2MzU2LDEuNzk0ODMgaCAyNi4xNzY2OSBjIDAuOTk4NzgsLTAuMDEgMS44MTYsLTAuNzk3MDggMS44NjI1NCwtMS43OTQ4MyB2IC03LjMyMTgzIGMgMC4wODA3LC0xLjMxOTQ3IC0wLjg4NzEyLC0xLjk4ODYgLTEuODYxNTMsLTEuOTk3OTcgeiIgLz4KCgk8L2c+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()); + } + }