@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | License: GPLv3 |
12 | 12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html |
13 | 13 | */ |
14 | -if (!defined('ABSPATH')) exit; |
|
14 | +if ( ! defined('ABSPATH')) exit; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | //Define basic names |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | defined('CGSS_PATH') or define('CGSS_PATH', plugin_dir_path(__FILE__)); |
22 | 22 | defined('CGSS_FILE') or define('CGSS_FILE', plugin_basename(__FILE__)); |
23 | 23 | |
24 | -defined('CGSS_EXECUTE') or define('CGSS_EXECUTE', plugin_dir_path(__FILE__).'src/'); |
|
25 | -defined('CGSS_HELPER') or define('CGSS_HELPER', plugin_dir_path(__FILE__).'helper/'); |
|
26 | -defined('CGSS_TRANSLATE') or define('CGSS_TRANSLATE', plugin_basename( plugin_dir_path(__FILE__).'asset/ln/')); |
|
24 | +defined('CGSS_EXECUTE') or define('CGSS_EXECUTE', plugin_dir_path(__FILE__) . 'src/'); |
|
25 | +defined('CGSS_HELPER') or define('CGSS_HELPER', plugin_dir_path(__FILE__) . 'helper/'); |
|
26 | +defined('CGSS_TRANSLATE') or define('CGSS_TRANSLATE', plugin_basename(plugin_dir_path(__FILE__) . 'asset/ln/')); |
|
27 | 27 | |
28 | 28 | //change /wp-plugin-framework/ with your /plugin-name/ |
29 | -defined('CGSS_JS') or define('CGSS_JS', plugins_url().'/complete-google-seo-scan/asset/js/'); |
|
30 | -defined('CGSS_CSS') or define('CGSS_CSS', plugins_url().'/complete-google-seo-scan/asset/css/'); |
|
31 | -defined('CGSS_IMAGE') or define('CGSS_IMAGE', plugins_url().'/complete-google-seo-scan/asset/img/'); |
|
29 | +defined('CGSS_JS') or define('CGSS_JS', plugins_url() . '/complete-google-seo-scan/asset/js/'); |
|
30 | +defined('CGSS_CSS') or define('CGSS_CSS', plugins_url() . '/complete-google-seo-scan/asset/css/'); |
|
31 | +defined('CGSS_IMAGE') or define('CGSS_IMAGE', plugins_url() . '/complete-google-seo-scan/asset/img/'); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * The Plugin |
39 | 39 | */ |
40 | 40 | function cgss_build() { |
41 | - if ( class_exists( 'NirjharLo\\Cgss\\Loader' ) ) { |
|
41 | + if (class_exists('NirjharLo\\Cgss\\Loader')) { |
|
42 | 42 | return NirjharLo\Cgss\Loader::instance(); |
43 | 43 | } |
44 | 44 | } |
@@ -11,7 +11,9 @@ |
||
11 | 11 | License: GPLv3 |
12 | 12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html |
13 | 13 | */ |
14 | -if (!defined('ABSPATH')) exit; |
|
14 | +if (!defined('ABSPATH')) { |
|
15 | + exit; |
|
16 | +} |
|
15 | 17 | |
16 | 18 | |
17 | 19 | //Define basic names |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | use \WP_List_Table; |
@@ -14,24 +14,24 @@ discard block |
||
14 | 14 | * $Table->display(); |
15 | 15 | * |
16 | 16 | */ |
17 | -if ( ! class_exists( 'CGSS_TABLE' ) ) { |
|
17 | +if ( ! class_exists('CGSS_TABLE')) { |
|
18 | 18 | |
19 | 19 | final class Table extends WP_List_Table { |
20 | 20 | |
21 | 21 | |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - parent::__construct( [ |
|
25 | - 'singular' => __( 'Post', 'cgss' ), |
|
26 | - 'plural' => __( 'Posts', 'cgss' ), |
|
24 | + parent::__construct([ |
|
25 | + 'singular' => __('Post', 'cgss'), |
|
26 | + 'plural' => __('Posts', 'cgss'), |
|
27 | 27 | 'ajax' => false, |
28 | - ] ); |
|
28 | + ]); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | 33 | //fetch the data using custom named method function |
34 | - public static function get_posts( $per_page = 10, $page_number = 1 ) { |
|
34 | + public static function get_posts($per_page = 10, $page_number = 1) { |
|
35 | 35 | |
36 | 36 | global $wpdb; |
37 | 37 | |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | $sql .= " QUERIES WHERE post_status='publish' AND post_type='$page'"; |
43 | 43 | |
44 | 44 | //Set filters in the query using $_REQUEST |
45 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
46 | - $sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] ); |
|
47 | - $sql .= ! empty( $_REQUEST['order'] ) ? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC'; |
|
45 | + if ( ! empty($_REQUEST['orderby'])) { |
|
46 | + $sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']); |
|
47 | + $sql .= ! empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC'; |
|
48 | 48 | } |
49 | 49 | $sql .= " LIMIT $per_page"; |
50 | - $sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page; |
|
50 | + $sql .= ' OFFSET ' . ($page_number - 1) * $per_page; |
|
51 | 51 | |
52 | 52 | //get the data from database |
53 | - $result = $wpdb->get_results( $sql, 'ARRAY_A' ); |
|
53 | + $result = $wpdb->get_results($sql, 'ARRAY_A'); |
|
54 | 54 | |
55 | 55 | // FETCH POST META DATA AND MERGE IT WITH RESULTS |
56 | 56 | $result = SELF::get_post_meta_data($result); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | //If there is no data to show |
64 | 64 | public function no_items() { |
65 | 65 | |
66 | - _e( 'No Published Posts are available.', 'cgss' ); |
|
66 | + _e('No Published Posts are available.', 'cgss'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -80,45 +80,45 @@ discard block |
||
80 | 80 | $sql = "SELECT COUNT(*) FROM {$wpdb->prefix}posts"; |
81 | 81 | $sql .= " QUERIES WHERE post_status='publish' AND post_type='$page'"; |
82 | 82 | |
83 | - return $wpdb->get_var( $sql ); |
|
83 | + return $wpdb->get_var($sql); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | |
88 | 88 | //Display columns content |
89 | - public function column_name( $item ) { |
|
89 | + public function column_name($item) { |
|
90 | 90 | |
91 | - $title = sprintf( '<strong>%s</strong>', $item['post_title'] ); |
|
91 | + $title = sprintf('<strong>%s</strong>', $item['post_title']); |
|
92 | 92 | |
93 | 93 | //Change the page instruction where you want to show it |
94 | 94 | $actions = array( |
95 | - 'scan' => sprintf( '<a href="?page='.$_GET['page'].'&scan='.$item['ID'].'" target="_blank">%s</a>', __( 'Scan', 'cgss' ) ), |
|
96 | - 'view' => sprintf( '<a href="'.get_permalink($item['ID']).'" target="_blank">%s</a>', __( 'View', 'cgss' ) ) |
|
95 | + 'scan' => sprintf('<a href="?page=' . $_GET['page'] . '&scan=' . $item['ID'] . '" target="_blank">%s</a>', __('Scan', 'cgss')), |
|
96 | + 'view' => sprintf('<a href="' . get_permalink($item['ID']) . '" target="_blank">%s</a>', __('View', 'cgss')) |
|
97 | 97 | ); |
98 | - return $title . $this->row_actions( $actions ); |
|
98 | + return $title . $this->row_actions($actions); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | |
103 | 103 | //set coulmns name |
104 | - public function column_default( $item, $column_name ) { |
|
104 | + public function column_default($item, $column_name) { |
|
105 | 105 | |
106 | - switch ( $column_name ) { |
|
106 | + switch ($column_name) { |
|
107 | 107 | |
108 | 108 | case 'post_title': |
109 | 109 | //This is the first column |
110 | - return $this->column_name( $item ); |
|
110 | + return $this->column_name($item); |
|
111 | 111 | case 'focus': |
112 | 112 | case 'word': |
113 | 113 | case 'link': |
114 | 114 | case 'image': |
115 | 115 | case 'share': |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | case 'time': |
118 | - return $item[ $column_name ]; |
|
118 | + return $item[$column_name]; |
|
119 | 119 | default: |
120 | 120 | //Show the whole array for troubleshooting purposes |
121 | - return print_r( $item, true ); |
|
121 | + return print_r($item, true); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | public function get_columns() { |
129 | 129 | |
130 | 130 | $columns = array( |
131 | - 'post_title' => __( 'Post', 'cgss' ), |
|
132 | - 'focus' => __( 'Focus', 'cgss' ), |
|
133 | - 'word' => __( 'Words', 'cgss' ), |
|
134 | - 'link' => __( 'Links', 'cgss' ), |
|
135 | - 'image' => __( 'Images', 'cgss' ), |
|
136 | - 'share' => __( 'Shares', 'cgss' ), |
|
137 | - 'time' => __( 'Time(s)', 'cgss' ), |
|
131 | + 'post_title' => __('Post', 'cgss'), |
|
132 | + 'focus' => __('Focus', 'cgss'), |
|
133 | + 'word' => __('Words', 'cgss'), |
|
134 | + 'link' => __('Links', 'cgss'), |
|
135 | + 'image' => __('Images', 'cgss'), |
|
136 | + 'share' => __('Shares', 'cgss'), |
|
137 | + 'time' => __('Time(s)', 'cgss'), |
|
138 | 138 | |
139 | 139 | ); |
140 | 140 | return $columns; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | public function get_sortable_columns() { |
147 | 147 | |
148 | 148 | $sortable_columns = array( |
149 | - 'post_title' => array( 'post_title', true ), |
|
149 | + 'post_title' => array('post_title', true), |
|
150 | 150 | ); |
151 | 151 | return $sortable_columns; |
152 | 152 | } |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | $this->_column_headers = $this->get_column_info(); |
160 | 160 | |
161 | 161 | /** Process bulk action */ |
162 | - $per_page = $this->get_items_per_page( 'post_per_page', 5 ); |
|
162 | + $per_page = $this->get_items_per_page('post_per_page', 5); |
|
163 | 163 | $current_page = $this->get_pagenum(); |
164 | 164 | $total_items = self::record_count(); |
165 | - $this->set_pagination_args( array( |
|
165 | + $this->set_pagination_args(array( |
|
166 | 166 | 'total_items' => $total_items, |
167 | 167 | 'per_page' => $per_page, |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | |
170 | - $this->items = self::get_posts( $per_page, $current_page ); |
|
170 | + $this->items = self::get_posts($per_page, $current_page); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -181,18 +181,18 @@ discard block |
||
181 | 181 | 'text' => array( |
182 | 182 | 'count' => '--', |
183 | 183 | 'top_key' => '--', |
184 | - 'links' => array( 'count' => '--' ), |
|
184 | + 'links' => array('count' => '--'), |
|
185 | 185 | ), |
186 | 186 | 'design' => array( |
187 | - 'image' => array( 'count' => '--' ) |
|
187 | + 'image' => array('count' => '--') |
|
188 | 188 | ), |
189 | 189 | 'social' => '--', |
190 | - 'speed' => array( 'down_time' => '--' ), |
|
190 | + 'speed' => array('down_time' => '--'), |
|
191 | 191 | ); |
192 | 192 | |
193 | 193 | $metas = array(); |
194 | 194 | foreach ($IDs as $post_id) { |
195 | - $meta = get_post_meta( $post_id, 'cgss_scan_result', true ); |
|
195 | + $meta = get_post_meta($post_id, 'cgss_scan_result', true); |
|
196 | 196 | $metas[] = is_array($meta) ? $meta : $empty_metas; |
197 | 197 | } |
198 | 198 | $text = array_column($metas, 'text'); |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | |
7 | 9 | use \WP_List_Table; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * Add scripts to the plugin. CSS and JS. |
6 | 6 | */ |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if ( ! defined('ABSPATH')) exit; |
|
8 | 8 | |
9 | 9 | |
10 | 10 | final class Script { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct() { |
14 | 14 | |
15 | - add_action( 'admin_head', array( $this, 'data_table_css' ) ); |
|
15 | + add_action('admin_head', array($this, 'data_table_css')); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 |
@@ -4,7 +4,9 @@ |
||
4 | 4 | /** |
5 | 5 | * Add scripts to the plugin. CSS and JS. |
6 | 6 | */ |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if ( ! defined( 'ABSPATH' ) ) { |
|
8 | + exit; |
|
9 | +} |
|
8 | 10 | |
9 | 11 | |
10 | 12 | final class Script { |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | use \NirjharLo\Cgss\Lib\Analysis\Lib\Tags; |
7 | 9 | use \NirjharLo\Cgss\Lib\Analysis\Lib\Text; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | use \NirjharLo\Cgss\Lib\Analysis\Lib\Tags; |
7 | 7 | use \NirjharLo\Cgss\Lib\Analysis\Lib\Text; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $this->header = $this->header_check(); |
31 | 31 | $ok = $this->header['ok']; |
32 | - if (!$ok) { |
|
32 | + if ( ! $ok) { |
|
33 | 33 | |
34 | 34 | $this->no_header_scan(); |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $this->parsed_url = $this->parse_url(); |
39 | 39 | $this->body = $this->get_body(); |
40 | 40 | $ok = $this->body['ok']; |
41 | - if (!$ok) { |
|
41 | + if ( ! $ok) { |
|
42 | 42 | |
43 | 43 | $this->no_body_scan(); |
44 | 44 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | // Prepare the DOM |
48 | 48 | $this->dom = new DOMDocument; |
49 | - libxml_use_internal_errors( true ); |
|
50 | - $this->dom->loadHTML( $this->body['body'] ); |
|
49 | + libxml_use_internal_errors(true); |
|
50 | + $this->dom->loadHTML($this->body['body']); |
|
51 | 51 | |
52 | 52 | // Parse the DOM |
53 | 53 | $this->title = $this->get_title(); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $toc = microtime(true); |
81 | 81 | |
82 | - $this->time = round( ( $toc - $tic ), 3 ); |
|
82 | + $this->time = round(($toc - $tic), 3); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $js = new Tags(); |
196 | 196 | $js->dom = $this->dom; |
197 | 197 | $js->tag = 'script'; |
198 | - $js->atts = array( 'src' ); |
|
198 | + $js->atts = array('src'); |
|
199 | 199 | |
200 | 200 | $js_list = $js->tag(); |
201 | 201 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $css = new Tags(); |
215 | 215 | $css->dom = $this->dom; |
216 | 216 | $css->tag = 'link'; |
217 | - $css->specify = array( 'att' => 'rel', 'val' => 'stylesheet', 'get_att' => 'href' ); |
|
217 | + $css->specify = array('att' => 'rel', 'val' => 'stylesheet', 'get_att' => 'href'); |
|
218 | 218 | |
219 | 219 | $css_list = $css->tag(); |
220 | 220 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function get_text_vars() { |
279 | 279 | |
280 | 280 | $text = new Text(); |
281 | - $text->dom = $this->dom; |
|
281 | + $text->dom = $this->dom; |
|
282 | 282 | $text->body_size = $this->body['size']; |
283 | 283 | $text->execute(); |
284 | 284 | $text_string = $text->text(); |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | $words = $text->words(); |
290 | 290 | $text_data['words'] = $words; |
291 | 291 | $text_data['text'] = $text_string; |
292 | - $text_data['count'] = count( $words ); |
|
292 | + $text_data['count'] = count($words); |
|
293 | 293 | $size = $text->size(); |
294 | - $text_data['size'] = round( ( $size / 1024 ), 1 ); |
|
294 | + $text_data['size'] = round(($size / 1024), 1); |
|
295 | 295 | $text_data['ratio'] = $text->ratio(); |
296 | 296 | |
297 | 297 | return $text_data; |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | //Get nested table |
302 | 302 | public function get_nested_table() { |
303 | 303 | |
304 | - $table = $this->dom->getElementsByTagName( 'table' ); |
|
304 | + $table = $this->dom->getElementsByTagName('table'); |
|
305 | 305 | |
306 | 306 | $nested_table_count = 0; |
307 | - if ( $table ) { |
|
308 | - foreach ( $table as $obj ) { |
|
309 | - $nested_table = $obj->getElementsByTagName( 'table' ); |
|
310 | - $nested_table_count = ( $nest_table ? $nested_table_count + 1 : $nested_table_count ); |
|
307 | + if ($table) { |
|
308 | + foreach ($table as $obj) { |
|
309 | + $nested_table = $obj->getElementsByTagName('table'); |
|
310 | + $nested_table_count = ($nest_table ? $nested_table_count + 1 : $nested_table_count); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | //Get heading tags |
319 | 319 | public function get_headings() { |
320 | 320 | |
321 | - $all_headings = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ); |
|
321 | + $all_headings = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'); |
|
322 | 322 | |
323 | 323 | $headings = array(); |
324 | - foreach ( $all_headings as $value ) { |
|
324 | + foreach ($all_headings as $value) { |
|
325 | 325 | |
326 | 326 | $head = new Tags(); |
327 | 327 | $head->dom = $this->dom; |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | $headings[$value] = $head_tag; |
332 | 332 | } |
333 | 333 | |
334 | - $headings_filtered = array_filter( $headings ); |
|
334 | + $headings_filtered = array_filter($headings); |
|
335 | 335 | |
336 | 336 | $heading = array(); |
337 | - $heading['names'] = array_keys( $headings_filtered ); |
|
337 | + $heading['names'] = array_keys($headings_filtered); |
|
338 | 338 | $heading['content'] = $headings_filtered; |
339 | 339 | |
340 | 340 | return $heading; |
@@ -367,15 +367,15 @@ discard block |
||
367 | 367 | ); |
368 | 368 | |
369 | 369 | $tag_style_value = array(); |
370 | - foreach( $tags as $value ) { |
|
370 | + foreach ($tags as $value) { |
|
371 | 371 | |
372 | 372 | $tag = new Tags(); |
373 | 373 | $tag->dom = $this->dom; |
374 | 374 | $tag->tag = $value; |
375 | - $tag->specify = array( 'att' => null, 'val' => null, 'get_att' => 'style', ); |
|
375 | + $tag->specify = array('att' => null, 'val' => null, 'get_att' => 'style',); |
|
376 | 376 | |
377 | 377 | $tag_style = $tag->tag(); |
378 | - $tag_style_value[] = ( $tag_style ? $value : false ); |
|
378 | + $tag_style_value[] = ($tag_style ? $value : false); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | $tag_style_filtered = array_filter($tag_style_value); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $iframes = new Tags(); |
394 | 394 | $iframes->dom = $this->dom; |
395 | 395 | $iframes->tag = 'iframe'; |
396 | - $iframes->specify = array( 'att' => null, 'val' => null, 'get_att' => 'src' ); |
|
396 | + $iframes->specify = array('att' => null, 'val' => null, 'get_att' => 'src'); |
|
397 | 397 | |
398 | 398 | $get_iframe = $iframes->tag(); |
399 | 399 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $images = new Tags(); |
408 | 408 | $images->dom = $this->dom; |
409 | 409 | $images->tag = 'img'; |
410 | - $images->atts = array( 'src', 'alt' ); |
|
410 | + $images->atts = array('src', 'alt'); |
|
411 | 411 | |
412 | 412 | $attributes = $images->atts(); |
413 | 413 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $links = new Tags(); |
431 | 431 | $links->dom = $this->dom; |
432 | 432 | $links->tag = 'a'; |
433 | - $links->atts = array( 'rel', 'href' ); |
|
433 | + $links->atts = array('rel', 'href'); |
|
434 | 434 | |
435 | 435 | $attributes = $links->atts(); |
436 | 436 | $anchors = $links->tag(); |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | if (filter_var($value, FILTER_VALIDATE_URL)) { |
447 | 447 | $link_num = $link_num + 1; |
448 | 448 | |
449 | - if( parse_url($value, PHP_URL_HOST) == $domain ) { |
|
449 | + if (parse_url($value, PHP_URL_HOST) == $domain) { |
|
450 | 450 | $ext_link_num = $ext_link_num + 1; |
451 | 451 | } |
452 | 452 | } |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | |
455 | 455 | $nofollow_link_num = 0; |
456 | 456 | foreach ($rels as $value) { |
457 | - if( strpos($value, 'nofollow') !== false ) { |
|
458 | - $nofollow_link_num = $nofollow_link_num +1; |
|
457 | + if (strpos($value, 'nofollow') !== false) { |
|
458 | + $nofollow_link_num = $nofollow_link_num + 1; |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -479,15 +479,15 @@ discard block |
||
479 | 479 | |
480 | 480 | $tags = array('title', 'description', 'url', 'image'); |
481 | 481 | $social_tag_val = array(); |
482 | - foreach( $tags as $value ) { |
|
482 | + foreach ($tags as $value) { |
|
483 | 483 | |
484 | 484 | $social_tag = new Tags(); |
485 | 485 | $social_tag->dom = $this->dom; |
486 | 486 | $social_tag->tag = 'meta'; |
487 | - $social_tag->specify = array('att' => 'property', 'val' => 'og:'.$value, 'get_att' => 'content'); |
|
487 | + $social_tag->specify = array('att' => 'property', 'val' => 'og:' . $value, 'get_att' => 'content'); |
|
488 | 488 | $social_tag_fetch = $social_tag->tag(); |
489 | 489 | |
490 | - $social_tag_val[$value] = ( $social_tag_fetch ? array_pop($social_tag_fetch) : false ); |
|
490 | + $social_tag_val[$value] = ($social_tag_fetch ? array_pop($social_tag_fetch) : false); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $social_tag_val; |
@@ -500,11 +500,11 @@ discard block |
||
500 | 500 | $viewport = new Tags(); |
501 | 501 | $viewport->dom = $this->dom; |
502 | 502 | $viewport->tag = 'meta'; |
503 | - $viewport->specify = array( 'att' => 'name', 'val' => 'viewport', 'get_att' => 'content' ); |
|
503 | + $viewport->specify = array('att' => 'name', 'val' => 'viewport', 'get_att' => 'content'); |
|
504 | 504 | $viewport_tag = $viewport->tag(); |
505 | 505 | |
506 | - $meta_viewport_val = ( $viewport_tag ? array_pop($viewport_tag) : false ); |
|
507 | - $meta_viewport = ( $meta_viewport_val && $meta_viewport_val != '' ) ? 1 : 0; |
|
506 | + $meta_viewport_val = ($viewport_tag ? array_pop($viewport_tag) : false); |
|
507 | + $meta_viewport = ($meta_viewport_val && $meta_viewport_val != '') ? 1 : 0; |
|
508 | 508 | |
509 | 509 | return $meta_viewport; |
510 | 510 | } |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | $canonical = new Tags(); |
520 | 520 | $canonical->dom = $this->dom; |
521 | 521 | $canonical->tag = 'meta'; |
522 | - $canonical->specify = array( 'att' => 'rel', 'val' => 'canonical', 'get_att' => 'href' ); |
|
522 | + $canonical->specify = array('att' => 'rel', 'val' => 'canonical', 'get_att' => 'href'); |
|
523 | 523 | $canonical_tag = $canonical->tag(); |
524 | 524 | |
525 | - $meta_canonical['val'] = ( $canonical_tag ? esc_url_raw(array_pop($canonical_tag)) : false ); |
|
526 | - $meta_canonical['ok'] = ( $meta_canonical['val'] && $meta_canonical['val'] != '' ) ? 1 : 0; |
|
525 | + $meta_canonical['val'] = ($canonical_tag ? esc_url_raw(array_pop($canonical_tag)) : false); |
|
526 | + $meta_canonical['ok'] = ($meta_canonical['val'] && $meta_canonical['val'] != '') ? 1 : 0; |
|
527 | 527 | |
528 | 528 | return $meta_canonical; |
529 | 529 | } |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | $robot = new Tags(); |
539 | 539 | $robot->dom = $this->dom; |
540 | 540 | $robot->tag = 'meta'; |
541 | - $robot->specify = array( 'att' => 'name', 'val' => 'robots', 'get_att' => 'content' ); |
|
541 | + $robot->specify = array('att' => 'name', 'val' => 'robots', 'get_att' => 'content'); |
|
542 | 542 | $robot_tag = $robot->tag(); |
543 | 543 | |
544 | - $meta_robot['val'] = ( $robot_tag ? array_pop($robot_tag) : false ); |
|
544 | + $meta_robot['val'] = ($robot_tag ? array_pop($robot_tag) : false); |
|
545 | 545 | $meta_robot['ok'] = $meta_robot['val'] && strpos($meta_robot['val'], 'index') !== false && strpos($meta_robot['val'], 'follow') !== false ? 1 : 0; |
546 | 546 | |
547 | 547 | return $meta_robot; |
@@ -555,10 +555,10 @@ discard block |
||
555 | 555 | $description = new Tags(); |
556 | 556 | $description->dom = $this->dom; |
557 | 557 | $description->tag = 'meta'; |
558 | - $description->specify = array( 'att' => 'name', 'val' => 'description', 'get_att' => 'content' ); |
|
558 | + $description->specify = array('att' => 'name', 'val' => 'description', 'get_att' => 'content'); |
|
559 | 559 | $desc = $description->tag(); |
560 | 560 | |
561 | - return ( $desc ? array_pop($desc) : false ); |
|
561 | + return ($desc ? array_pop($desc) : false); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $title_fetch->tag = 'title'; |
572 | 572 | $title = $title_fetch->tag(); |
573 | 573 | |
574 | - return ( $title ? array_pop($title) : false ); |
|
574 | + return ($title ? array_pop($title) : false); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | $response = array(); |
582 | 582 | |
583 | 583 | $start = microtime(true); |
584 | - $body = @file_get_contents( $this->url, FILE_USE_INCLUDE_PATH ); |
|
584 | + $body = @file_get_contents($this->url, FILE_USE_INCLUDE_PATH); |
|
585 | 585 | $end = microtime(true); |
586 | 586 | |
587 | 587 | $response['ok'] = empty($body) ? false : true; |
588 | - $response['time'] = round( ( $end - $start ), 3 ); |
|
588 | + $response['time'] = round(($end - $start), 3); |
|
589 | 589 | $response['body'] = $body; |
590 | - $response['size'] = mb_strlen( $body, '8bit' ); |
|
590 | + $response['size'] = mb_strlen($body, '8bit'); |
|
591 | 591 | |
592 | 592 | return $response; |
593 | 593 | } |
@@ -600,10 +600,10 @@ discard block |
||
600 | 600 | $response = array(); |
601 | 601 | |
602 | 602 | $start = microtime(true); |
603 | - $header = get_headers( $this->url, 1 ); |
|
603 | + $header = get_headers($this->url, 1); |
|
604 | 604 | $end = microtime(true); |
605 | 605 | |
606 | - $response['time'] = round( ( $end - $start ), 3 ); |
|
606 | + $response['time'] = round(($end - $start), 3); |
|
607 | 607 | $response['response'] = $header[0]; |
608 | 608 | $response['ok'] = (strchr($header[0], '200') != false) ? true : false; |
609 | 609 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | $parse['domain'] = $parsed_url['host']; |
623 | 623 | $parse['ssl'] = $parsed_url['scheme'] == 'http' ? false : true; |
624 | 624 | $parse['dynamic'] = array_key_exists('query', $parsed_url) ? true : false; |
625 | - $parse['underscore'] = ( strpos($this->url, '_') !== false ) ? true : false; |
|
625 | + $parse['underscore'] = (strpos($this->url, '_') !== false) ? true : false; |
|
626 | 626 | |
627 | 627 | return $parse; |
628 | 628 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | public function no_body_scan() { ?> |
633 | 633 | |
634 | 634 | <div class="notice notice-error"> |
635 | - <p><?php _e( 'The page could not be downloaded. Try again', 'cgss' ); ?></p> |
|
635 | + <p><?php _e('The page could not be downloaded. Try again', 'cgss'); ?></p> |
|
636 | 636 | </div> |
637 | 637 | <?PHP |
638 | 638 | } |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | public function no_header_scan() { ?> |
643 | 643 | |
644 | 644 | <div class="notice notice-error"> |
645 | - <p><?php _e( 'The header returned is not Ok. Try again', 'cgss' ); ?></p> |
|
645 | + <p><?php _e('The header returned is not Ok. Try again', 'cgss'); ?></p> |
|
646 | 646 | </div> |
647 | 647 | <?PHP |
648 | 648 | } |
@@ -2,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
4 | 4 | |
5 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
5 | +if ( ! defined( 'ABSPATH' ) ) { |
|
6 | + exit; |
|
7 | +} |
|
6 | 8 | |
7 | 9 | /** |
8 | 10 | * From result data found in scan, analyze a score of on-page optimization. Using approximate values |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
4 | 4 | |
5 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
5 | +if ( ! defined('ABSPATH')) exit; |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * From result data found in scan, analyze a score of on-page optimization. Using approximate values |
@@ -36,35 +36,35 @@ discard block |
||
36 | 36 | $score = $this->exact(); |
37 | 37 | |
38 | 38 | $star = 0; |
39 | - switch ( true ) { |
|
40 | - case ( $score >= 560 ): |
|
39 | + switch (true) { |
|
40 | + case ($score >= 560): |
|
41 | 41 | $star = 10; |
42 | 42 | break; |
43 | - case ( $score >= 490 ): |
|
43 | + case ($score >= 490): |
|
44 | 44 | $star = 9; |
45 | 45 | break; |
46 | - case ( $score >= 420 ): |
|
46 | + case ($score >= 420): |
|
47 | 47 | $star = 8; |
48 | 48 | break; |
49 | - case ( $score >= 350 ): |
|
49 | + case ($score >= 350): |
|
50 | 50 | $star = 7; |
51 | 51 | break; |
52 | - case ( $score >= 280 ): |
|
52 | + case ($score >= 280): |
|
53 | 53 | $star = 6; |
54 | 54 | break; |
55 | - case ( $score >= 210 ): |
|
55 | + case ($score >= 210): |
|
56 | 56 | $star = 5; |
57 | 57 | break; |
58 | - case ( $score >= 140 ): |
|
58 | + case ($score >= 140): |
|
59 | 59 | $star = 4; |
60 | 60 | break; |
61 | - case ( $score >= 70 ): |
|
61 | + case ($score >= 70): |
|
62 | 62 | $star = 3; |
63 | 63 | break; |
64 | - case ( $score >= 0 ): |
|
64 | + case ($score >= 0): |
|
65 | 65 | $star = 2; |
66 | 66 | break; |
67 | - case ( $score <= 0 ): |
|
67 | + case ($score <= 0): |
|
68 | 68 | $star = 1; |
69 | 69 | break; |
70 | 70 | } |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | $data = $this->snippet; |
78 | 78 | $score = 0; |
79 | 79 | |
80 | - $arr = array( $data['title'], $data['desc'] ); |
|
81 | - foreach ( $arr as $key ) { |
|
82 | - switch ( true ) { |
|
83 | - case ( $key && $key != '' ): |
|
80 | + $arr = array($data['title'], $data['desc']); |
|
81 | + foreach ($arr as $key) { |
|
82 | + switch (true) { |
|
83 | + case ($key && $key != ''): |
|
84 | 84 | $score += 25; |
85 | 85 | break; |
86 | - case ( ! $key || $key == '' ): |
|
86 | + case ( ! $key || $key == ''): |
|
87 | 87 | $score -= 25; |
88 | 88 | break; |
89 | 89 | } |
@@ -95,47 +95,47 @@ discard block |
||
95 | 95 | //image link to all link ratio and usage of most used word in anchor texts and heading texts: 200, 75 |
96 | 96 | public function text() { |
97 | 97 | $data = $this->text; |
98 | - if ( $data ) { |
|
98 | + if ($data) { |
|
99 | 99 | $score = 0; |
100 | 100 | $count = $data['count']; |
101 | - switch ( true ) { |
|
102 | - case ( $count < 200 ): |
|
101 | + switch (true) { |
|
102 | + case ($count < 200): |
|
103 | 103 | $score -= 10; |
104 | 104 | break; |
105 | - case ( $count > 200 ): |
|
105 | + case ($count > 200): |
|
106 | 106 | $score += 25; |
107 | 107 | break; |
108 | 108 | } |
109 | 109 | $ratio = $data['ratio']; |
110 | - switch ( true ) { |
|
111 | - case ( $ratio <= 15 ): |
|
110 | + switch (true) { |
|
111 | + case ($ratio <= 15): |
|
112 | 112 | $score -= 10; |
113 | 113 | break; |
114 | - case ( $ratio <= 70 ): |
|
114 | + case ($ratio <= 70): |
|
115 | 115 | $score += 25; |
116 | 116 | break; |
117 | - case ( $ratio > 70 ): |
|
117 | + case ($ratio > 70): |
|
118 | 118 | $score -= 10; |
119 | 119 | break; |
120 | 120 | } |
121 | - if ( $data['links'] ) { |
|
121 | + if ($data['links']) { |
|
122 | 122 | $links = $data['links']; |
123 | - if ( $count > 0 ) { |
|
124 | - $link_ratio = ( ( $links['count'] / $count ) * 100 ); |
|
125 | - switch ( true ) { |
|
126 | - case ( $link_ratio <= 50 ): |
|
123 | + if ($count > 0) { |
|
124 | + $link_ratio = (($links['count'] / $count) * 100); |
|
125 | + switch (true) { |
|
126 | + case ($link_ratio <= 50): |
|
127 | 127 | $score += 10; |
128 | 128 | break; |
129 | - case ( $link_ratio > 50 ): |
|
129 | + case ($link_ratio > 50): |
|
130 | 130 | $score -= 5; |
131 | 131 | break; |
132 | 132 | } |
133 | 133 | } |
134 | - switch ( true ) { |
|
135 | - case ( $links['no_text'] < 2 ): |
|
134 | + switch (true) { |
|
135 | + case ($links['no_text'] < 2): |
|
136 | 136 | $score += 10; |
137 | 137 | break; |
138 | - case ( $links['no_text'] > 2 ): |
|
138 | + case ($links['no_text'] > 2): |
|
139 | 139 | $score -= 5; |
140 | 140 | break; |
141 | 141 | } |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | $snip_data = $this->snippet; |
152 | 152 | $design_data = $this->design; |
153 | 153 | $img_data = $design_data['image']; |
154 | - $alts = (!empty($img_data['alt_value']) ? implode(' ', $img_data['alt_value']) : []); |
|
155 | - $url = implode( " ", explode( "-", $snip_data['url'] ) ); |
|
156 | - $arr = array( $snip_data['title'], $snip_data['desc'], $alts, $url, $anch, $hds ); |
|
157 | - foreach ( $arr as $val ) { |
|
158 | - if ( $val && $val != '' ) { |
|
159 | - $find_key = $this->key_chk( $val ); |
|
160 | - switch ( true ) { |
|
161 | - case ( ! $find_key ): |
|
154 | + $alts = ( ! empty($img_data['alt_value']) ? implode(' ', $img_data['alt_value']) : []); |
|
155 | + $url = implode(" ", explode("-", $snip_data['url'])); |
|
156 | + $arr = array($snip_data['title'], $snip_data['desc'], $alts, $url, $anch, $hds); |
|
157 | + foreach ($arr as $val) { |
|
158 | + if ($val && $val != '') { |
|
159 | + $find_key = $this->key_chk($val); |
|
160 | + switch (true) { |
|
161 | + case ( ! $find_key): |
|
162 | 162 | $score += 0; |
163 | 163 | break; |
164 | - case ( $find_key > 0 ): |
|
164 | + case ($find_key > 0): |
|
165 | 165 | $score += 10; |
166 | 166 | break; |
167 | 167 | } |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | //Score based on alt tags presence in images and top word found in those alt tags: 70, 45 |
177 | 177 | public function design() { |
178 | 178 | $data = $this->design; |
179 | - if ( $data ) { |
|
179 | + if ($data) { |
|
180 | 180 | $score = 0; |
181 | 181 | $img_data = $data['image']; |
182 | 182 | $no_alt_data = $img_data['no_alt_count']; |
183 | - switch ( $no_alt_data ) { |
|
183 | + switch ($no_alt_data) { |
|
184 | 184 | case 0: |
185 | 185 | $score += 25; |
186 | 186 | break; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | $nested_table = $data['nested_table']; |
193 | - switch ( $nested_table ) { |
|
193 | + switch ($nested_table) { |
|
194 | 194 | case 0: |
195 | 195 | $score += 10; |
196 | 196 | break; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | $tag_style = $data['tag_style']; |
203 | - switch ( $tag_style['count'] ) { |
|
203 | + switch ($tag_style['count']) { |
|
204 | 204 | case 0: |
205 | 205 | $score += 10; |
206 | 206 | break; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $vport = $data['vport']; |
213 | 213 | $media = $data['media']; |
214 | 214 | $media_ok = $media['ok']; |
215 | - if ( $vport and $media_ok and strlen( $vport ) > 0 and $media_ok > 0 ) { |
|
215 | + if ($vport and $media_ok and strlen($vport) > 0 and $media_ok > 0) { |
|
216 | 216 | $score += 25; |
217 | 217 | } else { |
218 | 218 | $score -= 10; |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | //determine score number of http requests and presence of code errors, viewport and social tags: 80, 40 |
227 | 227 | public function crawl() { |
228 | 228 | $data = $this->crawl; |
229 | - if ( $data ) { |
|
229 | + if ($data) { |
|
230 | 230 | $ip = $data['ip']; |
231 | 231 | $meta_robot = $data['meta_robot']; |
232 | 232 | |
233 | - if ( ! $data['cano'] or strlen( $data['cano'] ) != 0 ) { |
|
233 | + if ( ! $data['cano'] or strlen($data['cano']) != 0) { |
|
234 | 234 | $cano = 1; |
235 | 235 | } else { |
236 | 236 | $cano = 0; |
237 | 237 | } |
238 | - $arr = array( $data['ssl'], $data['dynamic'], $data['underscore'], $cano, $ip, $data['if_mod'], $meta_robot['ok'] ); |
|
238 | + $arr = array($data['ssl'], $data['dynamic'], $data['underscore'], $cano, $ip, $data['if_mod'], $meta_robot['ok']); |
|
239 | 239 | $score = 0; |
240 | - foreach ( $arr as $val ) { |
|
241 | - switch ( $val ) { |
|
240 | + foreach ($arr as $val) { |
|
241 | + switch ($val) { |
|
242 | 242 | case 1: |
243 | 243 | $score += 10; |
244 | 244 | break; |
@@ -256,23 +256,23 @@ discard block |
||
256 | 256 | //Overview score for url and canonical tag. Excluding robots tag,to be taken care of by jquery: 70, 35 |
257 | 257 | public function speed() { |
258 | 258 | $data = $this->speed; |
259 | - if ( $data ) { |
|
259 | + if ($data) { |
|
260 | 260 | $score = 0; |
261 | 261 | $down_time = $data['down_time']; |
262 | - switch ( true ) { |
|
263 | - case ( $down_time > 10 ): |
|
262 | + switch (true) { |
|
263 | + case ($down_time > 10): |
|
264 | 264 | $score -= 5; |
265 | 265 | break; |
266 | - case ( $down_time < 3 ): |
|
266 | + case ($down_time < 3): |
|
267 | 267 | $score += 10; |
268 | 268 | break; |
269 | - case ( $down_time <= 5 ): |
|
269 | + case ($down_time <= 5): |
|
270 | 270 | $score += 5; |
271 | 271 | break; |
272 | 272 | } |
273 | - $arr = array( $data['gzip'], $data['cache'] ); |
|
274 | - foreach ( $arr as $val ) { |
|
275 | - switch ( $val ) { |
|
273 | + $arr = array($data['gzip'], $data['cache']); |
|
274 | + foreach ($arr as $val) { |
|
275 | + switch ($val) { |
|
276 | 276 | case 1: |
277 | 277 | $score += 10; |
278 | 278 | break; |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | } |
284 | 284 | $css = $data['css']; |
285 | 285 | $js = $data['js']; |
286 | - $files_arr = array( $css['count'], $js['count'] ); |
|
287 | - foreach ( $files_arr as $val ) { |
|
288 | - switch ( true ) { |
|
289 | - case ( $val <= 10 ): |
|
286 | + $files_arr = array($css['count'], $js['count']); |
|
287 | + foreach ($files_arr as $val) { |
|
288 | + switch (true) { |
|
289 | + case ($val <= 10): |
|
290 | 290 | $score += 10; |
291 | 291 | break; |
292 | - case ( $val > 10 ): |
|
292 | + case ($val > 10): |
|
293 | 293 | $score -= 5; |
294 | 294 | break; |
295 | 295 | } |
296 | 296 | } |
297 | - $files_size_arr = array( $css['size'], $js['size'] ); |
|
298 | - foreach ( $files_size_arr as $val ) { |
|
299 | - switch ( true ) { |
|
300 | - case ( $val <= 100 ): |
|
297 | + $files_size_arr = array($css['size'], $js['size']); |
|
298 | + foreach ($files_size_arr as $val) { |
|
299 | + switch (true) { |
|
300 | + case ($val <= 100): |
|
301 | 301 | $score += 10; |
302 | 302 | break; |
303 | - case ( $val > 100 ): |
|
303 | + case ($val > 100): |
|
304 | 304 | $score -= 5; |
305 | 305 | break; |
306 | 306 | } |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | //Get the top word found |
315 | - public function key_chk( $txt ) { |
|
315 | + public function key_chk($txt) { |
|
316 | 316 | $show = 0; |
317 | 317 | $text = $this->text; |
318 | 318 | $keys = $text['keys']; |
319 | - foreach ( $keys as $key => $val ) { |
|
319 | + foreach ($keys as $key => $val) { |
|
320 | 320 | |
321 | - $num = substr_count( $key, $txt ); |
|
322 | - if ( $num > 0 ) { |
|
321 | + $num = substr_count($key, $txt); |
|
322 | + if ($num > 0) { |
|
323 | 323 | $show = 1; |
324 | 324 | } |
325 | 325 | } |
326 | - if ( $show == 0 ) { |
|
326 | + if ($show == 0) { |
|
327 | 327 | return false; |
328 | 328 | } else { |
329 | 329 | return $show; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | /** |
@@ -27,22 +27,22 @@ discard block |
||
27 | 27 | $compress_num = 0; |
28 | 28 | $compress_size = 0; |
29 | 29 | |
30 | - if ( $this->js_url ) { |
|
30 | + if ($this->js_url) { |
|
31 | 31 | |
32 | 32 | $num = count($this->js_url); |
33 | 33 | |
34 | 34 | //get files and check their bodies |
35 | - foreach ( $this->js_url as $val ) { |
|
36 | - $body = @file_get_contents( $val, FILE_USE_INCLUDE_PATH ); |
|
35 | + foreach ($this->js_url as $val) { |
|
36 | + $body = @file_get_contents($val, FILE_USE_INCLUDE_PATH); |
|
37 | 37 | if ($body) { |
38 | - $pre_size = mb_strlen( $body, '8bit' ); |
|
39 | - $size += round( ( $pre_size / 1024 ), 0 ); |
|
40 | - $pure_body = filter_var( $body, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW ); |
|
41 | - $pure_size = mb_strlen( $pure_body, '8bit' ); |
|
42 | - $percent_comp = 1 - ( $pure_size / $pre_size ); |
|
43 | - if ( $percent_comp > 0.05 ) { |
|
38 | + $pre_size = mb_strlen($body, '8bit'); |
|
39 | + $size += round(($pre_size / 1024), 0); |
|
40 | + $pure_body = filter_var($body, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
|
41 | + $pure_size = mb_strlen($pure_body, '8bit'); |
|
42 | + $percent_comp = 1 - ($pure_size / $pre_size); |
|
43 | + if ($percent_comp > 0.05) { |
|
44 | 44 | $compress_num += 1; |
45 | - $compress_size += round( ( ( $pre_size - $pure_size ) / 1024 ), 0 ); |
|
45 | + $compress_size += round((($pre_size - $pure_size) / 1024), 0); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -66,26 +66,26 @@ discard block |
||
66 | 66 | $compress_num = 0; |
67 | 67 | $compress_size = 0; |
68 | 68 | |
69 | - if ( $this->css_url ) { |
|
69 | + if ($this->css_url) { |
|
70 | 70 | |
71 | 71 | $num = count($this->css_url); |
72 | 72 | |
73 | 73 | //get files and check their bodies |
74 | - foreach ( $this->css_url as $val ) { |
|
75 | - $body = @file_get_contents( $val, FILE_USE_INCLUDE_PATH ); |
|
74 | + foreach ($this->css_url as $val) { |
|
75 | + $body = @file_get_contents($val, FILE_USE_INCLUDE_PATH); |
|
76 | 76 | if ($body) { |
77 | - $pre_size = mb_strlen( $body, '8bit' ); |
|
78 | - $size += round( ( $pre_size / 1024 ), 0 ); |
|
79 | - if ( strpos( $val, '.css' ) !== false ) { |
|
80 | - $import += substr_count( $body, '@import' ); |
|
81 | - $media += substr_count( $body, '@media' ); |
|
77 | + $pre_size = mb_strlen($body, '8bit'); |
|
78 | + $size += round(($pre_size / 1024), 0); |
|
79 | + if (strpos($val, '.css') !== false) { |
|
80 | + $import += substr_count($body, '@import'); |
|
81 | + $media += substr_count($body, '@media'); |
|
82 | 82 | } |
83 | - $pure_body = filter_var( $body, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW ); |
|
84 | - $pure_size = mb_strlen( $pure_body, '8bit' ); |
|
85 | - $percent_comp = 1 - ( $pure_size / $pre_size ); |
|
86 | - if ( $percent_comp > 0.05 ) { |
|
83 | + $pure_body = filter_var($body, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); |
|
84 | + $pure_size = mb_strlen($pure_body, '8bit'); |
|
85 | + $percent_comp = 1 - ($pure_size / $pre_size); |
|
86 | + if ($percent_comp > 0.05) { |
|
87 | 87 | $compress_num += 1; |
88 | - $compress_size += round( ( ( $pre_size - $pure_size ) / 1024 ), 0 ); |
|
88 | + $compress_size += round((($pre_size - $pure_size) / 1024), 0); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | |
7 | 9 | /** |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
4 | 4 | |
5 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
5 | +if ( ! defined('ABSPATH')) exit; |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * An object to extract most used pharases in an array of phrases, containing one or more words. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $four = $this->fetch(4); |
29 | 29 | $five = $this->fetch(5); |
30 | 30 | $six = $this->fetch(6); |
31 | - $keys = array_merge( $six, $five, $four, $three, $two, $one ); |
|
31 | + $keys = array_merge($six, $five, $four, $three, $two, $one); |
|
32 | 32 | return $keys; |
33 | 33 | } |
34 | 34 | |
@@ -38,45 +38,45 @@ discard block |
||
38 | 38 | $one_arr = $this->fetch(1); |
39 | 39 | $stop = $this->stop(); |
40 | 40 | $output = array(); |
41 | - foreach ( $one_arr as $val => $key ) { |
|
42 | - if ( strlen( $val ) > 3 and ! in_array( $val, $stop ) ) { |
|
41 | + foreach ($one_arr as $val => $key) { |
|
42 | + if (strlen($val) > 3 and ! in_array($val, $stop)) { |
|
43 | 43 | $output[$val] = $key; |
44 | 44 | } |
45 | 45 | } |
46 | - return array_slice( $output, 0, 10 ); |
|
46 | + return array_slice($output, 0, 10); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | //generate individual words from text content |
50 | - public function fetch( $n ) { |
|
50 | + public function fetch($n) { |
|
51 | 51 | |
52 | 52 | //compare text and words to find keyword |
53 | 53 | $keys = array(); |
54 | - $phrs = $this->prepare( $n ); |
|
54 | + $phrs = $this->prepare($n); |
|
55 | 55 | $phrs_count = count($phrs); |
56 | - foreach( $phrs as $val ) { |
|
57 | - $key_num = substr_count( $this->text, $val ); |
|
58 | - $key_per = round( ( ( ( $key_num * $n ) / $phrs_count ) * 100 ), 3 ); |
|
59 | - if ( $key_num > 1 and $key_per > 0.2 and ! isset( $keys[$val] ) ) { |
|
56 | + foreach ($phrs as $val) { |
|
57 | + $key_num = substr_count($this->text, $val); |
|
58 | + $key_per = round(((($key_num * $n) / $phrs_count) * 100), 3); |
|
59 | + if ($key_num > 1 and $key_per > 0.2 and ! isset($keys[$val])) { |
|
60 | 60 | $keys[$val] = $key_per; |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | //arrange them to select top final 3 keyword |
65 | - if ( is_array( $keys ) ) { |
|
66 | - arsort( $keys ); |
|
67 | - if ( $n != 1 ) { |
|
65 | + if (is_array($keys)) { |
|
66 | + arsort($keys); |
|
67 | + if ($n != 1) { |
|
68 | 68 | |
69 | 69 | //remove keys without much significance |
70 | 70 | $del_keys = array(); |
71 | - foreach ( $keys as $val => $key ) { |
|
72 | - $key_size = strlen( implode( '', explode( ' ', $val ) ) ) / 2; |
|
73 | - if ( $key_size <= $n ) { |
|
71 | + foreach ($keys as $val => $key) { |
|
72 | + $key_size = strlen(implode('', explode(' ', $val))) / 2; |
|
73 | + if ($key_size <= $n) { |
|
74 | 74 | $del_keys[] = $val; |
75 | 75 | } |
76 | 76 | } |
77 | - $new_keys = array_diff( $keys, $del_keys ); |
|
77 | + $new_keys = array_diff($keys, $del_keys); |
|
78 | 78 | |
79 | - $key_top = array_slice( $new_keys, 0, 3 ); |
|
79 | + $key_top = array_slice($new_keys, 0, 3); |
|
80 | 80 | } else { |
81 | 81 | $key_top = $keys; |
82 | 82 | } |
@@ -85,26 +85,26 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | //generate individual words from text content |
88 | - public function prepare( $n ) { |
|
88 | + public function prepare($n) { |
|
89 | 89 | $i = 0; |
90 | 90 | $part = array(); |
91 | 91 | $w_input = $this->words; |
92 | - for( $i = 0; $i < $n; $i++ ) { |
|
92 | + for ($i = 0; $i < $n; $i++) { |
|
93 | 93 | |
94 | 94 | //create an array of words of pharses as sub-arrays |
95 | - $pieces = array_chunk( $w_input, $n ); |
|
96 | - $last_one = array_pop( $pieces ); |
|
97 | - if ( is_array( $last_one ) and count( $last_one ) != $i ) { |
|
95 | + $pieces = array_chunk($w_input, $n); |
|
96 | + $last_one = array_pop($pieces); |
|
97 | + if (is_array($last_one) and count($last_one) != $i) { |
|
98 | 98 | unset($pieces[count($pieces) - 1]); |
99 | 99 | } |
100 | 100 | |
101 | 101 | //create phrase out of those sub array |
102 | - foreach( $pieces as $val ) { |
|
103 | - $part[] = implode( ' ', $val ); |
|
102 | + foreach ($pieces as $val) { |
|
103 | + $part[] = implode(' ', $val); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | //Offset input words first value to create more unique words |
107 | - $del_w_input = array_diff( $w_input, array( $w_input[0] ) ); |
|
107 | + $del_w_input = array_diff($w_input, array($w_input[0])); |
|
108 | 108 | $w_input = array_values($del_w_input); |
109 | 109 | } |
110 | 110 | return $part; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | //array of stop words |
114 | 114 | public function stop() { |
115 | - return array( 'from', 'that', 'this', 'what', 'when', 'where', 'have', 'they', 'just', 'your', 'most', 'their', 'some', 'then', 'there', 'them', 'make', 'ever', 'never', 'enough', 'should', 'would', 'could', 'also', 'such', 'shall', 'will', 'with' ); |
|
115 | + return array('from', 'that', 'this', 'what', 'when', 'where', 'have', 'they', 'just', 'your', 'most', 'their', 'some', 'then', 'there', 'them', 'make', 'ever', 'never', 'enough', 'should', 'would', 'could', 'also', 'such', 'shall', 'will', 'with'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | ?> |
@@ -2,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
4 | 4 | |
5 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
5 | +if ( ! defined( 'ABSPATH' ) ) { |
|
6 | + exit; |
|
7 | +} |
|
6 | 8 | |
7 | 9 | /** |
8 | 10 | * An object to extract most used pharases in an array of phrases, containing one or more words. |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | /** |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | public function cache() { |
22 | 22 | |
23 | 23 | $cache = 0; |
24 | - if ( is_array( $this->header ) ) { |
|
25 | - if ( array_key_exists( "Cache-Control", $this->header ) ) { |
|
24 | + if (is_array($this->header)) { |
|
25 | + if (array_key_exists("Cache-Control", $this->header)) { |
|
26 | 26 | $cache_val = $this->header["Cache-Control"]; |
27 | - if ( $cache_val ) { |
|
27 | + if ($cache_val) { |
|
28 | 28 | $cache = 1; |
29 | 29 | } |
30 | 30 | } |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | public function if_mod() { |
38 | 38 | |
39 | 39 | $if_mod = 0; |
40 | - if ( is_array( $this->header ) ) { |
|
41 | - if ( array_key_exists( "Last-Modified", $this->header ) ) { |
|
40 | + if (is_array($this->header)) { |
|
41 | + if (array_key_exists("Last-Modified", $this->header)) { |
|
42 | 42 | $if_mod = 1; |
43 | 43 | } |
44 | 44 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | public function alive() { |
51 | 51 | |
52 | 52 | $alive = 0; |
53 | - if ( is_array( $this->header ) ) { |
|
54 | - if ( array_key_exists( "Connection", $this->header ) ) { |
|
53 | + if (is_array($this->header)) { |
|
54 | + if (array_key_exists("Connection", $this->header)) { |
|
55 | 55 | $connection = $this->header["Connection"]; |
56 | - if ( $connection == "Keep-Alive" ) { |
|
56 | + if ($connection == "Keep-Alive") { |
|
57 | 57 | $alive = 1; |
58 | 58 | } |
59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $gzip = 0; |
69 | 69 | $encode = $_SERVER['HTTP_ACCEPT_ENCODING']; |
70 | - if ( substr( $encode, 0, 4 ) == 'gzip' ) { |
|
70 | + if (substr($encode, 0, 4) == 'gzip') { |
|
71 | 71 | $gzip = 1; |
72 | 72 | } |
73 | 73 | return $gzip; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | //Get the IP address |
78 | 78 | public function IP() { |
79 | 79 | |
80 | - $IP = gethostbyname( $this->domain ); |
|
80 | + $IP = gethostbyname($this->domain); |
|
81 | 81 | return $IP; |
82 | 82 | } |
83 | 83 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | |
7 | 9 | /** |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * |
@@ -36,37 +36,37 @@ discard block |
||
36 | 36 | //Fetch and scan tag values and return details as an array. |
37 | 37 | public function tag() { |
38 | 38 | |
39 | - $tag_obj = $this->dom->getElementsByTagName( $this->tag ); |
|
39 | + $tag_obj = $this->dom->getElementsByTagName($this->tag); |
|
40 | 40 | $num = 0; |
41 | 41 | $val = array(); |
42 | 42 | $specify = $this->specify; |
43 | - foreach ( $tag_obj as $obj ) { |
|
44 | - if ( $specify ) { |
|
45 | - if ( $specify["att"] && $specify["val"] ) { |
|
43 | + foreach ($tag_obj as $obj) { |
|
44 | + if ($specify) { |
|
45 | + if ($specify["att"] && $specify["val"]) { |
|
46 | 46 | |
47 | 47 | //individual_object->function_for_attribute |
48 | - $get_att = $this->get_att( $obj, $specify["att"] ); |
|
49 | - $get_val = $this->get_att( $obj, $specify["get_att"] ); |
|
50 | - if ( strtolower( $get_att ) == $specify["val"] and $get_val ) { |
|
48 | + $get_att = $this->get_att($obj, $specify["att"]); |
|
49 | + $get_val = $this->get_att($obj, $specify["get_att"]); |
|
50 | + if (strtolower($get_att) == $specify["val"] and $get_val) { |
|
51 | 51 | $val[] = $get_val; |
52 | 52 | } |
53 | 53 | } else { |
54 | - $get_val = $this->get_att( $obj, $specify["get_att"] ); |
|
55 | - if ( $get_val ) { |
|
54 | + $get_val = $this->get_att($obj, $specify["get_att"]); |
|
55 | + if ($get_val) { |
|
56 | 56 | $val[] = $get_val; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } else { |
60 | 60 | |
61 | 61 | //whole_object->individual_object |
62 | - $tag_val = $tag_obj->item( $num ); |
|
62 | + $tag_val = $tag_obj->item($num); |
|
63 | 63 | $val[] = $tag_val->nodeValue; |
64 | 64 | } |
65 | 65 | $num = $num + 1; |
66 | 66 | } |
67 | 67 | |
68 | 68 | //Format output result for easy usage |
69 | - if ( count( $val ) != 0 ) { |
|
69 | + if (count($val) != 0) { |
|
70 | 70 | return $val; |
71 | 71 | } else { |
72 | 72 | return false; |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | |
78 | 78 | // Fetch multiple attributes. |
79 | 79 | public function atts() { |
80 | - if ( $this->atts ) { |
|
81 | - $tag_obj = $this->dom->getElementsByTagName( $this->tag ); |
|
80 | + if ($this->atts) { |
|
81 | + $tag_obj = $this->dom->getElementsByTagName($this->tag); |
|
82 | 82 | $val = array(); |
83 | - foreach( $this->atts as $key ) { |
|
83 | + foreach ($this->atts as $key) { |
|
84 | 84 | $fetch = array(); |
85 | - foreach( $tag_obj as $obj ) { |
|
86 | - $fetch[] = $this->get_att( $obj, $key ); |
|
85 | + foreach ($tag_obj as $obj) { |
|
86 | + $fetch[] = $this->get_att($obj, $key); |
|
87 | 87 | } |
88 | 88 | $val[$key] = $fetch; |
89 | 89 | } |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | |
97 | 97 | |
98 | 98 | // Fetch single attributes. |
99 | - public function get_att( $obj, $val ) { |
|
99 | + public function get_att($obj, $val) { |
|
100 | 100 | |
101 | 101 | $data = false; |
102 | - $data = $obj->getAttribute( strtolower( $val ) ); |
|
103 | - if ( ! $data ) { |
|
104 | - $data = $obj->getAttribute( ucfirst( $val ) ); |
|
102 | + $data = $obj->getAttribute(strtolower($val)); |
|
103 | + if ( ! $data) { |
|
104 | + $data = $obj->getAttribute(ucfirst($val)); |
|
105 | 105 | } |
106 | - if ( ! $data ) { |
|
107 | - $data = $obj->getAttribute( strtoupper( $val ) ); |
|
106 | + if ( ! $data) { |
|
107 | + $data = $obj->getAttribute(strtoupper($val)); |
|
108 | 108 | } |
109 | 109 | return $data; |
110 | 110 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Analysis\Lib; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | /** |
7 | 9 | * |