@@ -29,64 +29,64 @@ discard block |
||
29 | 29 | <!-- Tabs --> |
30 | 30 | <h1 id="monsterinsights-settings-page-sub-nav" class="monsterinsights-sub-nav-container monsterinsights-nav-container" data-container="#monsterinsights-settings-sub-pages"> |
31 | 31 | <?php |
32 | - $i = 0; |
|
33 | - $class = ''; |
|
34 | - $is_pro = monsterinsights_is_pro_version(); |
|
35 | - foreach ( (array) monsterinsights_get_settings_tabs() as $id => $item ) { |
|
36 | - if ( isset( $item['comingsoon'] ) && $item['comingsoon'] || empty( $item['title'] ) ) { |
|
37 | - continue; |
|
38 | - } |
|
39 | - $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
40 | - ?> |
|
32 | + $i = 0; |
|
33 | + $class = ''; |
|
34 | + $is_pro = monsterinsights_is_pro_version(); |
|
35 | + foreach ( (array) monsterinsights_get_settings_tabs() as $id => $item ) { |
|
36 | + if ( isset( $item['comingsoon'] ) && $item['comingsoon'] || empty( $item['title'] ) ) { |
|
37 | + continue; |
|
38 | + } |
|
39 | + $class = ( 0 === $i ? 'monsterinsights-active' : '' ); |
|
40 | + ?> |
|
41 | 41 | <a class="monsterinsights-sub-nav-item monsterinsights-nav-item monsterinsights-active monstericon-<?php echo esc_attr( $id ); ?> <?php echo esc_attr( $class ); ?>" href="#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-<?php echo esc_attr( $id ); ?>" title="<?php echo esc_attr( $item['title'] ); ?>"> |
42 | 42 | <?php echo esc_html( $item['title'] ); ?> |
43 | 43 | </a> |
44 | 44 | <?php |
45 | - $i++; |
|
46 | - } |
|
47 | - ?> |
|
45 | + $i++; |
|
46 | + } |
|
47 | + ?> |
|
48 | 48 | </h1> |
49 | 49 | |
50 | 50 | <h1 class="monsterinsights-hideme"></h1><!-- so wp notices are below the nav bar --> |
51 | 51 | |
52 | 52 | <?php |
53 | - // Output any notices now |
|
54 | - /** |
|
55 | - * Developer Alert: |
|
56 | - * |
|
57 | - * Per the README, this is considered an internal hook and should |
|
58 | - * not be used by other developers. This hook's behavior may be modified |
|
59 | - * or the hook may be removed at any time, without warning. |
|
60 | - */ |
|
61 | - do_action( 'monsterinsights_settings_tracking_tab_notice' ); |
|
62 | - ?> |
|
53 | + // Output any notices now |
|
54 | + /** |
|
55 | + * Developer Alert: |
|
56 | + * |
|
57 | + * Per the README, this is considered an internal hook and should |
|
58 | + * not be used by other developers. This hook's behavior may be modified |
|
59 | + * or the hook may be removed at any time, without warning. |
|
60 | + */ |
|
61 | + do_action( 'monsterinsights_settings_tracking_tab_notice' ); |
|
62 | + ?> |
|
63 | 63 | |
64 | 64 | <!-- Tab Panels --> |
65 | 65 | <div id="monsterinsights-settings-sub-pages" class="monsterinsights-sub-nav-tabs monsterinsights-nav-tabs" data-navigation="#monsterinsights-settings-page-sub-nav"> |
66 | 66 | <?php |
67 | - $i = 0; |
|
68 | - foreach ( (array) monsterinsights_get_settings_tabs() as $id => $item ) { |
|
69 | - if ( isset( $item['comingsoon'] ) && $item['comingsoon'] || empty( $item['title'] ) ) { |
|
70 | - continue; |
|
71 | - } |
|
72 | - $class = ( 0 === $i ? ' monsterinsights-active' : '' ); |
|
73 | - ?> |
|
67 | + $i = 0; |
|
68 | + foreach ( (array) monsterinsights_get_settings_tabs() as $id => $item ) { |
|
69 | + if ( isset( $item['comingsoon'] ) && $item['comingsoon'] || empty( $item['title'] ) ) { |
|
70 | + continue; |
|
71 | + } |
|
72 | + $class = ( 0 === $i ? ' monsterinsights-active' : '' ); |
|
73 | + ?> |
|
74 | 74 | <div id="monsterinsights-sub-tab-<?php echo esc_attr( $id ); ?>" class="monsterinsights-sub-nav-tab monsterinsights-nav-tab<?php echo esc_attr( $class ); ?>"> |
75 | 75 | <?php if ( $item['level'] === 'lite' || $is_pro ) { ?> |
76 | 76 | <?php echo '<h2 class="monsterinsights-sub-tab-header">' . esc_html( $item['title'] ) . '</h2>'; ?> |
77 | 77 | <?php } ?> |
78 | 78 | <div class="monsterinsights-subtab-settings-notices"> |
79 | 79 | <?php |
80 | - // Output any notices now |
|
81 | - /** |
|
82 | - * Developer Alert: |
|
83 | - * |
|
84 | - * Per the README, this is considered an internal hook and should |
|
85 | - * not be used by other developers. This hook's behavior may be modified |
|
86 | - * or the hook may be removed at any time, without warning. |
|
87 | - */ |
|
88 | - do_action( 'monsterinsights_tracking_' . $id . '_tab_notice' ); |
|
89 | - ?> |
|
80 | + // Output any notices now |
|
81 | + /** |
|
82 | + * Developer Alert: |
|
83 | + * |
|
84 | + * Per the README, this is considered an internal hook and should |
|
85 | + * not be used by other developers. This hook's behavior may be modified |
|
86 | + * or the hook may be removed at any time, without warning. |
|
87 | + */ |
|
88 | + do_action( 'monsterinsights_tracking_' . $id . '_tab_notice' ); |
|
89 | + ?> |
|
90 | 90 | </div> |
91 | 91 | <!-- Settings Form --> |
92 | 92 | <?php $class = ( $item['level'] !== 'lite' && ! $is_pro ) ? 'monsterinsights-no-settings-shown' : ''; ?> |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | <table class="form-table"> |
95 | 95 | <tbody> |
96 | 96 | <?php |
97 | - //do_action( 'monsterinsights_settings_tab_top_' . $id ); |
|
98 | - echo monsterinsights_get_section_settings( $id, 'tracking' ); |
|
99 | - //do_action( 'monsterinsights_settings_tab_bottom_' . $id ); |
|
100 | - ?> |
|
97 | + //do_action( 'monsterinsights_settings_tab_top_' . $id ); |
|
98 | + echo monsterinsights_get_section_settings( $id, 'tracking' ); |
|
99 | + //do_action( 'monsterinsights_settings_tab_bottom_' . $id ); |
|
100 | + ?> |
|
101 | 101 | </tbody> |
102 | 102 | </table> |
103 | 103 | <?php echo monsterinsights_render_submit_field( $id, 'tracking' ); ?> |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | </form> |
111 | 111 | </div> |
112 | 112 | <?php |
113 | - $i++; |
|
114 | - } |
|
115 | - ?> |
|
113 | + $i++; |
|
114 | + } |
|
115 | + ?> |
|
116 | 116 | </div> |
117 | 117 | </div> |
118 | 118 | <?php |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | $network_license = get_site_option( 'monsterinsights_license' ); |
34 | 34 | if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty ( $network_license ) ) ) { |
35 | - $site_license = get_option( 'monsterinsights_license' ); |
|
36 | - $license_key = ! empty( $site_license['key'] ) ? esc_attr( $site_license['key'] ) : ''; |
|
37 | - $license_key_type = ! empty( $site_license['type'] ) ? esc_html( $site_license['type'] ) : ''; |
|
35 | + $site_license = get_option( 'monsterinsights_license' ); |
|
36 | + $license_key = ! empty( $site_license['key'] ) ? esc_attr( $site_license['key'] ) : ''; |
|
37 | + $license_key_type = ! empty( $site_license['type'] ) ? esc_html( $site_license['type'] ) : ''; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $profile_name = monsterinsights_get_option( 'analytics_profile_name', '' ); |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | <div id="monsterinsights-settings-general"> |
48 | 48 | <div class="monsterinsights-tab-settings-notices"> |
49 | 49 | <?php |
50 | - // Output any notices now |
|
51 | - /** |
|
52 | - * Developer Alert: |
|
53 | - * |
|
54 | - * Per the README, this is considered an internal hook and should |
|
55 | - * not be used by other developers. This hook's behavior may be modified |
|
56 | - * or the hook may be removed at any time, without warning. |
|
57 | - */ |
|
58 | - do_action( 'monsterinsights_settings_general_tab_notice' ); |
|
59 | - ?> |
|
50 | + // Output any notices now |
|
51 | + /** |
|
52 | + * Developer Alert: |
|
53 | + * |
|
54 | + * Per the README, this is considered an internal hook and should |
|
55 | + * not be used by other developers. This hook's behavior may be modified |
|
56 | + * or the hook may be removed at any time, without warning. |
|
57 | + */ |
|
58 | + do_action( 'monsterinsights_settings_general_tab_notice' ); |
|
59 | + ?> |
|
60 | 60 | </div> |
61 | 61 | <table class="form-table"> |
62 | 62 | <tbody> |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | |
141 | 141 | <!-- Disable Dashboard --> |
142 | 142 | <?php |
143 | - $title = esc_html__( 'Disable Dashboard', 'google-analytics-for-wordpress' ); |
|
144 | - $description = esc_html__( 'Hide the dashboard and reports pages.', 'google-analytics-for-wordpress' ); |
|
145 | - echo monsterinsights_make_checkbox( 'dashboards_disabled', $title, $description ); |
|
146 | - ?> |
|
143 | + $title = esc_html__( 'Disable Dashboard', 'google-analytics-for-wordpress' ); |
|
144 | + $description = esc_html__( 'Hide the dashboard and reports pages.', 'google-analytics-for-wordpress' ); |
|
145 | + echo monsterinsights_make_checkbox( 'dashboards_disabled', $title, $description ); |
|
146 | + ?> |
|
147 | 147 | |
148 | 148 | <?php if ( $tracking_mode === 'ga' || monsterinsights_is_debug_mode() ){ ?> |
149 | 149 | <tr id="monsterinsights-tracking-mode"> |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | </th> |
153 | 153 | <td> |
154 | 154 | <?php |
155 | - $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_analyticsjs', 'return' => 'general' ) ), 'monsterinsights-switch-to-analyticsjs-nonce' ) ); |
|
156 | - ?> |
|
155 | + $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_analyticsjs', 'return' => 'general' ) ), 'monsterinsights-switch-to-analyticsjs-nonce' ) ); |
|
156 | + ?> |
|
157 | 157 | <label><input type="radio" name="tracking_mode" value="ga" <?php checked( $tracking_mode, 'ga' ); ?> ><?php esc_html_e('GA.js (Deprecated)', 'google-analytics-for-wordpress'); ?> </label> |
158 | 158 | <label><input type="radio" name="tracking_mode" value="analytics" <?php checked( $tracking_mode, 'analytics' ); ?> ><?php esc_html_e( 'Analytics.js (Universal Analytics)', 'google-analytics-for-wordpress'); ?> </label> |
159 | 159 | <?php if ($tracking_mode === 'ga' ) { ?> |
160 | 160 | <?php echo monsterinsights_get_message( 'error', sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) ); |
161 | - ?> |
|
161 | + ?> |
|
162 | 162 | <?php } ?> |
163 | 163 | </td> |
164 | 164 | </tr> |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | </th> |
172 | 172 | <td> |
173 | 173 | <?php |
174 | - $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_jsevents', 'return' => 'general' ) ), 'monsterinsights-switch-to-jsevents-nonce' ) ); |
|
175 | - ?> |
|
174 | + $url = esc_url( wp_nonce_url( add_query_arg( array( 'monsterinsights-action' => 'switch_to_jsevents', 'return' => 'general' ) ), 'monsterinsights-switch-to-jsevents-nonce' ) ); |
|
175 | + ?> |
|
176 | 176 | <?php echo monsterinsights_get_message( 'error', sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking and we will eventually discontinue PHP based events tracking. To switch %1$sclick here%2$s.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ) ); |
177 | - ?> |
|
177 | + ?> |
|
178 | 178 | </td> |
179 | 179 | </tr> |
180 | 180 | <?php } ?> |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | |
196 | 196 | <!-- Tracking --> |
197 | 197 | <?php |
198 | - $title = esc_html__( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ); |
|
199 | - $description = esc_html__( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ); |
|
200 | - if ( ! $anon_tracking || monsterinsights_is_debug_mode() ){ |
|
201 | - echo monsterinsights_make_checkbox( 'anonymous_data', $title, $description ); |
|
202 | - } |
|
203 | - ?> |
|
198 | + $title = esc_html__( 'Allow Usage Tracking', 'google-analytics-for-wordpress' ); |
|
199 | + $description = esc_html__( 'By allowing us to track usage data we can better help you, because we know with which WordPress configurations, themes and plugins we should test.', 'google-analytics-for-wordpress' ); |
|
200 | + if ( ! $anon_tracking || monsterinsights_is_debug_mode() ){ |
|
201 | + echo monsterinsights_make_checkbox( 'anonymous_data', $title, $description ); |
|
202 | + } |
|
203 | + ?> |
|
204 | 204 | |
205 | 205 | <?php |
206 | - /** |
|
207 | - * Developer Alert: |
|
208 | - * |
|
209 | - * Per the README, this is considered an internal hook and should |
|
210 | - * not be used by other developers. This hook's behavior may be modified |
|
211 | - * or the hook may be removed at any time, without warning. |
|
212 | - */ |
|
213 | - do_action( 'monsterinsights_settings_general_box' ); |
|
214 | - ?> |
|
206 | + /** |
|
207 | + * Developer Alert: |
|
208 | + * |
|
209 | + * Per the README, this is considered an internal hook and should |
|
210 | + * not be used by other developers. This hook's behavior may be modified |
|
211 | + * or the hook may be removed at any time, without warning. |
|
212 | + */ |
|
213 | + do_action( 'monsterinsights_settings_general_box' ); |
|
214 | + ?> |
|
215 | 215 | </tbody> |
216 | 216 | </table> |
217 | 217 | <input type="hidden" name="monsterinsights_settings_tab" value="general"/> |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | $manual_ua_code = monsterinsights_is_valid_ua( $manual_ua_code ); // also sanitizes the string |
238 | 238 | |
239 | 239 | if ( $manual_ua_code ) { |
240 | - monsterinsights_update_option( 'manual_ua_code', $manual_ua_code ); |
|
240 | + monsterinsights_update_option( 'manual_ua_code', $manual_ua_code ); |
|
241 | 241 | } else { |
242 | - if ( empty ( $manual_ua_code ) && ! empty( $_POST['manual_ua_code'] ) ) { |
|
243 | - $throw_notice = true; |
|
244 | - } |
|
245 | - monsterinsights_update_option( 'manual_ua_code', '' ); |
|
242 | + if ( empty ( $manual_ua_code ) && ! empty( $_POST['manual_ua_code'] ) ) { |
|
243 | + $throw_notice = true; |
|
244 | + } |
|
245 | + monsterinsights_update_option( 'manual_ua_code', '' ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | $dashboards_disabled = isset( $_POST['dashboards_disabled'] ) ? 1 : 0; |
@@ -252,39 +252,39 @@ discard block |
||
252 | 252 | $tracking_mode = isset( $_POST['tracking_mode'] ) ? $_POST['tracking_mode'] : 'analytics'; |
253 | 253 | |
254 | 254 | if ( $old_tracking_mode === 'ga' || monsterinsights_is_debug_mode() ) { |
255 | - if ( $tracking_mode !== 'analytics' && $tracking_mode !== 'ga' ) { |
|
256 | - /** |
|
257 | - * Developer Alert: |
|
258 | - * |
|
259 | - * Per the README, this is considered an internal hook and should |
|
260 | - * not be used by other developers. This hook's behavior may be modified |
|
261 | - * or the hook may be removed at any time, without warning. |
|
262 | - */ |
|
263 | - $tracking_mode = apply_filters( 'monsterinsights_settings_save_general_tracking_mode', 'analytics' ); |
|
264 | - } |
|
265 | - monsterinsights_update_option( 'tracking_mode', $tracking_mode ); |
|
255 | + if ( $tracking_mode !== 'analytics' && $tracking_mode !== 'ga' ) { |
|
256 | + /** |
|
257 | + * Developer Alert: |
|
258 | + * |
|
259 | + * Per the README, this is considered an internal hook and should |
|
260 | + * not be used by other developers. This hook's behavior may be modified |
|
261 | + * or the hook may be removed at any time, without warning. |
|
262 | + */ |
|
263 | + $tracking_mode = apply_filters( 'monsterinsights_settings_save_general_tracking_mode', 'analytics' ); |
|
264 | + } |
|
265 | + monsterinsights_update_option( 'tracking_mode', $tracking_mode ); |
|
266 | 266 | } else { |
267 | - if ( $tracking_mode !== 'analytics' ) { |
|
268 | - /** |
|
269 | - * Developer Alert: |
|
270 | - * |
|
271 | - * Per the README, this is considered an internal hook and should |
|
272 | - * not be used by other developers. This hook's behavior may be modified |
|
273 | - * or the hook may be removed at any time, without warning. |
|
274 | - */ |
|
275 | - $tracking_mode = apply_filters( 'monsterinsights_settings_save_general_tracking_mode', 'analytics' ); |
|
276 | - } |
|
277 | - monsterinsights_update_option( 'tracking_mode', $tracking_mode ); |
|
267 | + if ( $tracking_mode !== 'analytics' ) { |
|
268 | + /** |
|
269 | + * Developer Alert: |
|
270 | + * |
|
271 | + * Per the README, this is considered an internal hook and should |
|
272 | + * not be used by other developers. This hook's behavior may be modified |
|
273 | + * or the hook may be removed at any time, without warning. |
|
274 | + */ |
|
275 | + $tracking_mode = apply_filters( 'monsterinsights_settings_save_general_tracking_mode', 'analytics' ); |
|
276 | + } |
|
277 | + monsterinsights_update_option( 'tracking_mode', $tracking_mode ); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | $automatic_updates = isset( $_POST['automatic_updates'] ) && in_array( $_POST['automatic_updates'], array( 'all', 'minor', 'none' ) ) ? $_POST['automatic_updates'] : false; |
281 | 281 | if ( $automatic_updates ) { |
282 | - monsterinsights_update_option( 'automatic_updates', $automatic_updates ); |
|
282 | + monsterinsights_update_option( 'automatic_updates', $automatic_updates ); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | $anonymous_data = isset( $_POST['anonymous_data'] ) ? 1 : 0; |
286 | 286 | if ( $anonymous_data ) { |
287 | - monsterinsights_update_option( 'anonymous_data', $anonymous_data ); |
|
287 | + monsterinsights_update_option( 'anonymous_data', $anonymous_data ); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | |
299 | 299 | // Output an admin notice so the user knows what happened |
300 | 300 | if ( $throw_notice ) { |
301 | - add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_invalid_ua_code' ); |
|
301 | + add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_invalid_ua_code' ); |
|
302 | 302 | } else { |
303 | - add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_updated_settings' ); |
|
303 | + add_action( 'monsterinsights_settings_general_tab_notice', 'monsterinsights_updated_settings' ); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | add_action( 'monsterinsights_settings_save_general', 'monsterinsights_settings_save_general', 11 ); |
307 | 307 | \ No newline at end of file |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | ?> |
27 | 27 | <div id="monsterinsights-settings-general"> |
28 | 28 | <?php |
29 | - ?> |
|
29 | + ?> |
|
30 | 30 | <?php //Status page coming soon. ?> |
31 | 31 | <!-- <hr /> --> |
32 | 32 | </div> |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function monsterinsights_system_info() { |
42 | 42 | if ( ! empty( $_REQUEST['monsterinsights-action'] ) && $_REQUEST['monsterinsights-action'] === 'download_sysinfo' ) { |
43 | - if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
44 | - return; |
|
45 | - } |
|
46 | - nocache_headers(); |
|
47 | - header( 'Content-Type: text/plain' ); |
|
48 | - header( 'Content-Disposition: attachment; filename="monsterinsights-system-info.txt"' ); |
|
49 | - echo wp_strip_all_tags( $_POST['monsterinsights-sysinfo'] ); |
|
50 | - die(); |
|
43 | + if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { |
|
44 | + return; |
|
45 | + } |
|
46 | + nocache_headers(); |
|
47 | + header( 'Content-Type: text/plain' ); |
|
48 | + header( 'Content-Disposition: attachment; filename="monsterinsights-system-info.txt"' ); |
|
49 | + echo wp_strip_all_tags( $_POST['monsterinsights-sysinfo'] ); |
|
50 | + die(); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | //add_action( 'admin_init', 'monsterinsights_system_info' ); |
54 | 54 | \ No newline at end of file |
@@ -34,54 +34,54 @@ |
||
34 | 34 | */ |
35 | 35 | function monsterinsights_add_capabilities( $caps, $cap, $user_id, $args ) { |
36 | 36 | switch( $cap ) { |
37 | - case 'monsterinsights_view_dashboard' : |
|
38 | - $roles = monsterinsights_get_option( 'view_reports', array() ); |
|
37 | + case 'monsterinsights_view_dashboard' : |
|
38 | + $roles = monsterinsights_get_option( 'view_reports', array() ); |
|
39 | 39 | |
40 | - $user_can_via_settings = false; |
|
41 | - if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
42 | - foreach ( $roles as $role ) { |
|
43 | - if ( is_string( $role ) ) { |
|
44 | - if ( user_can( $user_id, $role ) ) { |
|
45 | - $user_can_via_settings = true; |
|
46 | - break; |
|
47 | - } |
|
48 | - } |
|
49 | - } |
|
50 | - } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
51 | - if ( user_can( $user_id, $roles ) ) { |
|
52 | - $user_can_via_settings = true; |
|
53 | - } |
|
54 | - } |
|
40 | + $user_can_via_settings = false; |
|
41 | + if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
42 | + foreach ( $roles as $role ) { |
|
43 | + if ( is_string( $role ) ) { |
|
44 | + if ( user_can( $user_id, $role ) ) { |
|
45 | + $user_can_via_settings = true; |
|
46 | + break; |
|
47 | + } |
|
48 | + } |
|
49 | + } |
|
50 | + } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
51 | + if ( user_can( $user_id, $roles ) ) { |
|
52 | + $user_can_via_settings = true; |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | - if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
57 | - $caps = array(); |
|
58 | - } |
|
56 | + if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
57 | + $caps = array(); |
|
58 | + } |
|
59 | 59 | |
60 | - break; |
|
61 | - case 'monsterinsights_save_settings' : |
|
62 | - $roles = monsterinsights_get_option( 'save_settings', array() ); |
|
60 | + break; |
|
61 | + case 'monsterinsights_save_settings' : |
|
62 | + $roles = monsterinsights_get_option( 'save_settings', array() ); |
|
63 | 63 | |
64 | - $user_can_via_settings = false; |
|
65 | - if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
66 | - foreach ( $roles as $role ) { |
|
67 | - if ( is_string( $role ) ) { |
|
68 | - if ( user_can( $user_id, $role ) ) { |
|
69 | - $user_can_via_settings = true; |
|
70 | - break; |
|
71 | - } |
|
72 | - } |
|
73 | - } |
|
74 | - } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
75 | - if ( user_can( $user_id, $roles ) ) { |
|
76 | - $user_can_via_settings = true; |
|
77 | - } |
|
78 | - } |
|
64 | + $user_can_via_settings = false; |
|
65 | + if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
66 | + foreach ( $roles as $role ) { |
|
67 | + if ( is_string( $role ) ) { |
|
68 | + if ( user_can( $user_id, $role ) ) { |
|
69 | + $user_can_via_settings = true; |
|
70 | + break; |
|
71 | + } |
|
72 | + } |
|
73 | + } |
|
74 | + } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
75 | + if ( user_can( $user_id, $roles ) ) { |
|
76 | + $user_can_via_settings = true; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
81 | - $caps = array(); |
|
82 | - } |
|
80 | + if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
81 | + $caps = array(); |
|
82 | + } |
|
83 | 83 | |
84 | - break; |
|
84 | + break; |
|
85 | 85 | } |
86 | 86 | return $caps; |
87 | 87 | } |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | $hook = 'monsterinsights_settings'; |
33 | 33 | |
34 | 34 | if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) { |
35 | - // If dashboards disabled, first settings page |
|
36 | - add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' ); |
|
37 | - $hook = 'monsterinsights_settings'; |
|
35 | + // If dashboards disabled, first settings page |
|
36 | + add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' ); |
|
37 | + $hook = 'monsterinsights_settings'; |
|
38 | 38 | |
39 | - add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' ); |
|
39 | + add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' ); |
|
40 | 40 | } else { |
41 | - // if dashboards enabled, first dashboard |
|
42 | - add_menu_page( __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard', 'monsterinsights_dashboard_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' ); |
|
41 | + // if dashboards enabled, first dashboard |
|
42 | + add_menu_page( __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard', 'monsterinsights_dashboard_page', plugins_url( 'assets/css/images/[email protected]', $base->file ), '100.00013467543' ); |
|
43 | 43 | |
44 | - $hook = 'monsterinsights_dashboard'; |
|
44 | + $hook = 'monsterinsights_dashboard'; |
|
45 | 45 | |
46 | - add_submenu_page( $hook, __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Dashboard', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard' ); |
|
46 | + add_submenu_page( $hook, __( 'Dashboard:', 'google-analytics-for-wordpress' ), __( 'Dashboard', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_dashboard' ); |
|
47 | 47 | |
48 | - // then settings page |
|
49 | - add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' ); |
|
48 | + // then settings page |
|
49 | + add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if ( ! $dashboards_disabled ) { |
53 | - // then reports |
|
54 | - add_submenu_page( $hook, __( 'Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' ); |
|
53 | + // then reports |
|
54 | + add_submenu_page( $hook, __( 'Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // then tools |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | // then addons |
61 | 61 | $network_license = get_site_option( 'monsterinsights_license' ); |
62 | 62 | if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_license ) ) ) { |
63 | - add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:#7cc048"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', 'monsterinsights_addons', 'monsterinsights_addons_page' ); |
|
63 | + add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:#7cc048"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', 'monsterinsights_addons', 'monsterinsights_addons_page' ); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | add_action( 'admin_menu', 'monsterinsights_admin_menu' ); |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | // First, let's see if this is an MS network enabled plugin. If it is, we should load the license |
75 | 75 | // menu page and the updater on the network panel |
76 | 76 | if ( ! function_exists( 'is_plugin_active_for_network' ) ) { |
77 | - require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
|
77 | + require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ); |
81 | 81 | if ( ! is_plugin_active_for_network( $plugin ) ) { |
82 | - return; |
|
82 | + return; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $hook = 'monsterinsights_network'; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | function monsterinsights_add_admin_body_class( $classes ) { |
102 | 102 | $screen = get_current_screen(); |
103 | 103 | if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
104 | - return $classes; |
|
104 | + return $classes; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return "$classes monsterinsights_page "; |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | |
122 | 122 | // If lite, show a link where they can get pro from |
123 | 123 | if ( ! monsterinsights_is_pro_version() ) { |
124 | - $get_pro = '<a title="Get MonsterInsights Pro" href="https://www.monsterinsights.com/upgrade-to-pro/">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>'; |
|
125 | - array_unshift( $links, $get_pro ); |
|
124 | + $get_pro = '<a title="Get MonsterInsights Pro" href="https://www.monsterinsights.com/upgrade-to-pro/">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>'; |
|
125 | + array_unshift( $links, $get_pro ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // If Lite, support goes to forum. If pro, it goes to our website |
129 | 129 | if ( monsterinsights_is_pro_version() ) { |
130 | - $support = '<a title="MonsterInsights Pro Support" href="https://www.monsterinsights.com/my-account/support/">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>'; |
|
131 | - array_unshift( $links, $support ); |
|
130 | + $support = '<a title="MonsterInsights Pro Support" href="https://www.monsterinsights.com/my-account/support/">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>'; |
|
131 | + array_unshift( $links, $support ); |
|
132 | 132 | } else { |
133 | - $support = '<a title="MonsterInsights Lite Support" href="https://wordpress.org/support/plugin/google-analytics-for-wordpress">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>'; |
|
134 | - array_unshift( $links, $support ); |
|
133 | + $support = '<a title="MonsterInsights Lite Support" href="https://wordpress.org/support/plugin/google-analytics-for-wordpress">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>'; |
|
134 | + array_unshift( $links, $support ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>'; |
@@ -158,26 +158,26 @@ discard block |
||
158 | 158 | $base = MonsterInsights(); |
159 | 159 | |
160 | 160 | if ( monsterinsights_is_pro_version() ) { |
161 | - $dir = trailingslashit( plugin_dir_path( $base->file ) . 'pro/includes/admin/partials' ); |
|
161 | + $dir = trailingslashit( plugin_dir_path( $base->file ) . 'pro/includes/admin/partials' ); |
|
162 | 162 | |
163 | - if ( file_exists( $dir . $template . '.php' ) ) { |
|
164 | - require_once( $dir . $template . '.php' ); |
|
165 | - return true; |
|
166 | - } |
|
163 | + if ( file_exists( $dir . $template . '.php' ) ) { |
|
164 | + require_once( $dir . $template . '.php' ); |
|
165 | + return true; |
|
166 | + } |
|
167 | 167 | } else { |
168 | - $dir = trailingslashit( plugin_dir_path( $base->file ) . 'lite/includes/admin/partials' ); |
|
168 | + $dir = trailingslashit( plugin_dir_path( $base->file ) . 'lite/includes/admin/partials' ); |
|
169 | 169 | |
170 | - if ( file_exists( $dir . $template . '.php' ) ) { |
|
171 | - require_once( $dir . $template . '.php' ); |
|
172 | - return true; |
|
173 | - } |
|
170 | + if ( file_exists( $dir . $template . '.php' ) ) { |
|
171 | + require_once( $dir . $template . '.php' ); |
|
172 | + return true; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $dir = trailingslashit( plugin_dir_path( $base->file ) . 'includes/admin/partials' ); |
177 | 177 | |
178 | 178 | if ( file_exists( $dir . $template . '.php' ) ) { |
179 | - require_once( $dir . $template . '.php' ); |
|
180 | - return true; |
|
179 | + require_once( $dir . $template . '.php' ); |
|
180 | + return true; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return false; |
@@ -196,15 +196,15 @@ discard block |
||
196 | 196 | // Get the current screen, and check whether we're viewing a MonsterInsights screen; |
197 | 197 | $screen = get_current_screen(); |
198 | 198 | if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { |
199 | - return; |
|
199 | + return; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // If here, we're on an MonsterInsights screen, so output the header. |
203 | 203 | monsterinsights_load_admin_partial( 'header', array( |
204 | - 'mascot' => plugins_url( 'assets/css/images/mascot.png', $base->file ), |
|
205 | - 'logo' => plugins_url( 'assets/css/images/logo.png', $base->file ), |
|
206 | - '2xmascot' => plugins_url( 'assets/css/images/[email protected]', $base->file ), |
|
207 | - '2xlogo' => plugins_url( 'assets/css/images/[email protected]', $base->file ), |
|
204 | + 'mascot' => plugins_url( 'assets/css/images/mascot.png', $base->file ), |
|
205 | + 'logo' => plugins_url( 'assets/css/images/logo.png', $base->file ), |
|
206 | + '2xmascot' => plugins_url( 'assets/css/images/[email protected]', $base->file ), |
|
207 | + '2xlogo' => plugins_url( 'assets/css/images/[email protected]', $base->file ), |
|
208 | 208 | ) ); |
209 | 209 | } |
210 | 210 | add_action( 'in_admin_header','monsterinsights_admin_header', 100 ); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | function monsterinsights_welcome_redirect() { |
213 | 213 | // Bail if no activation redirect |
214 | 214 | if ( ! get_transient( '_monsterinsights_activation_redirect' ) ) { |
215 | - return; |
|
215 | + return; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | // Delete the redirect transient |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | |
221 | 221 | // Bail if activating from network, or bulk |
222 | 222 | if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
223 | - return; |
|
223 | + return; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $upgrade = get_option( 'monsterinsights_version_upgraded_from' ); |
227 | 227 | if( ! $upgrade ) { // First time install |
228 | - //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit; |
|
228 | + //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit; |
|
229 | 229 | } else { // Update |
230 | - return; |
|
231 | - //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit; |
|
230 | + return; |
|
231 | + //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | //add_action( 'admin_init', 'monsterinsights_welcome_redirect', 11 ); @todo: Investigate |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | function monsterinsights_admin_footer( $text ) { |
245 | 245 | global $current_screen; |
246 | 246 | if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) { |
247 | - $url = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5'; |
|
248 | - $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' . $url . '" target="_blank" rel="noopener noreferrer">★★★★★</a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' ); |
|
247 | + $url = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5'; |
|
248 | + $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' . $url . '" target="_blank" rel="noopener noreferrer">★★★★★</a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' ); |
|
249 | 249 | } |
250 | 250 | return $text; |
251 | 251 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | // Don't show on MonsterInsights pages |
256 | 256 | $screen = get_current_screen(); |
257 | 257 | if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) { |
258 | - return; |
|
258 | + return; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $analytics = monsterinsights_get_option( 'tracking_mode', 'analytics' ); |
@@ -265,33 +265,33 @@ discard block |
||
265 | 265 | $notices = get_option( 'monsterinsights_notices' ); |
266 | 266 | |
267 | 267 | if ( ! is_array( $notices ) ) { |
268 | - $notices = array(); |
|
268 | + $notices = array(); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | if ( $analytics === 'ga' && ! isset( $notices ['monsterinsights_deprecated_ga' ] ) ){ |
272 | 272 | echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_ga">'; |
273 | - echo '<p>'; |
|
274 | - echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); |
|
275 | - echo '</p>'; |
|
276 | - echo '</div>'; |
|
273 | + echo '<p>'; |
|
274 | + echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated ga.js tracking which we will be removing support for in an upcoming release. We recommend switching to analytics.js, as it is significantly more accurate than ga.js, and allows for functionality (like the more accurate Javascript based events tracking we offer). Further Google Analytics has deprecated support for ga.js, and it may stop working at any time when Google decides to disable it from their server. To switch to using the newer Universal Analytics (analytics.js) %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); |
|
275 | + echo '</p>'; |
|
276 | + echo '</div>'; |
|
277 | 277 | } else if ( $events === 'php' && ! isset( $notices ['monsterinsights_deprecated_php' ] ) ){ |
278 | 278 | echo '<div class="notice notice-error is-dismissible monsterinsights-notice" data-notice="monsterinsights_deprecated_php">'; |
279 | - echo '<p>'; |
|
280 | - echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); |
|
281 | - echo '</p>'; |
|
282 | - echo '</div>'; |
|
279 | + echo '<p>'; |
|
280 | + echo sprintf( esc_html__( 'Warning: You\'re currently using deprecated PHP based events tracking which we will be removing support for in an upcoming release. We recommend switching to JS events tracking, as it is significantly more accurate than PHP based events tracking. To switch %1$sclick here%2$s. Users who do not manually switch over will be automatically switched over in an upcoming release.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); |
|
281 | + echo '</p>'; |
|
282 | + echo '</div>'; |
|
283 | 283 | } else if ( empty( $updates) && ! isset( $notices ['monsterinsights_automatic_updates' ] ) ){ |
284 | - if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) { |
|
285 | - return; |
|
286 | - } |
|
287 | - if ( defined( 'MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE' ) && MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE ) { |
|
288 | - return; |
|
289 | - } |
|
290 | - echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">'; |
|
291 | - echo '<p>'; |
|
292 | - echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); |
|
293 | - echo '</p>'; |
|
294 | - echo '</div>'; |
|
284 | + if ( defined( 'MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE' ) && MONSTERINSIGHTS_SHOWING_EMPTY_CONFIG_NOTICE ) { |
|
285 | + return; |
|
286 | + } |
|
287 | + if ( defined( 'MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE' ) && MONSTERINSIGHTS_SHOWING_OPTIN_TRACKING_NOTICE ) { |
|
288 | + return; |
|
289 | + } |
|
290 | + echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">'; |
|
291 | + echo '<p>'; |
|
292 | + echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' ); |
|
293 | + echo '</p>'; |
|
294 | + echo '</div>'; |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | add_action( 'admin_notices', 'monsterinsights_deprecated_notices' ); |
298 | 298 | \ No newline at end of file |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | 38 | |
39 | - // Populate $notices |
|
40 | - $this->notices = get_option( 'monsterinsights_notices' ); |
|
41 | - if ( ! is_array( $this->notices ) ) { |
|
42 | - $this->notices = array(); |
|
43 | - } |
|
39 | + // Populate $notices |
|
40 | + $this->notices = get_option( 'monsterinsights_notices' ); |
|
41 | + if ( ! is_array( $this->notices ) ) { |
|
42 | + $this->notices = array(); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | */ |
56 | 56 | |
57 | 57 | public function is_dismissed( $notice ) { |
58 | - if ( ! isset( $this->notices[ $notice ] ) ) { |
|
59 | - return false; |
|
60 | - } |
|
61 | - return true; |
|
58 | + if ( ! isset( $this->notices[ $notice ] ) ) { |
|
59 | + return false; |
|
60 | + } |
|
61 | + return true; |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @return null |
73 | 73 | */ |
74 | 74 | public function dismiss( $notice ) { |
75 | - $this->notices[ $notice ] = true; |
|
76 | - update_option( 'monsterinsights_notices', $this->notices ); |
|
75 | + $this->notices[ $notice ] = true; |
|
76 | + update_option( 'monsterinsights_notices', $this->notices ); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @return null |
89 | 89 | */ |
90 | 90 | public function undismiss( $notice ) { |
91 | - unset( $this->notices[ $notice ] ); |
|
92 | - update_option( 'monsterinsights_notices', $this->notices ); |
|
91 | + unset( $this->notices[ $notice ] ); |
|
92 | + update_option( 'monsterinsights_notices', $this->notices ); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param bool $is_dismissible User can Dismiss Message (default: false) |
109 | 109 | */ |
110 | 110 | public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) { |
111 | - /* Available/Planned $args options |
|
111 | + /* Available/Planned $args options |
|
112 | 112 | * $args = array( |
113 | 113 | * 'primary' => array( |
114 | 114 | * 'text' => '', |
@@ -127,110 +127,110 @@ discard block |
||
127 | 127 | */ |
128 | 128 | |
129 | 129 | |
130 | - // Check if the notice is dismissible, and if so has been dismissed. |
|
131 | - if ( $is_dismissible && $this->is_dismissed( $name ) ) { |
|
132 | - // Nothing to show here, return! |
|
133 | - return ''; |
|
134 | - } |
|
130 | + // Check if the notice is dismissible, and if so has been dismissed. |
|
131 | + if ( $is_dismissible && $this->is_dismissed( $name ) ) { |
|
132 | + // Nothing to show here, return! |
|
133 | + return ''; |
|
134 | + } |
|
135 | 135 | |
136 | - $dismissible = ( $is_dismissible ) ? ' is-dismissible': ''; |
|
136 | + $dismissible = ( $is_dismissible ) ? ' is-dismissible': ''; |
|
137 | 137 | |
138 | - // Display inline notice |
|
139 | - ob_start(); |
|
140 | - ?> |
|
138 | + // Display inline notice |
|
139 | + ob_start(); |
|
140 | + ?> |
|
141 | 141 | <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>"> |
142 | 142 | <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>"> |
143 | 143 | </div> |
144 | 144 | <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>"> |
145 | 145 | <?php |
146 | - // Title |
|
147 | - if ( ! empty ( $title ) ) { |
|
148 | - ?> |
|
146 | + // Title |
|
147 | + if ( ! empty ( $title ) ) { |
|
148 | + ?> |
|
149 | 149 | <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p> |
150 | 150 | <?php |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | - // Message |
|
154 | - if ( ! empty( $message ) ) { |
|
155 | - if ( empty( $args['skip_message_escape'] ) ) { |
|
156 | - ?> |
|
153 | + // Message |
|
154 | + if ( ! empty( $message ) ) { |
|
155 | + if ( empty( $args['skip_message_escape'] ) ) { |
|
156 | + ?> |
|
157 | 157 | <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p> |
158 | 158 | <?php |
159 | - } else { |
|
160 | - ?> |
|
159 | + } else { |
|
160 | + ?> |
|
161 | 161 | <p class="monsterinsights-notice-message"><?php echo $message; ?></p> |
162 | 162 | <?php |
163 | - } |
|
164 | - } |
|
163 | + } |
|
164 | + } |
|
165 | 165 | |
166 | - // Primary Button |
|
167 | - if ( ! empty( $args['primary']['text'] ) ) { |
|
166 | + // Primary Button |
|
167 | + if ( ! empty( $args['primary']['text'] ) ) { |
|
168 | 168 | |
169 | - $text = ''; |
|
170 | - if ( ! empty( $args['primary']['text'] ) ) { |
|
171 | - $text = $args['primary']['text']; |
|
172 | - } |
|
173 | - |
|
174 | - $url = '#'; |
|
175 | - if ( ! empty( $args['primary']['url'] ) ) { |
|
176 | - $url = $args['primary']['url']; |
|
177 | - } |
|
178 | - |
|
179 | - $target = ''; |
|
180 | - if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') { |
|
181 | - $target = ' target="_blank" rel="noopener noreferrer"'; |
|
182 | - } |
|
183 | - |
|
184 | - $class = 'button button-primary'; |
|
185 | - if ( ! empty( $args['primary']['class'] ) ) { |
|
186 | - $class = ' class="'. $args['primary']['class'] . '"'; |
|
187 | - } |
|
188 | - ?> |
|
169 | + $text = ''; |
|
170 | + if ( ! empty( $args['primary']['text'] ) ) { |
|
171 | + $text = $args['primary']['text']; |
|
172 | + } |
|
173 | + |
|
174 | + $url = '#'; |
|
175 | + if ( ! empty( $args['primary']['url'] ) ) { |
|
176 | + $url = $args['primary']['url']; |
|
177 | + } |
|
178 | + |
|
179 | + $target = ''; |
|
180 | + if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') { |
|
181 | + $target = ' target="_blank" rel="noopener noreferrer"'; |
|
182 | + } |
|
183 | + |
|
184 | + $class = 'button button-primary'; |
|
185 | + if ( ! empty( $args['primary']['class'] ) ) { |
|
186 | + $class = ' class="'. $args['primary']['class'] . '"'; |
|
187 | + } |
|
188 | + ?> |
|
189 | 189 | <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a> |
190 | 190 | <?php |
191 | - } |
|
191 | + } |
|
192 | 192 | |
193 | - // Secondary Button |
|
194 | - if ( ! empty( $args['secondary']['text'] ) ) { |
|
193 | + // Secondary Button |
|
194 | + if ( ! empty( $args['secondary']['text'] ) ) { |
|
195 | 195 | |
196 | - $text = ''; |
|
197 | - if ( ! empty( $args['secondary']['text'] ) ) { |
|
198 | - $text = $args['secondary']['text']; |
|
199 | - } |
|
200 | - |
|
201 | - $url = '#'; |
|
202 | - if ( ! empty( $args['secondary']['url'] ) ) { |
|
203 | - $url = $args['secondary']['url']; |
|
204 | - } |
|
205 | - |
|
206 | - $target = ''; |
|
207 | - if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') { |
|
208 | - $target = ' target="_blank" rel="noopener noreferrer"'; |
|
209 | - } |
|
210 | - |
|
211 | - $class = 'button button-secondary'; |
|
212 | - if ( ! empty( $args['secondary']['class'] ) ) { |
|
213 | - $class = ' class="'. $args['secondary']['class'] . '"'; |
|
214 | - } |
|
215 | - ?> |
|
196 | + $text = ''; |
|
197 | + if ( ! empty( $args['secondary']['text'] ) ) { |
|
198 | + $text = $args['secondary']['text']; |
|
199 | + } |
|
200 | + |
|
201 | + $url = '#'; |
|
202 | + if ( ! empty( $args['secondary']['url'] ) ) { |
|
203 | + $url = $args['secondary']['url']; |
|
204 | + } |
|
205 | + |
|
206 | + $target = ''; |
|
207 | + if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') { |
|
208 | + $target = ' target="_blank" rel="noopener noreferrer"'; |
|
209 | + } |
|
210 | + |
|
211 | + $class = 'button button-secondary'; |
|
212 | + if ( ! empty( $args['secondary']['class'] ) ) { |
|
213 | + $class = ' class="'. $args['secondary']['class'] . '"'; |
|
214 | + } |
|
215 | + ?> |
|
216 | 216 | <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a> |
217 | 217 | <?php |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - // Dismiss Button |
|
221 | - if ( $is_dismissible ) { |
|
222 | - ?> |
|
220 | + // Dismiss Button |
|
221 | + if ( $is_dismissible ) { |
|
222 | + ?> |
|
223 | 223 | <button type="button" class="notice-dismiss<?php echo $dismissible; ?>"> |
224 | 224 | <span class="screen-reader-text"> |
225 | 225 | <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?> |
226 | 226 | </span> |
227 | 227 | </button> |
228 | 228 | <?php |
229 | - } |
|
230 | - ?> |
|
229 | + } |
|
230 | + ?> |
|
231 | 231 | </div> |
232 | 232 | </div> |
233 | 233 | <?php |
234 | - return ob_get_clean(); |
|
234 | + return ob_get_clean(); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct( $args = array() ) { |
27 | 27 | |
28 | - parent::__construct(); |
|
28 | + parent::__construct(); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function set_upgrader( &$upgrader ) { |
40 | 40 | |
41 | - if ( is_object( $upgrader ) ) { |
|
42 | - $this->upgrader =& $upgrader; |
|
43 | - } |
|
41 | + if ( is_object( $upgrader ) ) { |
|
42 | + $this->upgrader =& $upgrader; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function set_result( $result ) { |
55 | 55 | |
56 | - $this->result = $result; |
|
56 | + $this->result = $result; |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function error( $errors ) { |
84 | 84 | |
85 | - if ( ! empty( $errors ) ) { |
|
86 | - echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) ); |
|
87 | - die; |
|
88 | - } |
|
85 | + if ( ! empty( $errors ) ) { |
|
86 | + echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) ); |
|
87 | + die; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | } |
91 | 91 |
@@ -115,37 +115,37 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function __construct( array $config ) { |
117 | 117 | |
118 | - // Load the base class object. |
|
119 | - $this->base = MonsterInsights(); |
|
120 | - |
|
121 | - // Set class properties. |
|
122 | - $accepted_args = array( |
|
123 | - 'plugin_name', |
|
124 | - 'plugin_slug', |
|
125 | - 'plugin_path', |
|
126 | - 'plugin_url', |
|
127 | - 'remote_url', |
|
128 | - 'version', |
|
129 | - 'key' |
|
130 | - ); |
|
131 | - foreach ( $accepted_args as $arg ) { |
|
132 | - $this->$arg = $config[$arg]; |
|
133 | - } |
|
134 | - |
|
135 | - // If the user cannot update plugins, stop processing here. |
|
136 | - if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) { |
|
137 | - return; |
|
138 | - } |
|
139 | - |
|
140 | - // Load the updater hooks and filters. |
|
141 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) ); |
|
142 | - |
|
143 | - add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); |
|
144 | - add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 ); |
|
145 | - |
|
146 | - // ManageWP premium update filters |
|
147 | - //add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) ); |
|
148 | - //add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) ); |
|
118 | + // Load the base class object. |
|
119 | + $this->base = MonsterInsights(); |
|
120 | + |
|
121 | + // Set class properties. |
|
122 | + $accepted_args = array( |
|
123 | + 'plugin_name', |
|
124 | + 'plugin_slug', |
|
125 | + 'plugin_path', |
|
126 | + 'plugin_url', |
|
127 | + 'remote_url', |
|
128 | + 'version', |
|
129 | + 'key' |
|
130 | + ); |
|
131 | + foreach ( $accepted_args as $arg ) { |
|
132 | + $this->$arg = $config[$arg]; |
|
133 | + } |
|
134 | + |
|
135 | + // If the user cannot update plugins, stop processing here. |
|
136 | + if ( ! current_user_can( 'update_plugins' ) && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) { |
|
137 | + return; |
|
138 | + } |
|
139 | + |
|
140 | + // Load the updater hooks and filters. |
|
141 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'update_plugins_filter' ) ); |
|
142 | + |
|
143 | + add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); |
|
144 | + add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 ); |
|
145 | + |
|
146 | + // ManageWP premium update filters |
|
147 | + //add_filter( 'mwp_premium_update_notification', array( $this, 'premium_update_push' ) ); |
|
148 | + //add_filter( 'mwp_premium_perform_update', array( $this, 'premium_update' ) ); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -158,33 +158,33 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function update_plugins_filter( $value ) { |
160 | 160 | |
161 | - // If no update object exists, return early. |
|
162 | - if ( empty( $value ) ) { |
|
163 | - return $value; |
|
164 | - } |
|
165 | - |
|
166 | - // Run update check by pinging the external API. If it fails, return the default update object. |
|
167 | - if ( ! $this->update ) { |
|
168 | - $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) ); |
|
169 | - if ( ! $this->update || ! empty( $this->update->error ) ) { |
|
170 | - $this->update = false; |
|
171 | - return $value; |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - // Infuse the update object with our data if the version from the remote API is newer. |
|
176 | - if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) { |
|
177 | - // The $plugin_update object contains new_version, package, slug and last_update keys. |
|
178 | - //$this->update->full_slug = $this->plugin_slug; |
|
179 | - //$this->update->name = $this->plugin_name; |
|
180 | - $this->update->monsterinsights_plugin = true; |
|
181 | - $this->update->old_version = $this->version; |
|
182 | - $this->update->plugin = $this->plugin_path; |
|
183 | - $value->response[$this->plugin_path] = $this->update; |
|
184 | - } |
|
185 | - |
|
186 | - // Return the update object. |
|
187 | - return $value; |
|
161 | + // If no update object exists, return early. |
|
162 | + if ( empty( $value ) ) { |
|
163 | + return $value; |
|
164 | + } |
|
165 | + |
|
166 | + // Run update check by pinging the external API. If it fails, return the default update object. |
|
167 | + if ( ! $this->update ) { |
|
168 | + $this->update = $this->perform_remote_request( 'get-plugin-update', array( 'tgm-updater-plugin' => $this->plugin_slug ) ); |
|
169 | + if ( ! $this->update || ! empty( $this->update->error ) ) { |
|
170 | + $this->update = false; |
|
171 | + return $value; |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + // Infuse the update object with our data if the version from the remote API is newer. |
|
176 | + if ( isset( $this->update->new_version ) && version_compare( $this->version, $this->update->new_version, '<' ) ) { |
|
177 | + // The $plugin_update object contains new_version, package, slug and last_update keys. |
|
178 | + //$this->update->full_slug = $this->plugin_slug; |
|
179 | + //$this->update->name = $this->plugin_name; |
|
180 | + $this->update->monsterinsights_plugin = true; |
|
181 | + $this->update->old_version = $this->version; |
|
182 | + $this->update->plugin = $this->plugin_path; |
|
183 | + $value->response[$this->plugin_path] = $this->update; |
|
184 | + } |
|
185 | + |
|
186 | + // Return the update object. |
|
187 | + return $value; |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function http_request_args( $args, $url ) { |
201 | 201 | |
202 | - // If this is an SSL request and we are performing an upgrade routine, disable SSL verification. |
|
203 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) { |
|
204 | - $args['sslverify'] = false; |
|
205 | - } |
|
202 | + // If this is an SSL request and we are performing an upgrade routine, disable SSL verification. |
|
203 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'tgm-updater-action=get-plugin-update' ) ) { |
|
204 | + $args['sslverify'] = false; |
|
205 | + } |
|
206 | 206 | |
207 | - return $args; |
|
207 | + return $args; |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function plugins_api( $api, $action = '', $args = null ) { |
223 | 223 | |
224 | - $plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug ); |
|
224 | + $plugin = ( 'plugin_information' == $action ) && isset( $args->slug ) && ( $this->plugin_slug == $args->slug ); |
|
225 | 225 | |
226 | - // If our plugin matches the request, set our own plugin data, else return the default response. |
|
227 | - if ( $plugin ) { |
|
228 | - return $this->set_plugins_api( $api ); |
|
229 | - } else { |
|
230 | - return $api; |
|
231 | - } |
|
226 | + // If our plugin matches the request, set our own plugin data, else return the default response. |
|
227 | + if ( $plugin ) { |
|
228 | + return $this->set_plugins_api( $api ); |
|
229 | + } else { |
|
230 | + return $api; |
|
231 | + } |
|
232 | 232 | |
233 | 233 | } |
234 | 234 | |
@@ -242,82 +242,82 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function set_plugins_api( $default_api ) { |
244 | 244 | |
245 | - // Perform the remote request to retrieve our plugin information. If it fails, return the default object. |
|
246 | - if ( ! $this->info ) { |
|
247 | - $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) ); |
|
248 | - if ( ! $this->info || ! empty( $this->info->error ) ) { |
|
249 | - $this->info = false; |
|
250 | - return $default_api; |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - // Create a new stdClass object and populate it with our plugin information. |
|
255 | - $api = new stdClass; |
|
256 | - $api->name = isset( $this->info->name ) ? $this->info->name : ''; |
|
257 | - $api->slug = isset( $this->info->slug ) ? $this->info->slug : ''; |
|
258 | - $api->version = isset( $this->info->version ) ? $this->info->version : ''; |
|
259 | - $api->author = isset( $this->info->author ) ? $this->info->author : ''; |
|
260 | - $api->author_profile = isset( $this->info->author_profile ) ? $this->info->author_profile : ''; |
|
261 | - $api->requires = isset( $this->info->requires ) ? $this->info->requires : ''; |
|
262 | - $api->tested = isset( $this->info->tested ) ? $this->info->tested : ''; |
|
263 | - $api->last_updated = isset( $this->info->last_updated ) ? $this->info->last_updated : ''; |
|
264 | - $api->homepage = isset( $this->info->homepage ) ? $this->info->homepage : ''; |
|
265 | - |
|
266 | - $changelog = isset( $this->info->changelog ) ? $this->info->changelog : ''; |
|
267 | - $description = isset( $this->info->description ) ? $this->info->description : ''; |
|
268 | - |
|
269 | - if ( ! empty( $changelog ) ) { |
|
270 | - if ( ! empty( $description ) ) { |
|
271 | - $api->sections['description'] = $description; |
|
272 | - $api->sections['changelog'] = $changelog; |
|
273 | - } else { |
|
274 | - $api->sections['changelog'] = $changelog; |
|
275 | - } |
|
276 | - } else if ( ! empty( $description ) ) { |
|
277 | - $api->sections['description'] = $description; |
|
278 | - } else { |
|
279 | - $api->sections = array(); |
|
280 | - } |
|
281 | - |
|
282 | - $api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : ''; |
|
283 | - |
|
284 | - // Return the new API object with our custom data. |
|
285 | - return $api; |
|
245 | + // Perform the remote request to retrieve our plugin information. If it fails, return the default object. |
|
246 | + if ( ! $this->info ) { |
|
247 | + $this->info = $this->perform_remote_request( 'get-plugin-info', array( 'tgm-updater-plugin' => $this->plugin_slug ) ); |
|
248 | + if ( ! $this->info || ! empty( $this->info->error ) ) { |
|
249 | + $this->info = false; |
|
250 | + return $default_api; |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + // Create a new stdClass object and populate it with our plugin information. |
|
255 | + $api = new stdClass; |
|
256 | + $api->name = isset( $this->info->name ) ? $this->info->name : ''; |
|
257 | + $api->slug = isset( $this->info->slug ) ? $this->info->slug : ''; |
|
258 | + $api->version = isset( $this->info->version ) ? $this->info->version : ''; |
|
259 | + $api->author = isset( $this->info->author ) ? $this->info->author : ''; |
|
260 | + $api->author_profile = isset( $this->info->author_profile ) ? $this->info->author_profile : ''; |
|
261 | + $api->requires = isset( $this->info->requires ) ? $this->info->requires : ''; |
|
262 | + $api->tested = isset( $this->info->tested ) ? $this->info->tested : ''; |
|
263 | + $api->last_updated = isset( $this->info->last_updated ) ? $this->info->last_updated : ''; |
|
264 | + $api->homepage = isset( $this->info->homepage ) ? $this->info->homepage : ''; |
|
265 | + |
|
266 | + $changelog = isset( $this->info->changelog ) ? $this->info->changelog : ''; |
|
267 | + $description = isset( $this->info->description ) ? $this->info->description : ''; |
|
268 | + |
|
269 | + if ( ! empty( $changelog ) ) { |
|
270 | + if ( ! empty( $description ) ) { |
|
271 | + $api->sections['description'] = $description; |
|
272 | + $api->sections['changelog'] = $changelog; |
|
273 | + } else { |
|
274 | + $api->sections['changelog'] = $changelog; |
|
275 | + } |
|
276 | + } else if ( ! empty( $description ) ) { |
|
277 | + $api->sections['description'] = $description; |
|
278 | + } else { |
|
279 | + $api->sections = array(); |
|
280 | + } |
|
281 | + |
|
282 | + $api->download_link = isset( $this->info->download_link ) ? $this->info->download_link : ''; |
|
283 | + |
|
284 | + // Return the new API object with our custom data. |
|
285 | + return $api; |
|
286 | 286 | |
287 | 287 | } |
288 | 288 | |
289 | 289 | // Integration with ManageWP |
290 | 290 | public function premium_update_push( $premium_update ) { |
291 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
292 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
293 | - } |
|
294 | - |
|
295 | - $update = $this->set_plugins_api( array() ); |
|
296 | - if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) { |
|
297 | - $plugin_data = get_plugin_data( $update->slug ); |
|
298 | - $plugin_data['type'] = 'plugin'; |
|
299 | - $plugin_data['slug'] = $update->slug; |
|
300 | - $plugin_data['new_version'] = $update->version; |
|
301 | - $premium_update[] = $plugin_data; |
|
302 | - } |
|
303 | - return $premium_update; |
|
291 | + if ( ! function_exists( 'get_plugin_data' ) ) { |
|
292 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
293 | + } |
|
294 | + |
|
295 | + $update = $this->set_plugins_api( array() ); |
|
296 | + if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) { |
|
297 | + $plugin_data = get_plugin_data( $update->slug ); |
|
298 | + $plugin_data['type'] = 'plugin'; |
|
299 | + $plugin_data['slug'] = $update->slug; |
|
300 | + $plugin_data['new_version'] = $update->version; |
|
301 | + $premium_update[] = $plugin_data; |
|
302 | + } |
|
303 | + return $premium_update; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | // Integration with ManageWP |
307 | 307 | public function premium_update( $premium_update ) { |
308 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
309 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
310 | - } |
|
311 | - |
|
312 | - $update = $this->set_plugins_api( array() ); |
|
313 | - if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) { |
|
314 | - $plugin_data = get_plugin_data( $update->slug ); |
|
315 | - $plugin_data['type'] = 'plugin'; |
|
316 | - $plugin_data['slug'] = $update->slug; |
|
317 | - $plugin_data['url'] = $update->download_link; // OR provide your own callback function for managing the update |
|
318 | - array_push( $premium_update, $plugin_data ); |
|
319 | - } |
|
320 | - return $premium_update; |
|
308 | + if ( ! function_exists( 'get_plugin_data' ) ) { |
|
309 | + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
310 | + } |
|
311 | + |
|
312 | + $update = $this->set_plugins_api( array() ); |
|
313 | + if ( ! empty( $update ) && version_compare( MONSTERINSIGHTS_VERSION, $update->version, '<' ) ) { |
|
314 | + $plugin_data = get_plugin_data( $update->slug ); |
|
315 | + $plugin_data['type'] = 'plugin'; |
|
316 | + $plugin_data['slug'] = $update->slug; |
|
317 | + $plugin_data['url'] = $update->download_link; // OR provide your own callback function for managing the update |
|
318 | + array_push( $premium_update, $plugin_data ); |
|
319 | + } |
|
320 | + return $premium_update; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -333,47 +333,47 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) { |
335 | 335 | |
336 | - // Build the body of the request. |
|
337 | - $body = wp_parse_args( |
|
338 | - $body, |
|
339 | - array( |
|
340 | - 'tgm-updater-action' => $action, |
|
341 | - 'tgm-updater-key' => $this->key, |
|
342 | - 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
343 | - 'tgm-updater-referer' => site_url(), |
|
344 | - 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
|
345 | - 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
|
346 | - ) |
|
347 | - ); |
|
348 | - $body = http_build_query( $body, '', '&' ); |
|
349 | - |
|
350 | - // Build the headers of the request. |
|
351 | - $headers = wp_parse_args( |
|
352 | - $headers, |
|
353 | - array( |
|
354 | - 'Content-Type' => 'application/x-www-form-urlencoded', |
|
355 | - 'Content-Length' => strlen( $body ) |
|
356 | - ) |
|
357 | - ); |
|
358 | - |
|
359 | - // Setup variable for wp_remote_post. |
|
360 | - $post = array( |
|
361 | - 'headers' => $headers, |
|
362 | - 'body' => $body |
|
363 | - ); |
|
364 | - |
|
365 | - // Perform the query and retrieve the response. |
|
366 | - $response = wp_remote_post( esc_url_raw( $this->remote_url ), $post ); |
|
367 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
368 | - $response_body = wp_remote_retrieve_body( $response ); |
|
369 | - |
|
370 | - // Bail out early if there are any errors. |
|
371 | - if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
372 | - return false; |
|
373 | - } |
|
374 | - |
|
375 | - // Return the json decoded content. |
|
376 | - return json_decode( $response_body ); |
|
336 | + // Build the body of the request. |
|
337 | + $body = wp_parse_args( |
|
338 | + $body, |
|
339 | + array( |
|
340 | + 'tgm-updater-action' => $action, |
|
341 | + 'tgm-updater-key' => $this->key, |
|
342 | + 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
343 | + 'tgm-updater-referer' => site_url(), |
|
344 | + 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
|
345 | + 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
|
346 | + ) |
|
347 | + ); |
|
348 | + $body = http_build_query( $body, '', '&' ); |
|
349 | + |
|
350 | + // Build the headers of the request. |
|
351 | + $headers = wp_parse_args( |
|
352 | + $headers, |
|
353 | + array( |
|
354 | + 'Content-Type' => 'application/x-www-form-urlencoded', |
|
355 | + 'Content-Length' => strlen( $body ) |
|
356 | + ) |
|
357 | + ); |
|
358 | + |
|
359 | + // Setup variable for wp_remote_post. |
|
360 | + $post = array( |
|
361 | + 'headers' => $headers, |
|
362 | + 'body' => $body |
|
363 | + ); |
|
364 | + |
|
365 | + // Perform the query and retrieve the response. |
|
366 | + $response = wp_remote_post( esc_url_raw( $this->remote_url ), $post ); |
|
367 | + $response_code = wp_remote_retrieve_response_code( $response ); |
|
368 | + $response_body = wp_remote_retrieve_body( $response ); |
|
369 | + |
|
370 | + // Bail out early if there are any errors. |
|
371 | + if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
372 | + return false; |
|
373 | + } |
|
374 | + |
|
375 | + // Return the json decoded content. |
|
376 | + return json_decode( $response_body ); |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | } |
380 | 380 | \ No newline at end of file |
@@ -57,29 +57,29 @@ discard block |
||
57 | 57 | * @since 6.0.0 |
58 | 58 | */ |
59 | 59 | public function __construct() { |
60 | - // Load the base class object. |
|
61 | - $this->base = MonsterInsights(); |
|
62 | - add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
60 | + // Load the base class object. |
|
61 | + $this->base = MonsterInsights(); |
|
62 | + add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function admin_init() { |
66 | - // Possibly verify the key. |
|
67 | - $this->maybe_verify_key(); |
|
68 | - |
|
69 | - // Add potential admin notices for actions around the admin. |
|
70 | - add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ) ); |
|
71 | - add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ) ); |
|
72 | - |
|
73 | - // Grab the license key. If it is not set (even after verification), return early. |
|
74 | - $this->key = monsterinsights_get_license_key(); |
|
75 | - if ( ! $this->key ) { |
|
76 | - return; |
|
77 | - } |
|
78 | - |
|
79 | - // Possibly handle validating, deactivating and refreshing license keys. |
|
80 | - $this->maybe_validate_key(); |
|
81 | - $this->maybe_deactivate_key(); |
|
82 | - $this->maybe_refresh_key(); |
|
66 | + // Possibly verify the key. |
|
67 | + $this->maybe_verify_key(); |
|
68 | + |
|
69 | + // Add potential admin notices for actions around the admin. |
|
70 | + add_action( 'admin_notices', array( $this, 'monsterinsights_notices' ) ); |
|
71 | + add_action( 'network_admin_notices', array( $this, 'monsterinsights_notices' ) ); |
|
72 | + |
|
73 | + // Grab the license key. If it is not set (even after verification), return early. |
|
74 | + $this->key = monsterinsights_get_license_key(); |
|
75 | + if ( ! $this->key ) { |
|
76 | + return; |
|
77 | + } |
|
78 | + |
|
79 | + // Possibly handle validating, deactivating and refreshing license keys. |
|
80 | + $this->maybe_validate_key(); |
|
81 | + $this->maybe_deactivate_key(); |
|
82 | + $this->maybe_refresh_key(); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function maybe_verify_key() { |
93 | 93 | |
94 | - if ( ! $this->is_verifying_key() ) { |
|
95 | - return; |
|
96 | - } |
|
94 | + if ( ! $this->is_verifying_key() ) { |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | - if ( ! $this->verify_key_action() ) { |
|
99 | - return; |
|
100 | - } |
|
98 | + if ( ! $this->verify_key_action() ) { |
|
99 | + return; |
|
100 | + } |
|
101 | 101 | |
102 | - $this->verify_key(); |
|
102 | + $this->verify_key(); |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | |
@@ -110,41 +110,41 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function verify_key() { |
112 | 112 | |
113 | - // Perform a request to verify the key. |
|
114 | - $verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) ); |
|
115 | - |
|
116 | - // If it returns false, send back a generic error message and return. |
|
117 | - if ( ! $verify ) { |
|
118 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
119 | - return; |
|
120 | - } |
|
121 | - |
|
122 | - // If an error is returned, set the error and return. |
|
123 | - if ( ! empty( $verify->error ) ) { |
|
124 | - $this->errors[] = $verify->error; |
|
125 | - return; |
|
126 | - } |
|
127 | - |
|
128 | - // Otherwise, our request has been done successfully. Update the option and set the success message. |
|
129 | - if ( is_multisite() && is_network_admin() ) { |
|
130 | - $option = get_site_option( 'monsterinsights_license' ); |
|
131 | - $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
132 | - $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
133 | - $option['is_expired'] = false; |
|
134 | - $option['is_disabled'] = false; |
|
135 | - $option['is_invalid'] = false; |
|
136 | - $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
137 | - update_site_option( 'monsterinsights_license', $option ); |
|
138 | - } else { |
|
139 | - $option = get_option( 'monsterinsights_license' ); |
|
140 | - $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
141 | - $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
142 | - $option['is_expired'] = false; |
|
143 | - $option['is_disabled'] = false; |
|
144 | - $option['is_invalid'] = false; |
|
145 | - $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
146 | - update_option( 'monsterinsights_license', $option ); |
|
147 | - } |
|
113 | + // Perform a request to verify the key. |
|
114 | + $verify = $this->perform_remote_request( 'verify-key', array( 'tgm-updater-key' => trim( $_POST['monsterinsights-license-key'] ) ) ); |
|
115 | + |
|
116 | + // If it returns false, send back a generic error message and return. |
|
117 | + if ( ! $verify ) { |
|
118 | + $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
119 | + return; |
|
120 | + } |
|
121 | + |
|
122 | + // If an error is returned, set the error and return. |
|
123 | + if ( ! empty( $verify->error ) ) { |
|
124 | + $this->errors[] = $verify->error; |
|
125 | + return; |
|
126 | + } |
|
127 | + |
|
128 | + // Otherwise, our request has been done successfully. Update the option and set the success message. |
|
129 | + if ( is_multisite() && is_network_admin() ) { |
|
130 | + $option = get_site_option( 'monsterinsights_license' ); |
|
131 | + $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
132 | + $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
133 | + $option['is_expired'] = false; |
|
134 | + $option['is_disabled'] = false; |
|
135 | + $option['is_invalid'] = false; |
|
136 | + $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
137 | + update_site_option( 'monsterinsights_license', $option ); |
|
138 | + } else { |
|
139 | + $option = get_option( 'monsterinsights_license' ); |
|
140 | + $option['key'] = trim( $_POST['monsterinsights-license-key'] ); |
|
141 | + $option['type'] = isset( $verify->type ) ? $verify->type : $option['type']; |
|
142 | + $option['is_expired'] = false; |
|
143 | + $option['is_disabled'] = false; |
|
144 | + $option['is_invalid'] = false; |
|
145 | + $this->success[] = isset( $verify->success ) ? $verify->success : esc_html__( 'Congratulations! This site is now receiving automatic updates.', 'google-analytics-for-wordpress' ); |
|
146 | + update_option( 'monsterinsights_license', $option ); |
|
147 | + } |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function is_verifying_key() { |
159 | 159 | |
160 | - return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-verify-submit'] ); |
|
160 | + return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-verify-submit'] ); |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function verify_key_action() { |
172 | 172 | |
173 | - return isset( $_POST['monsterinsights-verify-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
173 | + return isset( $_POST['monsterinsights-verify-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
174 | 174 | |
175 | 175 | } |
176 | 176 | |
@@ -183,21 +183,21 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function maybe_validate_key() { |
185 | 185 | |
186 | - // Only run every 12 hours. |
|
187 | - $timestamp = get_option( 'monsterinsights_license_updates' ); |
|
188 | - if ( ! $timestamp ) { |
|
189 | - $timestamp = strtotime( '+8 hours' ); |
|
190 | - update_option( 'monsterinsights_license_updates', $timestamp ); |
|
191 | - $this->validate_key(); |
|
192 | - } else { |
|
193 | - $current_timestamp = time(); |
|
194 | - if ( $current_timestamp < $timestamp ) { |
|
195 | - return; |
|
196 | - } else { |
|
197 | - update_option( 'monsterinsights_license_updates', strtotime( '+8 hours' ) ); |
|
198 | - $this->validate_key(); |
|
199 | - } |
|
200 | - } |
|
186 | + // Only run every 12 hours. |
|
187 | + $timestamp = get_option( 'monsterinsights_license_updates' ); |
|
188 | + if ( ! $timestamp ) { |
|
189 | + $timestamp = strtotime( '+8 hours' ); |
|
190 | + update_option( 'monsterinsights_license_updates', $timestamp ); |
|
191 | + $this->validate_key(); |
|
192 | + } else { |
|
193 | + $current_timestamp = time(); |
|
194 | + if ( $current_timestamp < $timestamp ) { |
|
195 | + return; |
|
196 | + } else { |
|
197 | + update_option( 'monsterinsights_license_updates', strtotime( '+8 hours' ) ); |
|
198 | + $this->validate_key(); |
|
199 | + } |
|
200 | + } |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -209,103 +209,103 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function validate_key( $forced = false ) { |
211 | 211 | |
212 | - $validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) ); |
|
212 | + $validate = $this->perform_remote_request( 'validate-key', array( 'tgm-updater-key' => $this->key ) ); |
|
213 | 213 | |
214 | - // If there was a basic API error in validation, only set the transient for 10 minutes before retrying. |
|
215 | - if ( ! $validate ) { |
|
216 | - // If forced, set contextual success message. |
|
217 | - if ( $forced ) { |
|
218 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
219 | - } |
|
214 | + // If there was a basic API error in validation, only set the transient for 10 minutes before retrying. |
|
215 | + if ( ! $validate ) { |
|
216 | + // If forced, set contextual success message. |
|
217 | + if ( $forced ) { |
|
218 | + $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
219 | + } |
|
220 | 220 | |
221 | - return; |
|
222 | - } |
|
223 | - |
|
224 | - // If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license. |
|
225 | - if ( isset( $validate->key ) || isset( $validate->author ) ) { |
|
226 | - $option = array(); |
|
227 | - if ( is_multisite() && is_network_admin() ) { |
|
228 | - $option = get_site_option( 'monsterinsights_license' ); |
|
229 | - } else { |
|
230 | - $option = get_option( 'monsterinsights_license' ); |
|
231 | - } |
|
232 | - $option['is_expired'] = false; |
|
233 | - $option['is_disabled'] = false; |
|
234 | - $option['is_invalid'] = true; |
|
235 | - if ( is_multisite() && is_network_admin() ) { |
|
236 | - update_site_option( 'monsterinsights_license', $option ); |
|
237 | - } else { |
|
238 | - update_option( 'monsterinsights_license', $option ); |
|
239 | - } |
|
240 | - return; |
|
241 | - } |
|
242 | - |
|
243 | - // If the license has expired, set the transient and expired flag and return. |
|
244 | - if ( isset( $validate->expired ) ) { |
|
245 | - $option = array(); |
|
246 | - if ( is_multisite() && is_network_admin() ) { |
|
247 | - $option = get_site_option( 'monsterinsights_license' ); |
|
248 | - } else { |
|
249 | - $option = get_option( 'monsterinsights_license' ); |
|
250 | - } |
|
251 | - $option['is_expired'] = true; |
|
252 | - $option['is_disabled'] = false; |
|
253 | - $option['is_invalid'] = false; |
|
254 | - if ( is_multisite() && is_network_admin() ) { |
|
255 | - update_site_option( 'monsterinsights_license', $option ); |
|
256 | - } else { |
|
257 | - update_option( 'monsterinsights_license', $option ); |
|
258 | - } |
|
259 | - return; |
|
260 | - } |
|
261 | - |
|
262 | - // If the license is disabled, set the transient and disabled flag and return. |
|
263 | - if ( isset( $validate->disabled ) ) { |
|
264 | - $option = array(); |
|
265 | - if ( is_multisite() && is_network_admin() ) { |
|
266 | - $option = get_site_option( 'monsterinsights_license' ); |
|
267 | - } else { |
|
268 | - $option = get_option( 'monsterinsights_license' ); |
|
269 | - } |
|
270 | - $option['is_expired'] = false; |
|
271 | - $option['is_disabled'] = true; |
|
272 | - $option['is_invalid'] = false; |
|
273 | - if ( is_multisite() && is_network_admin() ) { |
|
274 | - update_site_option( 'monsterinsights_license', $option ); |
|
275 | - } else { |
|
276 | - update_option( 'monsterinsights_license', $option ); |
|
277 | - } |
|
278 | - return; |
|
279 | - } |
|
280 | - |
|
281 | - // If forced, set contextual success message. |
|
282 | - if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) { |
|
283 | - $key = ''; |
|
284 | - if ( ! empty( $validate->key ) ) { |
|
285 | - $key = $validate->key; |
|
286 | - } else { |
|
287 | - $key = $this->key; |
|
288 | - } |
|
289 | - delete_transient( '_monsterinsights_addons' ); |
|
290 | - monsterinsights_get_addons_data( $key ); |
|
291 | - $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' ); |
|
292 | - } |
|
293 | - |
|
294 | - $option = array(); |
|
295 | - if ( is_multisite() && is_network_admin() ) { |
|
296 | - $option = get_site_option( 'monsterinsights_license' ); |
|
297 | - } else { |
|
298 | - $option = get_option( 'monsterinsights_license' ); |
|
299 | - } |
|
300 | - $option['type'] = isset( $validate->type ) ? $validate->type : $option['type']; |
|
301 | - $option['is_expired'] = false; |
|
302 | - $option['is_disabled'] = false; |
|
303 | - $option['is_invalid'] = false; |
|
304 | - if ( is_multisite() && is_network_admin() ) { |
|
305 | - update_site_option( 'monsterinsights_license', $option ); |
|
306 | - } else { |
|
307 | - update_option( 'monsterinsights_license', $option ); |
|
308 | - } |
|
221 | + return; |
|
222 | + } |
|
223 | + |
|
224 | + // If a key or author error is returned, the license no longer exists or the user has been deleted, so reset license. |
|
225 | + if ( isset( $validate->key ) || isset( $validate->author ) ) { |
|
226 | + $option = array(); |
|
227 | + if ( is_multisite() && is_network_admin() ) { |
|
228 | + $option = get_site_option( 'monsterinsights_license' ); |
|
229 | + } else { |
|
230 | + $option = get_option( 'monsterinsights_license' ); |
|
231 | + } |
|
232 | + $option['is_expired'] = false; |
|
233 | + $option['is_disabled'] = false; |
|
234 | + $option['is_invalid'] = true; |
|
235 | + if ( is_multisite() && is_network_admin() ) { |
|
236 | + update_site_option( 'monsterinsights_license', $option ); |
|
237 | + } else { |
|
238 | + update_option( 'monsterinsights_license', $option ); |
|
239 | + } |
|
240 | + return; |
|
241 | + } |
|
242 | + |
|
243 | + // If the license has expired, set the transient and expired flag and return. |
|
244 | + if ( isset( $validate->expired ) ) { |
|
245 | + $option = array(); |
|
246 | + if ( is_multisite() && is_network_admin() ) { |
|
247 | + $option = get_site_option( 'monsterinsights_license' ); |
|
248 | + } else { |
|
249 | + $option = get_option( 'monsterinsights_license' ); |
|
250 | + } |
|
251 | + $option['is_expired'] = true; |
|
252 | + $option['is_disabled'] = false; |
|
253 | + $option['is_invalid'] = false; |
|
254 | + if ( is_multisite() && is_network_admin() ) { |
|
255 | + update_site_option( 'monsterinsights_license', $option ); |
|
256 | + } else { |
|
257 | + update_option( 'monsterinsights_license', $option ); |
|
258 | + } |
|
259 | + return; |
|
260 | + } |
|
261 | + |
|
262 | + // If the license is disabled, set the transient and disabled flag and return. |
|
263 | + if ( isset( $validate->disabled ) ) { |
|
264 | + $option = array(); |
|
265 | + if ( is_multisite() && is_network_admin() ) { |
|
266 | + $option = get_site_option( 'monsterinsights_license' ); |
|
267 | + } else { |
|
268 | + $option = get_option( 'monsterinsights_license' ); |
|
269 | + } |
|
270 | + $option['is_expired'] = false; |
|
271 | + $option['is_disabled'] = true; |
|
272 | + $option['is_invalid'] = false; |
|
273 | + if ( is_multisite() && is_network_admin() ) { |
|
274 | + update_site_option( 'monsterinsights_license', $option ); |
|
275 | + } else { |
|
276 | + update_option( 'monsterinsights_license', $option ); |
|
277 | + } |
|
278 | + return; |
|
279 | + } |
|
280 | + |
|
281 | + // If forced, set contextual success message. |
|
282 | + if ( ( ! empty( $validate->key ) || ! empty( $this->key ) ) && $forced ) { |
|
283 | + $key = ''; |
|
284 | + if ( ! empty( $validate->key ) ) { |
|
285 | + $key = $validate->key; |
|
286 | + } else { |
|
287 | + $key = $this->key; |
|
288 | + } |
|
289 | + delete_transient( '_monsterinsights_addons' ); |
|
290 | + monsterinsights_get_addons_data( $key ); |
|
291 | + $this->success[] = esc_html__( 'Congratulations! Your key has been refreshed successfully.', 'google-analytics-for-wordpress' ); |
|
292 | + } |
|
293 | + |
|
294 | + $option = array(); |
|
295 | + if ( is_multisite() && is_network_admin() ) { |
|
296 | + $option = get_site_option( 'monsterinsights_license' ); |
|
297 | + } else { |
|
298 | + $option = get_option( 'monsterinsights_license' ); |
|
299 | + } |
|
300 | + $option['type'] = isset( $validate->type ) ? $validate->type : $option['type']; |
|
301 | + $option['is_expired'] = false; |
|
302 | + $option['is_disabled'] = false; |
|
303 | + $option['is_invalid'] = false; |
|
304 | + if ( is_multisite() && is_network_admin() ) { |
|
305 | + update_site_option( 'monsterinsights_license', $option ); |
|
306 | + } else { |
|
307 | + update_option( 'monsterinsights_license', $option ); |
|
308 | + } |
|
309 | 309 | |
310 | 310 | } |
311 | 311 | |
@@ -318,15 +318,15 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function maybe_deactivate_key() { |
320 | 320 | |
321 | - if ( ! $this->is_deactivating_key() ) { |
|
322 | - return; |
|
323 | - } |
|
321 | + if ( ! $this->is_deactivating_key() ) { |
|
322 | + return; |
|
323 | + } |
|
324 | 324 | |
325 | - if ( ! $this->deactivate_key_action() ) { |
|
326 | - return; |
|
327 | - } |
|
325 | + if ( ! $this->deactivate_key_action() ) { |
|
326 | + return; |
|
327 | + } |
|
328 | 328 | |
329 | - $this->deactivate_key(); |
|
329 | + $this->deactivate_key(); |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | |
@@ -337,29 +337,29 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function deactivate_key() { |
339 | 339 | |
340 | - // Perform a request to deactivate the key. |
|
341 | - $deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) ); |
|
342 | - |
|
343 | - // If it returns false, send back a generic error message and return. |
|
344 | - if ( ! $deactivate ) { |
|
345 | - $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
346 | - return; |
|
347 | - } |
|
348 | - |
|
349 | - // If an error is returned, set the error and return. |
|
350 | - if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) { |
|
351 | - $this->errors[] = $deactivate->error; |
|
352 | - return; |
|
353 | - } |
|
354 | - |
|
355 | - // Otherwise, our request has been done successfully. Reset the option and set the success message. |
|
356 | - $this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' ); |
|
357 | - update_option( 'monsterinsights_license', array() ); |
|
358 | - if ( is_multisite() && is_network_admin() ) { |
|
359 | - update_site_option( 'monsterinsights_license', array() ); |
|
360 | - } else { |
|
361 | - update_option( 'monsterinsights_license', array() ); |
|
362 | - } |
|
340 | + // Perform a request to deactivate the key. |
|
341 | + $deactivate = $this->perform_remote_request( 'deactivate-key', array( 'tgm-updater-key' => $_POST['monsterinsights-license-key'] ) ); |
|
342 | + |
|
343 | + // If it returns false, send back a generic error message and return. |
|
344 | + if ( ! $deactivate ) { |
|
345 | + $this->errors[] = esc_html__( 'There was an error connecting to the remote key API. Please try again later.', 'google-analytics-for-wordpress' ); |
|
346 | + return; |
|
347 | + } |
|
348 | + |
|
349 | + // If an error is returned, set the error and return. |
|
350 | + if ( ! empty( $deactivate->error ) && ! monsterinsights_is_debug_mode() ) { |
|
351 | + $this->errors[] = $deactivate->error; |
|
352 | + return; |
|
353 | + } |
|
354 | + |
|
355 | + // Otherwise, our request has been done successfully. Reset the option and set the success message. |
|
356 | + $this->success[] = isset( $deactivate->success ) ? $deactivate->success : esc_html__( 'Congratulations! You have deactivated the key from this site successfully.', 'google-analytics-for-wordpress' ); |
|
357 | + update_option( 'monsterinsights_license', array() ); |
|
358 | + if ( is_multisite() && is_network_admin() ) { |
|
359 | + update_site_option( 'monsterinsights_license', array() ); |
|
360 | + } else { |
|
361 | + update_option( 'monsterinsights_license', array() ); |
|
362 | + } |
|
363 | 363 | |
364 | 364 | } |
365 | 365 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function is_deactivating_key() { |
374 | 374 | |
375 | - return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-deactivate-submit'] ); |
|
375 | + return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-deactivate-submit'] ); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function deactivate_key_action() { |
387 | 387 | |
388 | - return isset( $_POST['monsterinsights-deactivate-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
388 | + return isset( $_POST['monsterinsights-deactivate-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
389 | 389 | |
390 | 390 | } |
391 | 391 | |
@@ -398,16 +398,16 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function maybe_refresh_key() { |
400 | 400 | |
401 | - if ( ! $this->is_refreshing_key() ) { |
|
402 | - return; |
|
403 | - } |
|
401 | + if ( ! $this->is_refreshing_key() ) { |
|
402 | + return; |
|
403 | + } |
|
404 | 404 | |
405 | - if ( ! $this->refresh_key_action() ) { |
|
406 | - return; |
|
407 | - } |
|
405 | + if ( ! $this->refresh_key_action() ) { |
|
406 | + return; |
|
407 | + } |
|
408 | 408 | |
409 | - // Refreshing is simply a word alias for validating a key. Force true to set contextual messages. |
|
410 | - $this->validate_key( true ); |
|
409 | + // Refreshing is simply a word alias for validating a key. Force true to set contextual messages. |
|
410 | + $this->validate_key( true ); |
|
411 | 411 | |
412 | 412 | } |
413 | 413 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function is_refreshing_key() { |
422 | 422 | |
423 | - return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-refresh-submit'] ); |
|
423 | + return isset( $_POST['monsterinsights-license-key'] ) && isset( $_POST['monsterinsights-refresh-submit'] ); |
|
424 | 424 | |
425 | 425 | } |
426 | 426 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function refresh_key_action() { |
435 | 435 | |
436 | - return isset( $_POST['monsterinsights-refresh-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
436 | + return isset( $_POST['monsterinsights-refresh-submit'] ) && wp_verify_nonce( $_POST['monsterinsights-key-nonce'], 'monsterinsights-key-nonce' ); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
@@ -444,127 +444,127 @@ discard block |
||
444 | 444 | */ |
445 | 445 | public function monsterinsights_notices() { |
446 | 446 | |
447 | - // Grab the option and output any nag dealing with license keys. |
|
448 | - $key = monsterinsights_get_license_key(); |
|
447 | + // Grab the option and output any nag dealing with license keys. |
|
448 | + $key = monsterinsights_get_license_key(); |
|
449 | 449 | |
450 | - $option = array(); |
|
451 | - if ( is_multisite() && is_network_admin() ) { |
|
452 | - $option = get_site_option( 'monsterinsights_license' ); |
|
453 | - } else { |
|
454 | - $option = get_option( 'monsterinsights_license' ); |
|
455 | - } |
|
450 | + $option = array(); |
|
451 | + if ( is_multisite() && is_network_admin() ) { |
|
452 | + $option = get_site_option( 'monsterinsights_license' ); |
|
453 | + } else { |
|
454 | + $option = get_option( 'monsterinsights_license' ); |
|
455 | + } |
|
456 | 456 | |
457 | - if ( ! monsterinsights_is_pro_version() ) { |
|
458 | - return; |
|
459 | - } |
|
457 | + if ( ! monsterinsights_is_pro_version() ) { |
|
458 | + return; |
|
459 | + } |
|
460 | 460 | |
461 | - if ( is_multisite() && is_network_admin() ) { |
|
462 | - // If a key has expired, output nag about renewing the key. |
|
463 | - if ( isset( $option['is_expired'] ) && $option['is_expired'] ) : |
|
464 | - ?> |
|
461 | + if ( is_multisite() && is_network_admin() ) { |
|
462 | + // If a key has expired, output nag about renewing the key. |
|
463 | + if ( isset( $option['is_expired'] ) && $option['is_expired'] ) : |
|
464 | + ?> |
|
465 | 465 | <div class="error"> |
466 | 466 | <p><?php printf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' ); ?></p> |
467 | 467 | </div> |
468 | 468 | <?php |
469 | - endif; |
|
469 | + endif; |
|
470 | 470 | |
471 | - // If a key has been disabled, output nag about using another key. |
|
472 | - if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) : |
|
473 | - ?> |
|
471 | + // If a key has been disabled, output nag about using another key. |
|
472 | + if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) : |
|
473 | + ?> |
|
474 | 474 | <div class="error"> |
475 | 475 | <p><?php esc_html_e( 'Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
476 | 476 | </div> |
477 | 477 | <?php |
478 | - endif; |
|
478 | + endif; |
|
479 | 479 | |
480 | - // If a key is invalid, output nag about using another key. |
|
481 | - if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) : |
|
482 | - ?> |
|
480 | + // If a key is invalid, output nag about using another key. |
|
481 | + if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) : |
|
482 | + ?> |
|
483 | 483 | <div class="error"> |
484 | 484 | <p><?php esc_html_e( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
485 | 485 | </div> |
486 | 486 | <?php |
487 | - endif; |
|
487 | + endif; |
|
488 | 488 | |
489 | - // If there are any license errors, output them now. |
|
490 | - if ( ! empty( $this->errors ) ) : |
|
491 | - ?> |
|
489 | + // If there are any license errors, output them now. |
|
490 | + if ( ! empty( $this->errors ) ) : |
|
491 | + ?> |
|
492 | 492 | <div class="error"> |
493 | 493 | <p><?php echo implode( '<br>', $this->errors ); ?></p> |
494 | 494 | </div> |
495 | 495 | <?php |
496 | - endif; |
|
496 | + endif; |
|
497 | 497 | |
498 | - // If there are any success messages, output them now. |
|
499 | - if ( ! empty( $this->success ) ) : |
|
500 | - ?> |
|
498 | + // If there are any success messages, output them now. |
|
499 | + if ( ! empty( $this->success ) ) : |
|
500 | + ?> |
|
501 | 501 | <div class="updated"> |
502 | 502 | <p><?php echo implode( '<br>', $this->success ); ?></p> |
503 | 503 | </div> |
504 | 504 | <?php |
505 | - endif; |
|
506 | - } else { |
|
507 | - // If there is no license key, output nag about ensuring key is set for automatic updates. |
|
508 | - if ( ! $key ) : |
|
509 | - if ( ! monsterinsights_is_pro_version() ) { |
|
510 | - return; |
|
511 | - } |
|
512 | - $screen = get_current_screen(); |
|
513 | - if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) { |
|
514 | - return; |
|
515 | - } |
|
516 | - ?> |
|
505 | + endif; |
|
506 | + } else { |
|
507 | + // If there is no license key, output nag about ensuring key is set for automatic updates. |
|
508 | + if ( ! $key ) : |
|
509 | + if ( ! monsterinsights_is_pro_version() ) { |
|
510 | + return; |
|
511 | + } |
|
512 | + $screen = get_current_screen(); |
|
513 | + if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) { |
|
514 | + return; |
|
515 | + } |
|
516 | + ?> |
|
517 | 517 | <div class="error"> |
518 | 518 | <p><?php printf( esc_html__( 'No valid license key has been entered, so automatic updates for MonsterInsights have been turned off. %1$sPlease click here to enter your license key and begin receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( add_query_arg( array( 'page' => 'monsterinsights_settings' ), admin_url( 'admin.php' ) ) ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
519 | 519 | </div> |
520 | 520 | <?php |
521 | - endif; |
|
521 | + endif; |
|
522 | 522 | |
523 | - // If a key has expired, output nag about renewing the key. |
|
524 | - if ( isset( $option['is_expired'] ) && $option['is_expired'] ) : |
|
525 | - ?> |
|
523 | + // If a key has expired, output nag about renewing the key. |
|
524 | + if ( isset( $option['is_expired'] ) && $option['is_expired'] ) : |
|
525 | + ?> |
|
526 | 526 | <div class="error"> |
527 | 527 | <p><?php printf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key and continue receiving automatic updates.%2$s', 'google-analytics-for-wordpress' ), '<a href="https://www.monsterinsights.com/login/" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
528 | 528 | </div> |
529 | 529 | <?php |
530 | - endif; |
|
530 | + endif; |
|
531 | 531 | |
532 | - // If a key has been disabled, output nag about using another key. |
|
533 | - if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) : |
|
534 | - ?> |
|
532 | + // If a key has been disabled, output nag about using another key. |
|
533 | + if ( isset( $option['is_disabled'] ) && $option['is_disabled'] ) : |
|
534 | + ?> |
|
535 | 535 | <div class="error"> |
536 | 536 | <p><?php esc_html_e( 'Your license key for MonsterInsights has been disabled. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
537 | 537 | </div> |
538 | 538 | <?php |
539 | - endif; |
|
539 | + endif; |
|
540 | 540 | |
541 | - // If a key is invalid, output nag about using another key. |
|
542 | - if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) : |
|
543 | - ?> |
|
541 | + // If a key is invalid, output nag about using another key. |
|
542 | + if ( isset( $option['is_invalid'] ) && $option['is_invalid'] ) : |
|
543 | + ?> |
|
544 | 544 | <div class="error"> |
545 | 545 | <p><?php esc_html_e( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key to continue receiving automatic updates.', 'google-analytics-for-wordpress' ); ?></p> |
546 | 546 | </div> |
547 | 547 | <?php |
548 | - endif; |
|
548 | + endif; |
|
549 | 549 | |
550 | - // If there are any license errors, output them now. |
|
551 | - if ( ! empty( $this->errors ) ) : |
|
552 | - ?> |
|
550 | + // If there are any license errors, output them now. |
|
551 | + if ( ! empty( $this->errors ) ) : |
|
552 | + ?> |
|
553 | 553 | <div class="error"> |
554 | 554 | <p><?php echo implode( '<br>', $this->errors ); ?></p> |
555 | 555 | </div> |
556 | 556 | <?php |
557 | - endif; |
|
557 | + endif; |
|
558 | 558 | |
559 | - // If there are any success messages, output them now. |
|
560 | - if ( ! empty( $this->success ) ) : |
|
561 | - ?> |
|
559 | + // If there are any success messages, output them now. |
|
560 | + if ( ! empty( $this->success ) ) : |
|
561 | + ?> |
|
562 | 562 | <div class="updated"> |
563 | 563 | <p><?php echo implode( '<br>', $this->success ); ?></p> |
564 | 564 | </div> |
565 | 565 | <?php |
566 | - endif; |
|
567 | - } |
|
566 | + endif; |
|
567 | + } |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -580,47 +580,47 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function perform_remote_request( $action, $body = array(), $headers = array(), $return_format = 'json' ) { |
582 | 582 | |
583 | - // Build the body of the request. |
|
584 | - $body = wp_parse_args( |
|
585 | - $body, |
|
586 | - array( |
|
587 | - 'tgm-updater-action' => $action, |
|
588 | - 'tgm-updater-key' => $this->key, |
|
589 | - 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
590 | - 'tgm-updater-referer' => site_url(), |
|
591 | - 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
|
592 | - 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
|
593 | - ) |
|
594 | - ); |
|
595 | - $body = http_build_query( $body, '', '&' ); |
|
596 | - |
|
597 | - // Build the headers of the request. |
|
598 | - $headers = wp_parse_args( |
|
599 | - $headers, |
|
600 | - array( |
|
601 | - 'Content-Type' => 'application/x-www-form-urlencoded', |
|
602 | - 'Content-Length' => strlen( $body ) |
|
603 | - ) |
|
604 | - ); |
|
605 | - |
|
606 | - // Setup variable for wp_remote_post. |
|
607 | - $post = array( |
|
608 | - 'headers' => $headers, |
|
609 | - 'body' => $body |
|
610 | - ); |
|
611 | - |
|
612 | - // Perform the query and retrieve the response. |
|
613 | - $response = wp_remote_post( 'https://www.monsterinsights.com', $post ); |
|
614 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
615 | - $response_body = wp_remote_retrieve_body( $response ); |
|
616 | - |
|
617 | - // Bail out early if there are any errors. |
|
618 | - if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
619 | - return false; |
|
620 | - } |
|
621 | - |
|
622 | - // Return the json decoded content. |
|
623 | - return json_decode( $response_body ); |
|
583 | + // Build the body of the request. |
|
584 | + $body = wp_parse_args( |
|
585 | + $body, |
|
586 | + array( |
|
587 | + 'tgm-updater-action' => $action, |
|
588 | + 'tgm-updater-key' => $this->key, |
|
589 | + 'tgm-updater-wp-version' => get_bloginfo( 'version' ), |
|
590 | + 'tgm-updater-referer' => site_url(), |
|
591 | + 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION, |
|
592 | + 'tgm-updater-is-pro' => monsterinsights_is_pro_version(), |
|
593 | + ) |
|
594 | + ); |
|
595 | + $body = http_build_query( $body, '', '&' ); |
|
596 | + |
|
597 | + // Build the headers of the request. |
|
598 | + $headers = wp_parse_args( |
|
599 | + $headers, |
|
600 | + array( |
|
601 | + 'Content-Type' => 'application/x-www-form-urlencoded', |
|
602 | + 'Content-Length' => strlen( $body ) |
|
603 | + ) |
|
604 | + ); |
|
605 | + |
|
606 | + // Setup variable for wp_remote_post. |
|
607 | + $post = array( |
|
608 | + 'headers' => $headers, |
|
609 | + 'body' => $body |
|
610 | + ); |
|
611 | + |
|
612 | + // Perform the query and retrieve the response. |
|
613 | + $response = wp_remote_post( 'https://www.monsterinsights.com', $post ); |
|
614 | + $response_code = wp_remote_retrieve_response_code( $response ); |
|
615 | + $response_body = wp_remote_retrieve_body( $response ); |
|
616 | + |
|
617 | + // Bail out early if there are any errors. |
|
618 | + if ( 200 != $response_code || is_wp_error( $response_body ) ) { |
|
619 | + return false; |
|
620 | + } |
|
621 | + |
|
622 | + // Return the json decoded content. |
|
623 | + return json_decode( $response_body ); |
|
624 | 624 | |
625 | 625 | } |
626 | 626 | } |
627 | 627 | \ No newline at end of file |