@@ -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; |
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 | } |
@@ -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 | |
7 | 7 | /** |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct() { |
14 | 14 | |
15 | - try{ |
|
15 | + try { |
|
16 | 16 | $this->data = $this->fetch(); |
17 | 17 | $this->compile(); |
18 | 18 | $this->save(); |
19 | - } catch(Exception $e) { |
|
20 | - echo __( 'Something went wrong', 'cgss') . ' ' . $e->get_message(); |
|
19 | + } catch (Exception $e) { |
|
20 | + echo __('Something went wrong', 'cgss') . ' ' . $e->get_message(); |
|
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $this->social, |
40 | 40 | ); |
41 | 41 | foreach ($result as $key => $value) { |
42 | - $sql = $wpdb->prepare("UPDATE {$wpdb->prefix}cgss_insight SET remark = %s WHERE ID = %d", $value, ($key+1)); |
|
42 | + $sql = $wpdb->prepare("UPDATE {$wpdb->prefix}cgss_insight SET remark = %s WHERE ID = %d", $value, ($key + 1)); |
|
43 | 43 | $update = $wpdb->query($sql); |
44 | 44 | } |
45 | 45 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | $score = $this->data['score']; |
52 | 52 | $this->count = (count($score) == 0 ? 1 : count($score)); |
53 | - $avarage_score = (count($score) == 0 ? 0 : round(array_sum($score)/count($score), 0)); |
|
53 | + $avarage_score = (count($score) == 0 ? 0 : round(array_sum($score) / count($score), 0)); |
|
54 | 54 | |
55 | - $this->score = sprintf(__('Avarage SEO score is %d out of 10', 'cgss'),$avarage_score); |
|
55 | + $this->score = sprintf(__('Avarage SEO score is %d out of 10', 'cgss'), $avarage_score); |
|
56 | 56 | $this->snippet = $this->snippet_analyze(); |
57 | 57 | $this->text = $this->text_analyze(); |
58 | 58 | $this->links = $this->link_analyze(); |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | foreach ($snippets as $snippet) { |
73 | 73 | $title = $snippet['title']; |
74 | 74 | $desc = $snippet['desc']; |
75 | - if (!empty($title) && !empty($desc)) { |
|
75 | + if ( ! empty($title) && ! empty($desc)) { |
|
76 | 76 | $snip_count++; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | $snip_fraction = $this->count - $snip_count; |
80 | 80 | |
81 | - $output = ($snip_fraction == 0) ? __( 'All snippets are ok', 'cgss' ) : sprintf(_n('%d page', '%d pages', $snip_fraction, 'cgss'), $snip_fraction) . ' ' . __( 'have incomplete snippets', 'cgss' ); |
|
81 | + $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 | 82 | return $output; |
83 | 83 | } |
84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $count = round(array_sum(array_column($text, 'count')) / $this->count, 0); |
91 | 91 | $ratio = round(array_sum(array_column($text, 'ratio')) / $this->count, 2); |
92 | 92 | |
93 | - $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) . '%'; |
|
93 | + $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 | 94 | return $output; |
95 | 95 | } |
96 | 96 | |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | $count = round(array_sum(array_column($links, 'count')) / $this->count, 0); |
104 | 104 | $external = round(array_sum(array_column($links, 'external')) / $this->count, 0); |
105 | 105 | $nofollow = round(array_sum(array_column($links, 'external')) / $this->count, 0); |
106 | - $external_percentage = ($count == 0 ? 0 : round(($external/$count)*100, 0)); |
|
107 | - $nofollow_percentage = ($count == 0 ? 0 : round(($nofollow/$count)*100, 0)); |
|
106 | + $external_percentage = ($count == 0 ? 0 : round(($external / $count) * 100, 0)); |
|
107 | + $nofollow_percentage = ($count == 0 ? 0 : round(($nofollow / $count) * 100, 0)); |
|
108 | 108 | |
109 | - $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); |
|
109 | + $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 | 110 | return $output; |
111 | 111 | } |
112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $key_collect = array(); |
121 | 121 | $percent_collect = array(); |
122 | 122 | foreach ($keywords as $keyword) { |
123 | - $keys = (!empty($keyword) ? array_keys($keyword) : []); |
|
123 | + $keys = ( ! empty($keyword) ? array_keys($keyword) : []); |
|
124 | 124 | $top_key = $keys[0]; |
125 | 125 | $key_collect[] = count(explode(' ', $top_key)); |
126 | 126 | $percent_collect[] = $keyword[$top_key]; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $key_count = round(array_sum($key_collect) / $this->count, 1); |
130 | 130 | $percent = round(array_sum($percent_collect) / $this->count, 1); |
131 | 131 | |
132 | - $output = sprintf(__('Avarage foucs keyword is', 'cgss') . ' ' . _n( '%d word','%d words',$key_count, 'cgss' ) . ' ' . __('long. Keyword frequency of %d%','cgss'),$key_count,$percent); |
|
132 | + $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 | 133 | |
134 | 134 | return $output; |
135 | 135 | } |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | $image_count = array_sum(array_column($images, 'count')); |
145 | 145 | $no_alt_image = array_sum(array_column($images, 'no_alt_count')); |
146 | 146 | |
147 | - $avg_image = round(($image_count/$this->count), 0); |
|
147 | + $avg_image = round(($image_count / $this->count), 0); |
|
148 | 148 | |
149 | - $output = sprintf(__('Avarage', 'cgss') . ' ' . _n( '%d image is', '%d images are', $avg_image, 'cgss' ) . ' ' . __( 'found per page.', 'cgss'),$avg_image) . ' '; |
|
149 | + $output = sprintf(__('Avarage', 'cgss') . ' ' . _n('%d image is', '%d images are', $avg_image, 'cgss') . ' ' . __('found per page.', 'cgss'), $avg_image) . ' '; |
|
150 | 150 | if ($no_alt_image == 0) { |
151 | 151 | $output .= ' ' . __('All of them are optimized', 'cgss'); |
152 | 152 | } else { |
153 | - $no_alt_percent = round(($no_alt_image/$image_count)*100, 0); |
|
154 | - $output .= ' ' . sprintf(__('%d% among them doesn\'t have alt tag', 'cgss'),$no_alt_percent); |
|
153 | + $no_alt_percent = round(($no_alt_image / $image_count) * 100, 0); |
|
154 | + $output .= ' ' . sprintf(__('%d% among them doesn\'t have alt tag', 'cgss'), $no_alt_percent); |
|
155 | 155 | } |
156 | 156 | return $output; |
157 | 157 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | if ($vport == $this->count) { |
168 | 168 | $output = __('All pages are mobile optimized', 'cgss'); |
169 | 169 | } else { |
170 | - $no_mobile_percent = round(($vport/$this->count)*100, 0); |
|
171 | - $output = sprintf(__('%d% pages aren\'t mobile optimized', 'cgss'),$no_mobile_percent); |
|
170 | + $no_mobile_percent = round(($vport / $this->count) * 100, 0); |
|
171 | + $output = sprintf(__('%d% pages aren\'t mobile optimized', 'cgss'), $no_mobile_percent); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $output; |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | $res_time = array_sum(array_column($speed, 'res_time')); |
184 | 184 | $down_time = array_sum(array_column($speed, 'down_time')); |
185 | 185 | |
186 | - $avg_res_time = round(($res_time/$this->count) * 1000, 0); |
|
187 | - $avg_down_time = round(($down_time/$this->count) * 1000, 0); |
|
186 | + $avg_res_time = round(($res_time / $this->count) * 1000, 0); |
|
187 | + $avg_down_time = round(($down_time / $this->count) * 1000, 0); |
|
188 | 188 | |
189 | - $output = sprintf( __('Average response time is %d miliseconds and average download time is %d miliseconds', 'cgss'), $avg_res_time, $avg_down_time); |
|
189 | + $output = sprintf(__('Average response time is %d miliseconds and average download time is %d miliseconds', 'cgss'), $avg_res_time, $avg_down_time); |
|
190 | 190 | |
191 | 191 | return $output; |
192 | 192 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $fb_share = array_sum(array_column($social, 'fb_share')); |
201 | 201 | $fb_like = array_sum(array_column($social, 'fb_like')); |
202 | 202 | |
203 | - $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); |
|
203 | + $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 | 204 | |
205 | 205 | return $output; |
206 | 206 | } |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | |
212 | 212 | global $wpdb; |
213 | 213 | $sql = "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type!='attachment'"; |
214 | - $ids = $wpdb->get_results( $sql, 'ARRAY_A' );; |
|
214 | + $ids = $wpdb->get_results($sql, 'ARRAY_A'); ; |
|
215 | 215 | |
216 | 216 | $data_piece = array(); |
217 | 217 | foreach ($ids as $id) { |
218 | 218 | |
219 | - $meta = get_post_meta( $id['ID'], 'cgss_scan_result', true ); |
|
219 | + $meta = get_post_meta($id['ID'], 'cgss_scan_result', true); |
|
220 | 220 | if ($meta) { |
221 | 221 | $data_piece[] = $meta; |
222 | 222 | } |
@@ -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() { |
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() { |
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) { |
234 | 234 | |
235 | - return '<span class="dashicons dashicons-'.$icon.'"></span>'; |
|
235 | + return '<span class="dashicons dashicons-' . $icon . '"></span>'; |
|
236 | 236 | } |
237 | 237 | } ?> |