From 3d6fd14cb59a48ba4b0211b90d58b0fe887ff7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bouc=CC=8Cek?= Date: Fri, 5 Feb 2021 14:00:54 +0100 Subject: [PATCH 1/2] Composer: Mark dependency to JSON extension No BC because this dependency has been in the code for a long time, but unmarked --- composer.json | 1 + composer.lock | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4a84591..abf8713 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ }, "require": { "php": ">=5.6.20", + "ext-json": "*", "cmb2/cmb2": "dev-master", "webdevstudios/cmb2-post-search-field": "dev-master", "vyfakturuj/vyfakturuj-api-php": "^2.5" diff --git a/composer.lock b/composer.lock index 55d340e..888cb75 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "da5519615e1eb99622f6ec76ab27633d", + "content-hash": "eadc8d478390da4fc752e2480f9895b4", "packages": [ { "name": "cmb2/cmb2", @@ -181,7 +181,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.6.20" + "php": ">=5.6.20", + "ext-json": "*" }, "platform-dev": [], "plugin-api-version": "2.0.0" From dfb9568b5aa41066c81d8ca127081fdb795dd4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bouc=CC=8Cek?= Date: Fri, 5 Feb 2021 14:01:17 +0100 Subject: [PATCH 2/2] Simpleshop: Use new form code --- src/Shortcodes.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/Shortcodes.php b/src/Shortcodes.php index 2735a2d..d93164c 100644 --- a/src/Shortcodes.php +++ b/src/Shortcodes.php @@ -29,15 +29,30 @@ public function initialize() { public function simple_shop_form( $atts ) { - $formUrl = $this->settings->ssc_get_option( 'ssc_ss_form_url' ); - $query = http_build_query( [ 'id' => $atts['id'] ] ); - $url = sprintf( - "%s/iframe/js/?%s", - empty( $formUrl ) ? 'https://form.simpleshop.cz' : $formUrl, - $query + /** + * @noinspection BadExpressionStatementJS + * @noinspection JSUnresolvedFunction + * @noinspection JSUnnecessarySemicolon + * @noinspection CommaExpressionJS + */ + $template = + '' . PHP_EOL + . '
Prodejní formulář je vytvořen v systému ' + . 'SimpleShop.cz.' + . '
'; + + $formUrl = rtrim( $this->settings->ssc_get_option( 'ssc_ss_form_url', 'https://form.simpleshop.cz' ), '/' ); + $scriptUrl = $formUrl . '/prj/js/SimpleShopService.js'; + $formKey = $atts['id']; + + return sprintf( $template, + json_encode( $scriptUrl ), + json_encode( $formKey ), + htmlspecialchars( $formKey, ENT_QUOTES ) ); - - return ''; } public function simple_shop_content( $atts, $content = '' ) {