From 4e312ca70659d3e6ac018b25faef2a21c91e6093 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Fri, 11 Jan 2019 11:31:01 +0530 Subject: [PATCH 1/6] Fix issue with Time Pass/Subscription multiple exclude categories --- laterpay/application/Model/SubscriptionWP.php | 11 +++++++++++ laterpay/application/Model/TimePassWP.php | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/laterpay/application/Model/SubscriptionWP.php b/laterpay/application/Model/SubscriptionWP.php index 01f91b5d7..604e1871f 100644 --- a/laterpay/application/Model/SubscriptionWP.php +++ b/laterpay/application/Model/SubscriptionWP.php @@ -384,6 +384,17 @@ public function get_subscriptions_by_category_ids( $term_ids = null, $exclude = $subscriptions[ $key ] = $this->transform_post_to_subscription( $post ); } + // Unset subscription data if it contains excluded categories. + foreach ( $subscriptions as $key => $subscription ) { + if ( 1 === $subscription['access_to'] ) { + $found_categories = array_intersect( $term_ids, $subscription['access_category'] ); + + if ( ! empty( $found_categories ) ) { + unset( $subscriptions[$key] ); + } + } + } + // Store formatted data, in case same query is fired again. self::$term_data_store[$args_hash] = $subscriptions; diff --git a/laterpay/application/Model/TimePassWP.php b/laterpay/application/Model/TimePassWP.php index abe8a6799..12b2164b2 100644 --- a/laterpay/application/Model/TimePassWP.php +++ b/laterpay/application/Model/TimePassWP.php @@ -463,7 +463,19 @@ public function get_time_passes_by_category_ids( $term_ids = null, $exclude = fa $posts = $query->query( $query_args ); // Get formatted data and store it, in case same query is fired again. - $timepasses = $this->get_formatted_results( $posts ); + $timepasses = $this->get_formatted_results( $posts ); + + // Unset time pass data if it contains excluded categories. + foreach ( $timepasses as $key => $timepass ) { + if ( 1 === $timepass['access_to'] ) { + $found_categories = array_intersect( $term_ids, $timepass['access_category'] ); + + if ( ! empty( $found_categories ) ) { + unset( $timepasses[$key] ); + } + } + } + self::$term_data_store[$args_hash] = $timepasses; } From 569080fd44d2c17c93d87130f6a572b14805b69f Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Fri, 11 Jan 2019 12:30:07 +0530 Subject: [PATCH 2/6] Fix issue with missing categories in block editor --- .../asset_sources/js/laterpay-post-edit.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/laterpay/asset_sources/js/laterpay-post-edit.js b/laterpay/asset_sources/js/laterpay-post-edit.js index 29892f0f0..9bd804ed4 100755 --- a/laterpay/asset_sources/js/laterpay-post-edit.js +++ b/laterpay/asset_sources/js/laterpay-post-edit.js @@ -643,13 +643,26 @@ var eventCategory = 'LP WP Post'; var commonLabel = lpVars.gaData.sandbox_merchant_id + ' | ' + lpVars.postId + ' | '; - var selectedCategories = $('#categorychecklist :checkbox:checked'); var categoryLabel = []; - // Loop through selected categories and store in an array. - $.each( selectedCategories, function( i ) { - categoryLabel.push($('#'+selectedCategories[i].id).parent().text().trim()); - } ); + // Check editor type to get selected categories in post. + if ( ! wp.data ) { + var selectedCategories = $('#categorychecklist :checkbox:checked'); + + // Loop through selected categories and store in an array. + $.each( selectedCategories, function( i ) { + categoryLabel.push($('#'+selectedCategories[i].id).parent().text().trim()); + } ); + } else { + var selectedCategoriesGB = + $('div.editor-post-taxonomies__hierarchical-terms-list :checkbox:checked'); + + // Loop through checked categories and store label text in an array. + $.each( selectedCategoriesGB, function( i ) { + categoryLabel.push($(selectedCategoriesGB[i]).next( 'label' ).text().trim()); + } ); + + } // Send GA event with category details. lpGlobal.sendLPGAEvent( 'Post Published', eventCategory, commonLabel + categoryLabel.join(',') ); From 7d64f37462496177589c065e211d324902308719 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Fri, 11 Jan 2019 14:11:14 +0530 Subject: [PATCH 3/6] Remove esc_js as not necessary --- laterpay/application/Controller/Admin/Appearance.php | 2 +- laterpay/application/Controller/Admin/Post/Metabox.php | 2 +- laterpay/application/Controller/Admin/Pricing.php | 2 +- laterpay/application/Controller/Admin/Settings.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/laterpay/application/Controller/Admin/Appearance.php b/laterpay/application/Controller/Admin/Appearance.php index 6fec0b564..435d3750b 100644 --- a/laterpay/application/Controller/Admin/Appearance.php +++ b/laterpay/application/Controller/Admin/Appearance.php @@ -68,7 +68,7 @@ public function load_assets() { ), 'l10n_print_after' => 'lpVars.overlaySettings = JSON.parse(lpVars.overlaySettings)', 'gaData' => array( - 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? esc_js( $merchant_key ) : '', + 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? $merchant_key : '', ), ) ); diff --git a/laterpay/application/Controller/Admin/Post/Metabox.php b/laterpay/application/Controller/Admin/Post/Metabox.php index 341a5459c..983c498e7 100644 --- a/laterpay/application/Controller/Admin/Post/Metabox.php +++ b/laterpay/application/Controller/Admin/Post/Metabox.php @@ -148,7 +148,7 @@ public function load_scripts() { 'l10n_print_after' => 'jQuery.extend(lpVars, laterpay_post_edit)', 'postPriceBehaviour' => LaterPay_Helper_Pricing::get_post_price_behaviour(), 'gaData' => array( - 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? esc_js( $merchant_key ) : '', + 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? $merchant_key : '', ), ) ); diff --git a/laterpay/application/Controller/Admin/Pricing.php b/laterpay/application/Controller/Admin/Pricing.php index 61835a2e5..06586470d 100644 --- a/laterpay/application/Controller/Admin/Pricing.php +++ b/laterpay/application/Controller/Admin/Pricing.php @@ -146,7 +146,7 @@ public function load_assets() { lpVars.sub_vouchers_list = JSON.parse(lpVars.sub_vouchers_list); lpVars.vouchers_statistic = JSON.parse(lpVars.vouchers_statistic);', 'gaData' => array( - 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? esc_js( $merchant_key ) : '', + 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? $merchant_key : '', ), ) ); diff --git a/laterpay/application/Controller/Admin/Settings.php b/laterpay/application/Controller/Admin/Settings.php index 8ce46cbd2..ee5c7728f 100644 --- a/laterpay/application/Controller/Admin/Settings.php +++ b/laterpay/application/Controller/Admin/Settings.php @@ -78,8 +78,8 @@ public function load_assets() 'invalidCode' => esc_html__( 'Please enter valid UA-ID code!', 'laterpay' ), ), 'gaData' => array( - 'custom_roles' => array_map( 'esc_js', $custom_role_names ), - 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? esc_js( $merchant_key ) : '', + 'custom_roles' => $custom_role_names, + 'sandbox_merchant_id' => ( ! empty( $merchant_key ) ) ? $merchant_key : '', ), ) ); From 086ceda9eb137788949f4e73f477229c99e21341 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Fri, 11 Jan 2019 14:34:00 +0530 Subject: [PATCH 4/6] Remove Option helper for managing options for now --- .../application/Controller/Admin/Pricing.php | 2 +- laterpay/application/Helper/Option.php | 24 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 laterpay/application/Helper/Option.php diff --git a/laterpay/application/Controller/Admin/Pricing.php b/laterpay/application/Controller/Admin/Pricing.php index 06586470d..3de639739 100644 --- a/laterpay/application/Controller/Admin/Pricing.php +++ b/laterpay/application/Controller/Admin/Pricing.php @@ -1016,7 +1016,7 @@ protected function update_enabled_post_types( LaterPay_Core_Event $event ) { } // Update option for enabled post types. - $is_updated = LaterPay_Helper_Option::update_laterpay_option( 'laterpay_enabled_post_types', $enabled_post_types ); + $is_updated = update_option( 'laterpay_enabled_post_types', $enabled_post_types ); if ( ! $is_updated ) { diff --git a/laterpay/application/Helper/Option.php b/laterpay/application/Helper/Option.php deleted file mode 100644 index 91e3eea80..000000000 --- a/laterpay/application/Helper/Option.php +++ /dev/null @@ -1,24 +0,0 @@ - Date: Fri, 11 Jan 2019 14:43:43 +0530 Subject: [PATCH 5/6] Update language files --- laterpay/languages/laterpay-de_DE.mo | Bin 31702 -> 31702 bytes laterpay/languages/laterpay-de_DE.po | 8 ++------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/laterpay/languages/laterpay-de_DE.mo b/laterpay/languages/laterpay-de_DE.mo index 7c330fb4d49e81e89738e017ec82ee7519f59f41..fc45f016dfa17210ab580da85fd2b667a69f71d0 100644 GIT binary patch delta 33 kcmccio$=at#tlE+*bNm7O{`3eCb=s@nZ}zn+}D`^0N;xXMF0Q* delta 33 jcmccio$=at#tlE+*bNj6&8!SfCb=uZn42}+*O>qS-+v24 diff --git a/laterpay/languages/laterpay-de_DE.po b/laterpay/languages/laterpay-de_DE.po index 55f26a4df..b51d72cdd 100644 --- a/laterpay/languages/laterpay-de_DE.po +++ b/laterpay/languages/laterpay-de_DE.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: LaterPay 0.9.6\n" "Report-Msgid-Bugs-To: http://wordpress.org/tag/laterpay\n" -"POT-Creation-Date: 2019-01-10 16:14+0530\n" -"PO-Revision-Date: 2019-01-10 16:14+0530\n" +"POT-Creation-Date: 2019-01-11 14:42+0530\n" +"PO-Revision-Date: 2019-01-11 14:43+0530\n" "Last-Translator: lpadmin \n" "Language-Team: German\n" "Language: de_DE\n" @@ -1781,10 +1781,6 @@ msgstr "" "Kaufen Sie einen Zeitpass oder ein Abo und zahlen Sie mit einer " "Zahlungsmethode, der Sie vertrauen." -#: built_assets/js/laterpay-common.js:1 -msgid "lp_ga_purchased" -msgstr "" - #: built_assets/js/vendor/velocity.min.js:3 msgid "translateX" msgstr "" From 8d4790e1c8cc1beb5157c6770f609c777530474c Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Fri, 11 Jan 2019 14:44:29 +0530 Subject: [PATCH 6/6] Bump version to 2.4.1 Update Changelog --- composer.json | 2 +- gulpfile.js | 2 +- laterpay/README.txt | 8 ++++++-- laterpay/laterpay.php | 2 +- package.json | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 75416703f..0ff6967b7 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "laterpay/laterpay-wordpress-plugin", "description": "This is the official LaterPay plugin for selling digital content with WordPress", "license": "MIT", - "version": "2.4.0", + "version": "2.4.1", "config": { "vendor-dir": "laterpay/vendor", "secure-http": true diff --git a/gulpfile.js b/gulpfile.js index 2c9bbc311..3483a6809 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,7 +38,7 @@ var gulp = require('gulp'), // OPTIONS ------------------------------------------------------------------------------------------------------------- var gulpKnownOptions = { string: 'version', - default: { version: '2.4.0' } + default: { version: '2.4.1' } }; var gulpOptions = minimist(process.argv.slice(2), gulpKnownOptions); gulpOptions.svn = {}; diff --git a/laterpay/README.txt b/laterpay/README.txt index fb51faea4..e82314ff0 100644 --- a/laterpay/README.txt +++ b/laterpay/README.txt @@ -5,7 +5,7 @@ Donate link: https://laterpay.net Tags: laterpay, accept micropayments, accept payments, access control, billing, buy now pay later, content monetization, creditcard, debitcard, free to read, laterpay for wordpress, laterpay payment, laterpay plugin, micropayments, monetize, paid content, pay button, pay per use, payments, paywall, PPU, sell digital content, sell digital goods, single sale, wordpress laterpay, Payments, Content Monetization, Paywall, Paid Content, Publisher, Blogger Requires at least: 4.6 Tested up to: 5.0.2 -Stable tag: 2.4.0 +Stable tag: 2.4.1 Author URI: https://laterpay.net Plugin URI: https://github.com/laterpay/laterpay-wordpress-plugin License: MIT @@ -185,6 +185,10 @@ Please see the "Test and Live Mode" section. 6. The plugin provides a variety of advanced settings to customize the LaterPay plugin and adjust it to your needs. == Changelog == += 2.4.1 ( January 11, 2019 ) = +* Fix issue with multiple categories in exclude feature for TimePass and Subscription. +* Fix issue with missing categories data in Post Publish GA event. + = 2.4.0 ( January 10, 2019 ) = * Add support for multiple categories to be included or excluded. * Add GA events to capture Merchant Usage Data. @@ -687,7 +691,7 @@ KNOWN BUGS: == Upgrade notice == -= 2.4.0 ( January 10, 2019 ) = += 2.4.1 ( January 11, 2019 ) = Updated plugin initialization hook, Added support for multiple categories, Added GA events to capture Merchant usage data, Fixed Duplicate query issues and minor updates with LaterPay functionality. == Arbitrary section == diff --git a/laterpay/laterpay.php b/laterpay/laterpay.php index f27c5ca62..221a1ece3 100644 --- a/laterpay/laterpay.php +++ b/laterpay/laterpay.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/laterpay/laterpay-wordpress-plugin * Description: Sell digital content with LaterPay. It allows super easy and fast payments from as little as 5 cent up to 149.99 Euro at a 15% fee and no fixed costs. * Author: LaterPay GmbH, Mihail Turalenka and Aliaksandr Vahura - * Version: 2.4.0 + * Version: 2.4.1 * Author URI: https://laterpay.net/ * Textdomain: laterpay * Domain Path: /languages diff --git a/package.json b/package.json index f922640a0..14c95b867 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "laterpay-wordpress-plugin", - "version": "2.4.0", + "version": "2.4.1", "description": "LaterPay WordPress plugin", "main": "index.js", "dependencies": {},