@@ -79,29 +79,29 @@ |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | - public function insert_prelim_data() { |
|
83 | - |
|
84 | - $model = new InsightModel(); |
|
85 | - |
|
86 | - if ($model->count() === 0) { |
|
87 | - |
|
88 | - $init_insight = array( |
|
89 | - __('Score','cgss'), |
|
90 | - __('Snippet','cgss'), |
|
91 | - __('Text','cgss'), |
|
92 | - __('Links','cgss'), |
|
93 | - __('Keywords','cgss'), |
|
94 | - __('Images','cgss'), |
|
95 | - __('Responsive','cgss'), |
|
96 | - __('Speed','cgss'), |
|
97 | - __('Social','cgss') |
|
98 | - ); |
|
99 | - $no_data = __( 'No scan reports are available yet', 'cgss' ); |
|
100 | - foreach ($init_insight as $key => $value) { |
|
101 | - $model->insert($value, $no_data, $key + 1); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
82 | + public function insert_prelim_data() { |
|
83 | + |
|
84 | + $model = new InsightModel(); |
|
85 | + |
|
86 | + if ($model->count() === 0) { |
|
87 | + |
|
88 | + $init_insight = array( |
|
89 | + __('Score','cgss'), |
|
90 | + __('Snippet','cgss'), |
|
91 | + __('Text','cgss'), |
|
92 | + __('Links','cgss'), |
|
93 | + __('Keywords','cgss'), |
|
94 | + __('Images','cgss'), |
|
95 | + __('Responsive','cgss'), |
|
96 | + __('Speed','cgss'), |
|
97 | + __('Social','cgss') |
|
98 | + ); |
|
99 | + $no_data = __( 'No scan reports are available yet', 'cgss' ); |
|
100 | + foreach ($init_insight as $key => $value) { |
|
101 | + $model->insert($value, $no_data, $key + 1); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | 107 | //Include scripts |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | use \NirjharLo\Cgss\Lib\Script; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function instance() { |
35 | 35 | |
36 | - if ( is_null( self::$instance ) ) { |
|
36 | + if (is_null(self::$instance)) { |
|
37 | 37 | self::$instance = new self(); |
38 | 38 | self::$instance->init(); |
39 | 39 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | $install->phpVerAllowed = '5.4'; |
49 | 49 | $install->pluginPageLinks = array( |
50 | 50 | array( |
51 | - 'slug' => home_url().'/wp-admin/admin.php?page=seo-scan', |
|
52 | - 'label' => __( 'Dashboard', 'cgss' ) |
|
51 | + 'slug' => home_url() . '/wp-admin/admin.php?page=seo-scan', |
|
52 | + 'label' => __('Dashboard', 'cgss') |
|
53 | 53 | ), |
54 | 54 | ); |
55 | 55 | $install->execute(); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $tableName = 'cgss_insight'; |
76 | 76 | |
77 | 77 | global $wpdb; |
78 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$tableName" ); |
|
78 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}$tableName"); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,17 +86,17 @@ discard block |
||
86 | 86 | if ($model->count() === 0) { |
87 | 87 | |
88 | 88 | $init_insight = array( |
89 | - __('Score','cgss'), |
|
90 | - __('Snippet','cgss'), |
|
91 | - __('Text','cgss'), |
|
92 | - __('Links','cgss'), |
|
93 | - __('Keywords','cgss'), |
|
94 | - __('Images','cgss'), |
|
95 | - __('Responsive','cgss'), |
|
96 | - __('Speed','cgss'), |
|
97 | - __('Social','cgss') |
|
89 | + __('Score', 'cgss'), |
|
90 | + __('Snippet', 'cgss'), |
|
91 | + __('Text', 'cgss'), |
|
92 | + __('Links', 'cgss'), |
|
93 | + __('Keywords', 'cgss'), |
|
94 | + __('Images', 'cgss'), |
|
95 | + __('Responsive', 'cgss'), |
|
96 | + __('Speed', 'cgss'), |
|
97 | + __('Social', 'cgss') |
|
98 | 98 | ); |
99 | - $no_data = __( 'No scan reports are available yet', 'cgss' ); |
|
99 | + $no_data = __('No scan reports are available yet', 'cgss'); |
|
100 | 100 | foreach ($init_insight as $key => $value) { |
101 | 101 | $model->insert($value, $no_data, $key + 1); |
102 | 102 | } |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | |
138 | 138 | public function init() { |
139 | 139 | |
140 | - register_activation_hook( CGSS_FILE, array( $this, 'db_install' ) ); |
|
141 | - register_uninstall_hook( CGSS_FILE, array( 'BUILD', 'db_uninstall' ) ); //$this won't work here. |
|
140 | + register_activation_hook(CGSS_FILE, array($this, 'db_install')); |
|
141 | + register_uninstall_hook(CGSS_FILE, array('BUILD', 'db_uninstall')); //$this won't work here. |
|
142 | 142 | |
143 | 143 | add_action('init', array($this, 'installation')); |
144 | 144 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $this->settings(); |
147 | 147 | |
148 | 148 | // Add custom actions, defined in settings |
149 | - add_action( 'cgss_scan', array( $this, 'scan' ) ); |
|
150 | - add_action( 'cgss_fetch_insight', array( $this, 'insight' ) ); |
|
149 | + add_action('cgss_scan', array($this, 'scan')); |
|
150 | + add_action('cgss_fetch_insight', array($this, 'insight')); |
|
151 | 151 | } |
152 | 152 | } ?> |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | |
32 | 32 | |
33 | 33 | //fetch the data using custom named method function |
34 | - public static function get_insight() { |
|
34 | + public static function get_insight() { |
|
35 | 35 | |
36 | - $model = new InsightModel(); |
|
36 | + $model = new InsightModel(); |
|
37 | 37 | |
38 | - return $model->all(); |
|
39 | - } |
|
38 | + return $model->all(); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | //How many rows are present there |
52 | - public static function record_count() { |
|
52 | + public static function record_count() { |
|
53 | 53 | |
54 | - $model = new InsightModel(); |
|
54 | + $model = new InsightModel(); |
|
55 | 55 | |
56 | - return $model->count(); |
|
57 | - } |
|
56 | + return $model->count(); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | 60 |
@@ -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 | use \WP_List_Table; |
7 | 7 | use \NirjharLo\Cgss\Models\Insight as InsightModel; |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - parent::__construct( [ |
|
25 | - 'singular' => __( 'Insight', 'cgss' ), |
|
26 | - 'plural' => __( 'Inssight', 'cgss' ), |
|
24 | + parent::__construct([ |
|
25 | + 'singular' => __('Insight', 'cgss'), |
|
26 | + 'plural' => __('Inssight', 'cgss'), |
|
27 | 27 | 'ajax' => false, |
28 | - ] ); |
|
28 | + ]); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | //If there is no data to show |
44 | 44 | public function no_items() { |
45 | 45 | |
46 | - _e( 'Database is empty. Please reactivate the plugin.', 'cgss' ); |
|
46 | + _e('Database is empty. Please reactivate the plugin.', 'cgss'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -59,32 +59,32 @@ discard block |
||
59 | 59 | |
60 | 60 | |
61 | 61 | //Display columns content |
62 | - public function column_name( $item ) { |
|
62 | + public function column_name($item) { |
|
63 | 63 | |
64 | - $title = sprintf( '<strong>%s</strong>', $item['item'] ); |
|
64 | + $title = sprintf('<strong>%s</strong>', $item['item']); |
|
65 | 65 | |
66 | 66 | //Change the page instruction where you want to show it |
67 | 67 | $actions = array(); |
68 | - return $title . $this->row_actions( $actions ); |
|
68 | + return $title . $this->row_actions($actions); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
72 | 72 | |
73 | 73 | //set coulmns name |
74 | - public function column_default( $item, $column_name ) { |
|
74 | + public function column_default($item, $column_name) { |
|
75 | 75 | |
76 | - switch ( $column_name ) { |
|
76 | + switch ($column_name) { |
|
77 | 77 | |
78 | 78 | case 'item': |
79 | 79 | //This is the first column |
80 | - return $this->column_name( $item ); |
|
80 | + return $this->column_name($item); |
|
81 | 81 | case 'remark': |
82 | - return $item[ $column_name ]; |
|
82 | + return $item[$column_name]; |
|
83 | 83 | |
84 | 84 | default: |
85 | 85 | |
86 | 86 | //Show the whole array for troubleshooting purposes |
87 | - return print_r( $item, true ); |
|
87 | + return print_r($item, true); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | public function get_columns() { |
95 | 95 | |
96 | 96 | $columns = array( |
97 | - 'item' => __( 'Item', 'cgss' ), |
|
98 | - 'remark' => __( 'Remark', 'cgss' ), |
|
97 | + 'item' => __('Item', 'cgss'), |
|
98 | + 'remark' => __('Remark', 'cgss'), |
|
99 | 99 | ); |
100 | 100 | return $columns; |
101 | 101 | } |
@@ -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 | use \WP_List_Table; |
7 | 9 | use \NirjharLo\Cgss\Models\Insight as InsightModel; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | |
31 | 31 | //Display the score |
32 | - public function score_html(): string { |
|
32 | + public function score_html(): string { |
|
33 | 33 | |
34 | 34 | $score = $this->result['score']; |
35 | 35 | $social = $this->result['social']; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | // Display the snippets |
47 | - public function snippet_display(): string { |
|
47 | + public function snippet_display(): string { |
|
48 | 48 | |
49 | 49 | $snippet = $this->result['snip']; |
50 | 50 | $title = $snippet['title']; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | |
79 | 79 | // Display text and link data |
80 | - public function text_display(): string { |
|
80 | + public function text_display(): string { |
|
81 | 81 | |
82 | 82 | $text = $this->result['text']; |
83 | 83 | $keys = (!empty($text['keys']) ? implode(', ', array_keys($text['keys'])) : ''); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | |
108 | 108 | // Display design data |
109 | - public function design_display(): string { |
|
109 | + public function design_display(): string { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $design = $this->result['design']; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | |
140 | 140 | // Display crawl data |
141 | - public function crawl_display(): string { |
|
141 | + public function crawl_display(): string { |
|
142 | 142 | |
143 | 143 | $crawl = $this->result['crawl']; |
144 | 144 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | |
172 | 172 | // Display speed data |
173 | - public function speed_display(): string { |
|
173 | + public function speed_display(): string { |
|
174 | 174 | |
175 | 175 | $speed = $this->result['speed']; |
176 | 176 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | // Render the HTML |
201 | - public function render(): void { |
|
201 | + public function render(): void { |
|
202 | 202 | |
203 | 203 | $this->score_html = $this->score_html(); |
204 | 204 | $this->snippets_html = $this->snippet_display(); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | |
219 | - public function box($title, $icon, $desc): void { |
|
219 | + public function box($title, $icon, $desc): void { |
|
220 | 220 | |
221 | 221 | echo |
222 | 222 | '<div class="postbox"> |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | |
233 | - public function dashicon($icon): string { |
|
233 | + public function dashicon($icon): string { |
|
234 | 234 | |
235 | 235 | return '<span class="dashicons dashicons-'.$icon.'"></span>'; |
236 | 236 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace NirjharLo\Cgss\Lib\Action; |
4 | 4 | |
5 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
5 | +if ( ! defined('ABSPATH')) exit; |
|
6 | 6 | |
7 | 7 | use \NirjharLo\Cgss\Lib\Analysis\Crawl; |
8 | 8 | |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | public function __construct() { |
16 | 16 | |
17 | 17 | $post_id = intval($_GET['scan']); |
18 | - $url = get_permalink( $post_id ); |
|
18 | + $url = get_permalink($post_id); |
|
19 | 19 | |
20 | 20 | $crawl = new Crawl(); |
21 | 21 | $crawl->url = esc_url_raw($url); |
22 | 22 | $crawl->execute(); |
23 | 23 | $this->result = $crawl->result(); |
24 | 24 | |
25 | - update_post_meta( $post_id, 'cgss_scan_result', $this->result ); |
|
25 | + update_post_meta($post_id, 'cgss_scan_result', $this->result); |
|
26 | 26 | |
27 | 27 | $this->render(); |
28 | 28 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $fb_like = $social['fb_like']; |
38 | 38 | |
39 | 39 | $score_html = |
40 | - '<span>'.sprintf(__('Overall SEO score %d out of 10. Facebook shares: %d and likes: %d', 'cgss' ), $score, $fb_share, $fb_like ).'</span>'; |
|
40 | + '<span>' . sprintf(__('Overall SEO score %d out of 10. Facebook shares: %d and likes: %d', 'cgss'), $score, $fb_share, $fb_like) . '</span>'; |
|
41 | 41 | |
42 | 42 | return $score_html; |
43 | 43 | } |
@@ -58,17 +58,17 @@ discard block |
||
58 | 58 | $not_found = __('NOT_FOUND', 'cgss'); |
59 | 59 | $snippet_html = |
60 | 60 | '<ul> |
61 | - <li><strong>'.__('Search snippet', 'cgss').':</strong> |
|
61 | + <li><strong>'.__('Search snippet', 'cgss') . ':</strong> |
|
62 | 62 | <ul> |
63 | - <li>'.sprintf(__('Title: %s', 'cgss'),($title ? $title : $not_found)).'</li> |
|
64 | - <li>'.sprintf(__('Description: %s', 'cgss'),($desc ? $desc : $not_found)).'</li> |
|
63 | + <li>'.sprintf(__('Title: %s', 'cgss'), ($title ? $title : $not_found)) . '</li> |
|
64 | + <li>'.sprintf(__('Description: %s', 'cgss'), ($desc ? $desc : $not_found)) . '</li> |
|
65 | 65 | </ul> |
66 | 66 | </li> |
67 | - <li><strong>'.__('Social snippet(OGP)', 'cgss').':</strong> |
|
67 | + <li><strong>'.__('Social snippet(OGP)', 'cgss') . ':</strong> |
|
68 | 68 | <ul> |
69 | - <li>'.sprintf(__('Title: %s', 'cgss'),($social_title ? $social_title : $not_found)).'</li> |
|
70 | - <li>'.sprintf(__('Description: %s', 'cgss'),( $social_desc ? $social_desc : $not_found)).'</li> |
|
71 | - <li>'.sprintf(__('Image: %s', 'cgss'),( $social_image ? $social_image : $not_found)).'</li> |
|
69 | + <li>'.sprintf(__('Title: %s', 'cgss'), ($social_title ? $social_title : $not_found)) . '</li> |
|
70 | + <li>'.sprintf(__('Description: %s', 'cgss'), ($social_desc ? $social_desc : $not_found)) . '</li> |
|
71 | + <li>'.sprintf(__('Image: %s', 'cgss'), ($social_image ? $social_image : $not_found)) . '</li> |
|
72 | 72 | </ul></li> |
73 | 73 | </ul>'; |
74 | 74 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | public function text_display(): string { |
81 | 81 | |
82 | 82 | $text = $this->result['text']; |
83 | - $keys = (!empty($text['keys']) ? implode(', ', array_keys($text['keys'])) : ''); |
|
83 | + $keys = ( ! empty($text['keys']) ? implode(', ', array_keys($text['keys'])) : ''); |
|
84 | 84 | $count = $text['count']; |
85 | 85 | $ratio = $text['ratio']; |
86 | 86 | |
87 | 87 | $htags = $text['htags']; |
88 | - $headings = (!empty($htags['names']) ? implode( ', ', $htags['names'] ) : ''); |
|
88 | + $headings = ( ! empty($htags['names']) ? implode(', ', $htags['names']) : ''); |
|
89 | 89 | |
90 | 90 | $links = $text['links']; |
91 | 91 | $link_count = $links['count']; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | |
95 | 95 | $text_html = |
96 | 96 | '<ul> |
97 | - <li>'.sprintf(__('Keywords: %s','cgss'), $keys).'</li> |
|
98 | - <li>'.sprintf(__('Number of words: %s','cgss'), $count).'</li> |
|
99 | - <li>'.sprintf(__('Text to html ratio: %s percent','cgss'), $ratio).'</li> |
|
100 | - <li>'.sprintf(__('Heading tags in text hierarchy: %s','cgss'), $headings).'</li> |
|
101 | - <li>'.sprintf(__('Total Links: %d, Nofollow Links %d, External Links: %d','cgss'), $link_count, $link_nofollow, $link_external).'</li> |
|
97 | + <li>'.sprintf(__('Keywords: %s', 'cgss'), $keys) . '</li> |
|
98 | + <li>'.sprintf(__('Number of words: %s', 'cgss'), $count) . '</li> |
|
99 | + <li>'.sprintf(__('Text to html ratio: %s percent', 'cgss'), $ratio) . '</li> |
|
100 | + <li>'.sprintf(__('Heading tags in text hierarchy: %s', 'cgss'), $headings) . '</li> |
|
101 | + <li>'.sprintf(__('Total Links: %d, Nofollow Links %d, External Links: %d', 'cgss'), $link_count, $link_nofollow, $link_external) . '</li> |
|
102 | 102 | </ul>'; |
103 | 103 | |
104 | 104 | return $text_html; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $tag_style = $design['tag_style']; |
117 | 117 | $tag_style_count = $tag_style['count']; |
118 | - $tag_style_attributes = implode( ', ', $tag_style['tags'] ); |
|
118 | + $tag_style_attributes = implode(', ', $tag_style['tags']); |
|
119 | 119 | |
120 | 120 | $nested_table = $design['nested_table']; |
121 | 121 | $vport = $design['vport']; |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | $design_html = |
128 | 128 | '<ul> |
129 | - <li>'.sprintf(__('Total images: %d and images without alt tags: %d','cgss'), $image_count, $image_no_alt_count).'</li> |
|
130 | - <li>'.sprintf(__('iframe: %d','cgss'), $iframe).'</li> |
|
131 | - <li>'.sprintf(__('Nested Tables: %d','cgss'), $nested_table).'</li> |
|
132 | - <li>'.sprintf(__('Tags with style attribute: %s(%s)','cgss'), $tag_style_count, $tag_style_attributes).'</li> |
|
133 | - <li>'.sprintf(__('Mobile optimization: Viewport Tag: %d, @media Queries: %d','cgss'), $vport, $media).'</li> |
|
129 | + <li>'.sprintf(__('Total images: %d and images without alt tags: %d', 'cgss'), $image_count, $image_no_alt_count) . '</li> |
|
130 | + <li>'.sprintf(__('iframe: %d', 'cgss'), $iframe) . '</li> |
|
131 | + <li>'.sprintf(__('Nested Tables: %d', 'cgss'), $nested_table) . '</li> |
|
132 | + <li>'.sprintf(__('Tags with style attribute: %s(%s)', 'cgss'), $tag_style_count, $tag_style_attributes) . '</li> |
|
133 | + <li>'.sprintf(__('Mobile optimization: Viewport Tag: %d, @media Queries: %d', 'cgss'), $vport, $media) . '</li> |
|
134 | 134 | </ul>'; |
135 | 135 | |
136 | 136 | return $design_html; |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | $alive = $crawl['alive']; |
153 | 153 | $robot = $crawl['meta_robot']; |
154 | 154 | |
155 | - $on = __( 'on', 'cgss' ); |
|
156 | - $off = __( 'off', 'cgss' ); |
|
155 | + $on = __('on', 'cgss'); |
|
156 | + $off = __('off', 'cgss'); |
|
157 | 157 | |
158 | 158 | $crawl_html = |
159 | 159 | '<ul> |
160 | - <li>'.sprintf(__('Your URL parameters: SSL security: %s, Static url: %s, underscores in Url: %s','cgss'), (!$ssl ? $off : $on ), (!$dynamic ? $off : $on ), (!$underscore ? $off : $on )).'</li> |
|
161 | - <li>'.sprintf(__('If modified since header: %s','cgss'), ($if_mod == 0 ? $off : $on )).'</li> |
|
162 | - <li>'.sprintf(__('Canonical Url: %s','cgss'), ($cano == 0 ? $off : $on )).'</li> |
|
163 | - <li>'.sprintf(__('Meta Robot: %s','cgss'), (!$robot['ok'] ? $off : $on )).'</li> |
|
164 | - <li>'.sprintf(__('IP Forward: %s','cgss'), ($ip ? $ip : $off )).'</li> |
|
165 | - <li>'.sprintf(__('Keep alive connection: %s','cgss'), ($alive == 0 ? $off : $on )).'</li> |
|
160 | + <li>'.sprintf(__('Your URL parameters: SSL security: %s, Static url: %s, underscores in Url: %s', 'cgss'), ( ! $ssl ? $off : $on), ( ! $dynamic ? $off : $on), ( ! $underscore ? $off : $on)) . '</li> |
|
161 | + <li>'.sprintf(__('If modified since header: %s', 'cgss'), ($if_mod == 0 ? $off : $on)) . '</li> |
|
162 | + <li>'.sprintf(__('Canonical Url: %s', 'cgss'), ($cano == 0 ? $off : $on)) . '</li> |
|
163 | + <li>'.sprintf(__('Meta Robot: %s', 'cgss'), ( ! $robot['ok'] ? $off : $on)) . '</li> |
|
164 | + <li>'.sprintf(__('IP Forward: %s', 'cgss'), ($ip ? $ip : $off)) . '</li> |
|
165 | + <li>'.sprintf(__('Keep alive connection: %s', 'cgss'), ($alive == 0 ? $off : $on)) . '</li> |
|
166 | 166 | </ul>'; |
167 | 167 | |
168 | 168 | return $crawl_html; |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | $css = $speed['css']; |
182 | 182 | $js = $speed['js']; |
183 | 183 | |
184 | - $on = __( 'on', 'cgss' ); |
|
185 | - $off = __( 'off', 'cgss' ); |
|
184 | + $on = __('on', 'cgss'); |
|
185 | + $off = __('off', 'cgss'); |
|
186 | 186 | |
187 | 187 | $speed_html = |
188 | 188 | '<ul> |
189 | - <li>'. sprintf( __( 'Header response time %s s and page downloading time %s s', 'cgss' ), $res_time, $down_time ). '</li> |
|
190 | - <li>'.sprintf(__('gZip compression: %s','cgss'), ($gzip ? $off : $on )).'</li> |
|
191 | - <li>'.sprintf(__('Browser caching: %s','cgss'), ($cache ? $off : $on )).'</li> |
|
192 | - <li>'.sprintf(__('Requests made by CSS is %s and by JS is %s','cgss'), $css['count'], $js['count']).'</li> |
|
193 | - <li>'.sprintf(__('Resources can be compressed by %s kb for CSS and %s kb for JS','cgss'), $css['compress_num'], $js['compress_num']).'</li> |
|
189 | + <li>'. sprintf(__('Header response time %s s and page downloading time %s s', 'cgss'), $res_time, $down_time) . '</li> |
|
190 | + <li>'.sprintf(__('gZip compression: %s', 'cgss'), ($gzip ? $off : $on)) . '</li> |
|
191 | + <li>'.sprintf(__('Browser caching: %s', 'cgss'), ($cache ? $off : $on)) . '</li> |
|
192 | + <li>'.sprintf(__('Requests made by CSS is %s and by JS is %s', 'cgss'), $css['count'], $js['count']) . '</li> |
|
193 | + <li>'.sprintf(__('Resources can be compressed by %s kb for CSS and %s kb for JS', 'cgss'), $css['compress_num'], $js['compress_num']) . '</li> |
|
194 | 194 | </ul>'; |
195 | 195 | |
196 | 196 | return $speed_html; |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | // Render the HTML |
201 | 201 | public function render(): void { |
202 | 202 | |
203 | - $this->score_html = $this->score_html(); |
|
204 | - $this->snippets_html = $this->snippet_display(); |
|
203 | + $this->score_html = $this->score_html(); |
|
204 | + $this->snippets_html = $this->snippet_display(); |
|
205 | 205 | $this->text_html = $this->text_display(); |
206 | 206 | $this->design_html = $this->design_display(); |
207 | 207 | $this->crawl_html = $this->crawl_display(); |
208 | 208 | $this->speed_html = $this->speed_display(); |
209 | 209 | |
210 | - $this->box( null, null, $this->score_html ); |
|
211 | - $this->box( __( 'Snippets', 'cgss' ), $this->dashicon('align-none'), $this->snippets_html ); |
|
212 | - $this->box( __( 'Text & Links', 'cgss' ), $this->dashicon('text'), $this->text_html ); |
|
213 | - $this->box( __( 'Design', 'cgss' ), $this->dashicon('smartphone'), $this->design_html ); |
|
214 | - $this->box( __( 'Crawl', 'cgss' ), $this->dashicon('randomize'), $this->crawl_html ); |
|
215 | - $this->box( __( 'Speed', 'cgss' ), $this->dashicon('clock'), $this->speed_html ); |
|
210 | + $this->box(null, null, $this->score_html); |
|
211 | + $this->box(__('Snippets', 'cgss'), $this->dashicon('align-none'), $this->snippets_html); |
|
212 | + $this->box(__('Text & Links', 'cgss'), $this->dashicon('text'), $this->text_html); |
|
213 | + $this->box(__('Design', 'cgss'), $this->dashicon('smartphone'), $this->design_html); |
|
214 | + $this->box(__('Crawl', 'cgss'), $this->dashicon('randomize'), $this->crawl_html); |
|
215 | + $this->box(__('Speed', 'cgss'), $this->dashicon('clock'), $this->speed_html); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | |
233 | 233 | public function dashicon($icon): string { |
234 | 234 | |
235 | - return '<span class="dashicons dashicons-'.$icon.'"></span>'; |
|
235 | + return '<span class="dashicons dashicons-' . $icon . '"></span>'; |
|
236 | 236 | } |
237 | 237 | } ?> |
@@ -25,25 +25,25 @@ |
||
25 | 25 | |
26 | 26 | |
27 | 27 | //DB insert function |
28 | - public function save() { |
|
29 | - |
|
30 | - $model = new InsightModel(); |
|
31 | - |
|
32 | - $result = array( |
|
33 | - $this->score, |
|
34 | - $this->snippet, |
|
35 | - $this->text, |
|
36 | - $this->links, |
|
37 | - $this->keywords, |
|
38 | - $this->images, |
|
39 | - $this->responsive, |
|
40 | - $this->speed, |
|
41 | - $this->social, |
|
42 | - ); |
|
43 | - foreach ($result as $key => $value) { |
|
44 | - $model->updateRemark($key + 1, $value); |
|
45 | - } |
|
46 | - } |
|
28 | + public function save() { |
|
29 | + |
|
30 | + $model = new InsightModel(); |
|
31 | + |
|
32 | + $result = array( |
|
33 | + $this->score, |
|
34 | + $this->snippet, |
|
35 | + $this->text, |
|
36 | + $this->links, |
|
37 | + $this->keywords, |
|
38 | + $this->images, |
|
39 | + $this->responsive, |
|
40 | + $this->speed, |
|
41 | + $this->social, |
|
42 | + ); |
|
43 | + foreach ($result as $key => $value) { |
|
44 | + $model->updateRemark($key + 1, $value); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | 49 | //Compile the result |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Action; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | use \NirjharLo\Cgss\Models\Insight as InsightModel; |
7 | 7 | |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct() { |
16 | 16 | |
17 | - try{ |
|
17 | + try { |
|
18 | 18 | $this->data = $this->fetch(); |
19 | 19 | $this->compile(); |
20 | 20 | $this->save(); |
21 | - } catch(Exception $e) { |
|
22 | - echo __( 'Something went wrong', 'cgss') . ' ' . $e->get_message(); |
|
21 | + } catch (Exception $e) { |
|
22 | + echo __('Something went wrong', 'cgss') . ' ' . $e->get_message(); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | $score = $this->data['score']; |
53 | 53 | $this->count = (count($score) == 0 ? 1 : count($score)); |
54 | - $avarage_score = (count($score) == 0 ? 0 : round(array_sum($score)/count($score), 0)); |
|
54 | + $avarage_score = (count($score) == 0 ? 0 : round(array_sum($score) / count($score), 0)); |
|
55 | 55 | |
56 | - $this->score = sprintf(__('Avarage SEO score is %d out of 10', 'cgss'),$avarage_score); |
|
56 | + $this->score = sprintf(__('Avarage SEO score is %d out of 10', 'cgss'), $avarage_score); |
|
57 | 57 | $this->snippet = $this->snippet_analyze(); |
58 | 58 | $this->text = $this->text_analyze(); |
59 | 59 | $this->links = $this->link_analyze(); |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | foreach ($snippets as $snippet) { |
74 | 74 | $title = $snippet['title']; |
75 | 75 | $desc = $snippet['desc']; |
76 | - if (!empty($title) && !empty($desc)) { |
|
76 | + if ( ! empty($title) && ! empty($desc)) { |
|
77 | 77 | $snip_count++; |
78 | 78 | } |
79 | 79 | } |
80 | 80 | $snip_fraction = $this->count - $snip_count; |
81 | 81 | |
82 | - $output = ($snip_fraction == 0) ? __( 'All snippets are ok', 'cgss' ) : sprintf(_n('%d page', '%d pages', $snip_fraction, 'cgss'), $snip_fraction) . ' ' . __( 'have incomplete snippets', 'cgss' ); |
|
82 | + $output = ($snip_fraction == 0) ? __('All snippets are ok', 'cgss') : sprintf(_n('%d page', '%d pages', $snip_fraction, 'cgss'), $snip_fraction) . ' ' . __('have incomplete snippets', 'cgss'); |
|
83 | 83 | return $output; |
84 | 84 | } |
85 | 85 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $count = round(array_sum(array_column($text, 'count')) / $this->count, 0); |
92 | 92 | $ratio = round(array_sum(array_column($text, 'ratio')) / $this->count, 2); |
93 | 93 | |
94 | - $output = sprintf(__('Avarage', 'cgss') . ' ' . _n('%d word is','%d words are',$count,'cgss') . ' ' . __( 'found per page and avarage text to HTML ratio is %d', 'cgss'),$count,$ratio) . '%'; |
|
94 | + $output = sprintf(__('Avarage', 'cgss') . ' ' . _n('%d word is', '%d words are', $count, 'cgss') . ' ' . __('found per page and avarage text to HTML ratio is %d', 'cgss'), $count, $ratio) . '%'; |
|
95 | 95 | return $output; |
96 | 96 | } |
97 | 97 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | $count = round(array_sum(array_column($links, 'count')) / $this->count, 0); |
105 | 105 | $external = round(array_sum(array_column($links, 'external')) / $this->count, 0); |
106 | 106 | $nofollow = round(array_sum(array_column($links, 'external')) / $this->count, 0); |
107 | - $external_percentage = ($count == 0 ? 0 : round(($external/$count)*100, 0)); |
|
108 | - $nofollow_percentage = ($count == 0 ? 0 : round(($nofollow/$count)*100, 0)); |
|
107 | + $external_percentage = ($count == 0 ? 0 : round(($external / $count) * 100, 0)); |
|
108 | + $nofollow_percentage = ($count == 0 ? 0 : round(($nofollow / $count) * 100, 0)); |
|
109 | 109 | |
110 | - $output = sprintf(__('Avarage', 'cgss') . ' '. _n( '%d link is','%d links are', $count, 'cgss' ) . ' ' . __('found per page. %d% are external and %d% are nofollow among them.', 'cgss'),$count,$external_percentage,$nofollow_percentage); |
|
110 | + $output = sprintf(__('Avarage', 'cgss') . ' ' . _n('%d link is', '%d links are', $count, 'cgss') . ' ' . __('found per page. %d% are external and %d% are nofollow among them.', 'cgss'), $count, $external_percentage, $nofollow_percentage); |
|
111 | 111 | return $output; |
112 | 112 | } |
113 | 113 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $key_collect = array(); |
122 | 122 | $percent_collect = array(); |
123 | 123 | foreach ($keywords as $keyword) { |
124 | - $keys = (!empty($keyword) ? array_keys($keyword) : []); |
|
124 | + $keys = ( ! empty($keyword) ? array_keys($keyword) : []); |
|
125 | 125 | $top_key = $keys[0]; |
126 | 126 | $key_collect[] = count(explode(' ', $top_key)); |
127 | 127 | $percent_collect[] = $keyword[$top_key]; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $key_count = round(array_sum($key_collect) / $this->count, 1); |
131 | 131 | $percent = round(array_sum($percent_collect) / $this->count, 1); |
132 | 132 | |
133 | - $output = sprintf(__('Avarage foucs keyword is', 'cgss') . ' ' . _n( '%d word','%d words',$key_count, 'cgss' ) . ' ' . __('long. Keyword frequency of %d%','cgss'),$key_count,$percent); |
|
133 | + $output = sprintf(__('Avarage foucs keyword is', 'cgss') . ' ' . _n('%d word', '%d words', $key_count, 'cgss') . ' ' . __('long. Keyword frequency of %d%', 'cgss'), $key_count, $percent); |
|
134 | 134 | |
135 | 135 | return $output; |
136 | 136 | } |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | $image_count = array_sum(array_column($images, 'count')); |
146 | 146 | $no_alt_image = array_sum(array_column($images, 'no_alt_count')); |
147 | 147 | |
148 | - $avg_image = round(($image_count/$this->count), 0); |
|
148 | + $avg_image = round(($image_count / $this->count), 0); |
|
149 | 149 | |
150 | - $output = sprintf(__('Avarage', 'cgss') . ' ' . _n( '%d image is', '%d images are', $avg_image, 'cgss' ) . ' ' . __( 'found per page.', 'cgss'),$avg_image) . ' '; |
|
150 | + $output = sprintf(__('Avarage', 'cgss') . ' ' . _n('%d image is', '%d images are', $avg_image, 'cgss') . ' ' . __('found per page.', 'cgss'), $avg_image) . ' '; |
|
151 | 151 | if ($no_alt_image == 0) { |
152 | 152 | $output .= ' ' . __('All of them are optimized', 'cgss'); |
153 | 153 | } else { |
154 | - $no_alt_percent = round(($no_alt_image/$image_count)*100, 0); |
|
155 | - $output .= ' ' . sprintf(__('%d% among them doesn\'t have alt tag', 'cgss'),$no_alt_percent); |
|
154 | + $no_alt_percent = round(($no_alt_image / $image_count) * 100, 0); |
|
155 | + $output .= ' ' . sprintf(__('%d% among them doesn\'t have alt tag', 'cgss'), $no_alt_percent); |
|
156 | 156 | } |
157 | 157 | return $output; |
158 | 158 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | if ($vport == $this->count) { |
169 | 169 | $output = __('All pages are mobile optimized', 'cgss'); |
170 | 170 | } else { |
171 | - $no_mobile_percent = round(($vport/$this->count)*100, 0); |
|
172 | - $output = sprintf(__('%d% pages aren\'t mobile optimized', 'cgss'),$no_mobile_percent); |
|
171 | + $no_mobile_percent = round(($vport / $this->count) * 100, 0); |
|
172 | + $output = sprintf(__('%d% pages aren\'t mobile optimized', 'cgss'), $no_mobile_percent); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | return $output; |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | $res_time = array_sum(array_column($speed, 'res_time')); |
185 | 185 | $down_time = array_sum(array_column($speed, 'down_time')); |
186 | 186 | |
187 | - $avg_res_time = round(($res_time/$this->count) * 1000, 0); |
|
188 | - $avg_down_time = round(($down_time/$this->count) * 1000, 0); |
|
187 | + $avg_res_time = round(($res_time / $this->count) * 1000, 0); |
|
188 | + $avg_down_time = round(($down_time / $this->count) * 1000, 0); |
|
189 | 189 | |
190 | - $output = sprintf( __('Average response time is %d miliseconds and average download time is %d miliseconds', 'cgss'), $avg_res_time, $avg_down_time); |
|
190 | + $output = sprintf(__('Average response time is %d miliseconds and average download time is %d miliseconds', 'cgss'), $avg_res_time, $avg_down_time); |
|
191 | 191 | |
192 | 192 | return $output; |
193 | 193 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $fb_share = array_sum(array_column($social, 'fb_share')); |
202 | 202 | $fb_like = array_sum(array_column($social, 'fb_like')); |
203 | 203 | |
204 | - $output = sprintf( __('Total', 'cgss') . ': ' . _n( '%d share', '%d shares', $fb_share, 'cgss' ) . ' ' . __( 'in Facebook', 'cgss' ). ' | ' . _n( '%d Facebook like', '%d Facebook likes', $fb_like, 'cgss' ), $fb_share, $fb_like); |
|
204 | + $output = sprintf(__('Total', 'cgss') . ': ' . _n('%d share', '%d shares', $fb_share, 'cgss') . ' ' . __('in Facebook', 'cgss') . ' | ' . _n('%d Facebook like', '%d Facebook likes', $fb_like, 'cgss'), $fb_share, $fb_like); |
|
205 | 205 | |
206 | 206 | return $output; |
207 | 207 | } |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | |
213 | 213 | global $wpdb; |
214 | 214 | $sql = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type!='attachment'"; |
215 | - $ids = $wpdb->get_results( $sql, 'ARRAY_A' );; |
|
215 | + $ids = $wpdb->get_results($sql, 'ARRAY_A'); ; |
|
216 | 216 | |
217 | 217 | $data_piece = array(); |
218 | 218 | foreach ($ids as $id) { |
219 | 219 | |
220 | - $meta = get_post_meta( $id['ID'], 'cgss_scan_result', true ); |
|
220 | + $meta = get_post_meta($id['ID'], 'cgss_scan_result', true); |
|
221 | 221 | if ($meta) { |
222 | 222 | $data_piece[] = $meta; |
223 | 223 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace NirjharLo\Cgss\Lib\Action; |
3 | 3 | |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | use \NirjharLo\Cgss\Models\Insight as InsightModel; |
7 | 9 |
@@ -8,61 +8,61 @@ |
||
8 | 8 | */ |
9 | 9 | class Insight |
10 | 10 | { |
11 | - /** @var wpdb */ |
|
12 | - protected $db; |
|
11 | + /** @var wpdb */ |
|
12 | + protected $db; |
|
13 | 13 | |
14 | - /** @var string */ |
|
15 | - protected $table; |
|
14 | + /** @var string */ |
|
15 | + protected $table; |
|
16 | 16 | |
17 | - public function __construct(?wpdb $db = null) |
|
18 | - { |
|
19 | - global $wpdb; |
|
20 | - $this->db = $db ?: $wpdb; |
|
21 | - $this->table = $this->db->prefix . 'cgss_insight'; |
|
22 | - } |
|
17 | + public function __construct(?wpdb $db = null) |
|
18 | + { |
|
19 | + global $wpdb; |
|
20 | + $this->db = $db ?: $wpdb; |
|
21 | + $this->table = $this->db->prefix . 'cgss_insight'; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Get all rows from the insight table. |
|
26 | - */ |
|
27 | - public function all(): array |
|
28 | - { |
|
29 | - $sql = "SELECT * FROM {$this->table}"; |
|
30 | - return $this->db->get_results($sql, ARRAY_A); |
|
31 | - } |
|
24 | + /** |
|
25 | + * Get all rows from the insight table. |
|
26 | + */ |
|
27 | + public function all(): array |
|
28 | + { |
|
29 | + $sql = "SELECT * FROM {$this->table}"; |
|
30 | + return $this->db->get_results($sql, ARRAY_A); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Count rows in the insight table. |
|
35 | - */ |
|
36 | - public function count(): int |
|
37 | - { |
|
38 | - $sql = "SELECT COUNT(*) FROM {$this->table}"; |
|
39 | - return (int) $this->db->get_var($sql); |
|
40 | - } |
|
33 | + /** |
|
34 | + * Count rows in the insight table. |
|
35 | + */ |
|
36 | + public function count(): int |
|
37 | + { |
|
38 | + $sql = "SELECT COUNT(*) FROM {$this->table}"; |
|
39 | + return (int) $this->db->get_var($sql); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Insert an insight row. |
|
44 | - */ |
|
45 | - public function insert(string $item, string $remark, int $id): bool |
|
46 | - { |
|
47 | - $result = $this->db->insert( |
|
48 | - $this->table, |
|
49 | - ['ID' => $id, 'item' => $item, 'remark' => $remark], |
|
50 | - ['%d', '%s', '%s'] |
|
51 | - ); |
|
52 | - return $result !== false; |
|
53 | - } |
|
42 | + /** |
|
43 | + * Insert an insight row. |
|
44 | + */ |
|
45 | + public function insert(string $item, string $remark, int $id): bool |
|
46 | + { |
|
47 | + $result = $this->db->insert( |
|
48 | + $this->table, |
|
49 | + ['ID' => $id, 'item' => $item, 'remark' => $remark], |
|
50 | + ['%d', '%s', '%s'] |
|
51 | + ); |
|
52 | + return $result !== false; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Update remark value by row id. |
|
57 | - */ |
|
58 | - public function updateRemark(int $id, string $remark): int |
|
59 | - { |
|
60 | - return $this->db->update( |
|
61 | - $this->table, |
|
62 | - ['remark' => $remark], |
|
63 | - ['ID' => $id], |
|
64 | - ['%s'], |
|
65 | - ['%d'] |
|
66 | - ); |
|
67 | - } |
|
55 | + /** |
|
56 | + * Update remark value by row id. |
|
57 | + */ |
|
58 | + public function updateRemark(int $id, string $remark): int |
|
59 | + { |
|
60 | + return $this->db->update( |
|
61 | + $this->table, |
|
62 | + ['remark' => $remark], |
|
63 | + ['ID' => $id], |
|
64 | + ['%s'], |
|
65 | + ['%d'] |
|
66 | + ); |
|
67 | + } |
|
68 | 68 | } |