| @@ -24,8 +24,10 @@ | ||
| 24 | 24 | */ |
| 25 | 25 | private function __construct() { |
| 26 | 26 | add_action( 'admin_init', [ $this, 'check_installation_time' ], 10 ); |
| 27 | 27 | add_action( 'admin_init', [ $this, 'notice_actions' ], 5 ); |
| 28 | + | |
| 29 | + $this->remove_all_notices(); | |
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | /** |
| 31 | 33 | * Check if review notice should be shown or not |
| @@ -40,25 +42,21 @@ | ||
| 40 | 42 | if ( '1' == $nobug || 'yes' == $rated ) { |
| 41 | 43 | return; |
| 42 | 44 | } |
| 43 | 45 | |
| 46 | + $now = strtotime( 'now' ); | |
| 47 | + | |
| 44 | 48 | $install_date = ExtraSettings::instance()->get_option( 'rtsb_plugin_activation_time', false ); |
| 49 | + $showing_date = strtotime( '+15 days', $install_date ); | |
| 50 | + $remind_time = get_option( 'rtsb_admin_review_remind_me' ); | |
| 45 | 51 | |
| 46 | - // Bail until the activation time is recorded, otherwise the notice would show immediately. | |
| 47 | - if ( ! $install_date ) { | |
| 48 | - return; | |
| 52 | + if ( ! $remind_time ) { | |
| 53 | + $remind_time = $install_date; | |
| 49 | 54 | } |
| 50 | 55 | |
| 51 | - $now = strtotime( 'now' ); | |
| 52 | - $remind_time = get_option( 'rtsb_admin_review_remind_me' ); | |
| 56 | + $remind_due = strtotime( '+20 days', $remind_time ); | |
| 53 | 57 | |
| 54 | - if ( $remind_time ) { | |
| 55 | - // User asked to be reminded later: show again 20 days after that click. | |
| 56 | - if ( $now < strtotime( '+20 days', $remind_time ) ) { | |
| 57 | - return; | |
| 58 | - } | |
| 59 | - } elseif ( $now < strtotime( '+15 days', $install_date ) ) { | |
| 60 | - // First time: show 15 days after installation. | |
| 58 | + if ( ! $now > $showing_date || $now < $remind_due ) { | |
| 61 | 59 | return; |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | add_action( 'admin_notices', [ $this, 'display_admin_notice' ] ); |
| @@ -159,9 +157,9 @@ | ||
| 159 | 157 | $args = [ '_wpnonce' => wp_create_nonce( 'rtsb_notice_nonce' ) ]; |
| 160 | 158 | $dont_disturb = add_query_arg( $args + [ 'rtsb_admin_review_spare_me' => '1' ], $this->rtsb_current_admin_url() ); |
| 161 | 159 | $remind_me = add_query_arg( $args + [ 'rtsb_admin_review_remind_me' => '1' ], $this->rtsb_current_admin_url() ); |
| 162 | 160 | $rated = add_query_arg( $args + [ 'rtsb_admin_review_rated' => '1' ], $this->rtsb_current_admin_url() ); |
| 163 | - $reviewurl = 'https://wordpress.org/support/plugin/shopbuilder/reviews/#new-post'; | |
| 161 | + $reviewurl = 'https://wordpress.org/support/plugin/shopbuilder/reviews/?filter=5#new-post'; | |
| 164 | 162 | $plugin_name = 'ShopBuilder – Elementor WooCommerce Builder Addons'; |
| 165 | 163 | ?> |
| 166 | 164 | <div class="notice rtsb-review-notice rtsb-review-notice--extended"> |
| 167 | 165 | <div class="rtsb-review-notice_content"> |
| @@ -168,13 +166,15 @@ | ||
| 168 | 166 | <h3>Enjoying <?php echo esc_html( $plugin_name ); ?>? </h3> |
| 169 | 167 | <p>Thank you for choosing <strong>ShopBuilder</strong>. If you have found our plugin useful and makes you smile, please consider giving us a 5-star rating on WordPress.org. It will help us to grow.</p> |
| 170 | 168 | <div class="rtsb-review-notice_actions"> |
| 171 | 169 | <a href="<?php echo esc_url( $reviewurl ); ?>" |
| 172 | - class="rtsb-review-button rtsb-going-to-review rtsb-review-button--cta" target="_blank"><span>⭐ Yes, You Deserve It!</span></a> | |
| 170 | + class="rtsb-review-button rtsb-review-button--cta" target="_blank"><span>⭐ Yes, You Deserve It!</span></a> | |
| 173 | 171 | <a href="<?php echo esc_url( $rated ); ?>" |
| 174 | 172 | class="rtsb-review-button rtsb-review-button--cta rtsb-review-button--outline"><span>😀 Already Rated!</span></a> |
| 175 | 173 | <a href="<?php echo esc_url( $remind_me ); ?>" |
| 176 | 174 | class="rtsb-review-button rtsb-review-button--cta rtsb-review-button--outline"><span>🔔 Remind Me Later</span></a> |
| 175 | + <a href="<?php echo esc_url( $dont_disturb ); ?>" | |
| 176 | + class="rtsb-review-button rtsb-review-button--cta rtsb-review-button--error rtsb-review-button--outline"><span>😐 No Thanks </span></a> | |
| 177 | 177 | </div> |
| 178 | 178 | </div> |
| 179 | 179 | </div> |
| 180 | 180 | <style> |
| @@ -244,16 +244,15 @@ | ||
| 244 | 244 | padding: 0.4375rem 0.75rem; |
| 245 | 245 | border: 0; |
| 246 | 246 | border-radius: 3px;; |
| 247 | 247 | background: var(--e-button-context-color); |
| 248 | + color: #fff; | |
| 248 | 249 | vertical-align: middle; |
| 249 | 250 | text-align: center; |
| 250 | - text-decoration: none !important; | |
| 251 | + text-decoration: none; | |
| 251 | 252 | white-space: nowrap; |
| 252 | 253 | } |
| 253 | - .rtsb-going-to-review { | |
| 254 | - color: #fff !important; | |
| 255 | - } | |
| 254 | + | |
| 256 | 255 | .rtsb-review-button:active { |
| 257 | 256 | background: var(--e-button-context-color-dark); |
| 258 | 257 | color: #fff; |
| 259 | 258 | text-decoration: none; |
| @@ -302,6 +301,23 @@ | ||
| 302 | 301 | } |
| 303 | 302 | </style> |
| 304 | 303 | <?php |
| 305 | 304 | } |
| 305 | + } | |
| 306 | + | |
| 307 | + /** | |
| 308 | + * Remove admin notices | |
| 309 | + */ | |
| 310 | + public function remove_all_notices() { | |
| 311 | + add_action( | |
| 312 | + 'in_admin_header', | |
| 313 | + function () { | |
| 314 | + $screen = get_current_screen(); | |
| 315 | + if ( in_array( $screen->base, [ 'shopbuilder_page_rtsb-get-help' ], true ) ) { | |
| 316 | + remove_all_actions( 'admin_notices' ); | |
| 317 | + remove_all_actions( 'all_admin_notices' ); | |
| 318 | + } | |
| 319 | + }, | |
| 320 | + 1000 | |
| 321 | + ); | |
| 306 | 322 | } |
| 307 | 323 | } |