@@ -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)) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | abstract public function output(); |
53 | 53 | |
54 | - public function __construct( $attributes, $data ){ |
|
54 | + public function __construct( $attributes, $data ) { |
|
55 | 55 | $this->attributes = $attributes; |
56 | 56 | $this->data = $data; |
57 | 57 | } |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | public function get_json_data() { |
65 | 65 | $data = $this->get_options(); |
66 | 66 | |
67 | - if (empty($data)){ |
|
67 | + if ( empty( $data ) ) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | |
71 | - return json_encode($data); |
|
71 | + return json_encode( $data ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | abstract public function output(); |
53 | 53 | |
54 | - public function __construct( $attributes, $data ){ |
|
54 | + public function __construct( $attributes, $data ) { |
|
55 | 55 | $this->attributes = $attributes; |
56 | 56 | $this->data = $data; |
57 | 57 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function get_json_data() { |
65 | 65 | $data = $this->get_options(); |
66 | 66 | |
67 | - if (empty($data)){ |
|
67 | + if (empty($data)) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 |
@@ -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' . $suffix . '.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 | } |
@@ -12,17 +12,17 @@ discard block |
||
12 | 12 | * @return void |
13 | 13 | */ |
14 | 14 | public function register_frontend_scripts() { |
15 | - $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
15 | + $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
16 | 16 | |
17 | - wp_register_script('apexcharts', plugins_url('assets/js/frontend/apexcharts.min.js', MONSTERINSIGHTS_PLUGIN_FILE), array(), monsterinsights_get_asset_version(), true); |
|
18 | - wp_register_style('apexcharts', plugins_url('assets/js/frontend/apexcharts.css', MONSTERINSIGHTS_PLUGIN_FILE), array(), monsterinsights_get_asset_version(), true); |
|
17 | + wp_register_script( 'apexcharts', plugins_url( 'assets/js/frontend/apexcharts.min.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true ); |
|
18 | + wp_register_style( 'apexcharts', plugins_url( 'assets/js/frontend/apexcharts.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true ); |
|
19 | 19 | |
20 | 20 | $scripts_url = apply_filters( |
21 | 21 | 'monsterinsights_frontend_scripts_url', |
22 | - plugins_url('assets/js/frontend/block-scripts' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE) |
|
22 | + plugins_url( 'assets/js/frontend/block-scripts' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ) |
|
23 | 23 | ); |
24 | 24 | |
25 | - wp_register_script('monsterinsights-block-scripts', $scripts_url, array( 'apexcharts', 'jquery' ), monsterinsights_get_asset_version(), true); |
|
25 | + wp_register_script( 'monsterinsights-block-scripts', $scripts_url, array( 'apexcharts', 'jquery' ), monsterinsights_get_asset_version(), true ); |
|
26 | 26 | |
27 | 27 | $style_url = apply_filters( |
28 | 28 | 'monsterinsights_frontend_style_url', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | */ |
41 | 41 | private function load_assets() { |
42 | - wp_enqueue_script('monsterinsights-block-scripts'); |
|
42 | + wp_enqueue_script( 'monsterinsights-block-scripts' ); |
|
43 | 43 | wp_enqueue_style( 'monsterinsights-editor-frontend-style' ); |
44 | 44 | } |
45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param $block |
51 | 51 | * @return false|string |
52 | 52 | */ |
53 | - public function block_output($attributes, $block) { |
|
53 | + public function block_output( $attributes, $block ) { |
|
54 | 54 | $type = $attributes['type']; |
55 | 55 | $metric = $attributes['metric']; |
56 | 56 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | // Based on the $type and $metric we'll compose the template path and class name for the block output. |
66 | - $template_file = MONSTERINSIGHTS_PLUGIN_DIR . 'includes/gutenberg/site-insights/templates/' . $type . '/class-' . $type . '-' . $metric . '.php'; |
|
66 | + $template_file = MONSTERINSIGHTS_PLUGIN_DIR . 'includes/gutenberg/site-insights/templates/' . $type . '/class-' . $type . '-' . $metric . '.php'; |
|
67 | 67 | |
68 | - if (!file_exists($template_file)) { |
|
68 | + if ( ! file_exists( $template_file ) ) { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | require_once MONSTERINSIGHTS_PLUGIN_DIR . '/includes/gutenberg/site-insights/templates/class-site-insights-duoscorecard-template.php'; |
74 | 74 | require_once $template_file; |
75 | 75 | |
76 | - $class_name = 'MonsterInsights_SiteInsights_Template_' . ucfirst($type) . '_' . ucfirst($metric); |
|
76 | + $class_name = 'MonsterInsights_SiteInsights_Template_' . ucfirst( $type ) . '_' . ucfirst( $metric ); |
|
77 | 77 | |
78 | - if ( !class_exists($class_name) ) { |
|
78 | + if ( ! class_exists( $class_name ) ) { |
|
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
82 | - $template = new $class_name($attributes, $data); |
|
82 | + $template = new $class_name( $attributes, $data ); |
|
83 | 83 | $output = $template->output(); |
84 | 84 | |
85 | - $block_attributes = get_block_wrapper_attributes(array( |
|
85 | + $block_attributes = get_block_wrapper_attributes( array( |
|
86 | 86 | 'class' => "monsterinsights-{$type}-block", |
87 | - )); |
|
87 | + ) ); |
|
88 | 88 | |
89 | 89 | return sprintf( '<div %1$s>%2$s</div>', $block_attributes, $output ); |
90 | 90 | } |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | |
108 | 108 | $report = new MonsterInsights_Report_Site_Insights(); |
109 | 109 | |
110 | - $data = $report->get_data(array( |
|
110 | + $data = $report->get_data( array( |
|
111 | 111 | 'start' => date( 'Y-m-d', strtotime( '-31 days' ) ), |
112 | 112 | 'end' => date( 'Y-m-d', strtotime( '-1 days' ) ) |
113 | - )); |
|
113 | + ) ); |
|
114 | 114 | |
115 | - if ( !isset( $data['success'] ) || !$data['success'] || empty($data['data'])) { |
|
115 | + if ( ! isset( $data['success'] ) || ! $data['success'] || empty( $data['data'] ) ) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | array( 'html' => $content, 'analysed' => false ) |
62 | 62 | ); |
63 | 63 | } else { |
64 | - if(!isset($_REQUEST['q'])){ |
|
64 | + if ( ! isset( $_REQUEST['q'] ) ) { |
|
65 | 65 | wp_send_json_error( |
66 | 66 | array( 'html' => '', 'analysed' => false ) |
67 | 67 | ); |
68 | 68 | } |
69 | - $q = (isset($_REQUEST['q'])) ? sanitize_text_field($_REQUEST['q']) : ''; |
|
69 | + $q = ( isset( $_REQUEST['q'] ) ) ? sanitize_text_field( $_REQUEST['q'] ) : ''; |
|
70 | 70 | // send the response |
71 | 71 | wp_send_json_success( |
72 | 72 | array( |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return Object |
123 | 123 | */ |
124 | 124 | function get_headline_scores() { |
125 | - $input = (isset($_REQUEST['q'])) ? sanitize_text_field($_REQUEST['q']) : ''; |
|
125 | + $input = ( isset( $_REQUEST['q'] ) ) ? sanitize_text_field( $_REQUEST['q'] ) : ''; |
|
126 | 126 | |
127 | 127 | // init the result array |
128 | 128 | $result = new \stdClass(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // HDL type: Question |
284 | - $qn_quantifiers = array( |
|
284 | + $qn_quantifiers = array( |
|
285 | 285 | __( 'where', 'google-analytics-for-wordpress' ), |
286 | 286 | __( 'when', 'google-analytics-for-wordpress' ), |
287 | 287 | __( 'how', 'google-analytics-for-wordpress' ), |
@@ -366,12 +366,12 @@ discard block |
||
366 | 366 | |
367 | 367 | if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
368 | 368 | //check ip from share internet |
369 | - $ip = sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
369 | + $ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
370 | 370 | } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
371 | 371 | //to check ip is pass from proxy |
372 | - $ip = sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])); |
|
372 | + $ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ); |
|
373 | 373 | } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
374 | - $ip = sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
374 | + $ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // Fix potential CSV returned from $_SERVER variables |
@@ -61,7 +61,7 @@ |
||
61 | 61 | array( 'html' => $content, 'analysed' => false ) |
62 | 62 | ); |
63 | 63 | } else { |
64 | - if(!isset($_REQUEST['q'])){ |
|
64 | + if(!isset($_REQUEST['q'])) { |
|
65 | 65 | wp_send_json_error( |
66 | 66 | array( 'html' => '', 'analysed' => false ) |
67 | 67 | ); |
@@ -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( $temp ); |
@@ -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'; |