diff --git a/README.md b/README.md
index 7ce1995ed..a058e6094 100644
--- a/README.md
+++ b/README.md
@@ -17,18 +17,22 @@ The plugin is available on http://wordpress.org/plugins/laterpay
1. Fork it ( https://github.com/laterpay/laterpay-wordpress-plugin/fork )
2. Run `composer install` to install all the dependencies.
-3. Create your feature branch (`git checkout -b feature/my_new_feature`)
+3. Create your feature branch (`git checkout -b feature/my_new_feature develop`)
4. Add your changes, verify coding standards and language compatibility ( [Check #development-notes](#development-notes) )
5. Run `gulp build` for `js` and / or `css` changes. Please check [gulpfile](gulpfile.js) for more tasks.
6. Commit your changes (`git commit -am 'Added some feature'`)
7. Push to the branch (`git push origin feature/my_new_feature`)
8. Create a new Pull Request to develop.
+Note: Source code of the plugin resides in [laterpay](./laterpay) directory, you should copy / rsync files from this directory to your test site, in order to see the changes done.
+
+⚠️ Warning: Code from this repo is only to be used for development purposes. Always use the latest version available at http://wordpress.org/plugins/laterpay for production sites.
+
## Development Notes
##### Please run following commands from the root directory.
-1. Please verfiy your code is in compliance to the Coding Standards used in this Project.
+1. Please verify your code is in compliance to the Coding Standards used in this Project.
2. Run `composer phpcs filename` or `composer phpcs laterpay` to check for PHPCS errors/warnings.
3. Run `composer phpcompat` to check if the code is compatible for PHP 5.6 and above
@@ -54,4 +58,4 @@ The LaterPay WordPress plugin uses [Semantic Versioning 2.0.0](http://semver.org
## Copyright
-Copyright 2018 LaterPay GmbH – Released under MIT License
+Copyright 2019 LaterPay GmbH – Released under MIT License
diff --git a/composer.json b/composer.json
index aed04a413..80725bff3 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.5.2",
+ "version": "2.5.3",
"config": {
"vendor-dir": "laterpay/vendor",
"secure-http": true
diff --git a/composer.lock b/composer.lock
index 79e9ed630..d1b5661ff 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": "f7ebc8b3af366240a7c6fd7bb42f1b9a",
+ "content-hash": "38a9940d01fb8f5122bdfc0b30cf3a2b",
"packages": [
{
"name": "laterpay/laterpay-client-php",
@@ -303,16 +303,16 @@
},
{
"name": "squizlabs/php_codesniffer",
- "version": "3.4.1",
+ "version": "3.4.2",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "5b4333b4010625d29580eb4a41f1e53251be6baa"
+ "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5b4333b4010625d29580eb4a41f1e53251be6baa",
- "reference": "5b4333b4010625d29580eb4a41f1e53251be6baa",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8",
+ "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8",
"shasum": ""
},
"require": {
@@ -350,7 +350,7 @@
"phpcs",
"standards"
],
- "time": "2019-03-19T03:22:27+00:00"
+ "time": "2019-04-10T23:49:02+00:00"
},
{
"name": "wp-coding-standards/wpcs",
diff --git a/gulpfile.js b/gulpfile.js
index c63ff049c..0e30e45fd 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -38,7 +38,7 @@ var gulp = require('gulp'),
// OPTIONS -------------------------------------------------------------------------------------------------------------
var gulpKnownOptions = {
string: 'version',
- default: { version: '2.5.2' }
+ default: { version: '2.5.3' }
};
var gulpOptions = minimist(process.argv.slice(2), gulpKnownOptions);
gulpOptions.svn = {};
diff --git a/laterpay/README.txt b/laterpay/README.txt
index 79130a8b9..5c98345ad 100644
--- a/laterpay/README.txt
+++ b/laterpay/README.txt
@@ -4,8 +4,8 @@ Contributors: laterpay, dominik-rodler, mihail-turalenka, avahura, ahryb
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.1.1
-Stable tag: 2.5.2
+Tested up to: 5.2
+Stable tag: 2.5.3
Author URI: https://laterpay.net
Plugin URI: https://github.com/laterpay/laterpay-wordpress-plugin
License: MIT
@@ -45,7 +45,9 @@ The LaterPay WordPress plugin is easy to implement and offers a user interface t
* Data sharing
= What it costs you: =
+
LaterPay is performance-based and works on a revenue sharing basis - for a limited time we’re charging a rate of 15% of actual revenue generated with LaterPay, ALL-INCLUSIVE.
+
* No payment processing fees
* No chargeback fees
* No payout fees
@@ -68,7 +70,9 @@ when you need it. Contextual help for the current page is available via the ‘H
You can find further information about LaterPay and the LaterPay WordPress plugin in the [LaterPay Knowledge Base](https://www.laterpay.net/academy).
= Is this plugin crawler friendly? =
+
Yes!
+
* *Social media:* The plugin supports Facebook, Twitter, and Google+ crawlers, so it won’t hurt your social media reach.
* *Google and Google News:* The plugin also supports Google and Google News crawlers.
* Crawlers will never have access to the full content but only to your teaser content.
@@ -84,6 +88,12 @@ Yes!
6. The plugin provides a variety of advanced settings to customize the LaterPay plugin and adjust it to your needs.
== Changelog ==
+= 2.5.3 ( May 7, 2019 ) =
+* Optimize code and use internal cache, to reduce queries.
+* Add warning for subscription with invalid price.
+* Lower Subscription Minimum value to $1.99 and 1.49€ for US and EU region respectively.
+* Remove Hyperlinks from Obfuscated text.
+
= 2.5.2 ( April 2, 2019 ) =
* Add Advanced Tab, to inform about all advanced feature.
* Add disclaimer for Subscription voucher.
@@ -618,8 +628,8 @@ KNOWN BUGS:
== Upgrade notice ==
-= 2.5.2 ( April 2, 2019 ) =
-A new "Advanced" Tab containing information of advanced feature, updated plugin mode toggle behaviour and improvements with LaterPay functionality.
+= 2.5.3 ( May 7, 2019 ) =
+Code optimizations for reducing DB calls, reduced Subscription minimum value for both regions and minor improvements with LaterPay functionality.
== Arbitrary section ==
diff --git a/laterpay/application/Controller/Admin/Pricing.php b/laterpay/application/Controller/Admin/Pricing.php
index e53522370..c72ac1978 100644
--- a/laterpay/application/Controller/Admin/Pricing.php
+++ b/laterpay/application/Controller/Admin/Pricing.php
@@ -837,6 +837,7 @@ protected function subscription_form_save( LaterPay_Core_Event $event ) {
$event->set_result(
array(
'success' => true,
+ 'region' => get_option( 'laterpay_region', 'us' ),
'data' => $data,
'vouchers' => $vouchers,
'html' => $this->render_subscription( $hmtl_data ),
@@ -864,8 +865,9 @@ protected function subscription_delete( LaterPay_Core_Event $event ) {
$event->set_result(
array(
- 'success' => true,
- 'message' => esc_html__( 'Subscription deleted.', 'laterpay' ),
+ 'success' => true,
+ 'message' => esc_html__( 'Subscription deleted.', 'laterpay' ),
+ 'region' => get_option( 'laterpay_region', 'us' ),
)
);
} else {
diff --git a/laterpay/application/Controller/Frontend/Post.php b/laterpay/application/Controller/Frontend/Post.php
index 539903723..9be1c6da5 100644
--- a/laterpay/application/Controller/Frontend/Post.php
+++ b/laterpay/application/Controller/Frontend/Post.php
@@ -313,6 +313,10 @@ public function prefetch_post_access( LaterPay_Core_Event $event ) {
return;
}
+ if ( 1 === count( $posts ) && ! LaterPay_Helper_Post::is_enabled_type( $posts[0]->ID ) ) {
+ return;
+ }
+
$post_ids = array();
// as posts can also be loaded by widgets (e.g. recent posts and popular posts), we loop through all posts
// and bundle them in one API request to LaterPay, to avoid the overhead of multiple API requests
diff --git a/laterpay/application/Controller/Frontend/PreviewMode.php b/laterpay/application/Controller/Frontend/PreviewMode.php
index 54b68257d..c707e79fc 100644
--- a/laterpay/application/Controller/Frontend/PreviewMode.php
+++ b/laterpay/application/Controller/Frontend/PreviewMode.php
@@ -32,47 +32,6 @@ public static function get_subscribed_events() {
);
}
- /**
- * Check requirements for logging and rendering the post statistic pane via Ajax callback.
- *
- * @param WP_Post $post
- *
- * @return bool
- */
- protected function check_requirements( $post = null ) {
-
- if ( empty( $post ) ) {
- // check, if we're on a singular page
- if ( ! is_singular() ) {
- return false;
- }
-
- // check, if we have a post
- $post = get_post();
- if ( $post === null ) {
- return false;
- }
- }
-
- // don't collect statistics data, if the current post is not published
- if ( $post->post_status !== LaterPay_Helper_Pricing::STATUS_POST_PUBLISHED ) {
- return false;
- }
-
- // don't collect statistics data, if the current post_type is not an allowed post_type
- $allowed_post_types = $this->config->get( 'content.enabled_post_types' );
- if ( ! in_array( $post->post_type, $allowed_post_types, true ) ) {
- return false;
- }
-
- // don't collect statistics data, if the current post is not purchasable
- if ( ! LaterPay_Helper_Pricing::is_purchasable( $post->ID ) ) {
- return false;
- }
-
- return true;
- }
-
/**
* Callback to add the statistics placeholder to the footer.
*
@@ -82,9 +41,6 @@ protected function check_requirements( $post = null ) {
* @return void
*/
public function modify_footer( LaterPay_Core_Event $event ) {
- if ( ! $this->check_requirements() ) {
- return;
- }
// don't add the preview pane placeholder to the footer, if the user is not logged in
if ( ! LaterPay_Helper_User::can( 'laterpay_has_full_access_to_content', get_the_ID() ) ) {
diff --git a/laterpay/application/Helper/Config.php b/laterpay/application/Helper/Config.php
index 29aa636a9..7eb71a5dd 100644
--- a/laterpay/application/Helper/Config.php
+++ b/laterpay/application/Helper/Config.php
@@ -32,7 +32,7 @@ class LaterPay_Helper_Config {
'ppu_min' => 0.05,
'ppu_only_limit' => 1.48,
'ppu_max' => 5.00,
- 'sis_min' => 3.99,
+ 'sis_min' => 1.49,
'sis_only_limit' => 5.01,
'sis_max' => 149.99,
'sis_min_limit' => 1.50,
@@ -73,7 +73,7 @@ class LaterPay_Helper_Config {
'ppu_min' => 0.05,
'ppu_only_limit' => 1.98,
'ppu_max' => 5.00,
- 'sis_min' => 3.99,
+ 'sis_min' => 1.99,
'sis_only_limit' => 5.01,
'sis_max' => 149.99,
'sis_min_limit' => 2.00,
diff --git a/laterpay/application/Helper/Post.php b/laterpay/application/Helper/Post.php
index ad4cd1ff6..2cdd8640d 100644
--- a/laterpay/application/Helper/Post.php
+++ b/laterpay/application/Helper/Post.php
@@ -442,4 +442,21 @@ public static function is_content_purchasable( $post_id ) {
return true;
}
}
+
+ /**
+ * Check if post_type is salable.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return bool
+ */
+ public static function is_enabled_type( $post_id ) {
+ $enabled_types = (array) get_option( 'laterpay_enabled_post_types' );
+
+ if ( ! empty( $enabled_types ) && in_array( get_post_type( $post_id ), $enabled_types, true ) ) {
+ return true;
+ }
+
+ return false;
+ }
}
diff --git a/laterpay/application/Helper/Pricing.php b/laterpay/application/Helper/Pricing.php
index 31484434c..dfe271f67 100644
--- a/laterpay/application/Helper/Pricing.php
+++ b/laterpay/application/Helper/Pricing.php
@@ -23,6 +23,15 @@ class LaterPay_Helper_Pricing
const STATUS_POST_PUBLISHED = 'publish';
const META_KEY = 'laterpay_post_prices';
+ /**
+ * Internal cache for storing posts with their prices.
+ *
+ * @var array Internal cache of posts with their prices.
+ *
+ * @access private
+ */
+ private static $purchasable_posts = [];
+
/**
* Check, if the current post or a given post is purchasable.
*
@@ -38,8 +47,14 @@ public static function is_purchasable( $post_id = null ) {
}
}
- // check, if the current post price is not 0
- $price = LaterPay_Helper_Pricing::get_post_price( $post_id, true );
+ // Check if price already exists.
+ if ( isset( self::$purchasable_posts[ $post_id ] ) ) {
+ $price = self::$purchasable_posts[ $post_id ];
+ } else {
+ // check, if the current post price is not 0
+ $price = LaterPay_Helper_Pricing::get_post_price( $post_id, true );
+ self::$purchasable_posts[ $post_id ] = $price;
+ }
// Get current post price behaviour.
$post_price_behaviour = self::get_post_price_behaviour();
@@ -204,6 +219,11 @@ public static function recalculate_post_price( $post_id, $category_id, $post_pri
* @return float $price
*/
public static function get_post_price( $post_id, $recalculate = false ) {
+
+ if ( ! LaterPay_Helper_Post::is_enabled_type( $post_id ) ) {
+ return (float) 0;
+ }
+
$global_default_price = get_option( 'laterpay_global_price' );
$cache_key = 'laterpay_post_price_' . $post_id;
diff --git a/laterpay/application/Helper/String.php b/laterpay/application/Helper/String.php
index 26770f71b..b06fd0c3a 100644
--- a/laterpay/application/Helper/String.php
+++ b/laterpay/application/Helper/String.php
@@ -234,6 +234,10 @@ public static function get_scrambled_text( $content ) {
foreach ( $words as $key => $value ) {
$tag = ( ! empty( $tags[ $key ] ) ) ? $tags[ $key ] : '';
+ if ( ! empty( $tag[1] ) && 'a' === $tag[1] ) {
+ $tag = preg_replace( '//', '', $tag );
+ }
+
if ( ! in_array( trim( $tag, '<>/' ), $allowed_tags, true ) ) {
// Scramble the string before appending to final content.
$final_content .= self::scramble_text( $value ) . $tag;
diff --git a/laterpay/application/Model/SubscriptionWP.php b/laterpay/application/Model/SubscriptionWP.php
index 58c9ddb3c..dc3829398 100644
--- a/laterpay/application/Model/SubscriptionWP.php
+++ b/laterpay/application/Model/SubscriptionWP.php
@@ -82,25 +82,8 @@ public function get_subscription( $id, $ignore_deleted = false ) {
'fields' => 'ids',
);
- // Create a hash from the query args.
- $args_hash = md5( wp_json_encode( $query_args ) );
-
- // Check if data already exists for requested query args.
- if ( isset( self::$subscription_data_store[ $args_hash ] ) ) {
-
- // Get data from internal cache for already requested query.
- $current_posts = self::$subscription_data_store[ $args_hash ];
-
- } else {
-
- $query = new WP_Query( $query_args );
-
- // Get posts for requested args.
- $current_posts = $query->posts;
-
- self::$subscription_data_store[ $args_hash ] = $current_posts;
-
- }
+ // Get data from data store.
+ $current_posts = self::get_subscription_from_data_store( $query_args );
$id = ( isset( $current_posts[0] ) ) ? $current_posts[0] : '';
@@ -122,9 +105,8 @@ public function get_subscription( $id, $ignore_deleted = false ) {
$query_args['post_status'] = 'publish';
}
- $get_subscription_query = new WP_Query( $query_args );
-
- $posts = $get_subscription_query->get_posts();
+ // Get data from data store.
+ $posts = self::get_subscription_from_data_store( $query_args );
if ( isset( $posts[0] ) ) {
$subscription = $this->transform_post_to_subscription( $posts[0] );
@@ -572,4 +554,28 @@ private function ensure_post_meta_present( $post_meta ) {
return $post_meta_new;
}
+
+ /**
+ * Get subscription data from internal cache.
+ *
+ * @param array $query_args Query args to be passed to WP_Query.
+ *
+ * @return array
+ */
+ private function get_subscription_from_data_store( $query_args ) {
+
+ // Create a hash from the query args.
+ $args_hash = md5( wp_json_encode( $query_args ) );
+
+ // Check if data exists for requested query args, if not, add it to internal cache.
+ if ( ! isset( self::$subscription_data_store[ $args_hash ] ) ) {
+
+ $query = new WP_Query( $query_args );
+
+ // Get posts for requested args.
+ self::$subscription_data_store[ $args_hash ] = $query->posts;
+ }
+
+ return self::$subscription_data_store[ $args_hash ];
+ }
}
diff --git a/laterpay/asset_sources/js/laterpay-backend-pricing.js b/laterpay/asset_sources/js/laterpay-backend-pricing.js
index 307f204cc..d376b6bba 100644
--- a/laterpay/asset_sources/js/laterpay-backend-pricing.js
+++ b/laterpay/asset_sources/js/laterpay-backend-pricing.js
@@ -1187,6 +1187,28 @@
});
},
+ clearSubscriptionRegionWarning = function ( type, $entity, region, action, id ) {
+ // Hide subscription region price warning if all prices are ok.
+ if ( 'subscription' === type && Object.keys($entity.data.list).length ) {
+ var showSubscriptionRegionWarning = false;
+ if ( 'delete' === action ) {
+ delete $entity.data.list[id];
+ }
+
+ $.each( $entity.data.list, function( i ) {
+ var current_sub = $entity.data.list[i];
+ if ( current_sub.hasOwnProperty( 'price' ) &&
+ parseFloat(current_sub.price) < 1.99 && 'us' === region ) {
+ showSubscriptionRegionWarning = true;
+ }
+ } );
+
+ if ( false === showSubscriptionRegionWarning ) {
+ $('div.lp_js_subscriptionPanelWarning').hide();
+ }
+ }
+ },
+
addEntity = function(type) {
var $entity = $o[type];
@@ -1521,6 +1543,7 @@
}
$o.navigation.showMessage(r);
+ clearSubscriptionRegionWarning( type, $entity, r.region, 'edit' );
},
'json'
);
@@ -1601,6 +1624,8 @@
if ($($entity.wrapper + ':visible').length === 0) {
$($o.emptyState, $entity.editor).velocity('fadeIn', { duration: 400 });
}
+ clearSubscriptionRegionWarning( type, $entity, r.region,
+ 'delete', $wrapper.data($entity.data.id) );
} else {
$(this).stop().show();
}
diff --git a/laterpay/asset_sources/scss/pages/_pricing.scss b/laterpay/asset_sources/scss/pages/_pricing.scss
index 6d28f5897..77353d3db 100644
--- a/laterpay/asset_sources/scss/pages/_pricing.scss
+++ b/laterpay/asset_sources/scss/pages/_pricing.scss
@@ -102,6 +102,14 @@ div.lp_js_categoryPanelWarning {
}
}
+div.lp_js_subscriptionPanelWarning {
+ margin: 0 auto $fs;
+ width: 500px;
+ p {
+ color: #ff1744;
+ }
+}
+
// category default prices ---------------------------------------------------------------------------------------------
.lp_category-price-form {
diff --git a/laterpay/languages/laterpay-de_CH.mo b/laterpay/languages/laterpay-de_CH.mo
index d0e7b4f4b..0634d16a9 100644
Binary files a/laterpay/languages/laterpay-de_CH.mo and b/laterpay/languages/laterpay-de_CH.mo differ
diff --git a/laterpay/languages/laterpay-de_CH_informal.mo b/laterpay/languages/laterpay-de_CH_informal.mo
index d0e7b4f4b..0634d16a9 100644
Binary files a/laterpay/languages/laterpay-de_CH_informal.mo and b/laterpay/languages/laterpay-de_CH_informal.mo differ
diff --git a/laterpay/languages/laterpay-de_DE.mo b/laterpay/languages/laterpay-de_DE.mo
index d0e7b4f4b..0634d16a9 100644
Binary files a/laterpay/languages/laterpay-de_DE.mo and b/laterpay/languages/laterpay-de_DE.mo differ
diff --git a/laterpay/languages/laterpay-de_DE.po b/laterpay/languages/laterpay-de_DE.po
index 6181818b1..82fb58bc1 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-04-01 15:58+0530\n"
-"PO-Revision-Date: 2019-04-01 15:58+0530\n"
+"POT-Creation-Date: 2019-05-07 12:38+0530\n"
+"PO-Revision-Date: 2019-05-07 12:38+0530\n"
"Last-Translator: lpadmin
+ +