complianz-gdpr
Last commit date
DNSMPD
2 months ago
assets
1 month ago
config
2 months ago
cookie
1 month ago
cookiebanner
1 month ago
cron
7 months ago
documents
2 months ago
gutenberg
1 month ago
integrations
1 month ago
languages
1 month ago
mailer
1 year ago
onboarding
1 year ago
placeholders
7 months ago
progress
2 years ago
proof-of-consent
1 month ago
rest-api
1 month ago
settings
1 month ago
templates
6 months ago
upgrade
1 month ago
websitescan
2 months ago
LICENSE.txt
4 years ago
README.md
7 months ago
class-admin.php
6 months ago
class-company.php
2 years ago
class-cookie-blocker.php
7 months ago
class-export.php
2 years ago
class-installer.php
2 years ago
class-review.php
11 months ago
complianz-gpdr.php
1 month ago
functions-legacy.php
2 years ago
functions.php
2 months ago
index.php
7 years ago
loco.xml
4 years ago
readme.txt
1 month ago
security.md
2 years ago
system-status.php
1 year ago
uninstall.php
1 month ago
upgrade.php
2 months ago
class-review.php
177 lines
| 1 | <?php |
| 2 | /*100% match*/ |
| 3 | |
| 4 | defined( 'ABSPATH' ) or die( "you do not have access to this page!" ); |
| 5 | |
| 6 | if ( ! class_exists( "cmplz_review" ) ) { |
| 7 | class cmplz_review { |
| 8 | private static $_this; |
| 9 | |
| 10 | |
| 11 | function __construct() { |
| 12 | if ( isset( self::$_this ) ) { |
| 13 | wp_die( sprintf( '%s is a singleton class and you cannot create a second instance.', |
| 14 | get_class( $this ) ) ); |
| 15 | } |
| 16 | |
| 17 | self::$_this = $this; |
| 18 | |
| 19 | //uncomment for testing |
| 20 | // update_option('cmplz_review_notice_shown', false, false); |
| 21 | // update_option( 'cmplz_activation_time', strtotime( "-2 month" ), false ); |
| 22 | //show review notice, only to free users |
| 23 | if ( ! defined( "cmplz_premium" ) && ! is_multisite() ) { |
| 24 | if ( ! get_option( 'cmplz_review_notice_shown' ) |
| 25 | && get_option( 'cmplz_activation_time' ) |
| 26 | && get_option( 'cmplz_activation_time' ) |
| 27 | < strtotime( "-1 month" ) |
| 28 | ) { |
| 29 | add_action( 'wp_ajax_cmplz_dismiss_review_notice', array( $this, 'dismiss_review_notice_callback' ) ); |
| 30 | add_action( 'admin_notices', array( $this, 'show_leave_review_notice' ) ); |
| 31 | add_action( 'admin_print_footer_scripts', array( $this, 'insert_dismiss_review' ) ); |
| 32 | } |
| 33 | |
| 34 | //set a time for users who didn't have it set yet. |
| 35 | if ( ! get_option( 'cmplz_activation_time' ) ) { |
| 36 | update_option( 'cmplz_activation_time', time() , false ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | add_action('admin_init', array($this, 'process_get_review_dismiss' )); |
| 41 | |
| 42 | } |
| 43 | |
| 44 | static function this() { |
| 45 | return self::$_this; |
| 46 | } |
| 47 | |
| 48 | public function show_leave_review_notice() { |
| 49 | if (isset( $_GET['cmplz_dismiss_review'] ) ) return; |
| 50 | |
| 51 | /** |
| 52 | * Prevent notice from being shown on Gutenberg page, as it strips off the class we need for the ajax callback. |
| 53 | * |
| 54 | * */ |
| 55 | $screen = get_current_screen(); |
| 56 | if ( $screen && $screen->parent_base === 'edit' ) { |
| 57 | return; |
| 58 | } |
| 59 | ?> |
| 60 | <style> |
| 61 | #message.cmplz-review { |
| 62 | margin-left:10px !important; |
| 63 | } |
| 64 | .cmplz-review .button { |
| 65 | margin-right:10px; |
| 66 | } |
| 67 | .cmplz-review .cmplz-buttons-row { |
| 68 | padding:10px 0; |
| 69 | } |
| 70 | .cmplz-buttons-row a{ |
| 71 | padding-top:20px |
| 72 | } |
| 73 | </style> |
| 74 | <div id="message" |
| 75 | class="updated fade notice is-dismissible cmplz-review really-simple-plugins" |
| 76 | style="border-left:4px solid #333"> |
| 77 | <div class="cmplz-container" style="display:flex"> |
| 78 | <div class="cmplz-review-image" style="padding:20px 10px"><img width=80px" |
| 79 | src="<?php echo CMPLZ_URL ?>assets/images/icon-logo.svg" |
| 80 | alt="review-logo"> |
| 81 | </div> |
| 82 | <div style="margin-left:30px"> |
| 83 | <p><?php echo wp_kses_post( sprintf( __( 'Hi, you have been using Complianz | GDPR cookie consent for a month now, awesome! If you have a moment, please consider leaving a review on WordPress.org to spread the word. We greatly appreciate it! If you have any questions or feedback, leave us a %smessage%s.', 'complianz-gdpr' ), |
| 84 | '<a href="https://complianz.io/contact" target="_blank">', |
| 85 | '</a>') ); ?></p> |
| 86 | <div class="cmplz-buttons-row"> |
| 87 | <a class="button button-primary" target="_blank" href="https://wordpress.org/support/plugin/complianz-gdpr/reviews/#new-post"><?php esc_html_e(__( 'Leave a review', 'complianz-gdpr' ) ); ?></a> |
| 88 | |
| 89 | <div class="dashicons dashicons-calendar"></div> |
| 90 | <a href="#" id="maybe-later"><?php esc_html_e(__( 'Maybe later', 'complianz-gdpr' ) ); ?></a> |
| 91 | |
| 92 | <div class="dashicons dashicons-no-alt"></div> |
| 93 | <a href="<?php echo add_query_arg(array('page'=>'complianz', 'cmplz_dismiss_review'=>1), admin_url('admin.php') )?>"><?php esc_html_e(__( 'Don\'t show again', 'complianz-gdpr' )); ?></a> |
| 94 | </div> |
| 95 | </div> |
| 96 | </div> |
| 97 | </div> |
| 98 | <?php |
| 99 | |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Insert some ajax script to dismiss the review notice, and stop nagging about it |
| 104 | * |
| 105 | * @since 2.0 |
| 106 | * |
| 107 | * @access public |
| 108 | * |
| 109 | * type: dismiss, later |
| 110 | * |
| 111 | */ |
| 112 | |
| 113 | public function insert_dismiss_review() { |
| 114 | $ajax_nonce = wp_create_nonce( "cmplz_dismiss_review" ); |
| 115 | ?> |
| 116 | <script type='text/javascript'> |
| 117 | jQuery(document).ready(function ($) { |
| 118 | $(".cmplz-review.notice.is-dismissible").on("click", ".notice-dismiss", function (event) { |
| 119 | rsssl_dismiss_review('dismiss'); |
| 120 | }); |
| 121 | $(".cmplz-review.notice.is-dismissible").on("click", "#maybe-later", function (event) { |
| 122 | rsssl_dismiss_review('later'); |
| 123 | $(this).closest('.cmplz-review').remove(); |
| 124 | }); |
| 125 | $(".cmplz-review.notice.is-dismissible").on("click", ".review-dismiss", function (event) { |
| 126 | rsssl_dismiss_review('dismiss'); |
| 127 | $(this).closest('.cmplz-review').remove(); |
| 128 | }); |
| 129 | |
| 130 | function rsssl_dismiss_review(type) { |
| 131 | var data = { |
| 132 | 'action': 'cmplz_dismiss_review_notice', |
| 133 | 'type': type, |
| 134 | 'token': '<?php echo $ajax_nonce; ?>' |
| 135 | }; |
| 136 | $.post(ajaxurl, data, function (response) {}); |
| 137 | } |
| 138 | }); |
| 139 | </script> |
| 140 | <?php |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Process the ajax dismissal of the review message. |
| 145 | * |
| 146 | * @since 2.1 |
| 147 | * |
| 148 | * @access public |
| 149 | * |
| 150 | */ |
| 151 | |
| 152 | public function dismiss_review_notice_callback() { |
| 153 | $type = isset( $_POST['type'] ) ? $_POST['type'] : false; |
| 154 | |
| 155 | if ( $type === 'dismiss' ) { |
| 156 | update_option( 'cmplz_review_notice_shown', true, false ); |
| 157 | } |
| 158 | if ( $type === 'later' ) { |
| 159 | //Reset activation timestamp, notice will show again in one month. |
| 160 | update_option( 'cmplz_activation_time', time(), false ); |
| 161 | } |
| 162 | |
| 163 | wp_die(); // this is required to terminate immediately and return a proper response |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Dismiss review notice with get, which is more stable |
| 168 | */ |
| 169 | |
| 170 | public function process_get_review_dismiss(){ |
| 171 | if (isset( $_GET['cmplz_dismiss_review'] ) ){ |
| 172 | update_option( 'cmplz_review_notice_shown', true, false ); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 |