@@ -72,7 +72,7 @@ |
||
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - $url = network_site_url( '/' ); |
|
75 | + $url = network_site_url( '/' ); |
|
76 | 76 | |
77 | 77 | if ( ! function_exists( 'monsterinsights_is_dev_url' ) ) { |
78 | 78 | return false; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | ?> |
452 | 452 | <div class="error"> |
453 | - <p><?php echo sprintf(esc_html__('Please %1$suninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress'), '<a href="' . $url . '">', '</a>'); // phpcs:ignore ?></p> |
|
453 | + <p><?php echo sprintf( esc_html__( 'Please %1$suninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); // phpcs:ignore ?></p> |
|
454 | 454 | </div> |
455 | 455 | <?php |
456 | 456 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ( class_exists( 'MonsterInsights' ) ) { |
620 | 620 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
621 | - wp_die(sprintf(esc_html__('Please uninstall and remove MonsterInsights Pro before activating Google Analytics for WordPress by MonsterInsights. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress'), '<a href="' . $url . '">', '</a>')); // phpcs:ignore |
|
621 | + wp_die( sprintf( esc_html__( 'Please uninstall and remove MonsterInsights Pro before activating Google Analytics for WordPress by MonsterInsights. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress' ), '<a href="' . $url . '">', '</a>' ) ); // phpcs:ignore |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | require_once plugin_dir_path( __FILE__ ) . 'includes/compatibility-check.php'; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | 'shareasale_id' => monsterinsights_get_shareasale_id(), |
255 | 255 | 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ), |
256 | 256 | 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ), |
257 | - 'timezone' => date('e'), // phpcs:ignore |
|
257 | + 'timezone' => date( 'e' ), // phpcs:ignore |
|
258 | 258 | 'authed' => $site_auth || $ms_auth, |
259 | 259 | 'settings_url' => add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) ), |
260 | 260 | // Used to add notices for future deprecations. |
@@ -321,31 +321,31 @@ discard block |
||
321 | 321 | $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite'; |
322 | 322 | $plugin_path = plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ); |
323 | 323 | |
324 | - if ( ! isset( self::$manifest_data[ $js_file_path ] ) ) { |
|
324 | + if ( ! isset( self::$manifest_data[$js_file_path] ) ) { |
|
325 | 325 | return; |
326 | 326 | } |
327 | 327 | |
328 | - $js_imports = self::$manifest_data[ $js_file_path ]['imports']; |
|
328 | + $js_imports = self::$manifest_data[$js_file_path]['imports']; |
|
329 | 329 | $css_file_path = $plugin_path . $version_path . '/assets/vue/'; |
330 | 330 | |
331 | 331 | // Add JS own CSS file. |
332 | - if ( isset( self::$manifest_data[ $js_file_path ]['css'] ) ) { |
|
333 | - self::add_js_own_css_files( self::$manifest_data[ $js_file_path ]['css'], $version_path ); |
|
332 | + if ( isset( self::$manifest_data[$js_file_path]['css'] ) ) { |
|
333 | + self::add_js_own_css_files( self::$manifest_data[$js_file_path]['css'], $version_path ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // Loop through all imported js file of entry file. |
337 | 337 | foreach ( $js_imports as $js_filename ) { |
338 | 338 | // Check imported file available in manifest.json |
339 | - if ( ! isset( self::$manifest_data[ $js_filename ] ) ) { |
|
339 | + if ( ! isset( self::$manifest_data[$js_filename] ) ) { |
|
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | |
343 | 343 | // Check imported js file has it's own css. |
344 | - if ( ! isset( self::$manifest_data[ $js_filename ]['css'] ) ) { |
|
344 | + if ( ! isset( self::$manifest_data[$js_filename]['css'] ) ) { |
|
345 | 345 | continue; |
346 | 346 | } |
347 | 347 | |
348 | - $js_file_css = self::$manifest_data[ $js_filename ]['css']; |
|
348 | + $js_file_css = self::$manifest_data[$js_filename]['css']; |
|
349 | 349 | |
350 | 350 | // css must be array. |
351 | 351 | if ( ! is_array( $js_file_css ) ) { |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | // If the file is not available on manifest. |
398 | - if ( ! isset( self::$manifest_data[ $path ] ) ) { |
|
398 | + if ( ! isset( self::$manifest_data[$path] ) ) { |
|
399 | 399 | return; |
400 | 400 | } |
401 | 401 | |
402 | - $js_file = self::$manifest_data[ $path ]['file']; |
|
402 | + $js_file = self::$manifest_data[$path]['file']; |
|
403 | 403 | $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite'; |
404 | 404 | |
405 | 405 | return plugins_url( $version_path . '/assets/vue/' . $js_file, MONSTERINSIGHTS_PLUGIN_FILE ); |
@@ -41,7 +41,7 @@ |
||
41 | 41 | public function set_upgrader( &$upgrader ) { |
42 | 42 | |
43 | 43 | if ( is_object( $upgrader ) ) { |
44 | - $this->upgrader =& $upgrader; |
|
44 | + $this->upgrader = & $upgrader; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | // Fill summary data with total number of posts, pages, and comments. |
54 | 54 | if ( isset( $data['data']['summary'] ) ) { |
55 | - $posts = wp_count_posts('post'); |
|
55 | + $posts = wp_count_posts( 'post' ); |
|
56 | 56 | $data['data']['summary']['total_posts'] = $posts->publish; |
57 | - $pages = wp_count_posts('page'); |
|
57 | + $pages = wp_count_posts( 'page' ); |
|
58 | 58 | $data['data']['summary']['total_pages'] = $pages->publish; |
59 | 59 | $comments = get_comment_count(); |
60 | 60 | $data['data']['summary']['total_comments'] = $comments['all']; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | // Get the thumbnail for the post. |
65 | 65 | $post_id = url_to_postid( home_url() . $data['data']['popular_post']['url'] ); |
66 | 66 | $data['data']['popular_post']['id'] = $post_id; |
67 | - $data['data']['popular_post']['title'] = esc_html( get_the_title($post_id) ); |
|
67 | + $data['data']['popular_post']['title'] = esc_html( get_the_title( $post_id ) ); |
|
68 | 68 | $data['data']['popular_post']['img'] = get_the_post_thumbnail_url( $post_id, 'thumbnail' ); |
69 | 69 | } |
70 | 70 | |
71 | - if ( !empty( $data['data']['popular_page'] ) ) { |
|
71 | + if ( ! empty( $data['data']['popular_page'] ) ) { |
|
72 | 72 | // Compose the page url from homepage and the path we fetch from GA. |
73 | 73 | $data['data']['popular_page']['url'] = esc_url( home_url() . $data['data']['popular_page']['url'] ); |
74 | 74 | // Get the thumbnail for the post. |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __construct() |
20 | 20 | { |
21 | - $this->init_hooks(); |
|
21 | + $this->init_hooks(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | */ |
28 | 28 | private function init_hooks() |
29 | 29 | { |
30 | - // Rest API |
|
31 | - add_action( 'rest_api_init', [$this, 'register_ajax_endpoints'] ); |
|
30 | + // Rest API |
|
31 | + add_action( 'rest_api_init', [$this, 'register_ajax_endpoints'] ); |
|
32 | 32 | |
33 | - // Cron to clear expired feedback tracking |
|
34 | - add_action( 'monsterinsights_feature_feedback_clear_expired', [$this, 'clear_expired_feedback'] ); |
|
33 | + // Cron to clear expired feedback tracking |
|
34 | + add_action( 'monsterinsights_feature_feedback_clear_expired', [$this, 'clear_expired_feedback'] ); |
|
35 | 35 | |
36 | - if ( ! wp_next_scheduled( 'monsterinsights_feature_feedback_clear_expired' ) ) { |
|
37 | - wp_schedule_event( time(), 'weekly', 'monsterinsights_feature_feedback_clear_expired' ); |
|
38 | - } |
|
36 | + if ( ! wp_next_scheduled( 'monsterinsights_feature_feedback_clear_expired' ) ) { |
|
37 | + wp_schedule_event( time(), 'weekly', 'monsterinsights_feature_feedback_clear_expired' ); |
|
38 | + } |
|
39 | 39 | |
40 | - // Cron to send data to Relay |
|
41 | - add_action( 'monsterinsights_feature_feedback_checkin', [$this, 'feature_feedback_checkin'] ); |
|
40 | + // Cron to send data to Relay |
|
41 | + add_action( 'monsterinsights_feature_feedback_checkin', [$this, 'feature_feedback_checkin'] ); |
|
42 | 42 | |
43 | - if ( ! wp_next_scheduled( 'monsterinsights_feature_feedback_checkin' ) ) { |
|
44 | - wp_schedule_event( time(), 'daily', 'monsterinsights_feature_feedback_checkin' ); |
|
45 | - } |
|
43 | + if ( ! wp_next_scheduled( 'monsterinsights_feature_feedback_checkin' ) ) { |
|
44 | + wp_schedule_event( time(), 'daily', 'monsterinsights_feature_feedback_checkin' ); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public static function get_settings() |
49 | 49 | { |
50 | - $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
|
51 | - return [ |
|
52 | - 'tracked_features' => $tracked_features |
|
53 | - ]; |
|
50 | + $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
|
51 | + return [ |
|
52 | + 'tracked_features' => $tracked_features |
|
53 | + ]; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function register_ajax_endpoints() |
62 | 62 | { |
63 | - register_rest_route( 'monsterinsights/v1', '/feedback', array( |
|
64 | - 'methods' => WP_REST_Server::CREATABLE, |
|
65 | - 'callback' => [$this, 'submit_feedback'], |
|
66 | - 'permission_callback' => [$this, 'monsterinsights_permissions_callback'], |
|
67 | - )); |
|
63 | + register_rest_route( 'monsterinsights/v1', '/feedback', array( |
|
64 | + 'methods' => WP_REST_Server::CREATABLE, |
|
65 | + 'callback' => [$this, 'submit_feedback'], |
|
66 | + 'permission_callback' => [$this, 'monsterinsights_permissions_callback'], |
|
67 | + )); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function clear_expired_feedback() |
75 | 75 | { |
76 | - $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
|
76 | + $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
|
77 | 77 | |
78 | - $now = time(); |
|
78 | + $now = time(); |
|
79 | 79 | |
80 | - foreach ($tracked_features as $feature_key => $expires) { |
|
81 | - if ($now > $expires) { |
|
82 | - unset($tracked_features[$feature_key]); |
|
83 | - } |
|
84 | - } |
|
80 | + foreach ($tracked_features as $feature_key => $expires) { |
|
81 | + if ($now > $expires) { |
|
82 | + unset($tracked_features[$feature_key]); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - update_option( self::FEEDBACK_TRACKED_FEATURES, $tracked_features ); |
|
86 | + update_option( self::FEEDBACK_TRACKED_FEATURES, $tracked_features ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,32 +92,32 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function feature_feedback_checkin() |
94 | 94 | { |
95 | - $feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
|
95 | + $feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
|
96 | 96 | |
97 | - if ( empty($feedback) ) { |
|
98 | - return; |
|
99 | - } |
|
97 | + if ( empty($feedback) ) { |
|
98 | + return; |
|
99 | + } |
|
100 | 100 | |
101 | - $data = []; |
|
101 | + $data = []; |
|
102 | 102 | |
103 | - foreach ($feedback as $feature_key => $feedback_data) { |
|
104 | - $data[] = [ |
|
105 | - 'feature_key' => $feature_key, |
|
106 | - 'rating' => $feedback_data['rating'], |
|
107 | - 'feedback' => $feedback_data['message'], |
|
108 | - ]; |
|
109 | - } |
|
103 | + foreach ($feedback as $feature_key => $feedback_data) { |
|
104 | + $data[] = [ |
|
105 | + 'feature_key' => $feature_key, |
|
106 | + 'rating' => $feedback_data['rating'], |
|
107 | + 'feedback' => $feedback_data['message'], |
|
108 | + ]; |
|
109 | + } |
|
110 | 110 | |
111 | - $api = new MonsterInsights_API_Request( 'feature-feedback', [], 'POST' ); |
|
111 | + $api = new MonsterInsights_API_Request( 'feature-feedback', [], 'POST' ); |
|
112 | 112 | |
113 | - $result = $api->request([ |
|
114 | - 'feedback' => $data, |
|
115 | - ]); |
|
113 | + $result = $api->request([ |
|
114 | + 'feedback' => $data, |
|
115 | + ]); |
|
116 | 116 | |
117 | - if ( !is_wp_error( $result ) ) { |
|
118 | - // Clear option |
|
119 | - delete_option( self::FEEDBACK_SUBMITTED ); |
|
120 | - } |
|
117 | + if ( !is_wp_error( $result ) ) { |
|
118 | + // Clear option |
|
119 | + delete_option( self::FEEDBACK_SUBMITTED ); |
|
120 | + } |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,22 +127,22 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function submit_feedback($request ) |
129 | 129 | { |
130 | - if (empty($request['rating']) || empty($request['feature_key'])) { |
|
131 | - return new WP_Error('rest_invalid_param', 'Invalid parameter', ['status' => 400]); |
|
132 | - } |
|
133 | - |
|
134 | - // Store feedback to send to Relay later |
|
135 | - $feature_key = $request['feature_key']; |
|
136 | - $feedback = [ |
|
137 | - 'rating' => $request['rating'], |
|
138 | - 'message' => $request['message'], |
|
139 | - ]; |
|
140 | - |
|
141 | - $this->save_feedback($feature_key, $feedback); |
|
142 | - |
|
143 | - // Store to tracked features option |
|
144 | - $expires = time() + MONTH_IN_SECONDS; |
|
145 | - $this->add_tracked_feature($feature_key, $expires); |
|
130 | + if (empty($request['rating']) || empty($request['feature_key'])) { |
|
131 | + return new WP_Error('rest_invalid_param', 'Invalid parameter', ['status' => 400]); |
|
132 | + } |
|
133 | + |
|
134 | + // Store feedback to send to Relay later |
|
135 | + $feature_key = $request['feature_key']; |
|
136 | + $feedback = [ |
|
137 | + 'rating' => $request['rating'], |
|
138 | + 'message' => $request['message'], |
|
139 | + ]; |
|
140 | + |
|
141 | + $this->save_feedback($feature_key, $feedback); |
|
142 | + |
|
143 | + // Store to tracked features option |
|
144 | + $expires = time() + MONTH_IN_SECONDS; |
|
145 | + $this->add_tracked_feature($feature_key, $expires); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | */ |
154 | 154 | private function save_feedback($feature_key, $feedback) |
155 | 155 | { |
156 | - $stored_feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
|
157 | - $stored_feedback[$feature_key] = $feedback; |
|
156 | + $stored_feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
|
157 | + $stored_feedback[$feature_key] = $feedback; |
|
158 | 158 | |
159 | - update_option( self::FEEDBACK_SUBMITTED, $stored_feedback ); |
|
159 | + update_option( self::FEEDBACK_SUBMITTED, $stored_feedback ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | */ |
167 | 167 | private function add_tracked_feature($feature_key, $expires) |
168 | 168 | { |
169 | - $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
|
170 | - $tracked_features[$feature_key] = $expires; |
|
169 | + $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
|
170 | + $tracked_features[$feature_key] = $expires; |
|
171 | 171 | |
172 | - update_option( self::FEEDBACK_TRACKED_FEATURES, $tracked_features ); |
|
172 | + update_option( self::FEEDBACK_TRACKED_FEATURES, $tracked_features ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function monsterinsights_permissions_callback() |
181 | 181 | { |
182 | - // Check if the user has the required permissions |
|
183 | - return current_user_can( 'monsterinsights_save_settings' ); |
|
182 | + // Check if the user has the required permissions |
|
183 | + return current_user_can( 'monsterinsights_save_settings' ); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'methods' => WP_REST_Server::CREATABLE, |
65 | 65 | 'callback' => [$this, 'submit_feedback'], |
66 | 66 | 'permission_callback' => [$this, 'monsterinsights_permissions_callback'], |
67 | - )); |
|
67 | + ) ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | |
78 | 78 | $now = time(); |
79 | 79 | |
80 | - foreach ($tracked_features as $feature_key => $expires) { |
|
81 | - if ($now > $expires) { |
|
82 | - unset($tracked_features[$feature_key]); |
|
80 | + foreach ( $tracked_features as $feature_key => $expires ) { |
|
81 | + if ( $now > $expires ) { |
|
82 | + unset( $tracked_features[$feature_key] ); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | { |
95 | 95 | $feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
96 | 96 | |
97 | - if ( empty($feedback) ) { |
|
97 | + if ( empty( $feedback ) ) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
101 | 101 | $data = []; |
102 | 102 | |
103 | - foreach ($feedback as $feature_key => $feedback_data) { |
|
103 | + foreach ( $feedback as $feature_key => $feedback_data ) { |
|
104 | 104 | $data[] = [ |
105 | 105 | 'feature_key' => $feature_key, |
106 | 106 | 'rating' => $feedback_data['rating'], |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | |
111 | 111 | $api = new MonsterInsights_API_Request( 'feature-feedback', [], 'POST' ); |
112 | 112 | |
113 | - $result = $api->request([ |
|
113 | + $result = $api->request( [ |
|
114 | 114 | 'feedback' => $data, |
115 | - ]); |
|
115 | + ] ); |
|
116 | 116 | |
117 | - if ( !is_wp_error( $result ) ) { |
|
117 | + if ( ! is_wp_error( $result ) ) { |
|
118 | 118 | // Clear option |
119 | 119 | delete_option( self::FEEDBACK_SUBMITTED ); |
120 | 120 | } |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | * @param $request |
126 | 126 | * @return WP_Error|WP_HTTP_Response|WP_REST_Response |
127 | 127 | */ |
128 | - public function submit_feedback($request ) |
|
128 | + public function submit_feedback( $request ) |
|
129 | 129 | { |
130 | - if (empty($request['rating']) || empty($request['feature_key'])) { |
|
131 | - return new WP_Error('rest_invalid_param', 'Invalid parameter', ['status' => 400]); |
|
130 | + if ( empty( $request['rating'] ) || empty( $request['feature_key'] ) ) { |
|
131 | + return new WP_Error( 'rest_invalid_param', 'Invalid parameter', ['status' => 400] ); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // Store feedback to send to Relay later |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | 'message' => $request['message'], |
139 | 139 | ]; |
140 | 140 | |
141 | - $this->save_feedback($feature_key, $feedback); |
|
141 | + $this->save_feedback( $feature_key, $feedback ); |
|
142 | 142 | |
143 | 143 | // Store to tracked features option |
144 | 144 | $expires = time() + MONTH_IN_SECONDS; |
145 | - $this->add_tracked_feature($feature_key, $expires); |
|
145 | + $this->add_tracked_feature( $feature_key, $expires ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param $feedback |
152 | 152 | * @return void |
153 | 153 | */ |
154 | - private function save_feedback($feature_key, $feedback) |
|
154 | + private function save_feedback( $feature_key, $feedback ) |
|
155 | 155 | { |
156 | 156 | $stored_feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
157 | 157 | $stored_feedback[$feature_key] = $feedback; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param $expires |
165 | 165 | * @return void |
166 | 166 | */ |
167 | - private function add_tracked_feature($feature_key, $expires) |
|
167 | + private function add_tracked_feature( $feature_key, $expires ) |
|
168 | 168 | { |
169 | 169 | $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
170 | 170 | $tracked_features[$feature_key] = $expires; |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | * @author David Paternina |
6 | 6 | */ |
7 | -class MonsterInsights_Feature_Feedback |
|
8 | -{ |
|
7 | +class MonsterInsights_Feature_Feedback { |
|
9 | 8 | /** |
10 | 9 | * Feedback registered features |
11 | 10 | */ |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | */ |
17 | 16 | const FEEDBACK_SUBMITTED = 'monsterinsights_feedback_submitted'; |
18 | 17 | |
19 | - public function __construct() |
|
20 | - { |
|
18 | + public function __construct() { |
|
21 | 19 | $this->init_hooks(); |
22 | 20 | } |
23 | 21 | |
@@ -25,8 +23,7 @@ discard block |
||
25 | 23 | * Init hooks |
26 | 24 | * @return void |
27 | 25 | */ |
28 | - private function init_hooks() |
|
29 | - { |
|
26 | + private function init_hooks() { |
|
30 | 27 | // Rest API |
31 | 28 | add_action( 'rest_api_init', [$this, 'register_ajax_endpoints'] ); |
32 | 29 | |
@@ -45,8 +42,7 @@ discard block |
||
45 | 42 | } |
46 | 43 | } |
47 | 44 | |
48 | - public static function get_settings() |
|
49 | - { |
|
45 | + public static function get_settings() { |
|
50 | 46 | $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
51 | 47 | return [ |
52 | 48 | 'tracked_features' => $tracked_features |
@@ -58,8 +54,7 @@ discard block |
||
58 | 54 | * |
59 | 55 | * @return void |
60 | 56 | */ |
61 | - public function register_ajax_endpoints() |
|
62 | - { |
|
57 | + public function register_ajax_endpoints() { |
|
63 | 58 | register_rest_route( 'monsterinsights/v1', '/feedback', array( |
64 | 59 | 'methods' => WP_REST_Server::CREATABLE, |
65 | 60 | 'callback' => [$this, 'submit_feedback'], |
@@ -71,8 +66,7 @@ discard block |
||
71 | 66 | * Clear expired feedback |
72 | 67 | * @return void |
73 | 68 | */ |
74 | - public function clear_expired_feedback() |
|
75 | - { |
|
69 | + public function clear_expired_feedback() { |
|
76 | 70 | $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
77 | 71 | |
78 | 72 | $now = time(); |
@@ -90,8 +84,7 @@ discard block |
||
90 | 84 | * Checkin to send feedback to Relay |
91 | 85 | * @return void |
92 | 86 | */ |
93 | - public function feature_feedback_checkin() |
|
94 | - { |
|
87 | + public function feature_feedback_checkin() { |
|
95 | 88 | $feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
96 | 89 | |
97 | 90 | if ( empty($feedback) ) { |
@@ -125,8 +118,7 @@ discard block |
||
125 | 118 | * @param $request |
126 | 119 | * @return WP_Error|WP_HTTP_Response|WP_REST_Response |
127 | 120 | */ |
128 | - public function submit_feedback($request ) |
|
129 | - { |
|
121 | + public function submit_feedback($request ) { |
|
130 | 122 | if (empty($request['rating']) || empty($request['feature_key'])) { |
131 | 123 | return new WP_Error('rest_invalid_param', 'Invalid parameter', ['status' => 400]); |
132 | 124 | } |
@@ -151,8 +143,7 @@ discard block |
||
151 | 143 | * @param $feedback |
152 | 144 | * @return void |
153 | 145 | */ |
154 | - private function save_feedback($feature_key, $feedback) |
|
155 | - { |
|
146 | + private function save_feedback($feature_key, $feedback) { |
|
156 | 147 | $stored_feedback = get_option( self::FEEDBACK_SUBMITTED, [] ); |
157 | 148 | $stored_feedback[$feature_key] = $feedback; |
158 | 149 | |
@@ -164,8 +155,7 @@ discard block |
||
164 | 155 | * @param $expires |
165 | 156 | * @return void |
166 | 157 | */ |
167 | - private function add_tracked_feature($feature_key, $expires) |
|
168 | - { |
|
158 | + private function add_tracked_feature($feature_key, $expires) { |
|
169 | 159 | $tracked_features = get_option( self::FEEDBACK_TRACKED_FEATURES, [] ); |
170 | 160 | $tracked_features[$feature_key] = $expires; |
171 | 161 | |
@@ -177,8 +167,7 @@ discard block |
||
177 | 167 | * |
178 | 168 | * @return bool |
179 | 169 | */ |
180 | - public function monsterinsights_permissions_callback() |
|
181 | - { |
|
170 | + public function monsterinsights_permissions_callback() { |
|
182 | 171 | // Check if the user has the required permissions |
183 | 172 | return current_user_can( 'monsterinsights_save_settings' ); |
184 | 173 | } |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | |
11 | 11 | protected $type = 'graph'; |
12 | 12 | |
13 | - public function output(){ |
|
13 | + public function output() { |
|
14 | 14 | $json_data = $this->get_json_data(); |
15 | 15 | |
16 | - if (empty($json_data)) { |
|
16 | + if ( empty( $json_data ) ) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | protected function get_options() { |
26 | - if (empty($this->data['overviewgraph'])) { |
|
26 | + if ( empty( $this->data['overviewgraph'] ) ) { |
|
27 | 27 | return false; |
28 | 28 | } |
29 | 29 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | protected $type = 'graph'; |
12 | 12 | |
13 | - public function output(){ |
|
13 | + public function output() { |
|
14 | 14 | $json_data = $this->get_json_data(); |
15 | 15 | |
16 | 16 | if (empty($json_data)) { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | foreach ( $this->classes as $class ) { |
157 | 157 | |
158 | 158 | //In the scores array add another dimention for the class and set it's value to 1. EG $scores->neg->1 |
159 | - $scores[ $class ] = 1; |
|
159 | + $scores[$class] = 1; |
|
160 | 160 | |
161 | 161 | //For each of the individual words used loop through to see if they match anything in the $dictionary |
162 | 162 | foreach ( $tokens as $token ) { |
@@ -164,29 +164,29 @@ discard block |
||
164 | 164 | //If statement so to ignore tokens which are either too long or too short or in the $ignoreList |
165 | 165 | if ( strlen( $token ) > $this->minTokenLength && strlen( $token ) < $this->maxTokenLength && ! in_array( $token, $this->ignoreList ) ) { |
166 | 166 | //If dictionary[token][class] is set |
167 | - if ( isset( $this->dictionary[ $token ][ $class ] ) ) { |
|
167 | + if ( isset( $this->dictionary[$token][$class] ) ) { |
|
168 | 168 | //Set count equal to it |
169 | - $count = $this->dictionary[ $token ][ $class ]; |
|
169 | + $count = $this->dictionary[$token][$class]; |
|
170 | 170 | } else { |
171 | 171 | $count = 0; |
172 | 172 | } |
173 | 173 | |
174 | 174 | //Score[class] is calcumeted by $scores[class] x $count +1 divided by the $classTokCounts[class] + $tokCount |
175 | - $scores[ $class ] *= ( $count + 1 ); |
|
175 | + $scores[$class] *= ( $count + 1 ); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | 179 | //Score for this class is the prior probability multiplyied by the score for this class |
180 | - $scores[ $class ] = $this->prior[ $class ] * $scores[ $class ]; |
|
180 | + $scores[$class] = $this->prior[$class] * $scores[$class]; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | //Makes the scores relative percents |
184 | 184 | foreach ( $this->classes as $class ) { |
185 | - $total_score += $scores[ $class ]; |
|
185 | + $total_score += $scores[$class]; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | foreach ( $this->classes as $class ) { |
189 | - $scores[ $class ] = round( $scores[ $class ] / $total_score, 3 ); |
|
189 | + $scores[$class] = round( $scores[$class] / $total_score, 3 ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | //Sort array in reverse order |
@@ -241,21 +241,21 @@ discard block |
||
241 | 241 | //Loop through all of the entries |
242 | 242 | foreach ( (array) $words as $word ) { |
243 | 243 | |
244 | - $this->docCount ++; |
|
245 | - $this->classDocCounts[ $class ] ++; |
|
244 | + $this->docCount++; |
|
245 | + $this->classDocCounts[$class]++; |
|
246 | 246 | |
247 | 247 | //Trim word |
248 | 248 | $word = trim( $word ); |
249 | 249 | |
250 | 250 | //If this word isn't already in the dictionary with this class |
251 | - if ( ! isset( $this->dictionary[ $word ][ $class ] ) ) { |
|
251 | + if ( ! isset( $this->dictionary[$word][$class] ) ) { |
|
252 | 252 | |
253 | 253 | //Add to this word to the dictionary and set counter value as one. This function ensures that if a word is in the text file more than once it still is only accounted for one in the array |
254 | - $this->dictionary[ $word ][ $class ] = 1; |
|
254 | + $this->dictionary[$word][$class] = 1; |
|
255 | 255 | }//Close If statement |
256 | 256 | |
257 | - $this->classTokCounts[ $class ] ++; |
|
258 | - $this->tokCount ++; |
|
257 | + $this->classTokCounts[$class]++; |
|
258 | + $this->tokCount++; |
|
259 | 259 | }//Close while loop going through everyline in the text file |
260 | 260 | |
261 | 261 | return true; |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | //Set up empty word list array |
355 | 355 | $wordList = array(); |
356 | 356 | |
357 | - $fn = "{$this->dataFolder}data.{$type}.php";; |
|
357 | + $fn = "{$this->dataFolder}data.{$type}.php"; ; |
|
358 | 358 | if ( file_exists( $fn ) ) { |
359 | 359 | $temp = file_get_contents( $fn ); |
360 | 360 | $words = unserialize( trim( $temp ) ); |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | - $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
26 | - wp_enqueue_script( 'lodash', includes_url('js') . '/underscore.min.js' ); |
|
25 | + $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
26 | + wp_enqueue_script( 'lodash', includes_url( 'js' ) . '/underscore.min.js' ); |
|
27 | 27 | // @TODO Robo minification is breaking the editor. We will use the main version for now. |
28 | 28 | $plugins_js_path = '/assets/gutenberg/js/editor.js'; |
29 | 29 | $plugins_style_path = '/assets/gutenberg/css/editor.css'; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | 'page_insights_nonce' => wp_create_nonce( 'mi-admin-nonce' ), |
115 | 115 | 'isnetwork' => is_network_admin(), |
116 | 116 | 'is_v4' => true, |
117 | - 'dismiss_envira_promo' => isset($plugins['envira-gallery-lite/envira-gallery-lite.php']) || isset($plugins['envira-gallery/envira-gallery.php']) || get_transient('_monsterinsights_dismiss_envira_promo'), |
|
117 | + 'dismiss_envira_promo' => isset( $plugins['envira-gallery-lite/envira-gallery-lite.php'] ) || isset( $plugins['envira-gallery/envira-gallery.php'] ) || get_transient( '_monsterinsights_dismiss_envira_promo' ), |
|
118 | 118 | ) ) |
119 | 119 | ); |
120 | 120 | } |