@@ -6,97 +6,97 @@ |
||
6 | 6 | |
7 | 7 | class Translator |
8 | 8 | { |
9 | - /** |
|
10 | - * @param string $original |
|
11 | - * @param string $domain |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - public function translate($original, $domain, array $args) |
|
15 | - { |
|
16 | - $domains = apply_filters('site-reviews/translator/domains', [Application::ID]); |
|
17 | - if (!in_array($domain, $domains)) { |
|
18 | - return $original; |
|
19 | - } |
|
20 | - $args = $this->normalizeTranslationArgs($args); |
|
21 | - $strings = $this->getTranslationStrings($args['single'], $args['plural']); |
|
22 | - if (empty($strings)) { |
|
23 | - return $original; |
|
24 | - } |
|
25 | - $string = current($strings); |
|
26 | - return 'plural' == $string['type'] |
|
27 | - ? $this->translatePlural($domain, $string, $args) |
|
28 | - : $this->translateSingle($domain, $string, $args); |
|
29 | - } |
|
9 | + /** |
|
10 | + * @param string $original |
|
11 | + * @param string $domain |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + public function translate($original, $domain, array $args) |
|
15 | + { |
|
16 | + $domains = apply_filters('site-reviews/translator/domains', [Application::ID]); |
|
17 | + if (!in_array($domain, $domains)) { |
|
18 | + return $original; |
|
19 | + } |
|
20 | + $args = $this->normalizeTranslationArgs($args); |
|
21 | + $strings = $this->getTranslationStrings($args['single'], $args['plural']); |
|
22 | + if (empty($strings)) { |
|
23 | + return $original; |
|
24 | + } |
|
25 | + $string = current($strings); |
|
26 | + return 'plural' == $string['type'] |
|
27 | + ? $this->translatePlural($domain, $string, $args) |
|
28 | + : $this->translateSingle($domain, $string, $args); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Used when search/replacing a default text-domain translation |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function getTranslation(array $args) |
|
36 | - { |
|
37 | - $args = $this->normalizeTranslationArgs($args); |
|
38 | - return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Used when search/replacing a default text-domain translation |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function getTranslation(array $args) |
|
36 | + { |
|
37 | + $args = $this->normalizeTranslationArgs($args); |
|
38 | + return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $single |
|
43 | - * @param string $plural |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - protected function getTranslationStrings($single, $plural) |
|
47 | - { |
|
48 | - return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) { |
|
49 | - return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8') |
|
50 | - && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8'); |
|
51 | - }); |
|
52 | - } |
|
41 | + /** |
|
42 | + * @param string $single |
|
43 | + * @param string $plural |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + protected function getTranslationStrings($single, $plural) |
|
47 | + { |
|
48 | + return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) { |
|
49 | + return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8') |
|
50 | + && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8'); |
|
51 | + }); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - protected function normalizeTranslationArgs(array $args) |
|
58 | - { |
|
59 | - $defaults = [ |
|
60 | - 'context' => '', |
|
61 | - 'number' => 1, |
|
62 | - 'plural' => '', |
|
63 | - 'single' => '', |
|
64 | - ]; |
|
65 | - return shortcode_atts($defaults, $args); |
|
66 | - } |
|
54 | + /** |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + protected function normalizeTranslationArgs(array $args) |
|
58 | + { |
|
59 | + $defaults = [ |
|
60 | + 'context' => '', |
|
61 | + 'number' => 1, |
|
62 | + 'plural' => '', |
|
63 | + 'single' => '', |
|
64 | + ]; |
|
65 | + return shortcode_atts($defaults, $args); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $domain |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - protected function translatePlural($domain, array $string, array $args) |
|
73 | - { |
|
74 | - if (!empty($string['s2'])) { |
|
75 | - $args['single'] = $string['s2']; |
|
76 | - } |
|
77 | - if (!empty($string['p2'])) { |
|
78 | - $args['plural'] = $string['p2']; |
|
79 | - } |
|
80 | - return get_translations_for_domain($domain)->translate_plural( |
|
81 | - $args['single'], |
|
82 | - $args['plural'], |
|
83 | - $args['number'], |
|
84 | - $args['context'] |
|
85 | - ); |
|
86 | - } |
|
68 | + /** |
|
69 | + * @param string $domain |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + protected function translatePlural($domain, array $string, array $args) |
|
73 | + { |
|
74 | + if (!empty($string['s2'])) { |
|
75 | + $args['single'] = $string['s2']; |
|
76 | + } |
|
77 | + if (!empty($string['p2'])) { |
|
78 | + $args['plural'] = $string['p2']; |
|
79 | + } |
|
80 | + return get_translations_for_domain($domain)->translate_plural( |
|
81 | + $args['single'], |
|
82 | + $args['plural'], |
|
83 | + $args['number'], |
|
84 | + $args['context'] |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @param string $domain |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - protected function translateSingle($domain, array $string, array $args) |
|
93 | - { |
|
94 | - if (!empty($string['s2'])) { |
|
95 | - $args['single'] = $string['s2']; |
|
96 | - } |
|
97 | - return get_translations_for_domain($domain)->translate( |
|
98 | - $args['single'], |
|
99 | - $args['context'] |
|
100 | - ); |
|
101 | - } |
|
88 | + /** |
|
89 | + * @param string $domain |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + protected function translateSingle($domain, array $string, array $args) |
|
93 | + { |
|
94 | + if (!empty($string['s2'])) { |
|
95 | + $args['single'] = $string['s2']; |
|
96 | + } |
|
97 | + return get_translations_for_domain($domain)->translate( |
|
98 | + $args['single'], |
|
99 | + $args['context'] |
|
100 | + ); |
|
101 | + } |
|
102 | 102 | } |
@@ -11,31 +11,31 @@ discard block |
||
11 | 11 | * @param string $domain |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function translate($original, $domain, array $args) |
|
14 | + public function translate( $original, $domain, array $args ) |
|
15 | 15 | { |
16 | - $domains = apply_filters('site-reviews/translator/domains', [Application::ID]); |
|
17 | - if (!in_array($domain, $domains)) { |
|
16 | + $domains = apply_filters( 'site-reviews/translator/domains', [Application::ID] ); |
|
17 | + if( !in_array( $domain, $domains ) ) { |
|
18 | 18 | return $original; |
19 | 19 | } |
20 | - $args = $this->normalizeTranslationArgs($args); |
|
21 | - $strings = $this->getTranslationStrings($args['single'], $args['plural']); |
|
22 | - if (empty($strings)) { |
|
20 | + $args = $this->normalizeTranslationArgs( $args ); |
|
21 | + $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
|
22 | + if( empty($strings) ) { |
|
23 | 23 | return $original; |
24 | 24 | } |
25 | - $string = current($strings); |
|
25 | + $string = current( $strings ); |
|
26 | 26 | return 'plural' == $string['type'] |
27 | - ? $this->translatePlural($domain, $string, $args) |
|
28 | - : $this->translateSingle($domain, $string, $args); |
|
27 | + ? $this->translatePlural( $domain, $string, $args ) |
|
28 | + : $this->translateSingle( $domain, $string, $args ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Used when search/replacing a default text-domain translation |
33 | 33 | * @return string |
34 | 34 | */ |
35 | - public function getTranslation(array $args) |
|
35 | + public function getTranslation( array $args ) |
|
36 | 36 | { |
37 | - $args = $this->normalizeTranslationArgs($args); |
|
38 | - return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']); |
|
37 | + $args = $this->normalizeTranslationArgs( $args ); |
|
38 | + return get_translations_for_domain( Application::ID )->translate_plural( $args['single'], $args['plural'], $args['number'] ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | * @param string $plural |
44 | 44 | * @return array |
45 | 45 | */ |
46 | - protected function getTranslationStrings($single, $plural) |
|
46 | + protected function getTranslationStrings( $single, $plural ) |
|
47 | 47 | { |
48 | - return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) { |
|
49 | - return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8') |
|
50 | - && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8'); |
|
48 | + return array_filter( glsr( Translation::class )->translations(), function( $string ) use ($single, $plural) { |
|
49 | + return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
|
50 | + && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
|
51 | 51 | }); |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - protected function normalizeTranslationArgs(array $args) |
|
57 | + protected function normalizeTranslationArgs( array $args ) |
|
58 | 58 | { |
59 | 59 | $defaults = [ |
60 | 60 | 'context' => '', |
@@ -62,22 +62,22 @@ discard block |
||
62 | 62 | 'plural' => '', |
63 | 63 | 'single' => '', |
64 | 64 | ]; |
65 | - return shortcode_atts($defaults, $args); |
|
65 | + return shortcode_atts( $defaults, $args ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @param string $domain |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - protected function translatePlural($domain, array $string, array $args) |
|
72 | + protected function translatePlural( $domain, array $string, array $args ) |
|
73 | 73 | { |
74 | - if (!empty($string['s2'])) { |
|
74 | + if( !empty($string['s2']) ) { |
|
75 | 75 | $args['single'] = $string['s2']; |
76 | 76 | } |
77 | - if (!empty($string['p2'])) { |
|
77 | + if( !empty($string['p2']) ) { |
|
78 | 78 | $args['plural'] = $string['p2']; |
79 | 79 | } |
80 | - return get_translations_for_domain($domain)->translate_plural( |
|
80 | + return get_translations_for_domain( $domain )->translate_plural( |
|
81 | 81 | $args['single'], |
82 | 82 | $args['plural'], |
83 | 83 | $args['number'], |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | * @param string $domain |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - protected function translateSingle($domain, array $string, array $args) |
|
92 | + protected function translateSingle( $domain, array $string, array $args ) |
|
93 | 93 | { |
94 | - if (!empty($string['s2'])) { |
|
94 | + if( !empty($string['s2']) ) { |
|
95 | 95 | $args['single'] = $string['s2']; |
96 | 96 | } |
97 | - return get_translations_for_domain($domain)->translate( |
|
97 | + return get_translations_for_domain( $domain )->translate( |
|
98 | 98 | $args['single'], |
99 | 99 | $args['context'] |
100 | 100 | ); |
@@ -10,228 +10,228 @@ |
||
10 | 10 | |
11 | 11 | class TranslationController |
12 | 12 | { |
13 | - /** |
|
14 | - * @var Translator |
|
15 | - */ |
|
16 | - public $translator; |
|
17 | - |
|
18 | - public function __construct(Translator $translator) |
|
19 | - { |
|
20 | - $this->translator = $translator; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @param array $messages |
|
25 | - * @return array |
|
26 | - * @filter bulk_post_updated_messages |
|
27 | - */ |
|
28 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
29 | - { |
|
30 | - $messages = Arr::consolidateArray($messages); |
|
31 | - $messages[Application::POST_TYPE] = [ |
|
32 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
33 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
34 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
35 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
36 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
37 | - ]; |
|
38 | - return $messages; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $translation |
|
43 | - * @param string $text |
|
44 | - * @param string $domain |
|
45 | - * @return string |
|
46 | - * @filter gettext |
|
47 | - */ |
|
48 | - public function filterGettext($translation, $text, $domain) |
|
49 | - { |
|
50 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $translation |
|
55 | - * @param string $text |
|
56 | - * @return string |
|
57 | - * @filter site-reviews/gettext/site-reviews |
|
58 | - */ |
|
59 | - public function filterGettextSiteReviews($translation, $text) |
|
60 | - { |
|
61 | - return $this->translator->translate($translation, Application::ID, [ |
|
62 | - 'single' => $text, |
|
63 | - ]); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @param string $translation |
|
68 | - * @param string $text |
|
69 | - * @param string $context |
|
70 | - * @param string $domain |
|
71 | - * @return string |
|
72 | - * @filter gettext_with_context |
|
73 | - */ |
|
74 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
75 | - { |
|
76 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @param string $translation |
|
81 | - * @param string $text |
|
82 | - * @param string $context |
|
83 | - * @return string |
|
84 | - * @filter site-reviews/gettext_with_context/site-reviews |
|
85 | - */ |
|
86 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
87 | - { |
|
88 | - return $this->translator->translate($translation, Application::ID, [ |
|
89 | - 'context' => $context, |
|
90 | - 'single' => $text, |
|
91 | - ]); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param string $translation |
|
96 | - * @param string $single |
|
97 | - * @param string $plural |
|
98 | - * @param int $number |
|
99 | - * @param string $domain |
|
100 | - * @return string |
|
101 | - * @filter ngettext |
|
102 | - */ |
|
103 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
104 | - { |
|
105 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $translation |
|
110 | - * @param string $single |
|
111 | - * @param string $plural |
|
112 | - * @param int $number |
|
113 | - * @return string |
|
114 | - * @filter site-reviews/ngettext/site-reviews |
|
115 | - */ |
|
116 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
117 | - { |
|
118 | - return $this->translator->translate($translation, Application::ID, [ |
|
119 | - 'number' => $number, |
|
120 | - 'plural' => $plural, |
|
121 | - 'single' => $single, |
|
122 | - ]); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @param string $translation |
|
127 | - * @param string $single |
|
128 | - * @param string $plural |
|
129 | - * @param int $number |
|
130 | - * @param string $context |
|
131 | - * @param string $domain |
|
132 | - * @return string |
|
133 | - * @filter ngettext_with_context |
|
134 | - */ |
|
135 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
136 | - { |
|
137 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $translation |
|
142 | - * @param string $single |
|
143 | - * @param string $plural |
|
144 | - * @param int $number |
|
145 | - * @param string $context |
|
146 | - * @return string |
|
147 | - * @filter site-reviews/ngettext_with_context/site-reviews |
|
148 | - */ |
|
149 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
150 | - { |
|
151 | - return $this->translator->translate($translation, Application::ID, [ |
|
152 | - 'context' => $context, |
|
153 | - 'number' => $number, |
|
154 | - 'plural' => $plural, |
|
155 | - 'single' => $single, |
|
156 | - ]); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @param array $postStates |
|
161 | - * @param \WP_Post $post |
|
162 | - * @return array |
|
163 | - * @filter display_post_states |
|
164 | - */ |
|
165 | - public function filterPostStates($postStates, $post) |
|
166 | - { |
|
167 | - $postStates = Arr::consolidateArray($postStates); |
|
168 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
169 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
170 | - } |
|
171 | - return $postStates; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @param string $translation |
|
176 | - * @param string $text |
|
177 | - * @return string |
|
178 | - * @filter site-reviews/gettext/default |
|
179 | - * @filter site-reviews/gettext_with_context/default |
|
180 | - */ |
|
181 | - public function filterPostStatusLabels($translation, $text) |
|
182 | - { |
|
183 | - return $this->canModifyTranslation() |
|
184 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
185 | - : $translation; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @param string $translation |
|
190 | - * @param string $single |
|
191 | - * @param string $plural |
|
192 | - * @param int $number |
|
193 | - * @return string |
|
194 | - * @filter site-reviews/ngettext/default |
|
195 | - */ |
|
196 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
197 | - { |
|
198 | - if ($this->canModifyTranslation()) { |
|
199 | - $strings = [ |
|
200 | - 'Published' => __('Approved', 'site-reviews'), |
|
201 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
202 | - ]; |
|
203 | - foreach ($strings as $search => $replace) { |
|
204 | - if (!Str::contains($single, $search)) { |
|
205 | - continue; |
|
206 | - } |
|
207 | - return $this->translator->getTranslation([ |
|
208 | - 'number' => $number, |
|
209 | - 'plural' => str_replace($search, $replace, $plural), |
|
210 | - 'single' => str_replace($search, $replace, $single), |
|
211 | - ]); |
|
212 | - } |
|
213 | - } |
|
214 | - return $translation; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @return void |
|
219 | - * @action admin_enqueue_scripts |
|
220 | - */ |
|
221 | - public function translatePostStatusLabels() |
|
222 | - { |
|
223 | - if ($this->canModifyTranslation()) { |
|
224 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * @return bool |
|
230 | - */ |
|
231 | - protected function canModifyTranslation() |
|
232 | - { |
|
233 | - $screen = glsr_current_screen(); |
|
234 | - return Application::POST_TYPE == $screen->post_type |
|
235 | - && in_array($screen->base, ['edit', 'post']); |
|
236 | - } |
|
13 | + /** |
|
14 | + * @var Translator |
|
15 | + */ |
|
16 | + public $translator; |
|
17 | + |
|
18 | + public function __construct(Translator $translator) |
|
19 | + { |
|
20 | + $this->translator = $translator; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @param array $messages |
|
25 | + * @return array |
|
26 | + * @filter bulk_post_updated_messages |
|
27 | + */ |
|
28 | + public function filterBulkUpdateMessages($messages, array $counts) |
|
29 | + { |
|
30 | + $messages = Arr::consolidateArray($messages); |
|
31 | + $messages[Application::POST_TYPE] = [ |
|
32 | + 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
33 | + 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
34 | + 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
35 | + 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
36 | + 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
37 | + ]; |
|
38 | + return $messages; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $translation |
|
43 | + * @param string $text |
|
44 | + * @param string $domain |
|
45 | + * @return string |
|
46 | + * @filter gettext |
|
47 | + */ |
|
48 | + public function filterGettext($translation, $text, $domain) |
|
49 | + { |
|
50 | + return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $translation |
|
55 | + * @param string $text |
|
56 | + * @return string |
|
57 | + * @filter site-reviews/gettext/site-reviews |
|
58 | + */ |
|
59 | + public function filterGettextSiteReviews($translation, $text) |
|
60 | + { |
|
61 | + return $this->translator->translate($translation, Application::ID, [ |
|
62 | + 'single' => $text, |
|
63 | + ]); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @param string $translation |
|
68 | + * @param string $text |
|
69 | + * @param string $context |
|
70 | + * @param string $domain |
|
71 | + * @return string |
|
72 | + * @filter gettext_with_context |
|
73 | + */ |
|
74 | + public function filterGettextWithContext($translation, $text, $context, $domain) |
|
75 | + { |
|
76 | + return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @param string $translation |
|
81 | + * @param string $text |
|
82 | + * @param string $context |
|
83 | + * @return string |
|
84 | + * @filter site-reviews/gettext_with_context/site-reviews |
|
85 | + */ |
|
86 | + public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
87 | + { |
|
88 | + return $this->translator->translate($translation, Application::ID, [ |
|
89 | + 'context' => $context, |
|
90 | + 'single' => $text, |
|
91 | + ]); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param string $translation |
|
96 | + * @param string $single |
|
97 | + * @param string $plural |
|
98 | + * @param int $number |
|
99 | + * @param string $domain |
|
100 | + * @return string |
|
101 | + * @filter ngettext |
|
102 | + */ |
|
103 | + public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
104 | + { |
|
105 | + return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $translation |
|
110 | + * @param string $single |
|
111 | + * @param string $plural |
|
112 | + * @param int $number |
|
113 | + * @return string |
|
114 | + * @filter site-reviews/ngettext/site-reviews |
|
115 | + */ |
|
116 | + public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
117 | + { |
|
118 | + return $this->translator->translate($translation, Application::ID, [ |
|
119 | + 'number' => $number, |
|
120 | + 'plural' => $plural, |
|
121 | + 'single' => $single, |
|
122 | + ]); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @param string $translation |
|
127 | + * @param string $single |
|
128 | + * @param string $plural |
|
129 | + * @param int $number |
|
130 | + * @param string $context |
|
131 | + * @param string $domain |
|
132 | + * @return string |
|
133 | + * @filter ngettext_with_context |
|
134 | + */ |
|
135 | + public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
136 | + { |
|
137 | + return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $translation |
|
142 | + * @param string $single |
|
143 | + * @param string $plural |
|
144 | + * @param int $number |
|
145 | + * @param string $context |
|
146 | + * @return string |
|
147 | + * @filter site-reviews/ngettext_with_context/site-reviews |
|
148 | + */ |
|
149 | + public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
150 | + { |
|
151 | + return $this->translator->translate($translation, Application::ID, [ |
|
152 | + 'context' => $context, |
|
153 | + 'number' => $number, |
|
154 | + 'plural' => $plural, |
|
155 | + 'single' => $single, |
|
156 | + ]); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @param array $postStates |
|
161 | + * @param \WP_Post $post |
|
162 | + * @return array |
|
163 | + * @filter display_post_states |
|
164 | + */ |
|
165 | + public function filterPostStates($postStates, $post) |
|
166 | + { |
|
167 | + $postStates = Arr::consolidateArray($postStates); |
|
168 | + if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
169 | + $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
170 | + } |
|
171 | + return $postStates; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @param string $translation |
|
176 | + * @param string $text |
|
177 | + * @return string |
|
178 | + * @filter site-reviews/gettext/default |
|
179 | + * @filter site-reviews/gettext_with_context/default |
|
180 | + */ |
|
181 | + public function filterPostStatusLabels($translation, $text) |
|
182 | + { |
|
183 | + return $this->canModifyTranslation() |
|
184 | + ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
185 | + : $translation; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @param string $translation |
|
190 | + * @param string $single |
|
191 | + * @param string $plural |
|
192 | + * @param int $number |
|
193 | + * @return string |
|
194 | + * @filter site-reviews/ngettext/default |
|
195 | + */ |
|
196 | + public function filterPostStatusText($translation, $single, $plural, $number) |
|
197 | + { |
|
198 | + if ($this->canModifyTranslation()) { |
|
199 | + $strings = [ |
|
200 | + 'Published' => __('Approved', 'site-reviews'), |
|
201 | + 'Pending' => __('Unapproved', 'site-reviews'), |
|
202 | + ]; |
|
203 | + foreach ($strings as $search => $replace) { |
|
204 | + if (!Str::contains($single, $search)) { |
|
205 | + continue; |
|
206 | + } |
|
207 | + return $this->translator->getTranslation([ |
|
208 | + 'number' => $number, |
|
209 | + 'plural' => str_replace($search, $replace, $plural), |
|
210 | + 'single' => str_replace($search, $replace, $single), |
|
211 | + ]); |
|
212 | + } |
|
213 | + } |
|
214 | + return $translation; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @return void |
|
219 | + * @action admin_enqueue_scripts |
|
220 | + */ |
|
221 | + public function translatePostStatusLabels() |
|
222 | + { |
|
223 | + if ($this->canModifyTranslation()) { |
|
224 | + glsr(Labels::class)->translatePostStatusLabels(); |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * @return bool |
|
230 | + */ |
|
231 | + protected function canModifyTranslation() |
|
232 | + { |
|
233 | + $screen = glsr_current_screen(); |
|
234 | + return Application::POST_TYPE == $screen->post_type |
|
235 | + && in_array($screen->base, ['edit', 'post']); |
|
236 | + } |
|
237 | 237 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public $translator; |
17 | 17 | |
18 | - public function __construct(Translator $translator) |
|
18 | + public function __construct( Translator $translator ) |
|
19 | 19 | { |
20 | 20 | $this->translator = $translator; |
21 | 21 | } |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | * @return array |
26 | 26 | * @filter bulk_post_updated_messages |
27 | 27 | */ |
28 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
28 | + public function filterBulkUpdateMessages( $messages, array $counts ) |
|
29 | 29 | { |
30 | - $messages = Arr::consolidateArray($messages); |
|
30 | + $messages = Arr::consolidateArray( $messages ); |
|
31 | 31 | $messages[Application::POST_TYPE] = [ |
32 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
33 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
34 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
35 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
36 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
32 | + 'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ), |
|
33 | + 'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ), |
|
34 | + 'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ), |
|
35 | + 'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ), |
|
36 | + 'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ), |
|
37 | 37 | ]; |
38 | 38 | return $messages; |
39 | 39 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @return string |
46 | 46 | * @filter gettext |
47 | 47 | */ |
48 | - public function filterGettext($translation, $text, $domain) |
|
48 | + public function filterGettext( $translation, $text, $domain ) |
|
49 | 49 | { |
50 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
50 | + return apply_filters( 'site-reviews/gettext/'.$domain, $translation, $text ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | * @filter site-reviews/gettext/site-reviews |
58 | 58 | */ |
59 | - public function filterGettextSiteReviews($translation, $text) |
|
59 | + public function filterGettextSiteReviews( $translation, $text ) |
|
60 | 60 | { |
61 | - return $this->translator->translate($translation, Application::ID, [ |
|
61 | + return $this->translator->translate( $translation, Application::ID, [ |
|
62 | 62 | 'single' => $text, |
63 | - ]); |
|
63 | + ] ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @return string |
72 | 72 | * @filter gettext_with_context |
73 | 73 | */ |
74 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
74 | + public function filterGettextWithContext( $translation, $text, $context, $domain ) |
|
75 | 75 | { |
76 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
76 | + return apply_filters( 'site-reviews/gettext_with_context/'.$domain, $translation, $text, $context ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * @return string |
84 | 84 | * @filter site-reviews/gettext_with_context/site-reviews |
85 | 85 | */ |
86 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
86 | + public function filterGettextWithContextSiteReviews( $translation, $text, $context ) |
|
87 | 87 | { |
88 | - return $this->translator->translate($translation, Application::ID, [ |
|
88 | + return $this->translator->translate( $translation, Application::ID, [ |
|
89 | 89 | 'context' => $context, |
90 | 90 | 'single' => $text, |
91 | - ]); |
|
91 | + ] ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | * @filter ngettext |
102 | 102 | */ |
103 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
103 | + public function filterNgettext( $translation, $single, $plural, $number, $domain ) |
|
104 | 104 | { |
105 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
105 | + return apply_filters( 'site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | * @return string |
114 | 114 | * @filter site-reviews/ngettext/site-reviews |
115 | 115 | */ |
116 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
116 | + public function filterNgettextSiteReviews( $translation, $single, $plural, $number ) |
|
117 | 117 | { |
118 | - return $this->translator->translate($translation, Application::ID, [ |
|
118 | + return $this->translator->translate( $translation, Application::ID, [ |
|
119 | 119 | 'number' => $number, |
120 | 120 | 'plural' => $plural, |
121 | 121 | 'single' => $single, |
122 | - ]); |
|
122 | + ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * @return string |
133 | 133 | * @filter ngettext_with_context |
134 | 134 | */ |
135 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
135 | + public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain ) |
|
136 | 136 | { |
137 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
137 | + return apply_filters( 'site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * @return string |
147 | 147 | * @filter site-reviews/ngettext_with_context/site-reviews |
148 | 148 | */ |
149 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
149 | + public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context ) |
|
150 | 150 | { |
151 | - return $this->translator->translate($translation, Application::ID, [ |
|
151 | + return $this->translator->translate( $translation, Application::ID, [ |
|
152 | 152 | 'context' => $context, |
153 | 153 | 'number' => $number, |
154 | 154 | 'plural' => $plural, |
155 | 155 | 'single' => $single, |
156 | - ]); |
|
156 | + ] ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * @return array |
163 | 163 | * @filter display_post_states |
164 | 164 | */ |
165 | - public function filterPostStates($postStates, $post) |
|
165 | + public function filterPostStates( $postStates, $post ) |
|
166 | 166 | { |
167 | - $postStates = Arr::consolidateArray($postStates); |
|
168 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
169 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
167 | + $postStates = Arr::consolidateArray( $postStates ); |
|
168 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) { |
|
169 | + $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
|
170 | 170 | } |
171 | 171 | return $postStates; |
172 | 172 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @filter site-reviews/gettext/default |
179 | 179 | * @filter site-reviews/gettext_with_context/default |
180 | 180 | */ |
181 | - public function filterPostStatusLabels($translation, $text) |
|
181 | + public function filterPostStatusLabels( $translation, $text ) |
|
182 | 182 | { |
183 | 183 | return $this->canModifyTranslation() |
184 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
184 | + ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text ) |
|
185 | 185 | : $translation; |
186 | 186 | } |
187 | 187 | |
@@ -193,22 +193,22 @@ discard block |
||
193 | 193 | * @return string |
194 | 194 | * @filter site-reviews/ngettext/default |
195 | 195 | */ |
196 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
196 | + public function filterPostStatusText( $translation, $single, $plural, $number ) |
|
197 | 197 | { |
198 | - if ($this->canModifyTranslation()) { |
|
198 | + if( $this->canModifyTranslation() ) { |
|
199 | 199 | $strings = [ |
200 | - 'Published' => __('Approved', 'site-reviews'), |
|
201 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
200 | + 'Published' => __( 'Approved', 'site-reviews' ), |
|
201 | + 'Pending' => __( 'Unapproved', 'site-reviews' ), |
|
202 | 202 | ]; |
203 | - foreach ($strings as $search => $replace) { |
|
204 | - if (!Str::contains($single, $search)) { |
|
203 | + foreach( $strings as $search => $replace ) { |
|
204 | + if( !Str::contains( $single, $search ) ) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | - return $this->translator->getTranslation([ |
|
207 | + return $this->translator->getTranslation( [ |
|
208 | 208 | 'number' => $number, |
209 | - 'plural' => str_replace($search, $replace, $plural), |
|
210 | - 'single' => str_replace($search, $replace, $single), |
|
211 | - ]); |
|
209 | + 'plural' => str_replace( $search, $replace, $plural ), |
|
210 | + 'single' => str_replace( $search, $replace, $single ), |
|
211 | + ] ); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | return $translation; |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function translatePostStatusLabels() |
222 | 222 | { |
223 | - if ($this->canModifyTranslation()) { |
|
224 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
223 | + if( $this->canModifyTranslation() ) { |
|
224 | + glsr( Labels::class )->translatePostStatusLabels(); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | { |
233 | 233 | $screen = glsr_current_screen(); |
234 | 234 | return Application::POST_TYPE == $screen->post_type |
235 | - && in_array($screen->base, ['edit', 'post']); |
|
235 | + && in_array( $screen->base, ['edit', 'post'] ); |
|
236 | 236 | } |
237 | 237 | } |
@@ -13,81 +13,81 @@ |
||
13 | 13 | |
14 | 14 | class PublicController extends Controller |
15 | 15 | { |
16 | - /** |
|
17 | - * @return void |
|
18 | - * @action wp_enqueue_scripts |
|
19 | - */ |
|
20 | - public function enqueueAssets() |
|
21 | - { |
|
22 | - (new EnqueuePublicAssets())->handle(); |
|
23 | - } |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + * @action wp_enqueue_scripts |
|
19 | + */ |
|
20 | + public function enqueueAssets() |
|
21 | + { |
|
22 | + (new EnqueuePublicAssets())->handle(); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $tag |
|
27 | - * @param string $handle |
|
28 | - * @return string |
|
29 | - * @filter script_loader_tag |
|
30 | - */ |
|
31 | - public function filterEnqueuedScripts($tag, $handle) |
|
32 | - { |
|
33 | - $scripts = [Application::ID.'/google-recaptcha']; |
|
34 | - if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | - $tag = str_replace(' src=', ' async src=', $tag); |
|
36 | - } |
|
37 | - if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | - $tag = str_replace(' src=', ' defer src=', $tag); |
|
39 | - } |
|
40 | - return $tag; |
|
41 | - } |
|
25 | + /** |
|
26 | + * @param string $tag |
|
27 | + * @param string $handle |
|
28 | + * @return string |
|
29 | + * @filter script_loader_tag |
|
30 | + */ |
|
31 | + public function filterEnqueuedScripts($tag, $handle) |
|
32 | + { |
|
33 | + $scripts = [Application::ID.'/google-recaptcha']; |
|
34 | + if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | + $tag = str_replace(' src=', ' async src=', $tag); |
|
36 | + } |
|
37 | + if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | + $tag = str_replace(' src=', ' defer src=', $tag); |
|
39 | + } |
|
40 | + return $tag; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - * @filter site-reviews/config/forms/submission-form |
|
46 | - */ |
|
47 | - public function filterFieldOrder(array $config) |
|
48 | - { |
|
49 | - $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | - return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + * @filter site-reviews/config/forms/submission-form |
|
46 | + */ |
|
47 | + public function filterFieldOrder(array $config) |
|
48 | + { |
|
49 | + $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | + return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $view |
|
55 | - * @return string |
|
56 | - * @filter site-reviews/render/view |
|
57 | - */ |
|
58 | - public function filterRenderView($view) |
|
59 | - { |
|
60 | - return glsr(Style::class)->filterView($view); |
|
61 | - } |
|
53 | + /** |
|
54 | + * @param string $view |
|
55 | + * @return string |
|
56 | + * @filter site-reviews/render/view |
|
57 | + */ |
|
58 | + public function filterRenderView($view) |
|
59 | + { |
|
60 | + return glsr(Style::class)->filterView($view); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return void |
|
65 | - * @action site-reviews/builder |
|
66 | - */ |
|
67 | - public function modifyBuilder(Builder $instance) |
|
68 | - { |
|
69 | - call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
70 | - } |
|
63 | + /** |
|
64 | + * @return void |
|
65 | + * @action site-reviews/builder |
|
66 | + */ |
|
67 | + public function modifyBuilder(Builder $instance) |
|
68 | + { |
|
69 | + call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return void |
|
74 | - * @action wp_footer |
|
75 | - */ |
|
76 | - public function renderSchema() |
|
77 | - { |
|
78 | - glsr(Schema::class)->render(); |
|
79 | - } |
|
72 | + /** |
|
73 | + * @return void |
|
74 | + * @action wp_footer |
|
75 | + */ |
|
76 | + public function renderSchema() |
|
77 | + { |
|
78 | + glsr(Schema::class)->render(); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return CreateReview |
|
83 | - */ |
|
84 | - public function routerSubmitReview(array $request) |
|
85 | - { |
|
86 | - $validated = glsr(ValidateReview::class)->validate($request); |
|
87 | - $command = new CreateReview($validated->request); |
|
88 | - if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
89 | - $this->execute($command); |
|
90 | - } |
|
91 | - return $command; |
|
92 | - } |
|
81 | + /** |
|
82 | + * @return CreateReview |
|
83 | + */ |
|
84 | + public function routerSubmitReview(array $request) |
|
85 | + { |
|
86 | + $validated = glsr(ValidateReview::class)->validate($request); |
|
87 | + $command = new CreateReview($validated->request); |
|
88 | + if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
89 | + $this->execute($command); |
|
90 | + } |
|
91 | + return $command; |
|
92 | + } |
|
93 | 93 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | * @filter script_loader_tag |
30 | 30 | */ |
31 | - public function filterEnqueuedScripts($tag, $handle) |
|
31 | + public function filterEnqueuedScripts( $tag, $handle ) |
|
32 | 32 | { |
33 | 33 | $scripts = [Application::ID.'/google-recaptcha']; |
34 | - if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | - $tag = str_replace(' src=', ' async src=', $tag); |
|
34 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
35 | + $tag = str_replace( ' src=', ' async src=', $tag ); |
|
36 | 36 | } |
37 | - if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | - $tag = str_replace(' src=', ' defer src=', $tag); |
|
37 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
38 | + $tag = str_replace( ' src=', ' defer src=', $tag ); |
|
39 | 39 | } |
40 | 40 | return $tag; |
41 | 41 | } |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * @return array |
45 | 45 | * @filter site-reviews/config/forms/submission-form |
46 | 46 | */ |
47 | - public function filterFieldOrder(array $config) |
|
47 | + public function filterFieldOrder( array $config ) |
|
48 | 48 | { |
49 | - $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | - return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
49 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
50 | + return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | * @return string |
56 | 56 | * @filter site-reviews/render/view |
57 | 57 | */ |
58 | - public function filterRenderView($view) |
|
58 | + public function filterRenderView( $view ) |
|
59 | 59 | { |
60 | - return glsr(Style::class)->filterView($view); |
|
60 | + return glsr( Style::class )->filterView( $view ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @return void |
65 | 65 | * @action site-reviews/builder |
66 | 66 | */ |
67 | - public function modifyBuilder(Builder $instance) |
|
67 | + public function modifyBuilder( Builder $instance ) |
|
68 | 68 | { |
69 | - call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
69 | + call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function renderSchema() |
77 | 77 | { |
78 | - glsr(Schema::class)->render(); |
|
78 | + glsr( Schema::class )->render(); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @return CreateReview |
83 | 83 | */ |
84 | - public function routerSubmitReview(array $request) |
|
84 | + public function routerSubmitReview( array $request ) |
|
85 | 85 | { |
86 | - $validated = glsr(ValidateReview::class)->validate($request); |
|
87 | - $command = new CreateReview($validated->request); |
|
88 | - if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
89 | - $this->execute($command); |
|
86 | + $validated = glsr( ValidateReview::class )->validate( $request ); |
|
87 | + $command = new CreateReview( $validated->request ); |
|
88 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
89 | + $this->execute( $command ); |
|
90 | 90 | } |
91 | 91 | return $command; |
92 | 92 | } |
@@ -6,63 +6,63 @@ |
||
6 | 6 | |
7 | 7 | class Cache |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function getCloudflareIps() |
|
13 | - { |
|
14 | - if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) { |
|
15 | - $ipAddresses = array_fill_keys(['v4', 'v6'], []); |
|
16 | - foreach (array_keys($ipAddresses) as $version) { |
|
17 | - $url = 'https://www.cloudflare.com/ips-'.$version; |
|
18 | - $response = wp_remote_get($url, ['sslverify' => false]); |
|
19 | - if (is_wp_error($response)) { |
|
20 | - glsr_log()->error($response->get_error_message()); |
|
21 | - continue; |
|
22 | - } |
|
23 | - if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) { |
|
24 | - glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']'); |
|
25 | - continue; |
|
26 | - } |
|
27 | - $ipAddresses[$version] = array_filter( |
|
28 | - (array) preg_split('/\R/', wp_remote_retrieve_body($response)) |
|
29 | - ); |
|
30 | - } |
|
31 | - set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS); |
|
32 | - } |
|
33 | - return $ipAddresses; |
|
34 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function getCloudflareIps() |
|
13 | + { |
|
14 | + if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) { |
|
15 | + $ipAddresses = array_fill_keys(['v4', 'v6'], []); |
|
16 | + foreach (array_keys($ipAddresses) as $version) { |
|
17 | + $url = 'https://www.cloudflare.com/ips-'.$version; |
|
18 | + $response = wp_remote_get($url, ['sslverify' => false]); |
|
19 | + if (is_wp_error($response)) { |
|
20 | + glsr_log()->error($response->get_error_message()); |
|
21 | + continue; |
|
22 | + } |
|
23 | + if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) { |
|
24 | + glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']'); |
|
25 | + continue; |
|
26 | + } |
|
27 | + $ipAddresses[$version] = array_filter( |
|
28 | + (array) preg_split('/\R/', wp_remote_retrieve_body($response)) |
|
29 | + ); |
|
30 | + } |
|
31 | + set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS); |
|
32 | + } |
|
33 | + return $ipAddresses; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $metaKey |
|
38 | - * @return array |
|
39 | - */ |
|
40 | - public function getReviewCountsFor($metaKey) |
|
41 | - { |
|
42 | - $counts = wp_cache_get(Application::ID, $metaKey.'_count'); |
|
43 | - if (false === $counts) { |
|
44 | - $counts = []; |
|
45 | - $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey); |
|
46 | - foreach ($results as $result) { |
|
47 | - $counts[$result->name] = $result->num_posts; |
|
48 | - } |
|
49 | - wp_cache_set(Application::ID, $counts, $metaKey.'_count'); |
|
50 | - } |
|
51 | - return $counts; |
|
52 | - } |
|
36 | + /** |
|
37 | + * @param string $metaKey |
|
38 | + * @return array |
|
39 | + */ |
|
40 | + public function getReviewCountsFor($metaKey) |
|
41 | + { |
|
42 | + $counts = wp_cache_get(Application::ID, $metaKey.'_count'); |
|
43 | + if (false === $counts) { |
|
44 | + $counts = []; |
|
45 | + $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey); |
|
46 | + foreach ($results as $result) { |
|
47 | + $counts[$result->name] = $result->num_posts; |
|
48 | + } |
|
49 | + wp_cache_set(Application::ID, $counts, $metaKey.'_count'); |
|
50 | + } |
|
51 | + return $counts; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getRemotePostTest() |
|
58 | - { |
|
59 | - if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) { |
|
60 | - $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/'); |
|
61 | - $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299)) |
|
62 | - ? 'Works' |
|
63 | - : 'Does not work'; |
|
64 | - set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS); |
|
65 | - } |
|
66 | - return $test; |
|
67 | - } |
|
54 | + /** |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getRemotePostTest() |
|
58 | + { |
|
59 | + if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) { |
|
60 | + $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/'); |
|
61 | + $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299)) |
|
62 | + ? 'Works' |
|
63 | + : 'Does not work'; |
|
64 | + set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS); |
|
65 | + } |
|
66 | + return $test; |
|
67 | + } |
|
68 | 68 | } |
@@ -11,24 +11,24 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function getCloudflareIps() |
13 | 13 | { |
14 | - if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) { |
|
15 | - $ipAddresses = array_fill_keys(['v4', 'v6'], []); |
|
16 | - foreach (array_keys($ipAddresses) as $version) { |
|
14 | + if( false === ($ipAddresses = get_transient( Application::ID.'_cloudflare_ips' )) ) { |
|
15 | + $ipAddresses = array_fill_keys( ['v4', 'v6'], [] ); |
|
16 | + foreach( array_keys( $ipAddresses ) as $version ) { |
|
17 | 17 | $url = 'https://www.cloudflare.com/ips-'.$version; |
18 | - $response = wp_remote_get($url, ['sslverify' => false]); |
|
19 | - if (is_wp_error($response)) { |
|
20 | - glsr_log()->error($response->get_error_message()); |
|
18 | + $response = wp_remote_get( $url, ['sslverify' => false] ); |
|
19 | + if( is_wp_error( $response ) ) { |
|
20 | + glsr_log()->error( $response->get_error_message() ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | - if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) { |
|
24 | - glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']'); |
|
23 | + if( '200' != ($statusCode = wp_remote_retrieve_response_code( $response )) ) { |
|
24 | + glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' ); |
|
25 | 25 | continue; |
26 | 26 | } |
27 | 27 | $ipAddresses[$version] = array_filter( |
28 | - (array) preg_split('/\R/', wp_remote_retrieve_body($response)) |
|
28 | + (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) |
|
29 | 29 | ); |
30 | 30 | } |
31 | - set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS); |
|
31 | + set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS ); |
|
32 | 32 | } |
33 | 33 | return $ipAddresses; |
34 | 34 | } |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * @param string $metaKey |
38 | 38 | * @return array |
39 | 39 | */ |
40 | - public function getReviewCountsFor($metaKey) |
|
40 | + public function getReviewCountsFor( $metaKey ) |
|
41 | 41 | { |
42 | - $counts = wp_cache_get(Application::ID, $metaKey.'_count'); |
|
43 | - if (false === $counts) { |
|
42 | + $counts = wp_cache_get( Application::ID, $metaKey.'_count' ); |
|
43 | + if( false === $counts ) { |
|
44 | 44 | $counts = []; |
45 | - $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey); |
|
46 | - foreach ($results as $result) { |
|
45 | + $results = glsr( SqlQueries::class )->getReviewCountsFor( $metaKey ); |
|
46 | + foreach( $results as $result ) { |
|
47 | 47 | $counts[$result->name] = $result->num_posts; |
48 | 48 | } |
49 | - wp_cache_set(Application::ID, $counts, $metaKey.'_count'); |
|
49 | + wp_cache_set( Application::ID, $counts, $metaKey.'_count' ); |
|
50 | 50 | } |
51 | 51 | return $counts; |
52 | 52 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function getRemotePostTest() |
58 | 58 | { |
59 | - if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) { |
|
60 | - $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/'); |
|
61 | - $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299)) |
|
59 | + if( false === ($test = get_transient( Application::ID.'_remote_post_test' )) ) { |
|
60 | + $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
|
61 | + $test = !is_wp_error( $response ) && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
62 | 62 | ? 'Works' |
63 | 63 | : 'Does not work'; |
64 | - set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS); |
|
64 | + set_transient( Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS ); |
|
65 | 65 | } |
66 | 66 | return $test; |
67 | 67 | } |
@@ -6,41 +6,41 @@ |
||
6 | 6 | |
7 | 7 | class CreateReviewDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $guarded = [ |
|
13 | - 'assigned_to', |
|
14 | - 'content', |
|
15 | - 'date', |
|
16 | - 'pinned', |
|
17 | - 'response', |
|
18 | - 'review_id', |
|
19 | - 'review_type', |
|
20 | - 'title', |
|
21 | - ]; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $guarded = [ |
|
13 | + 'assigned_to', |
|
14 | + 'content', |
|
15 | + 'date', |
|
16 | + 'pinned', |
|
17 | + 'response', |
|
18 | + 'review_id', |
|
19 | + 'review_type', |
|
20 | + 'title', |
|
21 | + ]; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - protected function defaults() |
|
27 | - { |
|
28 | - return [ |
|
29 | - 'assigned_to' => '', |
|
30 | - 'author' => '', |
|
31 | - 'avatar' => '', |
|
32 | - 'content' => '', |
|
33 | - 'custom' => '', |
|
34 | - 'date' => '', |
|
35 | - 'email' => '', |
|
36 | - 'ip_address' => '', |
|
37 | - 'pinned' => false, |
|
38 | - 'rating' => '', |
|
39 | - 'response' => '', |
|
40 | - 'review_id' => md5(time().mt_rand()), |
|
41 | - 'review_type' => 'local', |
|
42 | - 'title' => '', |
|
43 | - 'url' => '', |
|
44 | - ]; |
|
45 | - } |
|
23 | + /** |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + protected function defaults() |
|
27 | + { |
|
28 | + return [ |
|
29 | + 'assigned_to' => '', |
|
30 | + 'author' => '', |
|
31 | + 'avatar' => '', |
|
32 | + 'content' => '', |
|
33 | + 'custom' => '', |
|
34 | + 'date' => '', |
|
35 | + 'email' => '', |
|
36 | + 'ip_address' => '', |
|
37 | + 'pinned' => false, |
|
38 | + 'rating' => '', |
|
39 | + 'response' => '', |
|
40 | + 'review_id' => md5(time().mt_rand()), |
|
41 | + 'review_type' => 'local', |
|
42 | + 'title' => '', |
|
43 | + 'url' => '', |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | 'pinned' => false, |
38 | 38 | 'rating' => '', |
39 | 39 | 'response' => '', |
40 | - 'review_id' => md5(time().mt_rand()), |
|
40 | + 'review_id' => md5( time().mt_rand() ), |
|
41 | 41 | 'review_type' => 'local', |
42 | 42 | 'title' => '', |
43 | 43 | 'url' => '', |
@@ -6,22 +6,22 @@ |
||
6 | 6 | |
7 | 7 | class ValidateReviewDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - protected function defaults() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'assign_to' => '', |
|
16 | - 'category' => '', |
|
17 | - 'content' => '', |
|
18 | - 'email' => '', |
|
19 | - 'form_id' => '', |
|
20 | - 'ip_address' => '', |
|
21 | - 'name' => '', |
|
22 | - 'rating' => '0', |
|
23 | - 'terms' => '', |
|
24 | - 'title' => '', |
|
25 | - ]; |
|
26 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + protected function defaults() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'assign_to' => '', |
|
16 | + 'category' => '', |
|
17 | + 'content' => '', |
|
18 | + 'email' => '', |
|
19 | + 'form_id' => '', |
|
20 | + 'ip_address' => '', |
|
21 | + 'name' => '', |
|
22 | + 'rating' => '0', |
|
23 | + 'terms' => '', |
|
24 | + 'title' => '', |
|
25 | + ]; |
|
26 | + } |
|
27 | 27 | } |
@@ -3,134 +3,134 @@ |
||
3 | 3 | defined('WPINC') || die; |
4 | 4 | |
5 | 5 | if (apply_filters('site-reviews/support/deprecated/v4', true)) { |
6 | - // Unprotected review meta has been deprecated |
|
7 | - add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | - $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | - if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
10 | - return $data; |
|
11 | - } |
|
12 | - glsr()->deprecated[] = sprintf( |
|
13 | - 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
|
14 | - $metaKey |
|
15 | - ); |
|
16 | - return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | - }, 10, 4); |
|
6 | + // Unprotected review meta has been deprecated |
|
7 | + add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | + $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | + if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
10 | + return $data; |
|
11 | + } |
|
12 | + glsr()->deprecated[] = sprintf( |
|
13 | + 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
|
14 | + $metaKey |
|
15 | + ); |
|
16 | + return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | + }, 10, 4); |
|
18 | 18 | |
19 | - // Modules/Html/Template.php |
|
20 | - add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
21 | - $search = '{{ navigation }}'; |
|
22 | - if (false !== strpos($template, $search)) { |
|
23 | - $context['navigation'] = $context['pagination']; |
|
24 | - glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
|
25 | - } |
|
26 | - return $context; |
|
27 | - }, 10, 2); |
|
19 | + // Modules/Html/Template.php |
|
20 | + add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
21 | + $search = '{{ navigation }}'; |
|
22 | + if (false !== strpos($template, $search)) { |
|
23 | + $context['navigation'] = $context['pagination']; |
|
24 | + glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
|
25 | + } |
|
26 | + return $context; |
|
27 | + }, 10, 2); |
|
28 | 28 | |
29 | - // Database/ReviewManager.php |
|
30 | - add_action('site-reviews/review/created', function ($review) { |
|
31 | - if (has_action('site-reviews/local/review/create')) { |
|
32 | - glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
|
33 | - do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
34 | - } |
|
35 | - }, 9); |
|
29 | + // Database/ReviewManager.php |
|
30 | + add_action('site-reviews/review/created', function ($review) { |
|
31 | + if (has_action('site-reviews/local/review/create')) { |
|
32 | + glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
|
33 | + do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
34 | + } |
|
35 | + }, 9); |
|
36 | 36 | |
37 | - // Handlers/CreateReview.php |
|
38 | - add_action('site-reviews/review/submitted', function ($review) { |
|
39 | - if (has_action('site-reviews/local/review/submitted')) { |
|
40 | - glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
|
41 | - do_action('site-reviews/local/review/submitted', null, $review); |
|
42 | - } |
|
43 | - if (has_filter('site-reviews/local/review/submitted/message')) { |
|
44 | - glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
|
45 | - } |
|
46 | - }, 9); |
|
37 | + // Handlers/CreateReview.php |
|
38 | + add_action('site-reviews/review/submitted', function ($review) { |
|
39 | + if (has_action('site-reviews/local/review/submitted')) { |
|
40 | + glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
|
41 | + do_action('site-reviews/local/review/submitted', null, $review); |
|
42 | + } |
|
43 | + if (has_filter('site-reviews/local/review/submitted/message')) { |
|
44 | + glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
|
45 | + } |
|
46 | + }, 9); |
|
47 | 47 | |
48 | - // Database/ReviewManager.php |
|
49 | - add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
50 | - if (has_filter('site-reviews/local/review')) { |
|
51 | - glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
|
52 | - return apply_filters('site-reviews/local/review', $values, $command); |
|
53 | - } |
|
54 | - return $values; |
|
55 | - }, 9, 2); |
|
48 | + // Database/ReviewManager.php |
|
49 | + add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
50 | + if (has_filter('site-reviews/local/review')) { |
|
51 | + glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
|
52 | + return apply_filters('site-reviews/local/review', $values, $command); |
|
53 | + } |
|
54 | + return $values; |
|
55 | + }, 9, 2); |
|
56 | 56 | |
57 | - // Handlers/EnqueuePublicAssets.php |
|
58 | - add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
59 | - if (has_filter('site-reviews/enqueue/localize')) { |
|
60 | - glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
|
61 | - return apply_filters('site-reviews/enqueue/localize', $variables); |
|
62 | - } |
|
63 | - return $variables; |
|
64 | - }, 9); |
|
57 | + // Handlers/EnqueuePublicAssets.php |
|
58 | + add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
59 | + if (has_filter('site-reviews/enqueue/localize')) { |
|
60 | + glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
|
61 | + return apply_filters('site-reviews/enqueue/localize', $variables); |
|
62 | + } |
|
63 | + return $variables; |
|
64 | + }, 9); |
|
65 | 65 | |
66 | - // Modules/Rating.php |
|
67 | - add_filter('site-reviews/rating/average', function ($average) { |
|
68 | - if (has_filter('site-reviews/average/rating')) { |
|
69 | - glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
|
70 | - } |
|
71 | - return $average; |
|
72 | - }, 9); |
|
66 | + // Modules/Rating.php |
|
67 | + add_filter('site-reviews/rating/average', function ($average) { |
|
68 | + if (has_filter('site-reviews/average/rating')) { |
|
69 | + glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
|
70 | + } |
|
71 | + return $average; |
|
72 | + }, 9); |
|
73 | 73 | |
74 | - // Modules/Rating.php |
|
75 | - add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
76 | - if (has_filter('site-reviews/bayesian/ranking')) { |
|
77 | - glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
|
78 | - } |
|
79 | - return $ranking; |
|
80 | - }, 9); |
|
74 | + // Modules/Rating.php |
|
75 | + add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
76 | + if (has_filter('site-reviews/bayesian/ranking')) { |
|
77 | + glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
|
78 | + } |
|
79 | + return $ranking; |
|
80 | + }, 9); |
|
81 | 81 | |
82 | - // Modules/Html/Partials/SiteReviews.php |
|
83 | - add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
84 | - if (has_filter('site-reviews/reviews/review/text')) { |
|
85 | - glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
86 | - } |
|
87 | - if (has_filter('site-reviews/reviews/review/title')) { |
|
88 | - glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
89 | - } |
|
90 | - return $renderedFields; |
|
91 | - }, 9); |
|
82 | + // Modules/Html/Partials/SiteReviews.php |
|
83 | + add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
84 | + if (has_filter('site-reviews/reviews/review/text')) { |
|
85 | + glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
86 | + } |
|
87 | + if (has_filter('site-reviews/reviews/review/title')) { |
|
88 | + glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
89 | + } |
|
90 | + return $renderedFields; |
|
91 | + }, 9); |
|
92 | 92 | |
93 | - // Modules/Html/Partials/SiteReviews.php |
|
94 | - add_filter('site-reviews/review/build/before', function ($review) { |
|
95 | - if (has_filter('site-reviews/rendered/review')) { |
|
96 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
|
97 | - } |
|
98 | - if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
99 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
100 | - } |
|
101 | - if (has_filter('site-reviews/rendered/review/order')) { |
|
102 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
103 | - } |
|
104 | - if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
105 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
|
106 | - } |
|
107 | - if (has_filter('site-reviews/reviews/navigation_links')) { |
|
108 | - glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
|
109 | - } |
|
110 | - return $review; |
|
111 | - }, 9); |
|
93 | + // Modules/Html/Partials/SiteReviews.php |
|
94 | + add_filter('site-reviews/review/build/before', function ($review) { |
|
95 | + if (has_filter('site-reviews/rendered/review')) { |
|
96 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
|
97 | + } |
|
98 | + if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
99 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
100 | + } |
|
101 | + if (has_filter('site-reviews/rendered/review/order')) { |
|
102 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
103 | + } |
|
104 | + if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
105 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
|
106 | + } |
|
107 | + if (has_filter('site-reviews/reviews/navigation_links')) { |
|
108 | + glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
|
109 | + } |
|
110 | + return $review; |
|
111 | + }, 9); |
|
112 | 112 | |
113 | - add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
114 | - if (has_filter('site-reviews/validate/review/submission')) { |
|
115 | - glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
116 | - return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
117 | - } |
|
118 | - return $result; |
|
119 | - }, 9, 2); |
|
113 | + add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
114 | + if (has_filter('site-reviews/validate/review/submission')) { |
|
115 | + glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
116 | + return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
117 | + } |
|
118 | + return $result; |
|
119 | + }, 9, 2); |
|
120 | 120 | |
121 | - add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
122 | - if (has_filter('site-reviews/addon/views/file')) { |
|
123 | - glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
|
124 | - $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
125 | - } |
|
126 | - return $file; |
|
127 | - }, 9, 3); |
|
121 | + add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
122 | + if (has_filter('site-reviews/addon/views/file')) { |
|
123 | + glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
|
124 | + $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
125 | + } |
|
126 | + return $file; |
|
127 | + }, 9, 3); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | add_action('wp_footer', function () { |
131 | - $notices = array_keys(array_flip(glsr()->deprecated)); |
|
132 | - natsort($notices); |
|
133 | - foreach ($notices as $notice) { |
|
134 | - glsr_log()->warning($notice); |
|
135 | - } |
|
131 | + $notices = array_keys(array_flip(glsr()->deprecated)); |
|
132 | + natsort($notices); |
|
133 | + foreach ($notices as $notice) { |
|
134 | + glsr_log()->warning($notice); |
|
135 | + } |
|
136 | 136 | }); |
@@ -1,136 +1,136 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | -if (apply_filters('site-reviews/support/deprecated/v4', true)) { |
|
5 | +if( apply_filters( 'site-reviews/support/deprecated/v4', true ) ) { |
|
6 | 6 | // Unprotected review meta has been deprecated |
7 | - add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | - $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | - if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
7 | + add_filter( 'get_post_metadata', function( $data, $postId, $metaKey, $single ) { |
|
8 | + $metaKeys = array_keys( glsr( 'Defaults\CreateReviewDefaults' )->defaults() ); |
|
9 | + if( !in_array( $metaKey, $metaKeys ) || glsr()->post_type != get_post_type( $postId ) ) { |
|
10 | 10 | return $data; |
11 | 11 | } |
12 | 12 | glsr()->deprecated[] = sprintf( |
13 | 13 | 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
14 | 14 | $metaKey |
15 | 15 | ); |
16 | - return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | - }, 10, 4); |
|
16 | + return get_post_meta( $postId, '_'.$metaKey, $single ); |
|
17 | + }, 10, 4 ); |
|
18 | 18 | |
19 | 19 | // Modules/Html/Template.php |
20 | - add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
20 | + add_filter( 'site-reviews/interpolate/reviews', function( $context, $template ) { |
|
21 | 21 | $search = '{{ navigation }}'; |
22 | - if (false !== strpos($template, $search)) { |
|
22 | + if( false !== strpos( $template, $search ) ) { |
|
23 | 23 | $context['navigation'] = $context['pagination']; |
24 | 24 | glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
25 | 25 | } |
26 | 26 | return $context; |
27 | - }, 10, 2); |
|
27 | + }, 10, 2 ); |
|
28 | 28 | |
29 | 29 | // Database/ReviewManager.php |
30 | - add_action('site-reviews/review/created', function ($review) { |
|
31 | - if (has_action('site-reviews/local/review/create')) { |
|
30 | + add_action( 'site-reviews/review/created', function( $review ) { |
|
31 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
32 | 32 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
33 | - do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
33 | + do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
|
34 | 34 | } |
35 | - }, 9); |
|
35 | + }, 9 ); |
|
36 | 36 | |
37 | 37 | // Handlers/CreateReview.php |
38 | - add_action('site-reviews/review/submitted', function ($review) { |
|
39 | - if (has_action('site-reviews/local/review/submitted')) { |
|
38 | + add_action( 'site-reviews/review/submitted', function( $review ) { |
|
39 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
40 | 40 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
41 | - do_action('site-reviews/local/review/submitted', null, $review); |
|
41 | + do_action( 'site-reviews/local/review/submitted', null, $review ); |
|
42 | 42 | } |
43 | - if (has_filter('site-reviews/local/review/submitted/message')) { |
|
43 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
44 | 44 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
45 | 45 | } |
46 | - }, 9); |
|
46 | + }, 9 ); |
|
47 | 47 | |
48 | 48 | // Database/ReviewManager.php |
49 | - add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
50 | - if (has_filter('site-reviews/local/review')) { |
|
49 | + add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
|
50 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
51 | 51 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
52 | - return apply_filters('site-reviews/local/review', $values, $command); |
|
52 | + return apply_filters( 'site-reviews/local/review', $values, $command ); |
|
53 | 53 | } |
54 | 54 | return $values; |
55 | - }, 9, 2); |
|
55 | + }, 9, 2 ); |
|
56 | 56 | |
57 | 57 | // Handlers/EnqueuePublicAssets.php |
58 | - add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
59 | - if (has_filter('site-reviews/enqueue/localize')) { |
|
58 | + add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
|
59 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
60 | 60 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
61 | - return apply_filters('site-reviews/enqueue/localize', $variables); |
|
61 | + return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
|
62 | 62 | } |
63 | 63 | return $variables; |
64 | - }, 9); |
|
64 | + }, 9 ); |
|
65 | 65 | |
66 | 66 | // Modules/Rating.php |
67 | - add_filter('site-reviews/rating/average', function ($average) { |
|
68 | - if (has_filter('site-reviews/average/rating')) { |
|
67 | + add_filter( 'site-reviews/rating/average', function( $average ) { |
|
68 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
69 | 69 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
70 | 70 | } |
71 | 71 | return $average; |
72 | - }, 9); |
|
72 | + }, 9 ); |
|
73 | 73 | |
74 | 74 | // Modules/Rating.php |
75 | - add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
76 | - if (has_filter('site-reviews/bayesian/ranking')) { |
|
75 | + add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
|
76 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
77 | 77 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
78 | 78 | } |
79 | 79 | return $ranking; |
80 | - }, 9); |
|
80 | + }, 9 ); |
|
81 | 81 | |
82 | 82 | // Modules/Html/Partials/SiteReviews.php |
83 | - add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
84 | - if (has_filter('site-reviews/reviews/review/text')) { |
|
83 | + add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
|
84 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
85 | 85 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
86 | 86 | } |
87 | - if (has_filter('site-reviews/reviews/review/title')) { |
|
87 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
88 | 88 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
89 | 89 | } |
90 | 90 | return $renderedFields; |
91 | - }, 9); |
|
91 | + }, 9 ); |
|
92 | 92 | |
93 | 93 | // Modules/Html/Partials/SiteReviews.php |
94 | - add_filter('site-reviews/review/build/before', function ($review) { |
|
95 | - if (has_filter('site-reviews/rendered/review')) { |
|
94 | + add_filter( 'site-reviews/review/build/before', function( $review ) { |
|
95 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
96 | 96 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
97 | 97 | } |
98 | - if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
98 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
99 | 99 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
100 | 100 | } |
101 | - if (has_filter('site-reviews/rendered/review/order')) { |
|
101 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
102 | 102 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
103 | 103 | } |
104 | - if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
104 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
105 | 105 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
106 | 106 | } |
107 | - if (has_filter('site-reviews/reviews/navigation_links')) { |
|
107 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
108 | 108 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
109 | 109 | } |
110 | 110 | return $review; |
111 | - }, 9); |
|
111 | + }, 9 ); |
|
112 | 112 | |
113 | - add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
114 | - if (has_filter('site-reviews/validate/review/submission')) { |
|
115 | - glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
116 | - return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
113 | + add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
|
114 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
115 | + glsr_log()->warning( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
|
116 | + return apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
|
117 | 117 | } |
118 | 118 | return $result; |
119 | - }, 9, 2); |
|
119 | + }, 9, 2 ); |
|
120 | 120 | |
121 | - add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
122 | - if (has_filter('site-reviews/addon/views/file')) { |
|
121 | + add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
|
122 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
123 | 123 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
124 | - $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
124 | + $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
|
125 | 125 | } |
126 | 126 | return $file; |
127 | - }, 9, 3); |
|
127 | + }, 9, 3 ); |
|
128 | 128 | } |
129 | 129 | |
130 | -add_action('wp_footer', function () { |
|
131 | - $notices = array_keys(array_flip(glsr()->deprecated)); |
|
132 | - natsort($notices); |
|
133 | - foreach ($notices as $notice) { |
|
134 | - glsr_log()->warning($notice); |
|
130 | +add_action( 'wp_footer', function() { |
|
131 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
132 | + natsort( $notices ); |
|
133 | + foreach( $notices as $notice ) { |
|
134 | + glsr_log()->warning( $notice ); |
|
135 | 135 | } |
136 | 136 | }); |
@@ -9,148 +9,148 @@ |
||
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 | - 'validationconfig' => glsr(Style::class)->validation, |
|
95 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
96 | - ]; |
|
97 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
99 | - } |
|
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 | + 'validationconfig' => glsr(Style::class)->validation, |
|
95 | + 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
96 | + ]; |
|
97 | + $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | + wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public function inlineStyles() |
|
105 | - { |
|
106 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
108 | - return; |
|
109 | - } |
|
110 | - if (!file_exists($inlineStylesheetPath)) { |
|
111 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
112 | - return; |
|
113 | - } |
|
114 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | - $stylesheet = str_replace( |
|
116 | - array_keys($inlineStylesheetValues), |
|
117 | - array_values($inlineStylesheetValues), |
|
118 | - file_get_contents($inlineStylesheetPath) |
|
119 | - ); |
|
120 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | - } |
|
101 | + /** |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public function inlineStyles() |
|
105 | + { |
|
106 | + $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | + if (!apply_filters('site-reviews/assets/css', true)) { |
|
108 | + return; |
|
109 | + } |
|
110 | + if (!file_exists($inlineStylesheetPath)) { |
|
111 | + glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
112 | + return; |
|
113 | + } |
|
114 | + $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
115 | + $stylesheet = str_replace( |
|
116 | + array_keys($inlineStylesheetValues), |
|
117 | + array_values($inlineStylesheetValues), |
|
118 | + file_get_contents($inlineStylesheetPath) |
|
119 | + ); |
|
120 | + wp_add_inline_style(Application::ID, $stylesheet); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - protected function buildInlineScript(array $variables) |
|
127 | - { |
|
128 | - $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
129 | - foreach ($variables as $key => $value) { |
|
130 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
131 | - } |
|
132 | - $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
133 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
135 | - } |
|
123 | + /** |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + protected function buildInlineScript(array $variables) |
|
127 | + { |
|
128 | + $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
|
129 | + foreach ($variables as $key => $value) { |
|
130 | + $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
131 | + } |
|
132 | + $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
|
133 | + $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | + return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - protected function getFixedSelectorsForPagination() |
|
141 | - { |
|
142 | - $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
143 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | - } |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + protected function getFixedSelectorsForPagination() |
|
141 | + { |
|
142 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
143 | + return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - protected function getStylesheet() |
|
150 | - { |
|
151 | - $currentStyle = glsr(Style::class)->style; |
|
152 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
155 | - } |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + protected function getStylesheet() |
|
150 | + { |
|
151 | + $currentStyle = glsr(Style::class)->style; |
|
152 | + return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | + ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | + : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
155 | + } |
|
156 | 156 | } |
@@ -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,13 +89,13 @@ 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 | - 'validationconfig' => glsr(Style::class)->validation, |
|
95 | - 'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(), |
|
94 | + 'validationconfig' => glsr( Style::class )->validation, |
|
95 | + 'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(), |
|
96 | 96 | ]; |
97 | - $variables = apply_filters('site-reviews/enqueue/public/localize', $variables); |
|
98 | - wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before'); |
|
97 | + $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables ); |
|
98 | + wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function inlineStyles() |
105 | 105 | { |
106 | - $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css'); |
|
107 | - if (!apply_filters('site-reviews/assets/css', true)) { |
|
106 | + $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
|
107 | + if( !apply_filters( 'site-reviews/assets/css', true ) ) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | - if (!file_exists($inlineStylesheetPath)) { |
|
111 | - glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath); |
|
110 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
111 | + glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
|
112 | 112 | return; |
113 | 113 | } |
114 | - $inlineStylesheetValues = glsr()->config('inline-styles'); |
|
114 | + $inlineStylesheetValues = glsr()->config( 'inline-styles' ); |
|
115 | 115 | $stylesheet = str_replace( |
116 | - array_keys($inlineStylesheetValues), |
|
117 | - array_values($inlineStylesheetValues), |
|
118 | - file_get_contents($inlineStylesheetPath) |
|
116 | + array_keys( $inlineStylesheetValues ), |
|
117 | + array_values( $inlineStylesheetValues ), |
|
118 | + file_get_contents( $inlineStylesheetPath ) |
|
119 | 119 | ); |
120 | - wp_add_inline_style(Application::ID, $stylesheet); |
|
120 | + wp_add_inline_style( Application::ID, $stylesheet ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - protected function buildInlineScript(array $variables) |
|
126 | + protected function buildInlineScript( array $variables ) |
|
127 | 127 | { |
128 | 128 | $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
129 | - foreach ($variables as $key => $value) { |
|
130 | - $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); |
|
129 | + foreach( $variables as $key => $value ) { |
|
130 | + $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); |
|
131 | 131 | } |
132 | 132 | $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
133 | - $optimizedScript = preg_replace($pattern, '$1$2', $script); |
|
134 | - return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables); |
|
133 | + $optimizedScript = preg_replace( $pattern, '$1$2', $script ); |
|
134 | + return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function getFixedSelectorsForPagination() |
141 | 141 | { |
142 | 142 | $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
143 | - return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors); |
|
143 | + return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function getStylesheet() |
150 | 150 | { |
151 | - $currentStyle = glsr(Style::class)->style; |
|
152 | - return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css')) |
|
153 | - ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css') |
|
154 | - : glsr()->url('assets/styles/'.Application::ID.'.css'); |
|
151 | + $currentStyle = glsr( Style::class )->style; |
|
152 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
153 | + ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
|
154 | + : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
|
155 | 155 | } |
156 | 156 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | |
7 | 7 | class StyleValidationDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - protected function defaults() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'error_tag' => 'div', |
|
16 | - 'error_tag_class' => 'glsr-field-error', |
|
17 | - 'field_class' => 'glsr-field', |
|
18 | - 'field_error_class' => 'glsr-has-error', |
|
19 | - 'input_error_class' => 'glsr-is-invalid', |
|
20 | - 'input_valid_class' => 'glsr-is-valid', |
|
21 | - 'message_error_class' => 'glsr-has-errors', |
|
22 | - 'message_initial_class' => 'glsr-is-visible', |
|
23 | - 'message_success_class' => 'glsr-has-success', |
|
24 | - 'message_tag' => 'div', |
|
25 | - 'message_tag_class' => 'glsr-form-message', |
|
26 | - ]; |
|
27 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + protected function defaults() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'error_tag' => 'div', |
|
16 | + 'error_tag_class' => 'glsr-field-error', |
|
17 | + 'field_class' => 'glsr-field', |
|
18 | + 'field_error_class' => 'glsr-has-error', |
|
19 | + 'input_error_class' => 'glsr-is-invalid', |
|
20 | + 'input_valid_class' => 'glsr-is-valid', |
|
21 | + 'message_error_class' => 'glsr-has-errors', |
|
22 | + 'message_initial_class' => 'glsr-is-visible', |
|
23 | + 'message_success_class' => 'glsr-has-success', |
|
24 | + 'message_tag' => 'div', |
|
25 | + 'message_tag_class' => 'glsr-form-message', |
|
26 | + ]; |
|
27 | + } |
|
28 | 28 | } |