1
|
|
|
<?php |
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Perform scan action |
6
|
|
|
*/ |
7
|
|
|
if ( ! class_exists( 'CGSS_SCAN' ) ) { |
8
|
|
|
|
9
|
|
|
final class CGSS_SCAN { |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
public function __construct() { |
13
|
|
|
|
14
|
|
|
$post_id = intval($_GET['scan']); |
15
|
|
|
$url = get_permalink( $post_id ); |
|
|
|
|
16
|
|
|
|
17
|
|
|
if (class_exists('CGSS_CRAWL')) { |
18
|
|
|
|
19
|
|
|
$crawl = new CGSS_CRAWL(); |
|
|
|
|
20
|
|
|
$crawl->url = esc_url_raw($url); |
|
|
|
|
21
|
|
|
$crawl->do(); |
22
|
|
|
$result = $crawl->result(); |
23
|
|
|
|
24
|
|
|
update_post_meta( $post_id, 'cgss_scan_result', $result ); |
|
|
|
|
25
|
|
|
|
26
|
|
|
$this->render($result); |
27
|
|
|
} |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
//Display the score |
32
|
|
|
public function score_html() { |
33
|
|
|
|
34
|
|
|
$score_html = ''; |
35
|
|
|
|
36
|
|
|
return $score_html; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
// Display the snippets |
41
|
|
|
public function snippet_display() { |
42
|
|
|
|
43
|
|
|
$snippet_html = ''; |
44
|
|
|
|
45
|
|
|
return $snippet_html; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
// Display text and link data |
50
|
|
|
public function text_display() { |
51
|
|
|
|
52
|
|
|
$text_html = ''; |
53
|
|
|
|
54
|
|
|
return $text_html; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
// Display design data |
59
|
|
|
public function design_display() { |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
$design_html = ''; |
63
|
|
|
|
64
|
|
|
return $design_html; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
// Display crawl data |
69
|
|
|
public function crawl_display() { |
70
|
|
|
|
71
|
|
|
$crawl_html = ''; |
72
|
|
|
|
73
|
|
|
return $crawl_html; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
// Display speed data |
78
|
|
|
public function speed_display() { |
79
|
|
|
|
80
|
|
|
$speed_html = ''; |
81
|
|
|
|
82
|
|
|
return $speed_html; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
// Render the HTML |
87
|
|
|
public function render($result) { |
|
|
|
|
88
|
|
|
|
89
|
|
|
$this->score = $this->score_html(); |
|
|
|
|
90
|
|
|
$this->snippets = $this->snippet_display(); |
|
|
|
|
91
|
|
|
$this->text = $this->text_display(); |
|
|
|
|
92
|
|
|
$this->design = $this->design_display(); |
|
|
|
|
93
|
|
|
$this->crawl = $this->crawl_display(); |
|
|
|
|
94
|
|
|
$this->speed = $this->speed_display(); |
|
|
|
|
95
|
|
|
|
96
|
|
|
$this->box( null, null, $this->score ); |
97
|
|
|
$this->box( __( 'Snippets', 'cgss' ), $this->dashicon('align-none'), $this->snippets ); |
|
|
|
|
98
|
|
|
$this->box( __( 'Text & Links', 'cgss' ), $this->dashicon('text'), $this->text ); |
99
|
|
|
$this->box( __( 'Design', 'cgss' ), $this->dashicon('smartphone'), $this->design ); |
100
|
|
|
$this->box( __( 'Crawl', 'cgss' ), $this->dashicon('randomize'), $this->crawl ); |
101
|
|
|
$this->box( __( 'Speed', 'cgss' ), $this->dashicon('clock'), $this->speed ); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
public function box($title, $icon, $desc) { |
106
|
|
|
|
107
|
|
|
echo |
108
|
|
|
'<div class="postbox"> |
109
|
|
|
<div class="inside"> |
110
|
|
|
<div class="main">' . |
111
|
|
|
'<h3>' . $icon . ' ' . $title . '</h3>' . |
112
|
|
|
$desc . |
113
|
|
|
'</div> |
114
|
|
|
</div> |
115
|
|
|
</div>'; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
public function dashicon($icon) { |
120
|
|
|
|
121
|
|
|
return '<span class="dashicons dashicons-'.$icon.'"></span>'; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
} ?> |
|
|
|
|