@@ -11,6 +11,6 @@ |
||
11 | 11 | */ |
12 | 12 | class Upgrader |
13 | 13 | { |
14 | - public function run() |
|
15 | - {} |
|
14 | + public function run() |
|
15 | + {} |
|
16 | 16 | } |
@@ -12,5 +12,6 @@ |
||
12 | 12 | class Upgrader |
13 | 13 | { |
14 | 14 | public function run() |
15 | - {} |
|
15 | + { |
|
16 | +} |
|
16 | 17 | } |
@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | class SiteReviewsFormShortcode extends Shortcode |
6 | 6 | { |
7 | - protected function hideOptions() |
|
8 | - { |
|
9 | - return [ |
|
10 | - 'rating' => __('Hide the rating field', 'site-reviews'), |
|
11 | - 'title' => __('Hide the title field', 'site-reviews'), |
|
12 | - 'content' => __('Hide the review field', 'site-reviews'), |
|
13 | - 'name' => __('Hide the name field', 'site-reviews'), |
|
14 | - 'email' => __('Hide the email field', 'site-reviews'), |
|
15 | - 'terms' => __('Hide the terms field', 'site-reviews'), |
|
16 | - ]; |
|
17 | - } |
|
7 | + protected function hideOptions() |
|
8 | + { |
|
9 | + return [ |
|
10 | + 'rating' => __('Hide the rating field', 'site-reviews'), |
|
11 | + 'title' => __('Hide the title field', 'site-reviews'), |
|
12 | + 'content' => __('Hide the review field', 'site-reviews'), |
|
13 | + 'name' => __('Hide the name field', 'site-reviews'), |
|
14 | + 'email' => __('Hide the email field', 'site-reviews'), |
|
15 | + 'terms' => __('Hide the terms field', 'site-reviews'), |
|
16 | + ]; |
|
17 | + } |
|
18 | 18 | } |
@@ -7,12 +7,12 @@ |
||
7 | 7 | protected function hideOptions() |
8 | 8 | { |
9 | 9 | return [ |
10 | - 'rating' => __('Hide the rating field', 'site-reviews'), |
|
11 | - 'title' => __('Hide the title field', 'site-reviews'), |
|
12 | - 'content' => __('Hide the review field', 'site-reviews'), |
|
13 | - 'name' => __('Hide the name field', 'site-reviews'), |
|
14 | - 'email' => __('Hide the email field', 'site-reviews'), |
|
15 | - 'terms' => __('Hide the terms field', 'site-reviews'), |
|
10 | + 'rating' => __( 'Hide the rating field', 'site-reviews' ), |
|
11 | + 'title' => __( 'Hide the title field', 'site-reviews' ), |
|
12 | + 'content' => __( 'Hide the review field', 'site-reviews' ), |
|
13 | + 'name' => __( 'Hide the name field', 'site-reviews' ), |
|
14 | + 'email' => __( 'Hide the email field', 'site-reviews' ), |
|
15 | + 'terms' => __( 'Hide the terms field', 'site-reviews' ), |
|
16 | 16 | ]; |
17 | 17 | } |
18 | 18 | } |
@@ -10,197 +10,197 @@ |
||
10 | 10 | |
11 | 11 | class SiteReviewsSummary |
12 | 12 | { |
13 | - /** |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $args; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var float |
|
20 | - */ |
|
21 | - protected $averageRating; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $ratingCounts; |
|
27 | - |
|
28 | - /** |
|
29 | - * @return void|string |
|
30 | - */ |
|
31 | - public function build(array $args = []) |
|
32 | - { |
|
33 | - $this->args = $args; |
|
34 | - $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args); |
|
35 | - if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) { |
|
36 | - return; |
|
37 | - } |
|
38 | - $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts); |
|
39 | - $this->generateSchema(); |
|
40 | - return glsr(Template::class)->build('templates/reviews-summary', [ |
|
41 | - 'context' => [ |
|
42 | - 'assigned_to' => $this->args['assigned_to'], |
|
43 | - 'category' => $this->args['category'], |
|
44 | - 'class' => $this->getClass(), |
|
45 | - 'id' => $this->args['id'], |
|
46 | - 'percentages' => $this->buildPercentage(), |
|
47 | - 'rating' => $this->buildRating(), |
|
48 | - 'stars' => $this->buildStars(), |
|
49 | - 'text' => $this->buildText(), |
|
50 | - ], |
|
51 | - ]); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @return void|string |
|
56 | - */ |
|
57 | - protected function buildPercentage() |
|
58 | - { |
|
59 | - if ($this->isHidden('bars')) { |
|
60 | - return; |
|
61 | - } |
|
62 | - $percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts)); |
|
63 | - $bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) { |
|
64 | - $label = $this->buildPercentageLabel($this->args['labels'][$level]); |
|
65 | - $background = $this->buildPercentageBackground($percentages[$level]); |
|
66 | - $count = apply_filters('site-reviews/summary/counts', |
|
67 | - $percentages[$level], |
|
68 | - $this->ratingCounts[$level] |
|
69 | - ); |
|
70 | - $percent = $this->buildPercentageCount($count); |
|
71 | - $value = $label.$background.$percent; |
|
72 | - $value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [ |
|
73 | - 'percent' => wp_strip_all_tags($count, true), |
|
74 | - 'rating' => $level, |
|
75 | - ]); |
|
76 | - return $carry.glsr(Builder::class)->div($value, [ |
|
77 | - 'class' => 'glsr-bar', |
|
78 | - ]); |
|
79 | - }); |
|
80 | - return $this->wrap('percentage', $bars); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string $percent |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - protected function buildPercentageBackground($percent) |
|
88 | - { |
|
89 | - $backgroundPercent = glsr(Builder::class)->span([ |
|
90 | - 'class' => 'glsr-bar-background-percent', |
|
91 | - 'style' => 'width:'.$percent, |
|
92 | - ]); |
|
93 | - return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $count |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - protected function buildPercentageCount($count) |
|
101 | - { |
|
102 | - return '<span class="glsr-bar-percent">'.$count.'</span>'; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @param string $label |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - protected function buildPercentageLabel($label) |
|
110 | - { |
|
111 | - return '<span class="glsr-bar-label">'.$label.'</span>'; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @return void|string |
|
116 | - */ |
|
117 | - protected function buildRating() |
|
118 | - { |
|
119 | - if ($this->isHidden('rating')) { |
|
120 | - return; |
|
121 | - } |
|
122 | - return $this->wrap('rating', '<span>'.$this->averageRating.'</span>'); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return void|string |
|
127 | - */ |
|
128 | - protected function buildStars() |
|
129 | - { |
|
130 | - if ($this->isHidden('stars')) { |
|
131 | - return; |
|
132 | - } |
|
133 | - $stars = glsr_star_rating($this->averageRating); |
|
134 | - return $this->wrap('stars', $stars); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @return void|string |
|
139 | - */ |
|
140 | - protected function buildText() |
|
141 | - { |
|
142 | - if ($this->isHidden('summary')) { |
|
143 | - return; |
|
144 | - } |
|
145 | - $count = intval(array_sum($this->ratingCounts)); |
|
146 | - if (empty($this->args['text'])) { |
|
147 | - // @todo document this change |
|
148 | - $this->args['text'] = _nx( |
|
149 | - '{rating} out of {max} stars (based on {num} review)', |
|
150 | - '{rating} out of {max} stars (based on {num} reviews)', |
|
151 | - $count, |
|
152 | - 'Do not translate {rating}, {max}, and {num}, they are template tags.', |
|
153 | - 'site-reviews' |
|
154 | - ); |
|
155 | - } |
|
156 | - $summary = str_replace( |
|
157 | - ['{rating}', '{max}', '{num}'], |
|
158 | - [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count], |
|
159 | - $this->args['text'] |
|
160 | - ); |
|
161 | - return $this->wrap('text', '<span>'.$summary.'</span>'); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - protected function generateSchema() |
|
168 | - { |
|
169 | - if (!wp_validate_boolean($this->args['schema'])) { |
|
170 | - return; |
|
171 | - } |
|
172 | - glsr(Schema::class)->store( |
|
173 | - glsr(Schema::class)->buildSummary($this->args) |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - protected function getClass() |
|
181 | - { |
|
182 | - return trim('glsr-summary glsr-default '.$this->args['class']); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @param string $key |
|
187 | - * @return bool |
|
188 | - */ |
|
189 | - protected function isHidden($key) |
|
190 | - { |
|
191 | - return in_array($key, $this->args['hide']); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @param string $key |
|
196 | - * @param string $value |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - protected function wrap($key, $value) |
|
200 | - { |
|
201 | - $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args); |
|
202 | - return glsr(Builder::class)->div($value, [ |
|
203 | - 'class' => 'glsr-summary-'.$key, |
|
204 | - ]); |
|
205 | - } |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $args; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var float |
|
20 | + */ |
|
21 | + protected $averageRating; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $ratingCounts; |
|
27 | + |
|
28 | + /** |
|
29 | + * @return void|string |
|
30 | + */ |
|
31 | + public function build(array $args = []) |
|
32 | + { |
|
33 | + $this->args = $args; |
|
34 | + $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args); |
|
35 | + if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) { |
|
36 | + return; |
|
37 | + } |
|
38 | + $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts); |
|
39 | + $this->generateSchema(); |
|
40 | + return glsr(Template::class)->build('templates/reviews-summary', [ |
|
41 | + 'context' => [ |
|
42 | + 'assigned_to' => $this->args['assigned_to'], |
|
43 | + 'category' => $this->args['category'], |
|
44 | + 'class' => $this->getClass(), |
|
45 | + 'id' => $this->args['id'], |
|
46 | + 'percentages' => $this->buildPercentage(), |
|
47 | + 'rating' => $this->buildRating(), |
|
48 | + 'stars' => $this->buildStars(), |
|
49 | + 'text' => $this->buildText(), |
|
50 | + ], |
|
51 | + ]); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @return void|string |
|
56 | + */ |
|
57 | + protected function buildPercentage() |
|
58 | + { |
|
59 | + if ($this->isHidden('bars')) { |
|
60 | + return; |
|
61 | + } |
|
62 | + $percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts)); |
|
63 | + $bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) { |
|
64 | + $label = $this->buildPercentageLabel($this->args['labels'][$level]); |
|
65 | + $background = $this->buildPercentageBackground($percentages[$level]); |
|
66 | + $count = apply_filters('site-reviews/summary/counts', |
|
67 | + $percentages[$level], |
|
68 | + $this->ratingCounts[$level] |
|
69 | + ); |
|
70 | + $percent = $this->buildPercentageCount($count); |
|
71 | + $value = $label.$background.$percent; |
|
72 | + $value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [ |
|
73 | + 'percent' => wp_strip_all_tags($count, true), |
|
74 | + 'rating' => $level, |
|
75 | + ]); |
|
76 | + return $carry.glsr(Builder::class)->div($value, [ |
|
77 | + 'class' => 'glsr-bar', |
|
78 | + ]); |
|
79 | + }); |
|
80 | + return $this->wrap('percentage', $bars); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string $percent |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + protected function buildPercentageBackground($percent) |
|
88 | + { |
|
89 | + $backgroundPercent = glsr(Builder::class)->span([ |
|
90 | + 'class' => 'glsr-bar-background-percent', |
|
91 | + 'style' => 'width:'.$percent, |
|
92 | + ]); |
|
93 | + return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $count |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + protected function buildPercentageCount($count) |
|
101 | + { |
|
102 | + return '<span class="glsr-bar-percent">'.$count.'</span>'; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @param string $label |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + protected function buildPercentageLabel($label) |
|
110 | + { |
|
111 | + return '<span class="glsr-bar-label">'.$label.'</span>'; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @return void|string |
|
116 | + */ |
|
117 | + protected function buildRating() |
|
118 | + { |
|
119 | + if ($this->isHidden('rating')) { |
|
120 | + return; |
|
121 | + } |
|
122 | + return $this->wrap('rating', '<span>'.$this->averageRating.'</span>'); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return void|string |
|
127 | + */ |
|
128 | + protected function buildStars() |
|
129 | + { |
|
130 | + if ($this->isHidden('stars')) { |
|
131 | + return; |
|
132 | + } |
|
133 | + $stars = glsr_star_rating($this->averageRating); |
|
134 | + return $this->wrap('stars', $stars); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return void|string |
|
139 | + */ |
|
140 | + protected function buildText() |
|
141 | + { |
|
142 | + if ($this->isHidden('summary')) { |
|
143 | + return; |
|
144 | + } |
|
145 | + $count = intval(array_sum($this->ratingCounts)); |
|
146 | + if (empty($this->args['text'])) { |
|
147 | + // @todo document this change |
|
148 | + $this->args['text'] = _nx( |
|
149 | + '{rating} out of {max} stars (based on {num} review)', |
|
150 | + '{rating} out of {max} stars (based on {num} reviews)', |
|
151 | + $count, |
|
152 | + 'Do not translate {rating}, {max}, and {num}, they are template tags.', |
|
153 | + 'site-reviews' |
|
154 | + ); |
|
155 | + } |
|
156 | + $summary = str_replace( |
|
157 | + ['{rating}', '{max}', '{num}'], |
|
158 | + [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count], |
|
159 | + $this->args['text'] |
|
160 | + ); |
|
161 | + return $this->wrap('text', '<span>'.$summary.'</span>'); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + protected function generateSchema() |
|
168 | + { |
|
169 | + if (!wp_validate_boolean($this->args['schema'])) { |
|
170 | + return; |
|
171 | + } |
|
172 | + glsr(Schema::class)->store( |
|
173 | + glsr(Schema::class)->buildSummary($this->args) |
|
174 | + ); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + protected function getClass() |
|
181 | + { |
|
182 | + return trim('glsr-summary glsr-default '.$this->args['class']); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @param string $key |
|
187 | + * @return bool |
|
188 | + */ |
|
189 | + protected function isHidden($key) |
|
190 | + { |
|
191 | + return in_array($key, $this->args['hide']); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @param string $key |
|
196 | + * @param string $value |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + protected function wrap($key, $value) |
|
200 | + { |
|
201 | + $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args); |
|
202 | + return glsr(Builder::class)->div($value, [ |
|
203 | + 'class' => 'glsr-summary-'.$key, |
|
204 | + ]); |
|
205 | + } |
|
206 | 206 | } |
@@ -28,16 +28,16 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @return void|string |
30 | 30 | */ |
31 | - public function build(array $args = []) |
|
31 | + public function build( array $args = [] ) |
|
32 | 32 | { |
33 | 33 | $this->args = $args; |
34 | - $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args); |
|
35 | - if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) { |
|
34 | + $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args ); |
|
35 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) ) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | - $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts); |
|
38 | + $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
|
39 | 39 | $this->generateSchema(); |
40 | - return glsr(Template::class)->build('templates/reviews-summary', [ |
|
40 | + return glsr( Template::class )->build( 'templates/reviews-summary', [ |
|
41 | 41 | 'context' => [ |
42 | 42 | 'assigned_to' => $this->args['assigned_to'], |
43 | 43 | 'category' => $this->args['category'], |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'stars' => $this->buildStars(), |
49 | 49 | 'text' => $this->buildText(), |
50 | 50 | ], |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,40 +56,40 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function buildPercentage() |
58 | 58 | { |
59 | - if ($this->isHidden('bars')) { |
|
59 | + if( $this->isHidden( 'bars' ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | - $percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts)); |
|
63 | - $bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) { |
|
64 | - $label = $this->buildPercentageLabel($this->args['labels'][$level]); |
|
65 | - $background = $this->buildPercentageBackground($percentages[$level]); |
|
66 | - $count = apply_filters('site-reviews/summary/counts', |
|
62 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
63 | + $bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use ($percentages) { |
|
64 | + $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
|
65 | + $background = $this->buildPercentageBackground( $percentages[$level] ); |
|
66 | + $count = apply_filters( 'site-reviews/summary/counts', |
|
67 | 67 | $percentages[$level], |
68 | 68 | $this->ratingCounts[$level] |
69 | 69 | ); |
70 | - $percent = $this->buildPercentageCount($count); |
|
70 | + $percent = $this->buildPercentageCount( $count ); |
|
71 | 71 | $value = $label.$background.$percent; |
72 | - $value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [ |
|
73 | - 'percent' => wp_strip_all_tags($count, true), |
|
72 | + $value = apply_filters( 'site-reviews/summary/wrap/bar', $value, $this->args, [ |
|
73 | + 'percent' => wp_strip_all_tags( $count, true ), |
|
74 | 74 | 'rating' => $level, |
75 | - ]); |
|
76 | - return $carry.glsr(Builder::class)->div($value, [ |
|
75 | + ] ); |
|
76 | + return $carry.glsr( Builder::class )->div( $value, [ |
|
77 | 77 | 'class' => 'glsr-bar', |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | }); |
80 | - return $this->wrap('percentage', $bars); |
|
80 | + return $this->wrap( 'percentage', $bars ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @param string $percent |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - protected function buildPercentageBackground($percent) |
|
87 | + protected function buildPercentageBackground( $percent ) |
|
88 | 88 | { |
89 | - $backgroundPercent = glsr(Builder::class)->span([ |
|
89 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
90 | 90 | 'class' => 'glsr-bar-background-percent', |
91 | 91 | 'style' => 'width:'.$percent, |
92 | - ]); |
|
92 | + ] ); |
|
93 | 93 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
94 | 94 | } |
95 | 95 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $count |
98 | 98 | * @return string |
99 | 99 | */ |
100 | - protected function buildPercentageCount($count) |
|
100 | + protected function buildPercentageCount( $count ) |
|
101 | 101 | { |
102 | 102 | return '<span class="glsr-bar-percent">'.$count.'</span>'; |
103 | 103 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string $label |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - protected function buildPercentageLabel($label) |
|
109 | + protected function buildPercentageLabel( $label ) |
|
110 | 110 | { |
111 | 111 | return '<span class="glsr-bar-label">'.$label.'</span>'; |
112 | 112 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function buildRating() |
118 | 118 | { |
119 | - if ($this->isHidden('rating')) { |
|
119 | + if( $this->isHidden( 'rating' ) ) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | - return $this->wrap('rating', '<span>'.$this->averageRating.'</span>'); |
|
122 | + return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildStars() |
129 | 129 | { |
130 | - if ($this->isHidden('stars')) { |
|
130 | + if( $this->isHidden( 'stars' ) ) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | - $stars = glsr_star_rating($this->averageRating); |
|
134 | - return $this->wrap('stars', $stars); |
|
133 | + $stars = glsr_star_rating( $this->averageRating ); |
|
134 | + return $this->wrap( 'stars', $stars ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function buildText() |
141 | 141 | { |
142 | - if ($this->isHidden('summary')) { |
|
142 | + if( $this->isHidden( 'summary' ) ) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | - $count = intval(array_sum($this->ratingCounts)); |
|
146 | - if (empty($this->args['text'])) { |
|
145 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
146 | + if( empty($this->args['text']) ) { |
|
147 | 147 | // @todo document this change |
148 | 148 | $this->args['text'] = _nx( |
149 | 149 | '{rating} out of {max} stars (based on {num} review)', |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | } |
156 | 156 | $summary = str_replace( |
157 | 157 | ['{rating}', '{max}', '{num}'], |
158 | - [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count], |
|
158 | + [$this->averageRating, glsr()->constant( 'MAX_RATING', Rating::class ), $count], |
|
159 | 159 | $this->args['text'] |
160 | 160 | ); |
161 | - return $this->wrap('text', '<span>'.$summary.'</span>'); |
|
161 | + return $this->wrap( 'text', '<span>'.$summary.'</span>' ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function generateSchema() |
168 | 168 | { |
169 | - if (!wp_validate_boolean($this->args['schema'])) { |
|
169 | + if( !wp_validate_boolean( $this->args['schema'] ) ) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | - glsr(Schema::class)->store( |
|
173 | - glsr(Schema::class)->buildSummary($this->args) |
|
172 | + glsr( Schema::class )->store( |
|
173 | + glsr( Schema::class )->buildSummary( $this->args ) |
|
174 | 174 | ); |
175 | 175 | } |
176 | 176 | |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function getClass() |
181 | 181 | { |
182 | - return trim('glsr-summary glsr-default '.$this->args['class']); |
|
182 | + return trim( 'glsr-summary glsr-default '.$this->args['class'] ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @param string $key |
187 | 187 | * @return bool |
188 | 188 | */ |
189 | - protected function isHidden($key) |
|
189 | + protected function isHidden( $key ) |
|
190 | 190 | { |
191 | - return in_array($key, $this->args['hide']); |
|
191 | + return in_array( $key, $this->args['hide'] ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | * @param string $value |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - protected function wrap($key, $value) |
|
199 | + protected function wrap( $key, $value ) |
|
200 | 200 | { |
201 | - $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args); |
|
202 | - return glsr(Builder::class)->div($value, [ |
|
201 | + $value = apply_filters( 'site-reviews/summary/wrap/'.$key, $value, $this->args ); |
|
202 | + return glsr( Builder::class )->div( $value, [ |
|
203 | 203 | 'class' => 'glsr-summary-'.$key, |
204 | - ]); |
|
204 | + ] ); |
|
205 | 205 | } |
206 | 206 | } |
@@ -7,86 +7,86 @@ |
||
7 | 7 | |
8 | 8 | class Template |
9 | 9 | { |
10 | - /** |
|
11 | - * @param string $templatePath |
|
12 | - * @return void|string |
|
13 | - */ |
|
14 | - public function build($templatePath, array $data = []) |
|
15 | - { |
|
16 | - $data = $this->normalize($data); |
|
17 | - $path = Str::removePrefix('templates/', $templatePath); |
|
18 | - $template = glsr()->build($templatePath, $data); |
|
19 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | - $template = $this->interpolate($template, $data, $path); |
|
21 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
23 | - return $template; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @param string $templatePath |
|
12 | + * @return void|string |
|
13 | + */ |
|
14 | + public function build($templatePath, array $data = []) |
|
15 | + { |
|
16 | + $data = $this->normalize($data); |
|
17 | + $path = Str::removePrefix('templates/', $templatePath); |
|
18 | + $template = glsr()->build($templatePath, $data); |
|
19 | + $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | + $template = $this->interpolate($template, $data, $path); |
|
21 | + $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | + $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
23 | + return $template; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Interpolate context values into template placeholders. |
|
28 | - * @param string $template |
|
29 | - * @param string $templatePath |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function interpolate($template, array $data = [], $templatePath) |
|
33 | - { |
|
34 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | - return $this->interpolateContext($template, $context); |
|
37 | - } |
|
26 | + /** |
|
27 | + * Interpolate context values into template placeholders. |
|
28 | + * @param string $template |
|
29 | + * @param string $templatePath |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function interpolate($template, array $data = [], $templatePath) |
|
33 | + { |
|
34 | + $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | + $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | + return $this->interpolateContext($template, $context); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Interpolate context values into template placeholders. |
|
41 | - * @param string $text |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function interpolateContext($text, array $context = []) |
|
45 | - { |
|
46 | - foreach ($context as $key => $value) { |
|
47 | - $text = strtr( |
|
48 | - $text, |
|
49 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
50 | - ); |
|
51 | - } |
|
52 | - return trim($text); |
|
53 | - } |
|
39 | + /** |
|
40 | + * Interpolate context values into template placeholders. |
|
41 | + * @param string $text |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function interpolateContext($text, array $context = []) |
|
45 | + { |
|
46 | + foreach ($context as $key => $value) { |
|
47 | + $text = strtr( |
|
48 | + $text, |
|
49 | + array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
50 | + ); |
|
51 | + } |
|
52 | + return trim($text); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param string $templatePath |
|
57 | - * @return void|string |
|
58 | - */ |
|
59 | - public function render($templatePath, array $data = []) |
|
60 | - { |
|
61 | - echo $this->build($templatePath, $data); |
|
62 | - } |
|
55 | + /** |
|
56 | + * @param string $templatePath |
|
57 | + * @return void|string |
|
58 | + */ |
|
59 | + public function render($templatePath, array $data = []) |
|
60 | + { |
|
61 | + echo $this->build($templatePath, $data); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - protected function normalize(array $data) |
|
68 | - { |
|
69 | - $arrayKeys = ['context', 'globals']; |
|
70 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
71 | - foreach ($arrayKeys as $key) { |
|
72 | - if (is_array($data[$key])) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $data[$key] = []; |
|
76 | - } |
|
77 | - return $data; |
|
78 | - } |
|
64 | + /** |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + protected function normalize(array $data) |
|
68 | + { |
|
69 | + $arrayKeys = ['context', 'globals']; |
|
70 | + $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
71 | + foreach ($arrayKeys as $key) { |
|
72 | + if (is_array($data[$key])) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $data[$key] = []; |
|
76 | + } |
|
77 | + return $data; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - protected function normalizeContext(array $context) |
|
84 | - { |
|
85 | - $context = array_filter($context, function ($value) { |
|
86 | - return !is_array($value) && !is_object($value); |
|
87 | - }); |
|
88 | - return array_map(function ($value) { |
|
89 | - return (string) $value; |
|
90 | - }, $context); |
|
91 | - } |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + protected function normalizeContext(array $context) |
|
84 | + { |
|
85 | + $context = array_filter($context, function ($value) { |
|
86 | + return !is_array($value) && !is_object($value); |
|
87 | + }); |
|
88 | + return array_map(function ($value) { |
|
89 | + return (string) $value; |
|
90 | + }, $context); |
|
91 | + } |
|
92 | 92 | } |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | * @param string $templatePath |
12 | 12 | * @return void|string |
13 | 13 | */ |
14 | - public function build($templatePath, array $data = []) |
|
14 | + public function build( $templatePath, array $data = [] ) |
|
15 | 15 | { |
16 | - $data = $this->normalize($data); |
|
17 | - $path = Str::removePrefix('templates/', $templatePath); |
|
18 | - $template = glsr()->build($templatePath, $data); |
|
19 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
20 | - $template = $this->interpolate($template, $data, $path); |
|
21 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
22 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
16 | + $data = $this->normalize( $data ); |
|
17 | + $path = Str::removePrefix( 'templates/', $templatePath ); |
|
18 | + $template = glsr()->build( $templatePath, $data ); |
|
19 | + $template = apply_filters( 'site-reviews/build/template/'.$path, $template, $data ); |
|
20 | + $template = $this->interpolate( $template, $data, $path ); |
|
21 | + $template = apply_filters( 'site-reviews/rendered/template', $template, $templatePath, $data ); |
|
22 | + $template = apply_filters( 'site-reviews/rendered/template/'.$path, $template, $data ); |
|
23 | 23 | return $template; |
24 | 24 | } |
25 | 25 | |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * @param string $templatePath |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function interpolate($template, array $data = [], $templatePath) |
|
32 | + public function interpolate( $template, array $data = [], $templatePath ) |
|
33 | 33 | { |
34 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
35 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
36 | - return $this->interpolateContext($template, $context); |
|
34 | + $context = $this->normalizeContext( Arr::get( $data, 'context', [] ) ); |
|
35 | + $context = apply_filters( 'site-reviews/interpolate/'.$templatePath, $context, $template, $data ); |
|
36 | + return $this->interpolateContext( $template, $context ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -41,35 +41,35 @@ discard block |
||
41 | 41 | * @param string $text |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function interpolateContext($text, array $context = []) |
|
44 | + public function interpolateContext( $text, array $context = [] ) |
|
45 | 45 | { |
46 | - foreach ($context as $key => $value) { |
|
46 | + foreach( $context as $key => $value ) { |
|
47 | 47 | $text = strtr( |
48 | 48 | $text, |
49 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
49 | + array_fill_keys( ['{'.$key.'}', '{{ '.$key.' }}'], $value ) |
|
50 | 50 | ); |
51 | 51 | } |
52 | - return trim($text); |
|
52 | + return trim( $text ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param string $templatePath |
57 | 57 | * @return void|string |
58 | 58 | */ |
59 | - public function render($templatePath, array $data = []) |
|
59 | + public function render( $templatePath, array $data = [] ) |
|
60 | 60 | { |
61 | - echo $this->build($templatePath, $data); |
|
61 | + echo $this->build( $templatePath, $data ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @return array |
66 | 66 | */ |
67 | - protected function normalize(array $data) |
|
67 | + protected function normalize( array $data ) |
|
68 | 68 | { |
69 | 69 | $arrayKeys = ['context', 'globals']; |
70 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
71 | - foreach ($arrayKeys as $key) { |
|
72 | - if (is_array($data[$key])) { |
|
70 | + $data = wp_parse_args( $data, array_fill_keys( $arrayKeys, [] ) ); |
|
71 | + foreach( $arrayKeys as $key ) { |
|
72 | + if( is_array( $data[$key] ) ) { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | $data[$key] = []; |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - protected function normalizeContext(array $context) |
|
83 | + protected function normalizeContext( array $context ) |
|
84 | 84 | { |
85 | - $context = array_filter($context, function ($value) { |
|
86 | - return !is_array($value) && !is_object($value); |
|
85 | + $context = array_filter( $context, function( $value ) { |
|
86 | + return !is_array( $value ) && !is_object( $value ); |
|
87 | 87 | }); |
88 | - return array_map(function ($value) { |
|
89 | - return (string) $value; |
|
90 | - }, $context); |
|
88 | + return array_map( function( $value ) { |
|
89 | + return (string)$value; |
|
90 | + }, $context ); |
|
91 | 91 | } |
92 | 92 | } |
@@ -1,42 +1,42 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
3 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
4 | 4 | <div class="glsr-card card"> |
5 | 5 | <h3>Export Settings</h3> |
6 | 6 | <p>Export the Site Reviews settings for this site to a <code>*.json</code> file. This allows you to easily import the plugin settings into another site.</p> |
7 | - <p>To export your Site Reviews' reviews and categories, please use the WordPress <a href="<?= admin_url('export.php'); ?>">Export</a> tool.</p> |
|
7 | + <p>To export your Site Reviews' reviews and categories, please use the WordPress <a href="<?= admin_url( 'export.php' ); ?>">Export</a> tool.</p> |
|
8 | 8 | <form method="post"> |
9 | 9 | <input type="hidden" name="{{ id }}[_action]" value="export-settings"> |
10 | - <?php wp_nonce_field('export-settings'); ?> |
|
11 | - <?php submit_button(__('Export Settings', 'site-reviews'), 'secondary'); ?> |
|
10 | + <?php wp_nonce_field( 'export-settings' ); ?> |
|
11 | + <?php submit_button( __( 'Export Settings', 'site-reviews' ), 'secondary' ); ?> |
|
12 | 12 | </form> |
13 | 13 | </div> |
14 | 14 | <?php endif; ?> |
15 | 15 | |
16 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
16 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
17 | 17 | <div class="glsr-card card"> |
18 | 18 | <h3>Import Settings</h3> |
19 | 19 | <p>Import the Site Reviews settings from a <code>*.json</code> file. This file can be obtained by exporting the settings on another site using the export tool below.</p> |
20 | - <p>To import your Site Reviews' reviews and categories from another website, please use the WordPress <a href="<?= admin_url('import.php'); ?>">Import</a> tool.</p> |
|
20 | + <p>To import your Site Reviews' reviews and categories from another website, please use the WordPress <a href="<?= admin_url( 'import.php' ); ?>">Import</a> tool.</p> |
|
21 | 21 | <form method="post" enctype="multipart/form-data"> |
22 | 22 | <input type="file" name="import-file"> |
23 | 23 | <input type="hidden" name="{{ id }}[_action]" value="import-settings"> |
24 | - <?php wp_nonce_field('import-settings'); ?> |
|
25 | - <?php submit_button(__('Import Settings', 'site-reviews'), 'secondary'); ?> |
|
24 | + <?php wp_nonce_field( 'import-settings' ); ?> |
|
25 | + <?php submit_button( __( 'Import Settings', 'site-reviews' ), 'secondary' ); ?> |
|
26 | 26 | </form> |
27 | 27 | </div> |
28 | 28 | <?php endif; ?> |
29 | 29 | |
30 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
30 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
31 | 31 | <div class="glsr-card card"> |
32 | 32 | <h3>Migrate Plugin</h3> |
33 | 33 | <p>Run this tool if your reviews stopped working correctly after upgrading the plugin to the latest version (i.e. read-only reviews, zero-star ratings, missing role capabilities, etc.).</p> |
34 | 34 | <form method="post"> |
35 | 35 | <input type="hidden" name="{{ id }}[_action]" value="migrate-reviews"> |
36 | - <?php wp_nonce_field('migrate-reviews'); ?> |
|
36 | + <?php wp_nonce_field( 'migrate-reviews' ); ?> |
|
37 | 37 | <p class="submit"> |
38 | 38 | <button type="submit" class="glsr-button button" name="migrate-reviews" id="migrate-reviews"> |
39 | - <span data-loading="<?= __('Migrating Reviews, please wait...', 'site-reviews'); ?>"><?= __('Run Migration', 'site-reviews'); ?></span> |
|
39 | + <span data-loading="<?= __( 'Migrating Reviews, please wait...', 'site-reviews' ); ?>"><?= __( 'Run Migration', 'site-reviews' ); ?></span> |
|
40 | 40 | </button> |
41 | 41 | </p> |
42 | 42 | </form> |
@@ -49,26 +49,26 @@ discard block |
||
49 | 49 | <p>If you suspect that the rating counts are incorrect (perhaps you have cloned a page that had reviews assigned to it, or edited/deleted reviews directly from your database), you can recalculate them here.</p> |
50 | 50 | <form method="post"> |
51 | 51 | <input type="hidden" name="{{ id }}[_action]" value="count-reviews"> |
52 | - <?php wp_nonce_field('count-reviews'); ?> |
|
52 | + <?php wp_nonce_field( 'count-reviews' ); ?> |
|
53 | 53 | <p class="submit"> |
54 | 54 | <button type="submit" class="glsr-button button" name="count-reviews" id="count-reviews"> |
55 | - <span data-loading="<?= __('Recalculating Counts, please wait...', 'site-reviews'); ?>"><?= __('Recalculate Counts', 'site-reviews'); ?></span> |
|
55 | + <span data-loading="<?= __( 'Recalculating Counts, please wait...', 'site-reviews' ); ?>"><?= __( 'Recalculate Counts', 'site-reviews' ); ?></span> |
|
56 | 56 | </button> |
57 | 57 | </p> |
58 | 58 | </form> |
59 | 59 | </div> |
60 | 60 | |
61 | -<?php if (glsr()->hasPermission('settings')) : ?> |
|
61 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
62 | 62 | <div class="glsr-card card"> |
63 | 63 | <h3>Reset Permissions</h3> |
64 | 64 | <p>Site Reviews provides custom post_type capabilities that mirror the capabilities of your posts by default. For example, if a user role has permission to edit others posts, then that role will also have permission to edit other users reviews.</p> |
65 | 65 | <p>If you have changed the capabilities of your user roles and you suspect that Site Reviews is not working correctly due to your changes, you may use this tool to reset the Site Reviews capabilities for your user roles.</p> |
66 | 66 | <form method="post"> |
67 | 67 | <input type="hidden" name="{{ id }}[_action]" value="reset-permissions"> |
68 | - <?php wp_nonce_field('reset-permissions'); ?> |
|
68 | + <?php wp_nonce_field( 'reset-permissions' ); ?> |
|
69 | 69 | <p class="submit"> |
70 | 70 | <button type="submit" class="glsr-button button" name="reset-permissions" id="reset-permissions"> |
71 | - <span data-loading="<?= __('Resetting Permissions, please wait...', 'site-reviews'); ?>"><?= __('Reset Permissions', 'site-reviews'); ?></span> |
|
71 | + <span data-loading="<?= __( 'Resetting Permissions, please wait...', 'site-reviews' ); ?>"><?= __( 'Reset Permissions', 'site-reviews' ); ?></span> |
|
72 | 72 | </button> |
73 | 73 | </p> |
74 | 74 | </form> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="et_contact_bottom_container"> |
4 | 4 | <button type="submit" class="glsr-button et_pb_contact_submit et_pb_button"> |
@@ -9,149 +9,149 @@ |
||
9 | 9 | |
10 | 10 | class EnqueuePublicAssets |
11 | 11 | { |
12 | - /** |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function handle() |
|
16 | - { |
|
17 | - $this->enqueueAssets(); |
|
18 | - $this->enqueuePolyfillService(); |
|
19 | - $this->enqueueRecaptchaScript(); |
|
20 | - $this->inlineScript(); |
|
21 | - $this->inlineStyles(); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function handle() |
|
16 | + { |
|
17 | + $this->enqueueAssets(); |
|
18 | + $this->enqueuePolyfillService(); |
|
19 | + $this->enqueueRecaptchaScript(); |
|
20 | + $this->inlineScript(); |
|
21 | + $this->inlineStyles(); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function enqueueAssets() |
|
28 | - { |
|
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | - wp_enqueue_style( |
|
31 | - Application::ID, |
|
32 | - $this->getStylesheet(), |
|
33 | - [], |
|
34 | - glsr()->version |
|
35 | - ); |
|
36 | - } |
|
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | - ? [Application::ID.'/polyfill'] |
|
40 | - : []; |
|
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | - wp_enqueue_script( |
|
43 | - Application::ID, |
|
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | - $dependencies, |
|
46 | - glsr()->version, |
|
47 | - true |
|
48 | - ); |
|
49 | - } |
|
50 | - } |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function enqueueAssets() |
|
28 | + { |
|
29 | + if (apply_filters('site-reviews/assets/css', true)) { |
|
30 | + wp_enqueue_style( |
|
31 | + Application::ID, |
|
32 | + $this->getStylesheet(), |
|
33 | + [], |
|
34 | + glsr()->version |
|
35 | + ); |
|
36 | + } |
|
37 | + if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | + $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
39 | + ? [Application::ID.'/polyfill'] |
|
40 | + : []; |
|
41 | + $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
42 | + wp_enqueue_script( |
|
43 | + Application::ID, |
|
44 | + glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
45 | + $dependencies, |
|
46 | + glsr()->version, |
|
47 | + true |
|
48 | + ); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function enqueuePolyfillService() |
|
56 | - { |
|
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | - return; |
|
59 | - } |
|
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | - 'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | - 'flags' => 'gated', |
|
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function enqueuePolyfillService() |
|
56 | + { |
|
57 | + if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
58 | + return; |
|
59 | + } |
|
60 | + wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
61 | + 'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
|
62 | + 'flags' => 'gated', |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function enqueueRecaptchaScript() |
|
70 | - { |
|
71 | - // wpforms-recaptcha |
|
72 | - // google-recaptcha |
|
73 | - // nf-google-recaptcha |
|
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | - return; |
|
76 | - } |
|
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | - 'hl' => $language, |
|
80 | - 'render' => 'explicit', |
|
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | - } |
|
66 | + /** |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function enqueueRecaptchaScript() |
|
70 | + { |
|
71 | + // wpforms-recaptcha |
|
72 | + // google-recaptcha |
|
73 | + // nf-google-recaptcha |
|
74 | + if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
75 | + return; |
|
76 | + } |
|
77 | + $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | + wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
79 | + 'hl' => $language, |
|
80 | + 'render' => 'explicit', |
|
81 | + ], 'https://www.google.com/recaptcha/api.js')); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function inlineScript() |
|
88 | - { |
|
89 | - $variables = [ |
|
90 | - 'action' => Application::PREFIX.'action', |
|
91 | - 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | - 'nameprefix' => Application::ID, |
|
94 | - 'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'), |
|
95 | - 'validationconfig' => glsr(Style::class)->validation, |
|
96 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
97 | - ]; |
|
98 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
99 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
100 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function inlineScript() |
|
88 | + { |
|
89 | + $variables = [ |
|
90 | + 'action' => Application::PREFIX.'action', |
|
91 | + 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
|
92 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
93 | + 'nameprefix' => Application::ID, |
|
94 | + 'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'), |
|
95 | + 'validationconfig' => glsr(Style::class)->validation, |
|
96 | + 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
97 | + ]; |
|
98 | + $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
99 | + wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public function inlineStyles() |
|
106 | - { |
|
107 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
108 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
109 | - return; |
|
110 | - } |
|
111 | - if (!file_exists($inlineStylesheetPath)) { |
|
112 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
113 | - return; |
|
114 | - } |
|
115 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
116 | - $stylesheet = str_replace( |
|
117 | - array_keys($inlineStylesheetValues), |
|
118 | - array_values($inlineStylesheetValues), |
|
119 | - file_get_contents($inlineStylesheetPath) |
|
120 | - ); |
|
121 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
122 | - } |
|
102 | + /** |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public function inlineStyles() |
|
106 | + { |
|
107 | + $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
108 | + if (!apply_filters('site-reviews/assets/css', true)) { |
|
109 | + return; |
|
110 | + } |
|
111 | + if (!file_exists($inlineStylesheetPath)) { |
|
112 | + glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
113 | + return; |
|
114 | + } |
|
115 | + $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
116 | + $stylesheet = str_replace( |
|
117 | + array_keys($inlineStylesheetValues), |
|
118 | + array_values($inlineStylesheetValues), |
|
119 | + file_get_contents($inlineStylesheetPath) |
|
120 | + ); |
|
121 | + wp_add_inline_style(Application::ID, $stylesheet); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - protected function buildInlineScript(array $variables) |
|
128 | - { |
|
129 | - $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
130 | - foreach ($variables as $key => $value) { |
|
131 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
132 | - } |
|
133 | - $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
134 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
135 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
136 | - } |
|
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + protected function buildInlineScript(array $variables) |
|
128 | + { |
|
129 | + $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
130 | + foreach ($variables as $key => $value) { |
|
131 | + $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
132 | + } |
|
133 | + $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
134 | + $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
135 | + return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * @return array |
|
140 | - */ |
|
141 | - protected function getFixedSelectorsForPagination() |
|
142 | - { |
|
143 | - $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
144 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
145 | - } |
|
138 | + /** |
|
139 | + * @return array |
|
140 | + */ |
|
141 | + protected function getFixedSelectorsForPagination() |
|
142 | + { |
|
143 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
144 | + return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - protected function getStylesheet() |
|
151 | - { |
|
152 | - $currentStyle = glsr(Style::class)->style; |
|
153 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
154 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
155 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
156 | - } |
|
147 | + /** |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + protected function getStylesheet() |
|
151 | + { |
|
152 | + $currentStyle = glsr(Style::class)->style; |
|
153 | + return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
154 | + ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
155 | + : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
156 | + } |
|
157 | 157 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function enqueueAssets() |
28 | 28 | { |
29 | - if (apply_filters('site-reviews/assets/css', true)) { |
|
29 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
30 | 30 | wp_enqueue_style( |
31 | 31 | Application::ID, |
32 | 32 | $this->getStylesheet(), |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | glsr()->version |
35 | 35 | ); |
36 | 36 | } |
37 | - if (apply_filters('site-reviews/assets/js', true)) { |
|
38 | - $dependencies = apply_filters('site-reviews/assets/polyfill', true) |
|
37 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
38 | + $dependencies = apply_filters( 'site-reviews/assets/polyfill', true ) |
|
39 | 39 | ? [Application::ID.'/polyfill'] |
40 | 40 | : []; |
41 | - $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies); |
|
41 | + $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies ); |
|
42 | 42 | wp_enqueue_script( |
43 | 43 | Application::ID, |
44 | - glsr()->url('assets/scripts/'.Application::ID.'.js'), |
|
44 | + glsr()->url( 'assets/scripts/'.Application::ID.'.js' ), |
|
45 | 45 | $dependencies, |
46 | 46 | glsr()->version, |
47 | 47 | true |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function enqueuePolyfillService() |
56 | 56 | { |
57 | - if (!apply_filters('site-reviews/assets/polyfill', true)) { |
|
57 | + if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | - wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([ |
|
60 | + wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [ |
|
61 | 61 | 'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
62 | 62 | 'flags' => 'gated', |
63 | - ], 'https://polyfill.io/v3/polyfill.min.js')); |
|
63 | + ], 'https://polyfill.io/v3/polyfill.min.js' ) ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | // wpforms-recaptcha |
72 | 72 | // google-recaptcha |
73 | 73 | // nf-google-recaptcha |
74 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
74 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | - $language = apply_filters('site-reviews/recaptcha/language', get_locale()); |
|
78 | - wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([ |
|
77 | + $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
|
78 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
79 | 79 | 'hl' => $language, |
80 | 80 | 'render' => 'explicit', |
81 | - ], 'https://www.google.com/recaptcha/api.js')); |
|
81 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | $variables = [ |
90 | 90 | 'action' => Application::PREFIX.'action', |
91 | 91 | 'ajaxpagination' => $this->getFixedSelectorsForPagination(), |
92 | - 'ajaxurl' => admin_url('admin-ajax.php'), |
|
92 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
93 | 93 | 'nameprefix' => Application::ID, |
94 | - 'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'), |
|
95 | - 'validationconfig' => glsr(Style::class)->validation, |
|
96 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
94 | + 'urlparameter' => glsr( OptionManager::class )->getBool( 'settings.reviews.pagination.url_parameter' ), |
|
95 | + 'validationconfig' => glsr( Style::class )->validation, |
|
96 | + 'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(), |
|
97 | 97 | ]; |
98 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
99 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
98 | + $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables ); |
|
99 | + wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,35 +104,35 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function inlineStyles() |
106 | 106 | { |
107 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
108 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
107 | + $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
|
108 | + if( !apply_filters( 'site-reviews/assets/css', true ) ) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | - if (!file_exists($inlineStylesheetPath)) { |
|
112 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
111 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
112 | + glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
|
113 | 113 | return; |
114 | 114 | } |
115 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | + $inlineStylesheetValues = glsr()->config( 'inline-styles' ); |
|
116 | 116 | $stylesheet = str_replace( |
117 | - array_keys($inlineStylesheetValues), |
|
118 | - array_values($inlineStylesheetValues), |
|
119 | - file_get_contents($inlineStylesheetPath) |
|
117 | + array_keys( $inlineStylesheetValues ), |
|
118 | + array_values( $inlineStylesheetValues ), |
|
119 | + file_get_contents( $inlineStylesheetPath ) |
|
120 | 120 | ); |
121 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | + wp_add_inline_style( Application::ID, $stylesheet ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - protected function buildInlineScript(array $variables) |
|
127 | + protected function buildInlineScript( array $variables ) |
|
128 | 128 | { |
129 | 129 | $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
130 | - foreach ($variables as $key => $value) { |
|
131 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
130 | + foreach( $variables as $key => $value ) { |
|
131 | + $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); |
|
132 | 132 | } |
133 | 133 | $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
134 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
135 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
134 | + $optimizedScript = preg_replace( $pattern, '$1$2', $script ); |
|
135 | + return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | protected function getFixedSelectorsForPagination() |
142 | 142 | { |
143 | 143 | $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
144 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | + return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function getStylesheet() |
151 | 151 | { |
152 | - $currentStyle = glsr(Style::class)->style; |
|
153 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
154 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
155 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
152 | + $currentStyle = glsr( Style::class )->style; |
|
153 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
154 | + ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
|
155 | + : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
|
156 | 156 | } |
157 | 157 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'fields' => [ |
|
5 | - 'input' => 'input', |
|
6 | - 'input_checkbox' => 'input', |
|
7 | - 'input_radio' => 'input', |
|
8 | - 'label' => 'et_pb_contact_form_label', |
|
9 | - 'select' => 'et_pb_contact_select input', |
|
10 | - 'textarea' => 'et_pb_contact_message input', |
|
11 | - ], |
|
12 | - 'validation' => [ |
|
13 | - 'field_error_class' => 'et_contact_error', |
|
14 | - 'input_error_class' => 'et_contact_error', |
|
15 | - ], |
|
4 | + 'fields' => [ |
|
5 | + 'input' => 'input', |
|
6 | + 'input_checkbox' => 'input', |
|
7 | + 'input_radio' => 'input', |
|
8 | + 'label' => 'et_pb_contact_form_label', |
|
9 | + 'select' => 'et_pb_contact_select input', |
|
10 | + 'textarea' => 'et_pb_contact_message input', |
|
11 | + ], |
|
12 | + 'validation' => [ |
|
13 | + 'field_error_class' => 'et_contact_error', |
|
14 | + 'input_error_class' => 'et_contact_error', |
|
15 | + ], |
|
16 | 16 | ]; |
@@ -13,378 +13,378 @@ |
||
13 | 13 | |
14 | 14 | class System |
15 | 15 | { |
16 | - const PAD = 40; |
|
16 | + const PAD = 40; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function __toString() |
|
22 | - { |
|
23 | - return $this->get(); |
|
24 | - } |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function __toString() |
|
22 | + { |
|
23 | + return $this->get(); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function get() |
|
30 | - { |
|
31 | - $details = [ |
|
32 | - 'plugin' => 'Plugin Details', |
|
33 | - 'addon' => 'Addon Details', |
|
34 | - 'browser' => 'Browser Details', |
|
35 | - 'server' => 'Server Details', |
|
36 | - 'php' => 'PHP Configuration', |
|
37 | - 'wordpress' => 'WordPress Configuration', |
|
38 | - 'mu-plugin' => 'Must-Use Plugins', |
|
39 | - 'multisite-plugin' => 'Network Active Plugins', |
|
40 | - 'active-plugin' => 'Active Plugins', |
|
41 | - 'inactive-plugin' => 'Inactive Plugins', |
|
42 | - 'setting' => 'Plugin Settings', |
|
43 | - 'reviews' => 'Review Counts', |
|
44 | - ]; |
|
45 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
48 | - return $carry.$this->implode( |
|
49 | - strtoupper($details[$key]), |
|
50 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
51 | - ); |
|
52 | - } |
|
53 | - return $carry; |
|
54 | - }); |
|
55 | - return trim($systemInfo); |
|
56 | - } |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function get() |
|
30 | + { |
|
31 | + $details = [ |
|
32 | + 'plugin' => 'Plugin Details', |
|
33 | + 'addon' => 'Addon Details', |
|
34 | + 'browser' => 'Browser Details', |
|
35 | + 'server' => 'Server Details', |
|
36 | + 'php' => 'PHP Configuration', |
|
37 | + 'wordpress' => 'WordPress Configuration', |
|
38 | + 'mu-plugin' => 'Must-Use Plugins', |
|
39 | + 'multisite-plugin' => 'Network Active Plugins', |
|
40 | + 'active-plugin' => 'Active Plugins', |
|
41 | + 'inactive-plugin' => 'Inactive Plugins', |
|
42 | + 'setting' => 'Plugin Settings', |
|
43 | + 'reviews' => 'Review Counts', |
|
44 | + ]; |
|
45 | + $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | + $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | + if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
48 | + return $carry.$this->implode( |
|
49 | + strtoupper($details[$key]), |
|
50 | + apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
51 | + ); |
|
52 | + } |
|
53 | + return $carry; |
|
54 | + }); |
|
55 | + return trim($systemInfo); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public function getActivePluginDetails() |
|
62 | - { |
|
63 | - $plugins = get_plugins(); |
|
64 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public function getActivePluginDetails() |
|
62 | + { |
|
63 | + $plugins = get_plugins(); |
|
64 | + $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | + $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | + return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public function getAddonDetails() |
|
73 | - { |
|
74 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | - ksort($details); |
|
76 | - return $details; |
|
77 | - } |
|
69 | + /** |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public function getAddonDetails() |
|
73 | + { |
|
74 | + $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | + ksort($details); |
|
76 | + return $details; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - public function getBrowserDetails() |
|
83 | - { |
|
84 | - $browser = new Browser(); |
|
85 | - $name = esc_attr($browser->getName()); |
|
86 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | - $version = esc_attr($browser->getVersion()); |
|
88 | - return [ |
|
89 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
90 | - 'Browser UA' => $userAgent, |
|
91 | - ]; |
|
92 | - } |
|
79 | + /** |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + public function getBrowserDetails() |
|
83 | + { |
|
84 | + $browser = new Browser(); |
|
85 | + $name = esc_attr($browser->getName()); |
|
86 | + $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | + $version = esc_attr($browser->getVersion()); |
|
88 | + return [ |
|
89 | + 'Browser Name' => sprintf('%s %s', $name, $version), |
|
90 | + 'Browser UA' => $userAgent, |
|
91 | + ]; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - public function getInactivePluginDetails() |
|
98 | - { |
|
99 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
101 | - $multisitePlugins = $this->getMultisitePluginDetails(); |
|
102 | - return empty($multisitePlugins) |
|
103 | - ? $inactivePlugins |
|
104 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
105 | - } |
|
94 | + /** |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + public function getInactivePluginDetails() |
|
98 | + { |
|
99 | + $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | + $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
101 | + $multisitePlugins = $this->getMultisitePluginDetails(); |
|
102 | + return empty($multisitePlugins) |
|
103 | + ? $inactivePlugins |
|
104 | + : array_diff($inactivePlugins, $multisitePlugins); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function getMuPluginDetails() |
|
111 | - { |
|
112 | - if (empty($plugins = get_mu_plugins())) { |
|
113 | - return []; |
|
114 | - } |
|
115 | - return $this->normalizePluginList($plugins); |
|
116 | - } |
|
107 | + /** |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function getMuPluginDetails() |
|
111 | + { |
|
112 | + if (empty($plugins = get_mu_plugins())) { |
|
113 | + return []; |
|
114 | + } |
|
115 | + return $this->normalizePluginList($plugins); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @return array |
|
120 | - */ |
|
121 | - public function getMultisitePluginDetails() |
|
122 | - { |
|
123 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | - if (!is_multisite() || empty($activePlugins)) { |
|
125 | - return []; |
|
126 | - } |
|
127 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
128 | - } |
|
118 | + /** |
|
119 | + * @return array |
|
120 | + */ |
|
121 | + public function getMultisitePluginDetails() |
|
122 | + { |
|
123 | + $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | + if (!is_multisite() || empty($activePlugins)) { |
|
125 | + return []; |
|
126 | + } |
|
127 | + return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @return array |
|
132 | - */ |
|
133 | - public function getPhpDetails() |
|
134 | - { |
|
135 | - $displayErrors = $this->getINI('display_errors', null) |
|
136 | - ? 'On ('.$this->getINI('display_errors').')' |
|
137 | - : 'N/A'; |
|
138 | - $intlSupport = extension_loaded('intl') |
|
139 | - ? phpversion('intl') |
|
140 | - : 'false'; |
|
141 | - return [ |
|
142 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | - 'Default Charset' => $this->getINI('default_charset'), |
|
144 | - 'Display Errors' => $displayErrors, |
|
145 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
146 | - 'Intl' => $intlSupport, |
|
147 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | - 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | - 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | - 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | - 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | - 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | - 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | - 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | - 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | - 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | - 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | - 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
160 | - ]; |
|
161 | - } |
|
130 | + /** |
|
131 | + * @return array |
|
132 | + */ |
|
133 | + public function getPhpDetails() |
|
134 | + { |
|
135 | + $displayErrors = $this->getINI('display_errors', null) |
|
136 | + ? 'On ('.$this->getINI('display_errors').')' |
|
137 | + : 'N/A'; |
|
138 | + $intlSupport = extension_loaded('intl') |
|
139 | + ? phpversion('intl') |
|
140 | + : 'false'; |
|
141 | + return [ |
|
142 | + 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | + 'Default Charset' => $this->getINI('default_charset'), |
|
144 | + 'Display Errors' => $displayErrors, |
|
145 | + 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
146 | + 'Intl' => $intlSupport, |
|
147 | + 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | + 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | + 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | + 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | + 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | + 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | + 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | + 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | + 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | + 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | + 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | + 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | + 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
160 | + ]; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * @return array |
|
165 | - */ |
|
166 | - public function getReviewsDetails() |
|
167 | - { |
|
168 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | - $counts = Arr::flattenArray($counts); |
|
170 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | - if (is_array($ratings)) { |
|
172 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
173 | - return; |
|
174 | - } |
|
175 | - glsr_log() |
|
176 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | - ->debug($ratings) |
|
178 | - ->debug($counts); |
|
179 | - }); |
|
180 | - ksort($counts); |
|
181 | - return $counts; |
|
182 | - } |
|
163 | + /** |
|
164 | + * @return array |
|
165 | + */ |
|
166 | + public function getReviewsDetails() |
|
167 | + { |
|
168 | + $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | + $counts = Arr::flattenArray($counts); |
|
170 | + array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | + if (is_array($ratings)) { |
|
172 | + $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
173 | + return; |
|
174 | + } |
|
175 | + glsr_log() |
|
176 | + ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | + ->debug($ratings) |
|
178 | + ->debug($counts); |
|
179 | + }); |
|
180 | + ksort($counts); |
|
181 | + return $counts; |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return array |
|
186 | - */ |
|
187 | - public function getServerDetails() |
|
188 | - { |
|
189 | - global $wpdb; |
|
190 | - return [ |
|
191 | - 'Host Name' => $this->getHostName(), |
|
192 | - 'MySQL Version' => $wpdb->db_version(), |
|
193 | - 'PHP Version' => PHP_VERSION, |
|
194 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
195 | - ]; |
|
196 | - } |
|
184 | + /** |
|
185 | + * @return array |
|
186 | + */ |
|
187 | + public function getServerDetails() |
|
188 | + { |
|
189 | + global $wpdb; |
|
190 | + return [ |
|
191 | + 'Host Name' => $this->getHostName(), |
|
192 | + 'MySQL Version' => $wpdb->db_version(), |
|
193 | + 'PHP Version' => PHP_VERSION, |
|
194 | + 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
195 | + ]; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * @return array |
|
200 | - */ |
|
201 | - public function getSettingDetails() |
|
202 | - { |
|
203 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | - $settings = Arr::flattenArray($settings, true); |
|
205 | - $settings = $this->purgeSensitiveData($settings); |
|
206 | - ksort($settings); |
|
207 | - $details = []; |
|
208 | - foreach ($settings as $key => $value) { |
|
209 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
210 | - continue; |
|
211 | - } |
|
212 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
213 | - $details[$key] = $value; |
|
214 | - } |
|
215 | - return $details; |
|
216 | - } |
|
198 | + /** |
|
199 | + * @return array |
|
200 | + */ |
|
201 | + public function getSettingDetails() |
|
202 | + { |
|
203 | + $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | + $settings = Arr::flattenArray($settings, true); |
|
205 | + $settings = $this->purgeSensitiveData($settings); |
|
206 | + ksort($settings); |
|
207 | + $details = []; |
|
208 | + foreach ($settings as $key => $value) { |
|
209 | + if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
210 | + continue; |
|
211 | + } |
|
212 | + $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
213 | + $details[$key] = $value; |
|
214 | + } |
|
215 | + return $details; |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public function getPluginDetails() |
|
222 | - { |
|
223 | - return [ |
|
224 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | - 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | - 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
228 | - 'Version (current)' => glsr()->version, |
|
229 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
230 | - ]; |
|
231 | - } |
|
218 | + /** |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public function getPluginDetails() |
|
222 | + { |
|
223 | + return [ |
|
224 | + 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | + 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | + 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | + 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
228 | + 'Version (current)' => glsr()->version, |
|
229 | + 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
230 | + ]; |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * @return array |
|
235 | - */ |
|
236 | - public function getWordpressDetails() |
|
237 | - { |
|
238 | - global $wpdb; |
|
239 | - $theme = wp_get_theme(); |
|
240 | - return [ |
|
241 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
243 | - 'Home URL' => home_url(), |
|
244 | - 'Language' => get_locale(), |
|
245 | - 'Memory Limit' => WP_MEMORY_LIMIT, |
|
246 | - 'Multisite' => var_export(is_multisite(), true), |
|
247 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
253 | - 'Site URL' => site_url(), |
|
254 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | - 'Version' => get_bloginfo('version'), |
|
256 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
258 | - 'WP Memory Limit' => WP_MEMORY_LIMIT, |
|
259 | - ]; |
|
260 | - } |
|
233 | + /** |
|
234 | + * @return array |
|
235 | + */ |
|
236 | + public function getWordpressDetails() |
|
237 | + { |
|
238 | + global $wpdb; |
|
239 | + $theme = wp_get_theme(); |
|
240 | + return [ |
|
241 | + 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | + 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
243 | + 'Home URL' => home_url(), |
|
244 | + 'Language' => get_locale(), |
|
245 | + 'Memory Limit' => WP_MEMORY_LIMIT, |
|
246 | + 'Multisite' => var_export(is_multisite(), true), |
|
247 | + 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | + 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | + 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | + 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | + 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | + 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
253 | + 'Site URL' => site_url(), |
|
254 | + 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | + 'Version' => get_bloginfo('version'), |
|
256 | + 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | + 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
258 | + 'WP Memory Limit' => WP_MEMORY_LIMIT, |
|
259 | + ]; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - protected function detectWebhostProvider() |
|
266 | - { |
|
267 | - $checks = [ |
|
268 | - '.accountservergroup.com' => 'Site5', |
|
269 | - '.gridserver.com' => 'MediaTemple Grid', |
|
270 | - '.inmotionhosting.com' => 'InMotion Hosting', |
|
271 | - '.ovh.net' => 'OVH', |
|
272 | - '.pair.com' => 'pair Networks', |
|
273 | - '.stabletransit.com' => 'Rackspace Cloud', |
|
274 | - '.stratoserver.net' => 'STRATO', |
|
275 | - '.sysfix.eu' => 'SysFix.eu Power Hosting', |
|
276 | - 'bluehost.com' => 'Bluehost', |
|
277 | - 'DH_USER' => 'DreamHost', |
|
278 | - 'Flywheel' => 'Flywheel', |
|
279 | - 'ipagemysql.com' => 'iPage', |
|
280 | - 'ipowermysql.com' => 'IPower', |
|
281 | - 'localhost:/tmp/mysql5.sock' => 'ICDSoft', |
|
282 | - 'mysqlv5' => 'NetworkSolutions', |
|
283 | - 'PAGELYBIN' => 'Pagely', |
|
284 | - 'secureserver.net' => 'GoDaddy', |
|
285 | - 'WPE_APIKEY' => 'WP Engine', |
|
286 | - ]; |
|
287 | - foreach ($checks as $key => $value) { |
|
288 | - if (!$this->isWebhostCheckValid($key)) { |
|
289 | - continue; |
|
290 | - } |
|
291 | - return $value; |
|
292 | - } |
|
293 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
294 | - } |
|
262 | + /** |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + protected function detectWebhostProvider() |
|
266 | + { |
|
267 | + $checks = [ |
|
268 | + '.accountservergroup.com' => 'Site5', |
|
269 | + '.gridserver.com' => 'MediaTemple Grid', |
|
270 | + '.inmotionhosting.com' => 'InMotion Hosting', |
|
271 | + '.ovh.net' => 'OVH', |
|
272 | + '.pair.com' => 'pair Networks', |
|
273 | + '.stabletransit.com' => 'Rackspace Cloud', |
|
274 | + '.stratoserver.net' => 'STRATO', |
|
275 | + '.sysfix.eu' => 'SysFix.eu Power Hosting', |
|
276 | + 'bluehost.com' => 'Bluehost', |
|
277 | + 'DH_USER' => 'DreamHost', |
|
278 | + 'Flywheel' => 'Flywheel', |
|
279 | + 'ipagemysql.com' => 'iPage', |
|
280 | + 'ipowermysql.com' => 'IPower', |
|
281 | + 'localhost:/tmp/mysql5.sock' => 'ICDSoft', |
|
282 | + 'mysqlv5' => 'NetworkSolutions', |
|
283 | + 'PAGELYBIN' => 'Pagely', |
|
284 | + 'secureserver.net' => 'GoDaddy', |
|
285 | + 'WPE_APIKEY' => 'WP Engine', |
|
286 | + ]; |
|
287 | + foreach ($checks as $key => $value) { |
|
288 | + if (!$this->isWebhostCheckValid($key)) { |
|
289 | + continue; |
|
290 | + } |
|
291 | + return $value; |
|
292 | + } |
|
293 | + return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * @return string |
|
298 | - */ |
|
299 | - protected function getHostName() |
|
300 | - { |
|
301 | - return sprintf('%s (%s)', |
|
302 | - $this->detectWebhostProvider(), |
|
303 | - Helper::getIpAddress() |
|
304 | - ); |
|
305 | - } |
|
296 | + /** |
|
297 | + * @return string |
|
298 | + */ |
|
299 | + protected function getHostName() |
|
300 | + { |
|
301 | + return sprintf('%s (%s)', |
|
302 | + $this->detectWebhostProvider(), |
|
303 | + Helper::getIpAddress() |
|
304 | + ); |
|
305 | + } |
|
306 | 306 | |
307 | - protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
308 | - { |
|
309 | - return function_exists('ini_get') |
|
310 | - ? ini_get($name) |
|
311 | - : $disabledValue; |
|
312 | - } |
|
307 | + protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
308 | + { |
|
309 | + return function_exists('ini_get') |
|
310 | + ? ini_get($name) |
|
311 | + : $disabledValue; |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * @return array |
|
316 | - */ |
|
317 | - protected function getWordpressPlugins() |
|
318 | - { |
|
319 | - $plugins = get_plugins(); |
|
320 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
323 | - return $active + $inactive; |
|
324 | - } |
|
314 | + /** |
|
315 | + * @return array |
|
316 | + */ |
|
317 | + protected function getWordpressPlugins() |
|
318 | + { |
|
319 | + $plugins = get_plugins(); |
|
320 | + $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | + $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | + $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
323 | + return $active + $inactive; |
|
324 | + } |
|
325 | 325 | |
326 | - /** |
|
327 | - * @param string $title |
|
328 | - * @return string |
|
329 | - */ |
|
330 | - protected function implode($title, array $details) |
|
331 | - { |
|
332 | - $strings = ['['.$title.']']; |
|
333 | - $padding = max(array_map('strlen', array_keys($details))); |
|
334 | - $padding = max([$padding, static::PAD]); |
|
335 | - foreach ($details as $key => $value) { |
|
336 | - $strings[] = is_string($key) |
|
337 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
338 | - : ' - '.$value; |
|
339 | - } |
|
340 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
341 | - } |
|
326 | + /** |
|
327 | + * @param string $title |
|
328 | + * @return string |
|
329 | + */ |
|
330 | + protected function implode($title, array $details) |
|
331 | + { |
|
332 | + $strings = ['['.$title.']']; |
|
333 | + $padding = max(array_map('strlen', array_keys($details))); |
|
334 | + $padding = max([$padding, static::PAD]); |
|
335 | + foreach ($details as $key => $value) { |
|
336 | + $strings[] = is_string($key) |
|
337 | + ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
338 | + : ' - '.$value; |
|
339 | + } |
|
340 | + return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
341 | + } |
|
342 | 342 | |
343 | - /** |
|
344 | - * @param string $key |
|
345 | - * @return bool |
|
346 | - */ |
|
347 | - protected function isWebhostCheckValid($key) |
|
348 | - { |
|
349 | - return defined($key) |
|
350 | - || filter_input(INPUT_SERVER, $key) |
|
351 | - || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | - || Str::contains(DB_HOST, $key) |
|
353 | - || Str::contains(php_uname(), $key); |
|
354 | - } |
|
343 | + /** |
|
344 | + * @param string $key |
|
345 | + * @return bool |
|
346 | + */ |
|
347 | + protected function isWebhostCheckValid($key) |
|
348 | + { |
|
349 | + return defined($key) |
|
350 | + || filter_input(INPUT_SERVER, $key) |
|
351 | + || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | + || Str::contains(DB_HOST, $key) |
|
353 | + || Str::contains(php_uname(), $key); |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * @return array |
|
358 | - */ |
|
359 | - protected function normalizePluginList(array $plugins) |
|
360 | - { |
|
361 | - $plugins = array_map(function ($plugin) { |
|
362 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | - }, $plugins); |
|
364 | - natcasesort($plugins); |
|
365 | - return array_flip($plugins); |
|
366 | - } |
|
356 | + /** |
|
357 | + * @return array |
|
358 | + */ |
|
359 | + protected function normalizePluginList(array $plugins) |
|
360 | + { |
|
361 | + $plugins = array_map(function ($plugin) { |
|
362 | + return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | + }, $plugins); |
|
364 | + natcasesort($plugins); |
|
365 | + return array_flip($plugins); |
|
366 | + } |
|
367 | 367 | |
368 | - /** |
|
369 | - * @return array |
|
370 | - */ |
|
371 | - protected function purgeSensitiveData(array $settings) |
|
372 | - { |
|
373 | - $keys = [ |
|
374 | - 'general.trustalyze_serial', |
|
375 | - 'licenses.', |
|
376 | - 'submissions.recaptcha.key', |
|
377 | - 'submissions.recaptcha.secret', |
|
378 | - ]; |
|
379 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | - foreach ($keys as $key) { |
|
381 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
382 | - continue; |
|
383 | - } |
|
384 | - $value = str_repeat('•', 13); |
|
385 | - return; |
|
386 | - } |
|
387 | - }); |
|
388 | - return $settings; |
|
389 | - } |
|
368 | + /** |
|
369 | + * @return array |
|
370 | + */ |
|
371 | + protected function purgeSensitiveData(array $settings) |
|
372 | + { |
|
373 | + $keys = [ |
|
374 | + 'general.trustalyze_serial', |
|
375 | + 'licenses.', |
|
376 | + 'submissions.recaptcha.key', |
|
377 | + 'submissions.recaptcha.secret', |
|
378 | + ]; |
|
379 | + array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | + foreach ($keys as $key) { |
|
381 | + if (!Str::startsWith($key, $setting) || empty($value)) { |
|
382 | + continue; |
|
383 | + } |
|
384 | + $value = str_repeat('•', 13); |
|
385 | + return; |
|
386 | + } |
|
387 | + }); |
|
388 | + return $settings; |
|
389 | + } |
|
390 | 390 | } |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | 'setting' => 'Plugin Settings', |
43 | 43 | 'reviews' => 'Review Counts', |
44 | 44 | ]; |
45 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
46 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
47 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
45 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) { |
|
46 | + $methodName = Helper::buildMethodName( 'get-'.$key.'-details' ); |
|
47 | + if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
|
48 | 48 | return $carry.$this->implode( |
49 | - strtoupper($details[$key]), |
|
50 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
49 | + strtoupper( $details[$key] ), |
|
50 | + apply_filters( 'site-reviews/system/'.$key, $systemDetails ) |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | return $carry; |
54 | 54 | }); |
55 | - return trim($systemInfo); |
|
55 | + return trim( $systemInfo ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | public function getActivePluginDetails() |
62 | 62 | { |
63 | 63 | $plugins = get_plugins(); |
64 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
65 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
66 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
64 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
65 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
66 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getAddonDetails() |
73 | 73 | { |
74 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
75 | - ksort($details); |
|
74 | + $details = apply_filters( 'site-reviews/addon/system-info', [] ); |
|
75 | + ksort( $details ); |
|
76 | 76 | return $details; |
77 | 77 | } |
78 | 78 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | public function getBrowserDetails() |
83 | 83 | { |
84 | 84 | $browser = new Browser(); |
85 | - $name = esc_attr($browser->getName()); |
|
86 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
87 | - $version = esc_attr($browser->getVersion()); |
|
85 | + $name = esc_attr( $browser->getName() ); |
|
86 | + $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() ); |
|
87 | + $version = esc_attr( $browser->getVersion() ); |
|
88 | 88 | return [ |
89 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
89 | + 'Browser Name' => sprintf( '%s %s', $name, $version ), |
|
90 | 90 | 'Browser UA' => $userAgent, |
91 | 91 | ]; |
92 | 92 | } |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function getInactivePluginDetails() |
98 | 98 | { |
99 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
100 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
99 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
100 | + $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
101 | 101 | $multisitePlugins = $this->getMultisitePluginDetails(); |
102 | 102 | return empty($multisitePlugins) |
103 | 103 | ? $inactivePlugins |
104 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
104 | + : array_diff( $inactivePlugins, $multisitePlugins ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getMuPluginDetails() |
111 | 111 | { |
112 | - if (empty($plugins = get_mu_plugins())) { |
|
112 | + if( empty($plugins = get_mu_plugins()) ) { |
|
113 | 113 | return []; |
114 | 114 | } |
115 | - return $this->normalizePluginList($plugins); |
|
115 | + return $this->normalizePluginList( $plugins ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getMultisitePluginDetails() |
122 | 122 | { |
123 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
124 | - if (!is_multisite() || empty($activePlugins)) { |
|
123 | + $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] ); |
|
124 | + if( !is_multisite() || empty($activePlugins) ) { |
|
125 | 125 | return []; |
126 | 126 | } |
127 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
127 | + return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,31 +132,31 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getPhpDetails() |
134 | 134 | { |
135 | - $displayErrors = $this->getINI('display_errors', null) |
|
136 | - ? 'On ('.$this->getINI('display_errors').')' |
|
135 | + $displayErrors = $this->getINI( 'display_errors', null ) |
|
136 | + ? 'On ('.$this->getINI( 'display_errors' ).')' |
|
137 | 137 | : 'N/A'; |
138 | - $intlSupport = extension_loaded('intl') |
|
139 | - ? phpversion('intl') |
|
138 | + $intlSupport = extension_loaded( 'intl' ) |
|
139 | + ? phpversion( 'intl' ) |
|
140 | 140 | : 'false'; |
141 | 141 | return [ |
142 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
143 | - 'Default Charset' => $this->getINI('default_charset'), |
|
142 | + 'cURL' => var_export( function_exists( 'curl_init' ), true ), |
|
143 | + 'Default Charset' => $this->getINI( 'default_charset' ), |
|
144 | 144 | 'Display Errors' => $displayErrors, |
145 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
145 | + 'fsockopen' => var_export( function_exists( 'fsockopen' ), true ), |
|
146 | 146 | 'Intl' => $intlSupport, |
147 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
148 | - 'Max Execution Time' => $this->getINI('max_execution_time'), |
|
149 | - 'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'), |
|
150 | - 'Max Input Vars' => $this->getINI('max_input_vars'), |
|
151 | - 'Memory Limit' => $this->getINI('memory_limit'), |
|
152 | - 'Post Max Size' => $this->getINI('post_max_size'), |
|
153 | - 'Sendmail Path' => $this->getINI('sendmail_path'), |
|
154 | - 'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')), |
|
155 | - 'Session Name' => esc_html($this->getINI('session.name')), |
|
156 | - 'Session Save Path' => esc_html($this->getINI('session.save_path')), |
|
157 | - 'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true), |
|
158 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true), |
|
159 | - 'Upload Max Filesize' => $this->getINI('upload_max_filesize'), |
|
147 | + 'IPv6' => var_export( defined( 'AF_INET6' ), true ), |
|
148 | + 'Max Execution Time' => $this->getINI( 'max_execution_time' ), |
|
149 | + 'Max Input Nesting Level' => $this->getINI( 'max_input_nesting_level' ), |
|
150 | + 'Max Input Vars' => $this->getINI( 'max_input_vars' ), |
|
151 | + 'Memory Limit' => $this->getINI( 'memory_limit' ), |
|
152 | + 'Post Max Size' => $this->getINI( 'post_max_size' ), |
|
153 | + 'Sendmail Path' => $this->getINI( 'sendmail_path' ), |
|
154 | + 'Session Cookie Path' => esc_html( $this->getINI( 'session.cookie_path' ) ), |
|
155 | + 'Session Name' => esc_html( $this->getINI( 'session.name' ) ), |
|
156 | + 'Session Save Path' => esc_html( $this->getINI( 'session.save_path' ) ), |
|
157 | + 'Session Use Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_cookies', false ) ), true ), |
|
158 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_only_cookies', false ) ), true ), |
|
159 | + 'Upload Max Filesize' => $this->getINI( 'upload_max_filesize' ), |
|
160 | 160 | ]; |
161 | 161 | } |
162 | 162 | |
@@ -165,19 +165,19 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function getReviewsDetails() |
167 | 167 | { |
168 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
169 | - $counts = Arr::flattenArray($counts); |
|
170 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
171 | - if (is_array($ratings)) { |
|
172 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
168 | + $counts = glsr( CountsManager::class )->getCounts(); |
|
169 | + $counts = Arr::flattenArray( $counts ); |
|
170 | + array_walk( $counts, function( &$ratings ) use ($counts) { |
|
171 | + if( is_array( $ratings ) ) { |
|
172 | + $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')'; |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | glsr_log() |
176 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
177 | - ->debug($ratings) |
|
178 | - ->debug($counts); |
|
176 | + ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
|
177 | + ->debug( $ratings ) |
|
178 | + ->debug( $counts ); |
|
179 | 179 | }); |
180 | - ksort($counts); |
|
180 | + ksort( $counts ); |
|
181 | 181 | return $counts; |
182 | 182 | } |
183 | 183 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'Host Name' => $this->getHostName(), |
192 | 192 | 'MySQL Version' => $wpdb->db_version(), |
193 | 193 | 'PHP Version' => PHP_VERSION, |
194 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
194 | + 'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ), |
|
195 | 195 | ]; |
196 | 196 | } |
197 | 197 | |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function getSettingDetails() |
202 | 202 | { |
203 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
204 | - $settings = Arr::flattenArray($settings, true); |
|
205 | - $settings = $this->purgeSensitiveData($settings); |
|
206 | - ksort($settings); |
|
203 | + $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
|
204 | + $settings = Arr::flattenArray( $settings, true ); |
|
205 | + $settings = $this->purgeSensitiveData( $settings ); |
|
206 | + ksort( $settings ); |
|
207 | 207 | $details = []; |
208 | - foreach ($settings as $key => $value) { |
|
209 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
208 | + foreach( $settings as $key => $value ) { |
|
209 | + if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
212 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/u', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
213 | 213 | $details[$key] = $value; |
214 | 214 | } |
215 | 215 | return $details; |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | public function getPluginDetails() |
222 | 222 | { |
223 | 223 | return [ |
224 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
225 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
226 | - 'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'), |
|
227 | - 'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'), |
|
224 | + 'Console level' => glsr( Console::class )->humanLevel(), |
|
225 | + 'Console size' => glsr( Console::class )->humanSize( '0' ), |
|
226 | + 'Last Migration Run' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_migration_run' ), 'unknown' ), |
|
227 | + 'Last Rating Count' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_review_count' ), 'unknown' ), |
|
228 | 228 | 'Version (current)' => glsr()->version, |
229 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
229 | + 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
|
230 | 230 | ]; |
231 | 231 | } |
232 | 232 | |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | global $wpdb; |
239 | 239 | $theme = wp_get_theme(); |
240 | 240 | return [ |
241 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
242 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
241 | + 'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ), |
|
242 | + 'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ), |
|
243 | 243 | 'Home URL' => home_url(), |
244 | 244 | 'Language' => get_locale(), |
245 | 245 | 'Memory Limit' => WP_MEMORY_LIMIT, |
246 | - 'Multisite' => var_export(is_multisite(), true), |
|
247 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
248 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
249 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
250 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
251 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
252 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
246 | + 'Multisite' => var_export( is_multisite(), true ), |
|
247 | + 'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ), |
|
248 | + 'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ), |
|
249 | + 'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ), |
|
250 | + 'Post Stati' => implode( ', ', get_post_stati() ), |
|
251 | + 'Remote Post' => glsr( Cache::class )->getRemotePostTest(), |
|
252 | + 'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ), |
|
253 | 253 | 'Site URL' => site_url(), |
254 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'), |
|
255 | - 'Version' => get_bloginfo('version'), |
|
256 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
257 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
254 | + 'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', $this->getINI( 'date.timezone' ).' (PHP)' ), |
|
255 | + 'Version' => get_bloginfo( 'version' ), |
|
256 | + 'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ), |
|
257 | + 'WP Max Upload Size' => size_format( wp_max_upload_size() ), |
|
258 | 258 | 'WP Memory Limit' => WP_MEMORY_LIMIT, |
259 | 259 | ]; |
260 | 260 | } |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | 'secureserver.net' => 'GoDaddy', |
285 | 285 | 'WPE_APIKEY' => 'WP Engine', |
286 | 286 | ]; |
287 | - foreach ($checks as $key => $value) { |
|
288 | - if (!$this->isWebhostCheckValid($key)) { |
|
287 | + foreach( $checks as $key => $value ) { |
|
288 | + if( !$this->isWebhostCheckValid( $key ) ) { |
|
289 | 289 | continue; |
290 | 290 | } |
291 | 291 | return $value; |
292 | 292 | } |
293 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
293 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | */ |
299 | 299 | protected function getHostName() |
300 | 300 | { |
301 | - return sprintf('%s (%s)', |
|
301 | + return sprintf( '%s (%s)', |
|
302 | 302 | $this->detectWebhostProvider(), |
303 | 303 | Helper::getIpAddress() |
304 | 304 | ); |
305 | 305 | } |
306 | 306 | |
307 | - protected function getINI($name, $disabledValue = 'ini_get() is disabled.') |
|
307 | + protected function getINI( $name, $disabledValue = 'ini_get() is disabled.' ) |
|
308 | 308 | { |
309 | - return function_exists('ini_get') |
|
310 | - ? ini_get($name) |
|
309 | + return function_exists( 'ini_get' ) |
|
310 | + ? ini_get( $name ) |
|
311 | 311 | : $disabledValue; |
312 | 312 | } |
313 | 313 | |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | protected function getWordpressPlugins() |
318 | 318 | { |
319 | 319 | $plugins = get_plugins(); |
320 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
321 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
322 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
320 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
321 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
322 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
323 | 323 | return $active + $inactive; |
324 | 324 | } |
325 | 325 | |
@@ -327,48 +327,48 @@ discard block |
||
327 | 327 | * @param string $title |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - protected function implode($title, array $details) |
|
330 | + protected function implode( $title, array $details ) |
|
331 | 331 | { |
332 | 332 | $strings = ['['.$title.']']; |
333 | - $padding = max(array_map('strlen', array_keys($details))); |
|
334 | - $padding = max([$padding, static::PAD]); |
|
335 | - foreach ($details as $key => $value) { |
|
336 | - $strings[] = is_string($key) |
|
337 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
333 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
334 | + $padding = max( [$padding, static::PAD] ); |
|
335 | + foreach( $details as $key => $value ) { |
|
336 | + $strings[] = is_string( $key ) |
|
337 | + ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value ) |
|
338 | 338 | : ' - '.$value; |
339 | 339 | } |
340 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
340 | + return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
344 | 344 | * @param string $key |
345 | 345 | * @return bool |
346 | 346 | */ |
347 | - protected function isWebhostCheckValid($key) |
|
347 | + protected function isWebhostCheckValid( $key ) |
|
348 | 348 | { |
349 | - return defined($key) |
|
350 | - || filter_input(INPUT_SERVER, $key) |
|
351 | - || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
352 | - || Str::contains(DB_HOST, $key) |
|
353 | - || Str::contains(php_uname(), $key); |
|
349 | + return defined( $key ) |
|
350 | + || filter_input( INPUT_SERVER, $key ) |
|
351 | + || Str::contains( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key ) |
|
352 | + || Str::contains( DB_HOST, $key ) |
|
353 | + || Str::contains( php_uname(), $key ); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @return array |
358 | 358 | */ |
359 | - protected function normalizePluginList(array $plugins) |
|
359 | + protected function normalizePluginList( array $plugins ) |
|
360 | 360 | { |
361 | - $plugins = array_map(function ($plugin) { |
|
362 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
363 | - }, $plugins); |
|
364 | - natcasesort($plugins); |
|
365 | - return array_flip($plugins); |
|
361 | + $plugins = array_map( function( $plugin ) { |
|
362 | + return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) ); |
|
363 | + }, $plugins ); |
|
364 | + natcasesort( $plugins ); |
|
365 | + return array_flip( $plugins ); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | 369 | * @return array |
370 | 370 | */ |
371 | - protected function purgeSensitiveData(array $settings) |
|
371 | + protected function purgeSensitiveData( array $settings ) |
|
372 | 372 | { |
373 | 373 | $keys = [ |
374 | 374 | 'general.trustalyze_serial', |
@@ -376,12 +376,12 @@ discard block |
||
376 | 376 | 'submissions.recaptcha.key', |
377 | 377 | 'submissions.recaptcha.secret', |
378 | 378 | ]; |
379 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
380 | - foreach ($keys as $key) { |
|
381 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
379 | + array_walk( $settings, function( &$value, $setting ) use ($keys) { |
|
380 | + foreach( $keys as $key ) { |
|
381 | + if( !Str::startsWith( $key, $setting ) || empty($value) ) { |
|
382 | 382 | continue; |
383 | 383 | } |
384 | - $value = str_repeat('•', 13); |
|
384 | + $value = str_repeat( '•', 13 ); |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | }); |