feature-feedback
1 year ago
licensing
1 year ago
notifications
6 months ago
pages
1 month ago
reports
1 month ago
site-notes
1 month ago
admin-assets.php
1 month ago
admin.php
1 month ago
ajax.php
1 month ago
api-auth.php
1 month ago
class-monsterinsights-am-deactivation-survey.php
8 months ago
class-monsterinsights-charitable-notice.php
7 months ago
class-monsterinsights-onboarding.php
1 month ago
class-monsterinsights-usage-tracking.php
1 month ago
common.php
1 month ago
eea-compliance.php
1 month ago
exclude-page-metabox.php
1 month ago
index.php
3 years ago
notice.php
1 year ago
notification-event-runner.php
1 year ago
notification-event.php
1 year ago
notifications.php
1 month ago
product-feed-cronjob.php
6 months ago
reporting.php
3 years ago
review.php
1 year ago
routes.php
1 month ago
setup-checklist.php
1 month ago
sharedcount.php
1 year ago
tracking.php
7 months ago
translations.php
1 year ago
uninstall.php
4 years ago
wp-site-health.php
3 years ago
review.php
206 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Ask for some love. |
| 5 | * |
| 6 | * @package MonsterInsights |
| 7 | * @author MonsterInsights |
| 8 | * @since 7.0.7 |
| 9 | * @license GPL-2.0+ |
| 10 | * @copyright Copyright (c) 2018, MonsterInsights LLC |
| 11 | * TODO: |
| 12 | * Go through this file and remove UA references/usages |
| 13 | * Check if this class is actually working |
| 14 | */ |
| 15 | class MonsterInsights_Review { |
| 16 | /** |
| 17 | * Primary class constructor. |
| 18 | * |
| 19 | * @since 7.0.7 |
| 20 | */ |
| 21 | public function __construct() { |
| 22 | // Admin notice requesting review. |
| 23 | add_action( 'admin_notices', array( $this, 'review_request' ) ); |
| 24 | add_action( 'wp_ajax_monsterinsights_review_dismiss', array( $this, 'review_dismiss' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Add admin notices as needed for reviews. |
| 29 | * |
| 30 | * @since 7.0.7 |
| 31 | */ |
| 32 | public function review_request() { |
| 33 | // Only consider showing the review request to admin users. |
| 34 | if ( ! is_super_admin() ) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | // If the user has opted out of product announcement notifications, don't |
| 39 | // display the review request. |
| 40 | if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) { |
| 41 | return; |
| 42 | } |
| 43 | // Verify that we can do a check for reviews. |
| 44 | $review = get_option( 'monsterinsights_review' ); |
| 45 | $time = time(); |
| 46 | $load = false; |
| 47 | |
| 48 | if ( ! $review ) { |
| 49 | $review = array( |
| 50 | 'time' => $time, |
| 51 | 'dismissed' => false, |
| 52 | ); |
| 53 | update_option( 'monsterinsights_review', $review ); |
| 54 | } else { |
| 55 | // Check if it has been dismissed or not. |
| 56 | if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && ( isset( $review['time'] ) && ( ( $review['time'] + DAY_IN_SECONDS ) <= $time ) ) ) { |
| 57 | $load = true; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // If we cannot load, return early. |
| 62 | if ( ! $load ) { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | $this->review(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Maybe show review request. |
| 71 | * |
| 72 | * @since 7.0.7 |
| 73 | */ |
| 74 | public function review() { |
| 75 | // Fetch when plugin was initially installed. |
| 76 | $activated = get_option( 'monsterinsights_over_time', array() ); |
| 77 | $v4_code = monsterinsights_get_v4_id(); |
| 78 | |
| 79 | if ( ! empty( $activated['connected_date'] ) ) { |
| 80 | // Only continue if plugin has been tracking for at least 14 days. |
| 81 | $days = 14; |
| 82 | if ( monsterinsights_get_option( 'gadwp_migrated', 0 ) > 0 ) { |
| 83 | $days = 21; |
| 84 | } |
| 85 | if ( ( $activated['connected_date'] + ( DAY_IN_SECONDS * $days ) ) > time() ) { |
| 86 | return; |
| 87 | } |
| 88 | } else { |
| 89 | if ( empty( $activated ) ) { |
| 90 | $data = array( |
| 91 | 'installed_version' => MONSTERINSIGHTS_VERSION, |
| 92 | 'installed_date' => time(), |
| 93 | 'installed_pro' => monsterinsights_is_pro_version(), |
| 94 | ); |
| 95 | } else { |
| 96 | $data = $activated; |
| 97 | } |
| 98 | // If already has a UA code mark as connected now. |
| 99 | if ( ! empty( $v4_code ) ) { |
| 100 | $data['connected_date'] = time(); |
| 101 | } |
| 102 | |
| 103 | update_option( 'monsterinsights_over_time', $data, false ); |
| 104 | |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | // Only proceed with displaying if the user is tracking. |
| 109 | if ( empty( $v4_code ) ) { |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | $feedback_url = add_query_arg( array( |
| 114 | 'wpf192157_24' => untrailingslashit( home_url() ), |
| 115 | 'wpf192157_26' => monsterinsights_get_license_key(), |
| 116 | 'wpf192157_27' => monsterinsights_is_pro_version() ? 'pro' : 'lite', |
| 117 | 'wpf192157_28' => MONSTERINSIGHTS_VERSION, |
| 118 | ), 'https://www.monsterinsights.com/plugin-feedback/' ); |
| 119 | $feedback_url = monsterinsights_get_url( 'review-notice', 'feedback', $feedback_url ); |
| 120 | ?> |
| 121 | <div class="notice notice-info is-dismissible monsterinsights-review-notice"> |
| 122 | <div class="monsterinsights-review-step"> |
| 123 | <p> |
| 124 | <?php |
| 125 | echo wp_kses( |
| 126 | sprintf( |
| 127 | __( 'Hey - we noticed you\'ve been using %1$s for a while - that\'s great! Could you do us a BIG favor and give it a 5-star review on WordPress to help us spread the word and boost our motivation?', 'google-analytics-for-wordpress' ), |
| 128 | '<strong>MonsterInsights</strong>' |
| 129 | ), |
| 130 | array( 'strong' => array() ) |
| 131 | ); |
| 132 | ?> |
| 133 | </p> |
| 134 | <p> |
| 135 | <a |
| 136 | href="https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/?filter=5#new-post" |
| 137 | class="monsterinsights-dismiss-review-notice monsterinsights-review-out" |
| 138 | target="_blank" |
| 139 | rel="noopener noreferrer" |
| 140 | > |
| 141 | <?php esc_html_e( 'Ok, you deserve it', 'google-analytics-for-wordpress' ); ?> |
| 142 | </a> |
| 143 | <br> |
| 144 | <a |
| 145 | href="#" |
| 146 | class="monsterinsights-dismiss-review-notice monsterinsights-review-later" |
| 147 | rel="noopener noreferrer" |
| 148 | > |
| 149 | <?php esc_html_e( 'Nope, maybe later', 'google-analytics-for-wordpress' ); ?> |
| 150 | </a> |
| 151 | <br> |
| 152 | <a |
| 153 | href="#" |
| 154 | class="monsterinsights-dismiss-review-notice" |
| 155 | rel="noopener noreferrer" |
| 156 | > |
| 157 | <?php esc_html_e( 'I already did', 'google-analytics-for-wordpress' ); ?> |
| 158 | </a> |
| 159 | </p> |
| 160 | </div> |
| 161 | </div> |
| 162 | <script type="text/javascript"> |
| 163 | jQuery(document).ready(function ($) { |
| 164 | $(document).on('click', '.monsterinsights-dismiss-review-notice', function (event) { |
| 165 | if (!$(this).hasClass('monsterinsights-review-out')) { |
| 166 | event.preventDefault(); |
| 167 | } |
| 168 | $.post(ajaxurl, { |
| 169 | action: 'monsterinsights_review_dismiss', |
| 170 | review_later: $(this).hasClass('monsterinsights-review-later') |
| 171 | }); |
| 172 | $('.monsterinsights-review-notice').remove(); |
| 173 | }); |
| 174 | }); |
| 175 | </script> |
| 176 | <?php |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Dismiss the review admin notice |
| 181 | * |
| 182 | * @since 7.0.7 |
| 183 | */ |
| 184 | public function review_dismiss() { |
| 185 | $review = get_option( 'monsterinsights_review', array() ); |
| 186 | $review['time'] = time(); |
| 187 | $review['dismissed'] = true; |
| 188 | update_option( 'monsterinsights_review', $review ); |
| 189 | |
| 190 | if ( is_super_admin() && is_multisite() ) { |
| 191 | $site_list = get_sites(); |
| 192 | foreach ( (array) $site_list as $site ) { |
| 193 | switch_to_blog( $site->blog_id ); |
| 194 | |
| 195 | update_option( 'monsterinsights_review', $review ); |
| 196 | |
| 197 | restore_current_blog(); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | die; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | new MonsterInsights_Review(); |
| 206 |