Skip to content

Commit

Permalink
Fixed review notice (#140)
Browse files Browse the repository at this point in the history
* Fixed review notice
  • Loading branch information
Balazs P authored and surajv committed Aug 13, 2019
1 parent ecef41f commit e4a5de7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
28 changes: 23 additions & 5 deletions admin/class-wpr-review-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@
class WPR_Review_Notice {

/**
* Dismiss transient key.
* Dismiss key.
*
* @var string
*/
private $dismiss_transient_key = 'wpr_review_notice_dismiss';
private $dismiss_key = 'wpr_review_notice_dismiss';

/**
* Show on later date key.
*
* @var string
*/
private $dismiss_later_key = 'wpr_review_notice_later';

/**
* Show the notice if number of reviews >= this value.
Expand Down Expand Up @@ -109,19 +116,30 @@ public function show_notice() {
public function handle_dismiss() {
$later = ! empty( $_POST['later'] );
if ( $later ) {
set_transient( $this->dismiss_transient_key, 1, MONTH_IN_SECONDS );
update_option( $this->dismiss_later_key, time() + MONTH_IN_SECONDS );
} else {
set_transient( $this->dismiss_transient_key, 1 );
update_option( $this->dismiss_key, '1' );
}
}

/**
* Checks if should show the notice.
*/
private function should_show() {
if ( get_transient( $this->dismiss_transient_key ) ) {
// Backwards compatibility for transients used in versions <= 5.2.5
if ( get_transient( 'wpr_review_notice_dismiss' ) ) {
return false;
}

if ( get_option( $this->dismiss_key ) ) {
return false;
}

$later_date = absint( get_option( $this->dismiss_later_key ) );
if ( $later_date > time() ) {
return false;
}

$query = wp_review_get_reviews_query(
'latest',
array(
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Creator's website link: http://mythemeshop.com/plugins/wp-review/
Tags: review, schema.org, rating, schema, user rating, google rating, star rating, product review
Requires at least: 4.0
Tested up to: 5.2.2
Stable tag: 5.2.5
Stable tag: 5.2.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -103,6 +103,9 @@ Please disable all plugins and check if rating is working properly. Then you can

== Changelog ==

= v5.2.6 (Aug 13, 2019) =
* Fixed the notice reappearing issue if transients are cleared or expired

= v5.2.5 (Jul 26, 2019) =
* Fixed review drafts showing up in the Widget

Expand Down
4 changes: 2 additions & 2 deletions wp-review.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Review
* Plugin URI: http://mythemeshop.com/plugins/wp-review/
* Description: Create reviews! Choose from stars, percentages or points for review scores. Supports Retina Display, WPMU and Unlimited Color Schemes.
* Version: 5.2.5
* Version: 5.2.6
* Author: MyThemeShop
* Author URI: http://mythemeshop.com/
* Text Domain: wp-review
Expand Down Expand Up @@ -45,7 +45,7 @@ function wp_review_php_upgrade_notice() {
}

/* Plugin version */
define( 'WP_REVIEW_PLUGIN_VERSION', '5.2.5' );
define( 'WP_REVIEW_PLUGIN_VERSION', '5.2.6' );

/* Sets the custom db table name. */
define( 'MTS_WP_REVIEW_DB_TABLE', 'mts_wp_reviews' );
Expand Down

0 comments on commit e4a5de7

Please sign in to comment.