@@ -9,239 +9,239 @@ |
||
9 | 9 | |
10 | 10 | class Settings |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - public $settings; |
|
16 | - |
|
17 | - /** |
|
18 | - * @param string $id |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function buildFields($id) |
|
22 | - { |
|
23 | - $this->settings = glsr(DefaultsManager::class)->settings(); |
|
24 | - $method = glsr(Helper::class)->buildMethodName($id, 'getTemplateDataFor'); |
|
25 | - $data = !method_exists($this, $method) |
|
26 | - ? $this->getTemplateData($id) |
|
27 | - : $this->$method($id); |
|
28 | - return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - protected function getFieldDefault(array $field) |
|
35 | - { |
|
36 | - return glsr_get($field, 'default'); |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - protected function getFieldNameForDependsOn($path) |
|
43 | - { |
|
44 | - $fieldName = glsr(Helper::class)->convertPathToName($path, OptionManager::databaseKey()); |
|
45 | - return $this->isMultiDependency($path) |
|
46 | - ? $fieldName.'[]' |
|
47 | - : $fieldName; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - protected function getSettingFields($path) |
|
54 | - { |
|
55 | - return array_filter($this->settings, function ($key) use ($path) { |
|
56 | - return glsr(Helper::class)->startsWith($path, $key); |
|
57 | - }, ARRAY_FILTER_USE_KEY); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - protected function getSettingRows(array $fields) |
|
64 | - { |
|
65 | - $rows = ''; |
|
66 | - foreach ($fields as $name => $field) { |
|
67 | - $field = wp_parse_args($field, [ |
|
68 | - 'is_setting' => true, |
|
69 | - 'name' => $name, |
|
70 | - ]); |
|
71 | - $rows.= new Field($this->normalize($field)); |
|
72 | - } |
|
73 | - return $rows; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @param string $id |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - protected function getTemplateData($id) |
|
81 | - { |
|
82 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
83 | - return [ |
|
84 | - 'context' => [ |
|
85 | - 'rows' => $this->getSettingRows($fields), |
|
86 | - ], |
|
87 | - ]; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @param string $id |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - protected function getTemplateDataForAddons($id) |
|
95 | - { |
|
96 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
97 | - $settings = glsr(Helper::class)->convertDotNotationArray($fields); |
|
98 | - $settingKeys = array_keys($settings['settings']['addons']); |
|
99 | - $results = []; |
|
100 | - foreach ($settingKeys as $key) { |
|
101 | - $addonFields = array_filter($fields, function ($path) use ($key) { |
|
102 | - return glsr(Helper::class)->startsWith('settings.addons.'.$key, $path); |
|
103 | - }, ARRAY_FILTER_USE_KEY); |
|
104 | - $results[$key] = $this->getSettingRows($addonFields); |
|
105 | - } |
|
106 | - ksort($results); |
|
107 | - return [ |
|
108 | - 'settings' => $results, |
|
109 | - ]; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @param string $id |
|
114 | - * @return array |
|
115 | - */ |
|
116 | - protected function getTemplateDataForLicenses($id) |
|
117 | - { |
|
118 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
119 | - ksort($fields); |
|
120 | - return [ |
|
121 | - 'context' => [ |
|
122 | - 'rows' => $this->getSettingRows($fields), |
|
123 | - ], |
|
124 | - ]; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - protected function getTemplateDataForTranslations() |
|
131 | - { |
|
132 | - $translations = glsr(Translation::class)->renderAll(); |
|
133 | - $class = empty($translations) |
|
134 | - ? 'glsr-hidden' |
|
135 | - : ''; |
|
136 | - return [ |
|
137 | - 'context' => [ |
|
138 | - 'class' => $class, |
|
139 | - 'database_key' => OptionManager::databaseKey(), |
|
140 | - 'translations' => $translations, |
|
141 | - ], |
|
142 | - ]; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * @param string $path |
|
147 | - * @param string|array $expectedValue |
|
148 | - * @return bool |
|
149 | - */ |
|
150 | - protected function isFieldHidden($path, $expectedValue) |
|
151 | - { |
|
152 | - $optionValue = glsr(OptionManager::class)->get( |
|
153 | - $path, |
|
154 | - glsr(Helper::class)->dataGet(glsr()->defaults, $path) |
|
155 | - ); |
|
156 | - if (is_array($expectedValue)) { |
|
157 | - return is_array($optionValue) |
|
158 | - ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
159 | - : !in_array($optionValue, $expectedValue); |
|
160 | - } |
|
161 | - return $optionValue != $expectedValue; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - protected function isMultiDependency($path) |
|
168 | - { |
|
169 | - if (isset($this->settings[$path])) { |
|
170 | - $field = $this->settings[$path]; |
|
171 | - return ('checkbox' == $field['type'] && !empty($field['options'])) |
|
172 | - || !empty($field['multiple']); |
|
173 | - } |
|
174 | - return false; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @return array |
|
179 | - */ |
|
180 | - protected function normalize(array $field) |
|
181 | - { |
|
182 | - $field = $this->normalizeDependsOn($field); |
|
183 | - $field = $this->normalizeLabelAndLegend($field); |
|
184 | - $field = $this->normalizeValue($field); |
|
185 | - return $field; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @return array |
|
190 | - */ |
|
191 | - protected function normalizeDependsOn(array $field) |
|
192 | - { |
|
193 | - if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
194 | - $isFieldHidden = false; |
|
195 | - $conditions = []; |
|
196 | - foreach ($field['depends_on'] as $path => $value) { |
|
197 | - $conditions[] = [ |
|
198 | - 'name' => $this->getFieldNameForDependsOn($path), |
|
199 | - 'value' => $value, |
|
200 | - ]; |
|
201 | - if ($this->isFieldHidden($path, $value)) { |
|
202 | - $isFieldHidden = true; |
|
203 | - } |
|
204 | - } |
|
205 | - $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
206 | - $field['is_hidden'] = $isFieldHidden; |
|
207 | - } |
|
208 | - return $field; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - protected function normalizeLabelAndLegend(array $field) |
|
215 | - { |
|
216 | - if (!empty($field['label'])) { |
|
217 | - $field['legend'] = $field['label']; |
|
218 | - unset($field['label']); |
|
219 | - } else { |
|
220 | - $field['is_valid'] = false; |
|
221 | - glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
222 | - } |
|
223 | - return $field; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return array |
|
228 | - */ |
|
229 | - protected function normalizeValue(array $field) |
|
230 | - { |
|
231 | - if (!isset($field['value'])) { |
|
232 | - $field['value'] = glsr(OptionManager::class)->get( |
|
233 | - $field['name'], |
|
234 | - $this->getFieldDefault($field) |
|
235 | - ); |
|
236 | - } |
|
237 | - return $field; |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * @return string |
|
242 | - */ |
|
243 | - protected function normalizeSettingPath($path) |
|
244 | - { |
|
245 | - return glsr(Helper::class)->prefix('settings.', rtrim($path, '.')); |
|
246 | - } |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + public $settings; |
|
16 | + |
|
17 | + /** |
|
18 | + * @param string $id |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function buildFields($id) |
|
22 | + { |
|
23 | + $this->settings = glsr(DefaultsManager::class)->settings(); |
|
24 | + $method = glsr(Helper::class)->buildMethodName($id, 'getTemplateDataFor'); |
|
25 | + $data = !method_exists($this, $method) |
|
26 | + ? $this->getTemplateData($id) |
|
27 | + : $this->$method($id); |
|
28 | + return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + protected function getFieldDefault(array $field) |
|
35 | + { |
|
36 | + return glsr_get($field, 'default'); |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + protected function getFieldNameForDependsOn($path) |
|
43 | + { |
|
44 | + $fieldName = glsr(Helper::class)->convertPathToName($path, OptionManager::databaseKey()); |
|
45 | + return $this->isMultiDependency($path) |
|
46 | + ? $fieldName.'[]' |
|
47 | + : $fieldName; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + protected function getSettingFields($path) |
|
54 | + { |
|
55 | + return array_filter($this->settings, function ($key) use ($path) { |
|
56 | + return glsr(Helper::class)->startsWith($path, $key); |
|
57 | + }, ARRAY_FILTER_USE_KEY); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + protected function getSettingRows(array $fields) |
|
64 | + { |
|
65 | + $rows = ''; |
|
66 | + foreach ($fields as $name => $field) { |
|
67 | + $field = wp_parse_args($field, [ |
|
68 | + 'is_setting' => true, |
|
69 | + 'name' => $name, |
|
70 | + ]); |
|
71 | + $rows.= new Field($this->normalize($field)); |
|
72 | + } |
|
73 | + return $rows; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @param string $id |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + protected function getTemplateData($id) |
|
81 | + { |
|
82 | + $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
83 | + return [ |
|
84 | + 'context' => [ |
|
85 | + 'rows' => $this->getSettingRows($fields), |
|
86 | + ], |
|
87 | + ]; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @param string $id |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + protected function getTemplateDataForAddons($id) |
|
95 | + { |
|
96 | + $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
97 | + $settings = glsr(Helper::class)->convertDotNotationArray($fields); |
|
98 | + $settingKeys = array_keys($settings['settings']['addons']); |
|
99 | + $results = []; |
|
100 | + foreach ($settingKeys as $key) { |
|
101 | + $addonFields = array_filter($fields, function ($path) use ($key) { |
|
102 | + return glsr(Helper::class)->startsWith('settings.addons.'.$key, $path); |
|
103 | + }, ARRAY_FILTER_USE_KEY); |
|
104 | + $results[$key] = $this->getSettingRows($addonFields); |
|
105 | + } |
|
106 | + ksort($results); |
|
107 | + return [ |
|
108 | + 'settings' => $results, |
|
109 | + ]; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @param string $id |
|
114 | + * @return array |
|
115 | + */ |
|
116 | + protected function getTemplateDataForLicenses($id) |
|
117 | + { |
|
118 | + $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
119 | + ksort($fields); |
|
120 | + return [ |
|
121 | + 'context' => [ |
|
122 | + 'rows' => $this->getSettingRows($fields), |
|
123 | + ], |
|
124 | + ]; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + protected function getTemplateDataForTranslations() |
|
131 | + { |
|
132 | + $translations = glsr(Translation::class)->renderAll(); |
|
133 | + $class = empty($translations) |
|
134 | + ? 'glsr-hidden' |
|
135 | + : ''; |
|
136 | + return [ |
|
137 | + 'context' => [ |
|
138 | + 'class' => $class, |
|
139 | + 'database_key' => OptionManager::databaseKey(), |
|
140 | + 'translations' => $translations, |
|
141 | + ], |
|
142 | + ]; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * @param string $path |
|
147 | + * @param string|array $expectedValue |
|
148 | + * @return bool |
|
149 | + */ |
|
150 | + protected function isFieldHidden($path, $expectedValue) |
|
151 | + { |
|
152 | + $optionValue = glsr(OptionManager::class)->get( |
|
153 | + $path, |
|
154 | + glsr(Helper::class)->dataGet(glsr()->defaults, $path) |
|
155 | + ); |
|
156 | + if (is_array($expectedValue)) { |
|
157 | + return is_array($optionValue) |
|
158 | + ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
159 | + : !in_array($optionValue, $expectedValue); |
|
160 | + } |
|
161 | + return $optionValue != $expectedValue; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + protected function isMultiDependency($path) |
|
168 | + { |
|
169 | + if (isset($this->settings[$path])) { |
|
170 | + $field = $this->settings[$path]; |
|
171 | + return ('checkbox' == $field['type'] && !empty($field['options'])) |
|
172 | + || !empty($field['multiple']); |
|
173 | + } |
|
174 | + return false; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @return array |
|
179 | + */ |
|
180 | + protected function normalize(array $field) |
|
181 | + { |
|
182 | + $field = $this->normalizeDependsOn($field); |
|
183 | + $field = $this->normalizeLabelAndLegend($field); |
|
184 | + $field = $this->normalizeValue($field); |
|
185 | + return $field; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @return array |
|
190 | + */ |
|
191 | + protected function normalizeDependsOn(array $field) |
|
192 | + { |
|
193 | + if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
194 | + $isFieldHidden = false; |
|
195 | + $conditions = []; |
|
196 | + foreach ($field['depends_on'] as $path => $value) { |
|
197 | + $conditions[] = [ |
|
198 | + 'name' => $this->getFieldNameForDependsOn($path), |
|
199 | + 'value' => $value, |
|
200 | + ]; |
|
201 | + if ($this->isFieldHidden($path, $value)) { |
|
202 | + $isFieldHidden = true; |
|
203 | + } |
|
204 | + } |
|
205 | + $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
206 | + $field['is_hidden'] = $isFieldHidden; |
|
207 | + } |
|
208 | + return $field; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + protected function normalizeLabelAndLegend(array $field) |
|
215 | + { |
|
216 | + if (!empty($field['label'])) { |
|
217 | + $field['legend'] = $field['label']; |
|
218 | + unset($field['label']); |
|
219 | + } else { |
|
220 | + $field['is_valid'] = false; |
|
221 | + glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
222 | + } |
|
223 | + return $field; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return array |
|
228 | + */ |
|
229 | + protected function normalizeValue(array $field) |
|
230 | + { |
|
231 | + if (!isset($field['value'])) { |
|
232 | + $field['value'] = glsr(OptionManager::class)->get( |
|
233 | + $field['name'], |
|
234 | + $this->getFieldDefault($field) |
|
235 | + ); |
|
236 | + } |
|
237 | + return $field; |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * @return string |
|
242 | + */ |
|
243 | + protected function normalizeSettingPath($path) |
|
244 | + { |
|
245 | + return glsr(Helper::class)->prefix('settings.', rtrim($path, '.')); |
|
246 | + } |
|
247 | 247 | } |
@@ -13,346 +13,346 @@ |
||
13 | 13 | |
14 | 14 | class ListTableController extends Controller |
15 | 15 | { |
16 | - /** |
|
17 | - * @return void |
|
18 | - * @action admin_action_approve |
|
19 | - */ |
|
20 | - public function approve() |
|
21 | - { |
|
22 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
23 | - return; |
|
24 | - } |
|
25 | - check_admin_referer('approve-review_'.($postId = $this->getPostId())); |
|
26 | - wp_update_post([ |
|
27 | - 'ID' => $postId, |
|
28 | - 'post_status' => 'publish', |
|
29 | - ]); |
|
30 | - wp_safe_redirect(wp_get_referer()); |
|
31 | - exit; |
|
32 | - } |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + * @action admin_action_approve |
|
19 | + */ |
|
20 | + public function approve() |
|
21 | + { |
|
22 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
23 | + return; |
|
24 | + } |
|
25 | + check_admin_referer('approve-review_'.($postId = $this->getPostId())); |
|
26 | + wp_update_post([ |
|
27 | + 'ID' => $postId, |
|
28 | + 'post_status' => 'publish', |
|
29 | + ]); |
|
30 | + wp_safe_redirect(wp_get_referer()); |
|
31 | + exit; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param array $messages |
|
36 | - * @return array |
|
37 | - * @filter bulk_post_updated_messages |
|
38 | - */ |
|
39 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
40 | - { |
|
41 | - $messages = glsr(Helper::class)->consolidateArray($messages); |
|
42 | - $messages[Application::POST_TYPE] = [ |
|
43 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
44 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
45 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
46 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
47 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
48 | - ]; |
|
49 | - return $messages; |
|
50 | - } |
|
34 | + /** |
|
35 | + * @param array $messages |
|
36 | + * @return array |
|
37 | + * @filter bulk_post_updated_messages |
|
38 | + */ |
|
39 | + public function filterBulkUpdateMessages($messages, array $counts) |
|
40 | + { |
|
41 | + $messages = glsr(Helper::class)->consolidateArray($messages); |
|
42 | + $messages[Application::POST_TYPE] = [ |
|
43 | + 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
44 | + 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
45 | + 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
46 | + 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
47 | + 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
48 | + ]; |
|
49 | + return $messages; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param array $columns |
|
54 | - * @return array |
|
55 | - * @filter manage_.Application::POST_TYPE._posts_columns |
|
56 | - */ |
|
57 | - public function filterColumnsForPostType($columns) |
|
58 | - { |
|
59 | - $columns = glsr(Helper::class)->consolidateArray($columns); |
|
60 | - $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
61 | - foreach ($postTypeColumns as $key => &$value) { |
|
62 | - if (!array_key_exists($key, $columns) || !empty($value)) { |
|
63 | - continue; |
|
64 | - } |
|
65 | - $value = $columns[$key]; |
|
66 | - } |
|
67 | - if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
68 | - unset($postTypeColumns['review_type']); |
|
69 | - } |
|
70 | - return array_filter($postTypeColumns, 'strlen'); |
|
71 | - } |
|
52 | + /** |
|
53 | + * @param array $columns |
|
54 | + * @return array |
|
55 | + * @filter manage_.Application::POST_TYPE._posts_columns |
|
56 | + */ |
|
57 | + public function filterColumnsForPostType($columns) |
|
58 | + { |
|
59 | + $columns = glsr(Helper::class)->consolidateArray($columns); |
|
60 | + $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
61 | + foreach ($postTypeColumns as $key => &$value) { |
|
62 | + if (!array_key_exists($key, $columns) || !empty($value)) { |
|
63 | + continue; |
|
64 | + } |
|
65 | + $value = $columns[$key]; |
|
66 | + } |
|
67 | + if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
68 | + unset($postTypeColumns['review_type']); |
|
69 | + } |
|
70 | + return array_filter($postTypeColumns, 'strlen'); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $status |
|
75 | - * @param WP_Post $post |
|
76 | - * @return string |
|
77 | - * @filter post_date_column_status |
|
78 | - */ |
|
79 | - public function filterDateColumnStatus($status, $post) |
|
80 | - { |
|
81 | - if (Application::POST_TYPE == glsr_get($post, 'post_type')) { |
|
82 | - $status = __('Submitted', 'site-reviews'); |
|
83 | - } |
|
84 | - return $status; |
|
85 | - } |
|
73 | + /** |
|
74 | + * @param string $status |
|
75 | + * @param WP_Post $post |
|
76 | + * @return string |
|
77 | + * @filter post_date_column_status |
|
78 | + */ |
|
79 | + public function filterDateColumnStatus($status, $post) |
|
80 | + { |
|
81 | + if (Application::POST_TYPE == glsr_get($post, 'post_type')) { |
|
82 | + $status = __('Submitted', 'site-reviews'); |
|
83 | + } |
|
84 | + return $status; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param array $hidden |
|
89 | - * @param WP_Screen $post |
|
90 | - * @return array |
|
91 | - * @filter default_hidden_columns |
|
92 | - */ |
|
93 | - public function filterDefaultHiddenColumns($hidden, $screen) |
|
94 | - { |
|
95 | - if (glsr_get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
96 | - $hidden = glsr(Helper::class)->consolidateArray($hidden); |
|
97 | - $hidden = ['reviewer']; |
|
98 | - } |
|
99 | - return $hidden; |
|
100 | - } |
|
87 | + /** |
|
88 | + * @param array $hidden |
|
89 | + * @param WP_Screen $post |
|
90 | + * @return array |
|
91 | + * @filter default_hidden_columns |
|
92 | + */ |
|
93 | + public function filterDefaultHiddenColumns($hidden, $screen) |
|
94 | + { |
|
95 | + if (glsr_get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
96 | + $hidden = glsr(Helper::class)->consolidateArray($hidden); |
|
97 | + $hidden = ['reviewer']; |
|
98 | + } |
|
99 | + return $hidden; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @param array $postStates |
|
104 | - * @param WP_Post $post |
|
105 | - * @return array |
|
106 | - * @filter display_post_states |
|
107 | - */ |
|
108 | - public function filterPostStates($postStates, $post) |
|
109 | - { |
|
110 | - $postStates = glsr(Helper::class)->consolidateArray($postStates); |
|
111 | - if (Application::POST_TYPE == glsr_get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
112 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
113 | - } |
|
114 | - return $postStates; |
|
115 | - } |
|
102 | + /** |
|
103 | + * @param array $postStates |
|
104 | + * @param WP_Post $post |
|
105 | + * @return array |
|
106 | + * @filter display_post_states |
|
107 | + */ |
|
108 | + public function filterPostStates($postStates, $post) |
|
109 | + { |
|
110 | + $postStates = glsr(Helper::class)->consolidateArray($postStates); |
|
111 | + if (Application::POST_TYPE == glsr_get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
112 | + $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
113 | + } |
|
114 | + return $postStates; |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @param array $actions |
|
119 | - * @param WP_Post $post |
|
120 | - * @return array |
|
121 | - * @filter post_row_actions |
|
122 | - */ |
|
123 | - public function filterRowActions($actions, $post) |
|
124 | - { |
|
125 | - if (Application::POST_TYPE != glsr_get($post, 'post_type') || 'trash' == $post->post_status) { |
|
126 | - return $actions; |
|
127 | - } |
|
128 | - unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
129 | - $rowActions = [ |
|
130 | - 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
131 | - 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
132 | - ]; |
|
133 | - $newActions = []; |
|
134 | - foreach ($rowActions as $key => $text) { |
|
135 | - $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
136 | - 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
137 | - 'class' => 'glsr-change-status', |
|
138 | - 'href' => wp_nonce_url( |
|
139 | - admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
140 | - $key.'-review_'.$post->ID |
|
141 | - ), |
|
142 | - ]); |
|
143 | - } |
|
144 | - return $newActions + glsr(Helper::class)->consolidateArray($actions); |
|
145 | - } |
|
117 | + /** |
|
118 | + * @param array $actions |
|
119 | + * @param WP_Post $post |
|
120 | + * @return array |
|
121 | + * @filter post_row_actions |
|
122 | + */ |
|
123 | + public function filterRowActions($actions, $post) |
|
124 | + { |
|
125 | + if (Application::POST_TYPE != glsr_get($post, 'post_type') || 'trash' == $post->post_status) { |
|
126 | + return $actions; |
|
127 | + } |
|
128 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
129 | + $rowActions = [ |
|
130 | + 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
131 | + 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
132 | + ]; |
|
133 | + $newActions = []; |
|
134 | + foreach ($rowActions as $key => $text) { |
|
135 | + $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
136 | + 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
137 | + 'class' => 'glsr-change-status', |
|
138 | + 'href' => wp_nonce_url( |
|
139 | + admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
140 | + $key.'-review_'.$post->ID |
|
141 | + ), |
|
142 | + ]); |
|
143 | + } |
|
144 | + return $newActions + glsr(Helper::class)->consolidateArray($actions); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @param array $columns |
|
149 | - * @return array |
|
150 | - * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
|
151 | - */ |
|
152 | - public function filterSortableColumns($columns) |
|
153 | - { |
|
154 | - $columns = glsr(Helper::class)->consolidateArray($columns); |
|
155 | - $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
156 | - unset($postTypeColumns['cb']); |
|
157 | - foreach ($postTypeColumns as $key => $value) { |
|
158 | - if (glsr(Helper::class)->startsWith('taxonomy', $key)) { |
|
159 | - continue; |
|
160 | - } |
|
161 | - $columns[$key] = $key; |
|
162 | - } |
|
163 | - return $columns; |
|
164 | - } |
|
147 | + /** |
|
148 | + * @param array $columns |
|
149 | + * @return array |
|
150 | + * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
|
151 | + */ |
|
152 | + public function filterSortableColumns($columns) |
|
153 | + { |
|
154 | + $columns = glsr(Helper::class)->consolidateArray($columns); |
|
155 | + $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
156 | + unset($postTypeColumns['cb']); |
|
157 | + foreach ($postTypeColumns as $key => $value) { |
|
158 | + if (glsr(Helper::class)->startsWith('taxonomy', $key)) { |
|
159 | + continue; |
|
160 | + } |
|
161 | + $columns[$key] = $key; |
|
162 | + } |
|
163 | + return $columns; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Customize the post_type status text. |
|
168 | - * @param string $translation |
|
169 | - * @param string $single |
|
170 | - * @param string $plural |
|
171 | - * @param int $number |
|
172 | - * @param string $domain |
|
173 | - * @return string |
|
174 | - * @filter ngettext |
|
175 | - */ |
|
176 | - public function filterStatusText($translation, $single, $plural, $number, $domain) |
|
177 | - { |
|
178 | - if ($this->canModifyTranslation($domain)) { |
|
179 | - $strings = [ |
|
180 | - 'Published' => __('Approved', 'site-reviews'), |
|
181 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
182 | - ]; |
|
183 | - foreach ($strings as $search => $replace) { |
|
184 | - if (false === strpos($single, $search)) { |
|
185 | - continue; |
|
186 | - } |
|
187 | - $translation = $this->getTranslation([ |
|
188 | - 'number' => $number, |
|
189 | - 'plural' => str_replace($search, $replace, $plural), |
|
190 | - 'single' => str_replace($search, $replace, $single), |
|
191 | - ]); |
|
192 | - } |
|
193 | - } |
|
194 | - return $translation; |
|
195 | - } |
|
166 | + /** |
|
167 | + * Customize the post_type status text. |
|
168 | + * @param string $translation |
|
169 | + * @param string $single |
|
170 | + * @param string $plural |
|
171 | + * @param int $number |
|
172 | + * @param string $domain |
|
173 | + * @return string |
|
174 | + * @filter ngettext |
|
175 | + */ |
|
176 | + public function filterStatusText($translation, $single, $plural, $number, $domain) |
|
177 | + { |
|
178 | + if ($this->canModifyTranslation($domain)) { |
|
179 | + $strings = [ |
|
180 | + 'Published' => __('Approved', 'site-reviews'), |
|
181 | + 'Pending' => __('Unapproved', 'site-reviews'), |
|
182 | + ]; |
|
183 | + foreach ($strings as $search => $replace) { |
|
184 | + if (false === strpos($single, $search)) { |
|
185 | + continue; |
|
186 | + } |
|
187 | + $translation = $this->getTranslation([ |
|
188 | + 'number' => $number, |
|
189 | + 'plural' => str_replace($search, $replace, $plural), |
|
190 | + 'single' => str_replace($search, $replace, $single), |
|
191 | + ]); |
|
192 | + } |
|
193 | + } |
|
194 | + return $translation; |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * @param string $columnName |
|
199 | - * @param string $postType |
|
200 | - * @return void |
|
201 | - * @action bulk_edit_custom_box |
|
202 | - */ |
|
203 | - public function renderBulkEditFields($columnName, $postType) |
|
204 | - { |
|
205 | - if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
206 | - glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
207 | - } |
|
208 | - } |
|
197 | + /** |
|
198 | + * @param string $columnName |
|
199 | + * @param string $postType |
|
200 | + * @return void |
|
201 | + * @action bulk_edit_custom_box |
|
202 | + */ |
|
203 | + public function renderBulkEditFields($columnName, $postType) |
|
204 | + { |
|
205 | + if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
206 | + glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * @param string $postType |
|
212 | - * @return void |
|
213 | - * @action restrict_manage_posts |
|
214 | - */ |
|
215 | - public function renderColumnFilters($postType) |
|
216 | - { |
|
217 | - glsr(Columns::class)->renderFilters($postType); |
|
218 | - } |
|
210 | + /** |
|
211 | + * @param string $postType |
|
212 | + * @return void |
|
213 | + * @action restrict_manage_posts |
|
214 | + */ |
|
215 | + public function renderColumnFilters($postType) |
|
216 | + { |
|
217 | + glsr(Columns::class)->renderFilters($postType); |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * @param string $column |
|
222 | - * @param string $postId |
|
223 | - * @return void |
|
224 | - * @action manage_posts_custom_column |
|
225 | - */ |
|
226 | - public function renderColumnValues($column, $postId) |
|
227 | - { |
|
228 | - glsr(Columns::class)->renderValues($column, $postId); |
|
229 | - } |
|
220 | + /** |
|
221 | + * @param string $column |
|
222 | + * @param string $postId |
|
223 | + * @return void |
|
224 | + * @action manage_posts_custom_column |
|
225 | + */ |
|
226 | + public function renderColumnValues($column, $postId) |
|
227 | + { |
|
228 | + glsr(Columns::class)->renderValues($column, $postId); |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * @param int $postId |
|
233 | - * @return void |
|
234 | - * @action save_post_.Application::POST_TYPE |
|
235 | - */ |
|
236 | - public function saveBulkEditFields($postId) |
|
237 | - { |
|
238 | - if (!current_user_can('edit_posts')) { |
|
239 | - return; |
|
240 | - } |
|
241 | - $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
242 | - if ($assignedTo && get_post($assignedTo)) { |
|
243 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
244 | - } |
|
245 | - } |
|
231 | + /** |
|
232 | + * @param int $postId |
|
233 | + * @return void |
|
234 | + * @action save_post_.Application::POST_TYPE |
|
235 | + */ |
|
236 | + public function saveBulkEditFields($postId) |
|
237 | + { |
|
238 | + if (!current_user_can('edit_posts')) { |
|
239 | + return; |
|
240 | + } |
|
241 | + $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
242 | + if ($assignedTo && get_post($assignedTo)) { |
|
243 | + glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
244 | + } |
|
245 | + } |
|
246 | 246 | |
247 | - /** |
|
248 | - * @return void |
|
249 | - * @action pre_get_posts |
|
250 | - */ |
|
251 | - public function setQueryForColumn(WP_Query $query) |
|
252 | - { |
|
253 | - if (!$this->hasPermission($query)) { |
|
254 | - return; |
|
255 | - } |
|
256 | - $this->setMetaQuery($query, [ |
|
257 | - 'rating', 'review_type', |
|
258 | - ]); |
|
259 | - $this->setOrderby($query); |
|
260 | - } |
|
247 | + /** |
|
248 | + * @return void |
|
249 | + * @action pre_get_posts |
|
250 | + */ |
|
251 | + public function setQueryForColumn(WP_Query $query) |
|
252 | + { |
|
253 | + if (!$this->hasPermission($query)) { |
|
254 | + return; |
|
255 | + } |
|
256 | + $this->setMetaQuery($query, [ |
|
257 | + 'rating', 'review_type', |
|
258 | + ]); |
|
259 | + $this->setOrderby($query); |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * @return void |
|
264 | - * @action admin_action_unapprove |
|
265 | - */ |
|
266 | - public function unapprove() |
|
267 | - { |
|
268 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
269 | - return; |
|
270 | - } |
|
271 | - check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
272 | - wp_update_post([ |
|
273 | - 'ID' => $postId, |
|
274 | - 'post_status' => 'pending', |
|
275 | - ]); |
|
276 | - wp_safe_redirect(wp_get_referer()); |
|
277 | - exit; |
|
278 | - } |
|
262 | + /** |
|
263 | + * @return void |
|
264 | + * @action admin_action_unapprove |
|
265 | + */ |
|
266 | + public function unapprove() |
|
267 | + { |
|
268 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
269 | + return; |
|
270 | + } |
|
271 | + check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
272 | + wp_update_post([ |
|
273 | + 'ID' => $postId, |
|
274 | + 'post_status' => 'pending', |
|
275 | + ]); |
|
276 | + wp_safe_redirect(wp_get_referer()); |
|
277 | + exit; |
|
278 | + } |
|
279 | 279 | |
280 | - /** |
|
281 | - * Check if the translation string can be modified. |
|
282 | - * @param string $domain |
|
283 | - * @return bool |
|
284 | - */ |
|
285 | - protected function canModifyTranslation($domain = 'default') |
|
286 | - { |
|
287 | - $screen = glsr_current_screen(); |
|
288 | - return 'default' == $domain |
|
289 | - && 'edit' == $screen->base |
|
290 | - && Application::POST_TYPE == $screen->post_type; |
|
291 | - } |
|
280 | + /** |
|
281 | + * Check if the translation string can be modified. |
|
282 | + * @param string $domain |
|
283 | + * @return bool |
|
284 | + */ |
|
285 | + protected function canModifyTranslation($domain = 'default') |
|
286 | + { |
|
287 | + $screen = glsr_current_screen(); |
|
288 | + return 'default' == $domain |
|
289 | + && 'edit' == $screen->base |
|
290 | + && Application::POST_TYPE == $screen->post_type; |
|
291 | + } |
|
292 | 292 | |
293 | - /** |
|
294 | - * Get the modified translation string. |
|
295 | - * @return string |
|
296 | - */ |
|
297 | - protected function getTranslation(array $args) |
|
298 | - { |
|
299 | - $defaults = [ |
|
300 | - 'number' => 0, |
|
301 | - 'plural' => '', |
|
302 | - 'single' => '', |
|
303 | - 'text' => '', |
|
304 | - ]; |
|
305 | - $args = (object) wp_parse_args($args, $defaults); |
|
306 | - $translations = get_translations_for_domain(Application::ID); |
|
307 | - return $args->text |
|
308 | - ? $translations->translate($args->text) |
|
309 | - : $translations->translate_plural($args->single, $args->plural, $args->number); |
|
310 | - } |
|
293 | + /** |
|
294 | + * Get the modified translation string. |
|
295 | + * @return string |
|
296 | + */ |
|
297 | + protected function getTranslation(array $args) |
|
298 | + { |
|
299 | + $defaults = [ |
|
300 | + 'number' => 0, |
|
301 | + 'plural' => '', |
|
302 | + 'single' => '', |
|
303 | + 'text' => '', |
|
304 | + ]; |
|
305 | + $args = (object) wp_parse_args($args, $defaults); |
|
306 | + $translations = get_translations_for_domain(Application::ID); |
|
307 | + return $args->text |
|
308 | + ? $translations->translate($args->text) |
|
309 | + : $translations->translate_plural($args->single, $args->plural, $args->number); |
|
310 | + } |
|
311 | 311 | |
312 | - /** |
|
313 | - * @return bool |
|
314 | - */ |
|
315 | - protected function hasPermission(WP_Query $query) |
|
316 | - { |
|
317 | - global $pagenow; |
|
318 | - return is_admin() |
|
319 | - && $query->is_main_query() |
|
320 | - && Application::POST_TYPE == $query->get('post_type') |
|
321 | - && 'edit.php' == $pagenow; |
|
322 | - } |
|
312 | + /** |
|
313 | + * @return bool |
|
314 | + */ |
|
315 | + protected function hasPermission(WP_Query $query) |
|
316 | + { |
|
317 | + global $pagenow; |
|
318 | + return is_admin() |
|
319 | + && $query->is_main_query() |
|
320 | + && Application::POST_TYPE == $query->get('post_type') |
|
321 | + && 'edit.php' == $pagenow; |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * @return void |
|
326 | - */ |
|
327 | - protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
328 | - { |
|
329 | - foreach ($metaKeys as $key) { |
|
330 | - if (!($value = filter_input(INPUT_GET, $key))) { |
|
331 | - continue; |
|
332 | - } |
|
333 | - $metaQuery = (array) $query->get('meta_query'); |
|
334 | - $metaQuery[] = [ |
|
335 | - 'key' => glsr(Helper::class)->prefix('_', $key), |
|
336 | - 'value' => $value, |
|
337 | - ]; |
|
338 | - $query->set('meta_query', $metaQuery); |
|
339 | - } |
|
340 | - } |
|
324 | + /** |
|
325 | + * @return void |
|
326 | + */ |
|
327 | + protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
328 | + { |
|
329 | + foreach ($metaKeys as $key) { |
|
330 | + if (!($value = filter_input(INPUT_GET, $key))) { |
|
331 | + continue; |
|
332 | + } |
|
333 | + $metaQuery = (array) $query->get('meta_query'); |
|
334 | + $metaQuery[] = [ |
|
335 | + 'key' => glsr(Helper::class)->prefix('_', $key), |
|
336 | + 'value' => $value, |
|
337 | + ]; |
|
338 | + $query->set('meta_query', $metaQuery); |
|
339 | + } |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * @return void |
|
344 | - */ |
|
345 | - protected function setOrderby(WP_Query $query) |
|
346 | - { |
|
347 | - $orderby = $query->get('orderby'); |
|
348 | - $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
349 | - unset($columns['cb'], $columns['title'], $columns['date']); |
|
350 | - if (in_array($orderby, array_keys($columns))) { |
|
351 | - if ('reviewer' == $orderby) { |
|
352 | - $orderby = '_author'; |
|
353 | - } |
|
354 | - $query->set('meta_key', $orderby); |
|
355 | - $query->set('orderby', 'meta_value'); |
|
356 | - } |
|
357 | - } |
|
342 | + /** |
|
343 | + * @return void |
|
344 | + */ |
|
345 | + protected function setOrderby(WP_Query $query) |
|
346 | + { |
|
347 | + $orderby = $query->get('orderby'); |
|
348 | + $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
349 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
350 | + if (in_array($orderby, array_keys($columns))) { |
|
351 | + if ('reviewer' == $orderby) { |
|
352 | + $orderby = '_author'; |
|
353 | + } |
|
354 | + $query->set('meta_key', $orderby); |
|
355 | + $query->set('orderby', 'meta_value'); |
|
356 | + } |
|
357 | + } |
|
358 | 358 | } |
@@ -9,126 +9,126 @@ |
||
9 | 9 | |
10 | 10 | class Helper |
11 | 11 | { |
12 | - use Arr; |
|
13 | - use Str; |
|
12 | + use Arr; |
|
13 | + use Str; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @param string $name |
|
17 | - * @param string $path |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function buildClassName($name, $path = '') |
|
21 | - { |
|
22 | - $className = $this->camelCase($name); |
|
23 | - $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
24 | - return !empty($path) |
|
25 | - ? __NAMESPACE__.'\\'.$path.'\\'.$className |
|
26 | - : $className; |
|
27 | - } |
|
15 | + /** |
|
16 | + * @param string $name |
|
17 | + * @param string $path |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function buildClassName($name, $path = '') |
|
21 | + { |
|
22 | + $className = $this->camelCase($name); |
|
23 | + $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
24 | + return !empty($path) |
|
25 | + ? __NAMESPACE__.'\\'.$path.'\\'.$className |
|
26 | + : $className; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param string $name |
|
31 | - * @param string $prefix |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public function buildMethodName($name, $prefix = '') |
|
35 | - { |
|
36 | - return lcfirst($prefix.$this->buildClassName($name)); |
|
37 | - } |
|
29 | + /** |
|
30 | + * @param string $name |
|
31 | + * @param string $prefix |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public function buildMethodName($name, $prefix = '') |
|
35 | + { |
|
36 | + return lcfirst($prefix.$this->buildClassName($name)); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $name |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function buildPropertyName($name) |
|
44 | - { |
|
45 | - return lcfirst($this->buildClassName($name)); |
|
46 | - } |
|
39 | + /** |
|
40 | + * @param string $name |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function buildPropertyName($name) |
|
44 | + { |
|
45 | + return lcfirst($this->buildClassName($name)); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $cast |
|
50 | - * @param mixed $value |
|
51 | - * @return mixed |
|
52 | - */ |
|
53 | - public function castTo($cast = '', $value) |
|
54 | - { |
|
55 | - switch ($cast) { |
|
56 | - case 'array': |
|
57 | - return (array) $value; |
|
58 | - case 'boolean': |
|
59 | - if ('no' === $value) { |
|
60 | - return false; |
|
61 | - } |
|
62 | - return (bool) $value; |
|
63 | - case 'integer': |
|
64 | - if (is_numeric($value) || is_string($value)) { |
|
65 | - return (int) $value; |
|
66 | - } |
|
67 | - // no break |
|
68 | - case 'object': |
|
69 | - return (object) (array) $value; |
|
70 | - case 'string': |
|
71 | - if (!is_array($value) && !is_object($value)) { |
|
72 | - return (string) $value; |
|
73 | - } |
|
74 | - // no break |
|
75 | - default: |
|
76 | - return $value; |
|
77 | - } |
|
78 | - } |
|
48 | + /** |
|
49 | + * @param string $cast |
|
50 | + * @param mixed $value |
|
51 | + * @return mixed |
|
52 | + */ |
|
53 | + public function castTo($cast = '', $value) |
|
54 | + { |
|
55 | + switch ($cast) { |
|
56 | + case 'array': |
|
57 | + return (array) $value; |
|
58 | + case 'boolean': |
|
59 | + if ('no' === $value) { |
|
60 | + return false; |
|
61 | + } |
|
62 | + return (bool) $value; |
|
63 | + case 'integer': |
|
64 | + if (is_numeric($value) || is_string($value)) { |
|
65 | + return (int) $value; |
|
66 | + } |
|
67 | + // no break |
|
68 | + case 'object': |
|
69 | + return (object) (array) $value; |
|
70 | + case 'string': |
|
71 | + if (!is_array($value) && !is_object($value)) { |
|
72 | + return (string) $value; |
|
73 | + } |
|
74 | + // no break |
|
75 | + default: |
|
76 | + return $value; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param string $key |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - public function filterInput($key, array $request = []) |
|
85 | - { |
|
86 | - if (isset($request[$key])) { |
|
87 | - return $request[$key]; |
|
88 | - } |
|
89 | - $variable = filter_input(INPUT_POST, $key); |
|
90 | - if (is_null($variable) && isset($_POST[$key])) { |
|
91 | - $variable = $_POST[$key]; |
|
92 | - } |
|
93 | - return $variable; |
|
94 | - } |
|
80 | + /** |
|
81 | + * @param string $key |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + public function filterInput($key, array $request = []) |
|
85 | + { |
|
86 | + if (isset($request[$key])) { |
|
87 | + return $request[$key]; |
|
88 | + } |
|
89 | + $variable = filter_input(INPUT_POST, $key); |
|
90 | + if (is_null($variable) && isset($_POST[$key])) { |
|
91 | + $variable = $_POST[$key]; |
|
92 | + } |
|
93 | + return $variable; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @param string $key |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function filterInputArray($key) |
|
101 | - { |
|
102 | - $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
103 | - if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
104 | - $variable = $_POST[$key]; |
|
105 | - } |
|
106 | - return (array) $variable; |
|
107 | - } |
|
96 | + /** |
|
97 | + * @param string $key |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function filterInputArray($key) |
|
101 | + { |
|
102 | + $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
103 | + if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
104 | + $variable = $_POST[$key]; |
|
105 | + } |
|
106 | + return (array) $variable; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getIpAddress() |
|
113 | - { |
|
114 | - $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
115 | - $ipv6 = defined('AF_INET6') |
|
116 | - ? $cloudflareIps['v6'] |
|
117 | - : []; |
|
118 | - $whitelist = apply_filters('site-reviews/whip/whitelist', [ |
|
119 | - Whip::CLOUDFLARE_HEADERS => [ |
|
120 | - Whip::IPV4 => $cloudflareIps['v4'], |
|
121 | - Whip::IPV6 => $ipv6, |
|
122 | - ], |
|
123 | - Whip::CUSTOM_HEADERS => [ |
|
124 | - Whip::IPV4 => ['127.0.0.1'], |
|
125 | - Whip::IPV6 => ['::1'], |
|
126 | - ], |
|
127 | - ]); |
|
128 | - $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR; |
|
129 | - $methods = apply_filters('site-reviews/whip/methods', $methods); |
|
130 | - $whip = new Whip($methods, $whitelist); |
|
131 | - do_action_ref_array('site-reviews/whip', [$whip]); |
|
132 | - return (string) $whip->getValidIpAddress(); |
|
133 | - } |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getIpAddress() |
|
113 | + { |
|
114 | + $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
115 | + $ipv6 = defined('AF_INET6') |
|
116 | + ? $cloudflareIps['v6'] |
|
117 | + : []; |
|
118 | + $whitelist = apply_filters('site-reviews/whip/whitelist', [ |
|
119 | + Whip::CLOUDFLARE_HEADERS => [ |
|
120 | + Whip::IPV4 => $cloudflareIps['v4'], |
|
121 | + Whip::IPV6 => $ipv6, |
|
122 | + ], |
|
123 | + Whip::CUSTOM_HEADERS => [ |
|
124 | + Whip::IPV4 => ['127.0.0.1'], |
|
125 | + Whip::IPV6 => ['::1'], |
|
126 | + ], |
|
127 | + ]); |
|
128 | + $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR; |
|
129 | + $methods = apply_filters('site-reviews/whip/methods', $methods); |
|
130 | + $whip = new Whip($methods, $whitelist); |
|
131 | + do_action_ref_array('site-reviews/whip', [$whip]); |
|
132 | + return (string) $whip->getValidIpAddress(); |
|
133 | + } |
|
134 | 134 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | class SqlQueries |
9 | 9 | { |
10 | 10 | protected $db; |
11 | - protected $postType; |
|
11 | + protected $postType; |
|
12 | 12 | |
13 | 13 | public function __construct() |
14 | 14 | { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param string $metaReviewId |
22 | 22 | * @return int |
23 | 23 | */ |
24 | - public function getPostIdFromReviewId($metaReviewId) |
|
24 | + public function getPostIdFromReviewId($metaReviewId) |
|
25 | 25 | { |
26 | 26 | $postId = $this->db->get_var(" |
27 | 27 | SELECT p.ID |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | AND m.meta_key = '_review_id' |
32 | 32 | AND m.meta_value = '{$metaReviewId}' |
33 | 33 | "); |
34 | - return intval($postId); |
|
34 | + return intval($postId); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param int $limit |
40 | 40 | * @return array |
41 | 41 | */ |
42 | - public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500) |
|
42 | + public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500) |
|
43 | 43 | { |
44 | 44 | return (array) $this->db->get_results(" |
45 | 45 | SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * @param string $metaKey |
64 | 64 | * @return array |
65 | 65 | */ |
66 | - public function getReviewCountsFor($metaKey) |
|
66 | + public function getReviewCountsFor($metaKey) |
|
67 | 67 | { |
68 | - $metaKey = glsr(Helper::class)->prefix('_', $metaKey); |
|
68 | + $metaKey = glsr(Helper::class)->prefix('_', $metaKey); |
|
69 | 69 | return (array) $this->db->get_results(" |
70 | 70 | SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts |
71 | 71 | FROM {$this->db->posts} AS p |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param string $reviewType |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function getReviewIdsByType($reviewType) |
|
84 | + public function getReviewIdsByType($reviewType) |
|
85 | 85 | { |
86 | 86 | $results = $this->db->get_col(" |
87 | 87 | SELECT DISTINCT m1.meta_value AS review_id |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | AND m2.meta_key = '_review_type' |
94 | 94 | AND m2.meta_value = '{$reviewType}' |
95 | 95 | "); |
96 | - return array_keys(array_flip($results)); |
|
96 | + return array_keys(array_flip($results)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | * @param int $limit |
102 | 102 | * @return array |
103 | 103 | */ |
104 | - public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100) |
|
104 | + public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100) |
|
105 | 105 | { |
106 | - sort($postIds); |
|
107 | - $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit); |
|
108 | - $postIds = implode(',', $postIds); |
|
106 | + sort($postIds); |
|
107 | + $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit); |
|
108 | + $postIds = implode(',', $postIds); |
|
109 | 109 | return (array) $this->db->get_results(" |
110 | 110 | SELECT p.ID, m.meta_value AS rating |
111 | 111 | FROM {$this->db->posts} AS p |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @param string $status |
127 | 127 | * @return array |
128 | 128 | */ |
129 | - public function getReviewsMeta($key, $status = 'publish') |
|
129 | + public function getReviewsMeta($key, $status = 'publish') |
|
130 | 130 | { |
131 | - $key = glsr(Helper::class)->prefix('_', $key); |
|
131 | + $key = glsr(Helper::class)->prefix('_', $key); |
|
132 | 132 | $values = $this->db->get_col(" |
133 | 133 | SELECT DISTINCT m.meta_value |
134 | 134 | FROM {$this->db->postmeta} m |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | GROUP BY p.ID -- remove duplicate meta_value entries |
141 | 141 | ORDER BY m.meta_id ASC -- sort by oldest meta_value |
142 | 142 | "); |
143 | - sort($values); |
|
143 | + sort($values); |
|
144 | 144 | return $values; |
145 | 145 | } |
146 | 146 | |
@@ -148,34 +148,34 @@ discard block |
||
148 | 148 | * @param string $and |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - protected function getAndForCounts(array $args, $and = '') |
|
151 | + protected function getAndForCounts(array $args, $and = '') |
|
152 | 152 | { |
153 | - $postIds = implode(',', array_filter(glsr_get($args, 'post_ids'))); |
|
154 | - $termIds = implode(',', array_filter(glsr_get($args, 'term_ids'))); |
|
155 | - if (!empty($args['type'])) { |
|
156 | - $and.= "AND m2.meta_value = '{$args['type']}' "; |
|
153 | + $postIds = implode(',', array_filter(glsr_get($args, 'post_ids'))); |
|
154 | + $termIds = implode(',', array_filter(glsr_get($args, 'term_ids'))); |
|
155 | + if (!empty($args['type'])) { |
|
156 | + $and.= "AND m2.meta_value = '{$args['type']}' "; |
|
157 | 157 | } |
158 | - if ($postIds) { |
|
159 | - $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) "; |
|
158 | + if ($postIds) { |
|
159 | + $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) "; |
|
160 | 160 | } |
161 | - if ($termIds) { |
|
162 | - $and.= "AND tr.term_taxonomy_id IN ({$termIds}) "; |
|
161 | + if ($termIds) { |
|
162 | + $and.= "AND tr.term_taxonomy_id IN ({$termIds}) "; |
|
163 | 163 | } |
164 | - return apply_filters('site-reviews/query/and-for-counts', $and); |
|
164 | + return apply_filters('site-reviews/query/and-for-counts', $and); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | 168 | * @param string $innerJoin |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - protected function getInnerJoinForCounts(array $args, $innerJoin = '') |
|
171 | + protected function getInnerJoinForCounts(array $args, $innerJoin = '') |
|
172 | 172 | { |
173 | - if (!empty(glsr_get($args, 'post_ids'))) { |
|
174 | - $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
|
173 | + if (!empty(glsr_get($args, 'post_ids'))) { |
|
174 | + $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
|
175 | 175 | } |
176 | - if (!empty(glsr_get($args, 'term_ids'))) { |
|
177 | - $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id "; |
|
176 | + if (!empty(glsr_get($args, 'term_ids'))) { |
|
177 | + $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id "; |
|
178 | 178 | } |
179 | - return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin); |
|
179 | + return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin); |
|
180 | 180 | } |
181 | 181 | } |
@@ -4,188 +4,188 @@ |
||
4 | 4 | |
5 | 5 | trait Arr |
6 | 6 | { |
7 | - /** |
|
8 | - * @return bool |
|
9 | - */ |
|
10 | - public function compareArrays(array $arr1, array $arr2) |
|
11 | - { |
|
12 | - sort($arr1); |
|
13 | - sort($arr2); |
|
14 | - return $arr1 == $arr2; |
|
15 | - } |
|
7 | + /** |
|
8 | + * @return bool |
|
9 | + */ |
|
10 | + public function compareArrays(array $arr1, array $arr2) |
|
11 | + { |
|
12 | + sort($arr1); |
|
13 | + sort($arr2); |
|
14 | + return $arr1 == $arr2; |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * @param mixed $array |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public function consolidateArray($array) |
|
22 | - { |
|
23 | - return is_array($array) || is_object($array) |
|
24 | - ? (array) $array |
|
25 | - : []; |
|
26 | - } |
|
17 | + /** |
|
18 | + * @param mixed $array |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public function consolidateArray($array) |
|
22 | + { |
|
23 | + return is_array($array) || is_object($array) |
|
24 | + ? (array) $array |
|
25 | + : []; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - public function convertDotNotationArray(array $array) |
|
32 | - { |
|
33 | - $results = []; |
|
34 | - foreach ($array as $path => $value) { |
|
35 | - $results = $this->dataSet($results, $path, $value); |
|
36 | - } |
|
37 | - return $results; |
|
38 | - } |
|
28 | + /** |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + public function convertDotNotationArray(array $array) |
|
32 | + { |
|
33 | + $results = []; |
|
34 | + foreach ($array as $path => $value) { |
|
35 | + $results = $this->dataSet($results, $path, $value); |
|
36 | + } |
|
37 | + return $results; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $string |
|
42 | - * @param mixed $callback |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - public function convertStringToArray($string, $callback = null) |
|
46 | - { |
|
47 | - $array = array_map('trim', explode(',', $string)); |
|
48 | - return $callback |
|
49 | - ? array_filter($array, $callback) |
|
50 | - : array_filter($array); |
|
51 | - } |
|
40 | + /** |
|
41 | + * @param string $string |
|
42 | + * @param mixed $callback |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + public function convertStringToArray($string, $callback = null) |
|
46 | + { |
|
47 | + $array = array_map('trim', explode(',', $string)); |
|
48 | + return $callback |
|
49 | + ? array_filter($array, $callback) |
|
50 | + : array_filter($array); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Get a value from an array of values using a dot-notation path as reference. |
|
55 | - * @param array $data |
|
56 | - * @param string $path |
|
57 | - * @param mixed $fallback |
|
58 | - * @return mixed |
|
59 | - */ |
|
60 | - public function dataGet($data, $path = '', $fallback = '') |
|
61 | - { |
|
62 | - $data = $this->consolidateArray($data); |
|
63 | - $keys = explode('.', $path); |
|
64 | - foreach ($keys as $key) { |
|
65 | - if (!isset($data[$key])) { |
|
66 | - return $fallback; |
|
67 | - } |
|
68 | - $data = $data[$key]; |
|
69 | - } |
|
70 | - return $data; |
|
71 | - } |
|
53 | + /** |
|
54 | + * Get a value from an array of values using a dot-notation path as reference. |
|
55 | + * @param array $data |
|
56 | + * @param string $path |
|
57 | + * @param mixed $fallback |
|
58 | + * @return mixed |
|
59 | + */ |
|
60 | + public function dataGet($data, $path = '', $fallback = '') |
|
61 | + { |
|
62 | + $data = $this->consolidateArray($data); |
|
63 | + $keys = explode('.', $path); |
|
64 | + foreach ($keys as $key) { |
|
65 | + if (!isset($data[$key])) { |
|
66 | + return $fallback; |
|
67 | + } |
|
68 | + $data = $data[$key]; |
|
69 | + } |
|
70 | + return $data; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Set a value to an array of values using a dot-notation path as reference. |
|
75 | - * @param string $path |
|
76 | - * @param mixed $value |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - public function dataSet(array $data, $path, $value) |
|
80 | - { |
|
81 | - $token = strtok($path, '.'); |
|
82 | - $ref = &$data; |
|
83 | - while (false !== $token) { |
|
84 | - $ref = $this->consolidateArray($ref); |
|
85 | - $ref = &$ref[$token]; |
|
86 | - $token = strtok('.'); |
|
87 | - } |
|
88 | - $ref = $value; |
|
89 | - return $data; |
|
90 | - } |
|
73 | + /** |
|
74 | + * Set a value to an array of values using a dot-notation path as reference. |
|
75 | + * @param string $path |
|
76 | + * @param mixed $value |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + public function dataSet(array $data, $path, $value) |
|
80 | + { |
|
81 | + $token = strtok($path, '.'); |
|
82 | + $ref = &$data; |
|
83 | + while (false !== $token) { |
|
84 | + $ref = $this->consolidateArray($ref); |
|
85 | + $ref = &$ref[$token]; |
|
86 | + $token = strtok('.'); |
|
87 | + } |
|
88 | + $ref = $value; |
|
89 | + return $data; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @param bool $flattenValue |
|
94 | - * @param string $prefix |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - public function flattenArray(array $array, $flattenValue = false, $prefix = '') |
|
98 | - { |
|
99 | - $result = []; |
|
100 | - foreach ($array as $key => $value) { |
|
101 | - $newKey = ltrim($prefix.'.'.$key, '.'); |
|
102 | - if ($this->isIndexedFlatArray($value)) { |
|
103 | - if ($flattenValue) { |
|
104 | - $value = '['.implode(', ', $value).']'; |
|
105 | - } |
|
106 | - } elseif (is_array($value)) { |
|
107 | - $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey)); |
|
108 | - continue; |
|
109 | - } |
|
110 | - $result[$newKey] = $value; |
|
111 | - } |
|
112 | - return $result; |
|
113 | - } |
|
92 | + /** |
|
93 | + * @param bool $flattenValue |
|
94 | + * @param string $prefix |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + public function flattenArray(array $array, $flattenValue = false, $prefix = '') |
|
98 | + { |
|
99 | + $result = []; |
|
100 | + foreach ($array as $key => $value) { |
|
101 | + $newKey = ltrim($prefix.'.'.$key, '.'); |
|
102 | + if ($this->isIndexedFlatArray($value)) { |
|
103 | + if ($flattenValue) { |
|
104 | + $value = '['.implode(', ', $value).']'; |
|
105 | + } |
|
106 | + } elseif (is_array($value)) { |
|
107 | + $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey)); |
|
108 | + continue; |
|
109 | + } |
|
110 | + $result[$newKey] = $value; |
|
111 | + } |
|
112 | + return $result; |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * @param string $key |
|
117 | - * @param string $position |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function insertInArray(array $array, array $insert, $key, $position = 'before') |
|
121 | - { |
|
122 | - $keyPosition = intval(array_search($key, array_keys($array))); |
|
123 | - if ('after' == $position) { |
|
124 | - ++$keyPosition; |
|
125 | - } |
|
126 | - if (false !== $keyPosition) { |
|
127 | - $result = array_slice($array, 0, $keyPosition); |
|
128 | - $result = array_merge($result, $insert); |
|
129 | - return array_merge($result, array_slice($array, $keyPosition)); |
|
130 | - } |
|
131 | - return array_merge($array, $insert); |
|
132 | - } |
|
115 | + /** |
|
116 | + * @param string $key |
|
117 | + * @param string $position |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function insertInArray(array $array, array $insert, $key, $position = 'before') |
|
121 | + { |
|
122 | + $keyPosition = intval(array_search($key, array_keys($array))); |
|
123 | + if ('after' == $position) { |
|
124 | + ++$keyPosition; |
|
125 | + } |
|
126 | + if (false !== $keyPosition) { |
|
127 | + $result = array_slice($array, 0, $keyPosition); |
|
128 | + $result = array_merge($result, $insert); |
|
129 | + return array_merge($result, array_slice($array, $keyPosition)); |
|
130 | + } |
|
131 | + return array_merge($array, $insert); |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @param mixed $array |
|
136 | - * @return bool |
|
137 | - */ |
|
138 | - public function isIndexedFlatArray($array) |
|
139 | - { |
|
140 | - if (!is_array($array) || array_filter($array, 'is_array')) { |
|
141 | - return false; |
|
142 | - } |
|
143 | - return wp_is_numeric_array($array); |
|
144 | - } |
|
134 | + /** |
|
135 | + * @param mixed $array |
|
136 | + * @return bool |
|
137 | + */ |
|
138 | + public function isIndexedFlatArray($array) |
|
139 | + { |
|
140 | + if (!is_array($array) || array_filter($array, 'is_array')) { |
|
141 | + return false; |
|
142 | + } |
|
143 | + return wp_is_numeric_array($array); |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @param bool $prefixed |
|
148 | - * @return array |
|
149 | - */ |
|
150 | - public function prefixArrayKeys(array $values, $prefixed = true) |
|
151 | - { |
|
152 | - $trim = '_'; |
|
153 | - $prefix = $prefixed |
|
154 | - ? $trim |
|
155 | - : ''; |
|
156 | - $prefixed = []; |
|
157 | - foreach ($values as $key => $value) { |
|
158 | - $key = trim($key); |
|
159 | - if (0 === strpos($key, $trim)) { |
|
160 | - $key = substr($key, strlen($trim)); |
|
161 | - } |
|
162 | - $prefixed[$prefix.$key] = $value; |
|
163 | - } |
|
164 | - return $prefixed; |
|
165 | - } |
|
146 | + /** |
|
147 | + * @param bool $prefixed |
|
148 | + * @return array |
|
149 | + */ |
|
150 | + public function prefixArrayKeys(array $values, $prefixed = true) |
|
151 | + { |
|
152 | + $trim = '_'; |
|
153 | + $prefix = $prefixed |
|
154 | + ? $trim |
|
155 | + : ''; |
|
156 | + $prefixed = []; |
|
157 | + foreach ($values as $key => $value) { |
|
158 | + $key = trim($key); |
|
159 | + if (0 === strpos($key, $trim)) { |
|
160 | + $key = substr($key, strlen($trim)); |
|
161 | + } |
|
162 | + $prefixed[$prefix.$key] = $value; |
|
163 | + } |
|
164 | + return $prefixed; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @return array |
|
169 | - */ |
|
170 | - public function removeEmptyArrayValues(array $array) |
|
171 | - { |
|
172 | - $result = []; |
|
173 | - foreach ($array as $key => $value) { |
|
174 | - if (!$value) { |
|
175 | - continue; |
|
176 | - } |
|
177 | - $result[$key] = is_array($value) |
|
178 | - ? $this->removeEmptyArrayValues($value) |
|
179 | - : $value; |
|
180 | - } |
|
181 | - return $result; |
|
182 | - } |
|
167 | + /** |
|
168 | + * @return array |
|
169 | + */ |
|
170 | + public function removeEmptyArrayValues(array $array) |
|
171 | + { |
|
172 | + $result = []; |
|
173 | + foreach ($array as $key => $value) { |
|
174 | + if (!$value) { |
|
175 | + continue; |
|
176 | + } |
|
177 | + $result[$key] = is_array($value) |
|
178 | + ? $this->removeEmptyArrayValues($value) |
|
179 | + : $value; |
|
180 | + } |
|
181 | + return $result; |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return array |
|
186 | - */ |
|
187 | - public function unprefixArrayKeys(array $values) |
|
188 | - { |
|
189 | - return $this->prefixArrayKeys($values, false); |
|
190 | - } |
|
184 | + /** |
|
185 | + * @return array |
|
186 | + */ |
|
187 | + public function unprefixArrayKeys(array $values) |
|
188 | + { |
|
189 | + return $this->prefixArrayKeys($values, false); |
|
190 | + } |
|
191 | 191 | } |
@@ -4,108 +4,108 @@ |
||
4 | 4 | |
5 | 5 | trait Str |
6 | 6 | { |
7 | - /** |
|
8 | - * @param string $string |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function camelCase($string) |
|
12 | - { |
|
13 | - $string = ucwords(str_replace(['-', '_'], ' ', trim($string))); |
|
14 | - return str_replace(' ', '', $string); |
|
15 | - } |
|
7 | + /** |
|
8 | + * @param string $string |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function camelCase($string) |
|
12 | + { |
|
13 | + $string = ucwords(str_replace(['-', '_'], ' ', trim($string))); |
|
14 | + return str_replace(' ', '', $string); |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * @param string $name |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function convertPathToId($path, $prefix = '') |
|
22 | - { |
|
23 | - return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix)); |
|
24 | - } |
|
17 | + /** |
|
18 | + * @param string $name |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function convertPathToId($path, $prefix = '') |
|
22 | + { |
|
23 | + return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix)); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param string $path |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function convertPathToName($path, $prefix = '') |
|
31 | - { |
|
32 | - $levels = explode('.', $path); |
|
33 | - return array_reduce($levels, function ($result, $value) { |
|
34 | - return $result .= '['.$value.']'; |
|
35 | - }, $prefix); |
|
36 | - } |
|
26 | + /** |
|
27 | + * @param string $path |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function convertPathToName($path, $prefix = '') |
|
31 | + { |
|
32 | + $levels = explode('.', $path); |
|
33 | + return array_reduce($levels, function ($result, $value) { |
|
34 | + return $result .= '['.$value.']'; |
|
35 | + }, $prefix); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $string |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function dashCase($string) |
|
43 | - { |
|
44 | - return str_replace('_', '-', $this->snakeCase($string)); |
|
45 | - } |
|
38 | + /** |
|
39 | + * @param string $string |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function dashCase($string) |
|
43 | + { |
|
44 | + return str_replace('_', '-', $this->snakeCase($string)); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $needle |
|
49 | - * @param string $haystack |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function endsWith($needle, $haystack) |
|
53 | - { |
|
54 | - $length = strlen($needle); |
|
55 | - return 0 != $length |
|
56 | - ? substr($haystack, -$length) === $needle |
|
57 | - : true; |
|
58 | - } |
|
47 | + /** |
|
48 | + * @param string $needle |
|
49 | + * @param string $haystack |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function endsWith($needle, $haystack) |
|
53 | + { |
|
54 | + $length = strlen($needle); |
|
55 | + return 0 != $length |
|
56 | + ? substr($haystack, -$length) === $needle |
|
57 | + : true; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $prefix |
|
62 | - * @param string $string |
|
63 | - * @param string|null $trim |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function prefix($prefix, $string, $trim = null) |
|
67 | - { |
|
68 | - if (null === $trim) { |
|
69 | - $trim = $prefix; |
|
70 | - } |
|
71 | - return $prefix.trim($this->removePrefix($trim, $string)); |
|
72 | - } |
|
60 | + /** |
|
61 | + * @param string $prefix |
|
62 | + * @param string $string |
|
63 | + * @param string|null $trim |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function prefix($prefix, $string, $trim = null) |
|
67 | + { |
|
68 | + if (null === $trim) { |
|
69 | + $trim = $prefix; |
|
70 | + } |
|
71 | + return $prefix.trim($this->removePrefix($trim, $string)); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param string $prefix |
|
76 | - * @param string $string |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function removePrefix($prefix, $string) |
|
80 | - { |
|
81 | - return $this->startsWith($prefix, $string) |
|
82 | - ? substr($string, strlen($prefix)) |
|
83 | - : $string; |
|
84 | - } |
|
74 | + /** |
|
75 | + * @param string $prefix |
|
76 | + * @param string $string |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function removePrefix($prefix, $string) |
|
80 | + { |
|
81 | + return $this->startsWith($prefix, $string) |
|
82 | + ? substr($string, strlen($prefix)) |
|
83 | + : $string; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @param string $string |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function snakeCase($string) |
|
91 | - { |
|
92 | - if (!ctype_lower($string)) { |
|
93 | - $string = preg_replace('/\s+/u', '', $string); |
|
94 | - $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string); |
|
95 | - $string = function_exists('mb_strtolower') |
|
96 | - ? mb_strtolower($string, 'UTF-8') |
|
97 | - : strtolower($string); |
|
98 | - } |
|
99 | - return str_replace('-', '_', $string); |
|
100 | - } |
|
86 | + /** |
|
87 | + * @param string $string |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function snakeCase($string) |
|
91 | + { |
|
92 | + if (!ctype_lower($string)) { |
|
93 | + $string = preg_replace('/\s+/u', '', $string); |
|
94 | + $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string); |
|
95 | + $string = function_exists('mb_strtolower') |
|
96 | + ? mb_strtolower($string, 'UTF-8') |
|
97 | + : strtolower($string); |
|
98 | + } |
|
99 | + return str_replace('-', '_', $string); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * @param string $needle |
|
104 | - * @param string $haystack |
|
105 | - * @return bool |
|
106 | - */ |
|
107 | - public function startsWith($needle, $haystack) |
|
108 | - { |
|
109 | - return substr($haystack, 0, strlen($needle)) === $needle; |
|
110 | - } |
|
102 | + /** |
|
103 | + * @param string $needle |
|
104 | + * @param string $haystack |
|
105 | + * @return bool |
|
106 | + */ |
|
107 | + public function startsWith($needle, $haystack) |
|
108 | + { |
|
109 | + return substr($haystack, 0, strlen($needle)) === $needle; |
|
110 | + } |
|
111 | 111 | } |
@@ -1,476 +1,476 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'settings.general.style' => [ |
|
5 | - 'default' => 'default', |
|
6 | - 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | - 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | - 'options' => [ |
|
9 | - 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | - 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | - 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | - 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | - 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | - 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | - 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | - 'divi' => 'Theme: Divi (v3)', |
|
17 | - 'materialize' => 'Theme: Materialize', |
|
18 | - 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | - 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | - 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | - ], |
|
22 | - 'type' => 'select', |
|
23 | - ], |
|
24 | - 'settings.general.require.approval' => [ |
|
25 | - 'default' => 'no', |
|
26 | - 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | - 'label' => __('Require Approval', 'site-reviews'), |
|
28 | - 'type' => 'yes_no', |
|
29 | - ], |
|
30 | - 'settings.general.require.login' => [ |
|
31 | - 'default' => 'no', |
|
32 | - 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | - 'label' => __('Require Login', 'site-reviews'), |
|
34 | - 'type' => 'yes_no', |
|
35 | - ], |
|
36 | - 'settings.general.require.login_register' => [ |
|
37 | - 'default' => 'no', |
|
38 | - 'depends_on' => [ |
|
39 | - 'settings.general.require.login' => 'yes', |
|
40 | - ], |
|
41 | - 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | - '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | - ), |
|
44 | - 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | - 'type' => 'yes_no', |
|
46 | - ], |
|
47 | - 'settings.general.support.multilingual' => [ |
|
48 | - 'default' => '', |
|
49 | - 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | - 'label' => __('Multilingual', 'site-reviews'), |
|
51 | - 'options' => [ |
|
52 | - '' => __('No Integration', 'site-reviews'), |
|
53 | - 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | - 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
55 | - ], |
|
56 | - 'type' => 'select', |
|
57 | - ], |
|
58 | - 'settings.general.support.rebusify' => [ |
|
59 | - 'default' => 'no', |
|
60 | - 'description' => sprintf(__('Integrate with the %s and sync your reviews to the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | - '<a href="https://rebusify.com">Rebusify Confidence System</a>' |
|
62 | - ), |
|
63 | - 'label' => __('Integrate with Rebusify', 'site-reviews'), |
|
64 | - 'type' => 'yes_no', |
|
65 | - ], |
|
66 | - 'settings.general.support.rebusify_api_key' => [ |
|
67 | - 'default' => '', |
|
68 | - 'depends_on' => [ |
|
69 | - 'settings.general.support.rebusify' => ['yes'], |
|
70 | - ], |
|
71 | - 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
72 | - '<a href="https://rebusify.com">rebusify.com</a>' |
|
73 | - ), |
|
74 | - 'label' => __('Rebusify API key', 'site-reviews'), |
|
75 | - 'type' => 'text', |
|
76 | - ], |
|
77 | - 'settings.general.notifications' => [ |
|
78 | - 'default' => [], |
|
79 | - 'label' => __('Notifications', 'site-reviews'), |
|
80 | - 'options' => [ |
|
81 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
82 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
83 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
84 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
85 | - ], |
|
86 | - 'type' => 'checkbox', |
|
87 | - ], |
|
88 | - 'settings.general.notification_email' => [ |
|
89 | - 'default' => '', |
|
90 | - 'depends_on' => [ |
|
91 | - 'settings.general.notifications' => ['custom'], |
|
92 | - ], |
|
93 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
94 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
95 | - 'type' => 'text', |
|
96 | - ], |
|
97 | - 'settings.general.notification_slack' => [ |
|
98 | - 'default' => '', |
|
99 | - 'depends_on' => [ |
|
100 | - 'settings.general.notifications' => ['slack'], |
|
101 | - ], |
|
102 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
103 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
104 | - ), |
|
105 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
106 | - 'type' => 'text', |
|
107 | - ], |
|
108 | - 'settings.general.notification_message' => [ |
|
109 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
110 | - 'depends_on' => [ |
|
111 | - 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
112 | - ], |
|
113 | - 'description' => __( |
|
114 | - 'To restore the default text, save an empty template. '. |
|
115 | - 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
116 | - '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
117 | - '<br><code>{review_title}</code> The review title'. |
|
118 | - '<br><code>{review_content}</code> The review content'. |
|
119 | - '<br><code>{review_author}</code> The review author'. |
|
120 | - '<br><code>{review_email}</code> The email of the review author'. |
|
121 | - '<br><code>{review_ip}</code> The IP address of the review author'. |
|
122 | - '<br><code>{review_link}</code> The link to edit/view a review', |
|
123 | - 'site-reviews' |
|
124 | - ), |
|
125 | - 'label' => __('Notification Template', 'site-reviews'), |
|
126 | - 'rows' => 10, |
|
127 | - 'type' => 'code', |
|
128 | - ], |
|
129 | - 'settings.reviews.date.format' => [ |
|
130 | - 'default' => '', |
|
131 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
132 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
133 | - ), |
|
134 | - 'label' => __('Date Format', 'site-reviews'), |
|
135 | - 'options' => [ |
|
136 | - '' => __('Use the default date format', 'site-reviews'), |
|
137 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
138 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
139 | - ], |
|
140 | - 'type' => 'select', |
|
141 | - ], |
|
142 | - 'settings.reviews.date.custom' => [ |
|
143 | - 'default' => get_option('date_format'), |
|
144 | - 'depends_on' => [ |
|
145 | - 'settings.reviews.date.format' => 'custom', |
|
146 | - ], |
|
147 | - 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
148 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
149 | - 'type' => 'text', |
|
150 | - ], |
|
151 | - 'settings.reviews.assigned_links' => [ |
|
152 | - 'default' => 'no', |
|
153 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
154 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
155 | - 'type' => 'yes_no', |
|
156 | - ], |
|
157 | - 'settings.reviews.avatars' => [ |
|
158 | - 'default' => 'no', |
|
159 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
160 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
161 | - 'type' => 'yes_no', |
|
162 | - ], |
|
163 | - 'settings.reviews.avatars_regenerate' => [ |
|
164 | - 'default' => 'no', |
|
165 | - 'depends_on' => [ |
|
166 | - 'settings.reviews.avatars' => 'yes', |
|
167 | - ], |
|
168 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
169 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
170 | - 'type' => 'yes_no', |
|
171 | - ], |
|
172 | - 'settings.reviews.avatars_size' => [ |
|
173 | - 'default' => 40, |
|
174 | - 'depends_on' => [ |
|
175 | - 'settings.reviews.avatars' => 'yes', |
|
176 | - ], |
|
177 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
178 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
179 | - 'type' => 'number', |
|
180 | - ], |
|
181 | - 'settings.reviews.excerpts' => [ |
|
182 | - 'default' => 'yes', |
|
183 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
184 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
185 | - 'type' => 'yes_no', |
|
186 | - ], |
|
187 | - 'settings.reviews.excerpts_length' => [ |
|
188 | - 'default' => 55, |
|
189 | - 'depends_on' => [ |
|
190 | - 'settings.reviews.excerpts' => 'yes', |
|
191 | - ], |
|
192 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
193 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
194 | - 'type' => 'number', |
|
195 | - ], |
|
196 | - 'settings.reviews.fallback' => [ |
|
197 | - 'default' => 'no', |
|
198 | - 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
199 | - '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
200 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
201 | - ), |
|
202 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
203 | - 'type' => 'yes_no', |
|
204 | - ], |
|
205 | - 'settings.schema.type.default' => [ |
|
206 | - 'default' => 'LocalBusiness', |
|
207 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
208 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
209 | - 'options' => [ |
|
210 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
211 | - 'Product' => __('Product', 'site-reviews'), |
|
212 | - 'custom' => __('Custom', 'site-reviews'), |
|
213 | - ], |
|
214 | - 'type' => 'select', |
|
215 | - ], |
|
216 | - 'settings.schema.type.custom' => [ |
|
217 | - 'default' => '', |
|
218 | - 'depends_on' => [ |
|
219 | - 'settings.schema.type.default' => 'custom', |
|
220 | - ], |
|
221 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
222 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
223 | - 'type' => 'text', |
|
224 | - ], |
|
225 | - 'settings.schema.name.default' => [ |
|
226 | - 'default' => 'post', |
|
227 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
228 | - 'label' => __('Default Name', 'site-reviews'), |
|
229 | - 'options' => [ |
|
230 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
231 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
232 | - ], |
|
233 | - 'type' => 'select', |
|
234 | - ], |
|
235 | - 'settings.schema.name.custom' => [ |
|
236 | - 'default' => '', |
|
237 | - 'depends_on' => [ |
|
238 | - 'settings.schema.name.default' => 'custom', |
|
239 | - ], |
|
240 | - 'label' => __('Custom Name', 'site-reviews'), |
|
241 | - 'type' => 'text', |
|
242 | - ], |
|
243 | - 'settings.schema.description.default' => [ |
|
244 | - 'default' => 'post', |
|
245 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
246 | - 'label' => __('Default Description', 'site-reviews'), |
|
247 | - 'options' => [ |
|
248 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
249 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
250 | - ], |
|
251 | - 'type' => 'select', |
|
252 | - ], |
|
253 | - 'settings.schema.description.custom' => [ |
|
254 | - 'default' => '', |
|
255 | - 'depends_on' => [ |
|
256 | - 'settings.schema.description.default' => 'custom', |
|
257 | - ], |
|
258 | - 'label' => __('Custom Description', 'site-reviews'), |
|
259 | - 'type' => 'text', |
|
260 | - ], |
|
261 | - 'settings.schema.url.default' => [ |
|
262 | - 'default' => 'post', |
|
263 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
264 | - 'label' => __('Default URL', 'site-reviews'), |
|
265 | - 'options' => [ |
|
266 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
267 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
268 | - ], |
|
269 | - 'type' => 'select', |
|
270 | - ], |
|
271 | - 'settings.schema.url.custom' => [ |
|
272 | - 'default' => '', |
|
273 | - 'depends_on' => [ |
|
274 | - 'settings.schema.url.default' => 'custom', |
|
275 | - ], |
|
276 | - 'label' => __('Custom URL', 'site-reviews'), |
|
277 | - 'type' => 'text', |
|
278 | - ], |
|
279 | - 'settings.schema.image.default' => [ |
|
280 | - 'default' => 'post', |
|
281 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
282 | - 'label' => __('Default Image', 'site-reviews'), |
|
283 | - 'options' => [ |
|
284 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
285 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
286 | - ], |
|
287 | - 'type' => 'select', |
|
288 | - ], |
|
289 | - 'settings.schema.image.custom' => [ |
|
290 | - 'default' => '', |
|
291 | - 'depends_on' => [ |
|
292 | - 'settings.schema.image.default' => 'custom', |
|
293 | - ], |
|
294 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
295 | - 'type' => 'text', |
|
296 | - ], |
|
297 | - 'settings.schema.address' => [ |
|
298 | - 'default' => '', |
|
299 | - 'depends_on' => [ |
|
300 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
301 | - ], |
|
302 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
303 | - 'label' => __('Address', 'site-reviews'), |
|
304 | - 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
305 | - 'type' => 'text', |
|
306 | - ], |
|
307 | - 'settings.schema.telephone' => [ |
|
308 | - 'default' => '', |
|
309 | - 'depends_on' => [ |
|
310 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
311 | - ], |
|
312 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
313 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
314 | - 'placeholder' => '+1 (877) 273-3049', |
|
315 | - 'type' => 'text', |
|
316 | - ], |
|
317 | - 'settings.schema.pricerange' => [ |
|
318 | - 'default' => '', |
|
319 | - 'depends_on' => [ |
|
320 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
321 | - ], |
|
322 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
323 | - 'label' => __('Price Range', 'site-reviews'), |
|
324 | - 'placeholder' => '$$-$$$', |
|
325 | - 'type' => 'text', |
|
326 | - ], |
|
327 | - 'settings.schema.offertype' => [ |
|
328 | - 'default' => 'AggregateOffer', |
|
329 | - 'depends_on' => [ |
|
330 | - 'settings.schema.type.default' => 'Product', |
|
331 | - ], |
|
332 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
333 | - 'label' => __('Offer Type', 'site-reviews'), |
|
334 | - 'options' => [ |
|
335 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
336 | - 'Offer' => __('Offer', 'site-reviews'), |
|
337 | - ], |
|
338 | - 'type' => 'select', |
|
339 | - ], |
|
340 | - 'settings.schema.price' => [ |
|
341 | - 'default' => '', |
|
342 | - 'depends_on' => [ |
|
343 | - 'settings.schema.type.default' => 'Product', |
|
344 | - 'settings.schema.offertype' => 'Offer', |
|
345 | - ], |
|
346 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
347 | - 'label' => __('Price', 'site-reviews'), |
|
348 | - 'placeholder' => '50.00', |
|
349 | - 'type' => 'text', |
|
350 | - ], |
|
351 | - 'settings.schema.lowprice' => [ |
|
352 | - 'default' => '', |
|
353 | - 'depends_on' => [ |
|
354 | - 'settings.schema.type.default' => 'Product', |
|
355 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
356 | - ], |
|
357 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
358 | - 'label' => __('Low Price', 'site-reviews'), |
|
359 | - 'placeholder' => '10.00', |
|
360 | - 'type' => 'text', |
|
361 | - ], |
|
362 | - 'settings.schema.highprice' => [ |
|
363 | - 'default' => '', |
|
364 | - 'depends_on' => [ |
|
365 | - 'settings.schema.type.default' => 'Product', |
|
366 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
367 | - ], |
|
368 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
369 | - 'label' => __('High Price', 'site-reviews'), |
|
370 | - 'placeholder' => '100.00', |
|
371 | - 'type' => 'text', |
|
372 | - ], |
|
373 | - 'settings.schema.pricecurrency' => [ |
|
374 | - 'default' => '', |
|
375 | - 'depends_on' => [ |
|
376 | - 'settings.schema.type.default' => 'Product', |
|
377 | - ], |
|
378 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
379 | - 'label' => __('Price Currency', 'site-reviews'), |
|
380 | - 'placeholder' => 'USD', |
|
381 | - 'type' => 'text', |
|
382 | - ], |
|
383 | - 'settings.submissions.required' => [ |
|
384 | - 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
385 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
386 | - 'label' => __('Required Fields', 'site-reviews'), |
|
387 | - 'options' => [ |
|
388 | - 'rating' => __('Rating', 'site-reviews'), |
|
389 | - 'title' => __('Title', 'site-reviews'), |
|
390 | - 'content' => __('Review', 'site-reviews'), |
|
391 | - 'name' => __('Name', 'site-reviews'), |
|
392 | - 'email' => __('Email', 'site-reviews'), |
|
393 | - 'terms' => __('Terms', 'site-reviews'), |
|
394 | - ], |
|
395 | - 'type' => 'checkbox', |
|
396 | - ], |
|
397 | - 'settings.submissions.recaptcha.integration' => [ |
|
398 | - 'default' => '', |
|
399 | - 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
400 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
401 | - 'options' => [ |
|
402 | - '' => 'Do not use reCAPTCHA', |
|
403 | - 'all' => 'Use reCAPTCHA', |
|
404 | - 'guest' => 'Use reCAPTCHA only for guest users', |
|
405 | - ], |
|
406 | - 'type' => 'select', |
|
407 | - ], |
|
408 | - 'settings.submissions.recaptcha.key' => [ |
|
409 | - 'default' => '', |
|
410 | - 'depends_on' => [ |
|
411 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
412 | - ], |
|
413 | - 'label' => __('Site Key', 'site-reviews'), |
|
414 | - 'type' => 'text', |
|
415 | - ], |
|
416 | - 'settings.submissions.recaptcha.secret' => [ |
|
417 | - 'default' => '', |
|
418 | - 'depends_on' => [ |
|
419 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
420 | - ], |
|
421 | - 'label' => __('Site Secret', 'site-reviews'), |
|
422 | - 'type' => 'text', |
|
423 | - ], |
|
424 | - 'settings.submissions.recaptcha.position' => [ |
|
425 | - 'default' => 'bottomleft', |
|
426 | - 'depends_on' => [ |
|
427 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
428 | - ], |
|
429 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
430 | - 'label' => __('Badge Position', 'site-reviews'), |
|
431 | - 'options' => [ |
|
432 | - 'bottomleft' => 'Bottom Left', |
|
433 | - 'bottomright' => 'Bottom Right', |
|
434 | - 'inline' => 'Inline', |
|
435 | - ], |
|
436 | - 'type' => 'select', |
|
437 | - ], |
|
438 | - 'settings.submissions.akismet' => [ |
|
439 | - 'default' => 'no', |
|
440 | - 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
441 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
442 | - 'type' => 'yes_no', |
|
443 | - ], |
|
444 | - 'settings.submissions.blacklist.integration' => [ |
|
445 | - 'default' => '', |
|
446 | - 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
447 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
448 | - ), |
|
449 | - 'label' => __('Blacklist', 'site-reviews'), |
|
450 | - 'options' => [ |
|
451 | - '' => 'Use the Site Reviews Blacklist', |
|
452 | - 'comments' => 'Use the WordPress Comment Blacklist', |
|
453 | - ], |
|
454 | - 'type' => 'select', |
|
455 | - ], |
|
456 | - 'settings.submissions.blacklist.entries' => [ |
|
457 | - 'default' => '', |
|
458 | - 'depends_on' => [ |
|
459 | - 'settings.submissions.blacklist.integration' => [''], |
|
460 | - ], |
|
461 | - 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
462 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
463 | - 'rows' => 10, |
|
464 | - 'type' => 'code', |
|
465 | - ], |
|
466 | - 'settings.submissions.blacklist.action' => [ |
|
467 | - 'default' => 'unapprove', |
|
468 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
469 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
470 | - 'options' => [ |
|
471 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
472 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
473 | - ], |
|
474 | - 'type' => 'select', |
|
475 | - ], |
|
4 | + 'settings.general.style' => [ |
|
5 | + 'default' => 'default', |
|
6 | + 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | + 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | + 'options' => [ |
|
9 | + 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | + 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | + 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | + 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | + 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | + 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | + 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | + 'divi' => 'Theme: Divi (v3)', |
|
17 | + 'materialize' => 'Theme: Materialize', |
|
18 | + 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | + 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | + 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | + ], |
|
22 | + 'type' => 'select', |
|
23 | + ], |
|
24 | + 'settings.general.require.approval' => [ |
|
25 | + 'default' => 'no', |
|
26 | + 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | + 'label' => __('Require Approval', 'site-reviews'), |
|
28 | + 'type' => 'yes_no', |
|
29 | + ], |
|
30 | + 'settings.general.require.login' => [ |
|
31 | + 'default' => 'no', |
|
32 | + 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | + 'label' => __('Require Login', 'site-reviews'), |
|
34 | + 'type' => 'yes_no', |
|
35 | + ], |
|
36 | + 'settings.general.require.login_register' => [ |
|
37 | + 'default' => 'no', |
|
38 | + 'depends_on' => [ |
|
39 | + 'settings.general.require.login' => 'yes', |
|
40 | + ], |
|
41 | + 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | + '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | + ), |
|
44 | + 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | + 'type' => 'yes_no', |
|
46 | + ], |
|
47 | + 'settings.general.support.multilingual' => [ |
|
48 | + 'default' => '', |
|
49 | + 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | + 'label' => __('Multilingual', 'site-reviews'), |
|
51 | + 'options' => [ |
|
52 | + '' => __('No Integration', 'site-reviews'), |
|
53 | + 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | + 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
55 | + ], |
|
56 | + 'type' => 'select', |
|
57 | + ], |
|
58 | + 'settings.general.support.rebusify' => [ |
|
59 | + 'default' => 'no', |
|
60 | + 'description' => sprintf(__('Integrate with the %s and sync your reviews to the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | + '<a href="https://rebusify.com">Rebusify Confidence System</a>' |
|
62 | + ), |
|
63 | + 'label' => __('Integrate with Rebusify', 'site-reviews'), |
|
64 | + 'type' => 'yes_no', |
|
65 | + ], |
|
66 | + 'settings.general.support.rebusify_api_key' => [ |
|
67 | + 'default' => '', |
|
68 | + 'depends_on' => [ |
|
69 | + 'settings.general.support.rebusify' => ['yes'], |
|
70 | + ], |
|
71 | + 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
72 | + '<a href="https://rebusify.com">rebusify.com</a>' |
|
73 | + ), |
|
74 | + 'label' => __('Rebusify API key', 'site-reviews'), |
|
75 | + 'type' => 'text', |
|
76 | + ], |
|
77 | + 'settings.general.notifications' => [ |
|
78 | + 'default' => [], |
|
79 | + 'label' => __('Notifications', 'site-reviews'), |
|
80 | + 'options' => [ |
|
81 | + 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
82 | + 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
83 | + 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
84 | + 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
85 | + ], |
|
86 | + 'type' => 'checkbox', |
|
87 | + ], |
|
88 | + 'settings.general.notification_email' => [ |
|
89 | + 'default' => '', |
|
90 | + 'depends_on' => [ |
|
91 | + 'settings.general.notifications' => ['custom'], |
|
92 | + ], |
|
93 | + 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
94 | + 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
95 | + 'type' => 'text', |
|
96 | + ], |
|
97 | + 'settings.general.notification_slack' => [ |
|
98 | + 'default' => '', |
|
99 | + 'depends_on' => [ |
|
100 | + 'settings.general.notifications' => ['slack'], |
|
101 | + ], |
|
102 | + 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
103 | + '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
104 | + ), |
|
105 | + 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
106 | + 'type' => 'text', |
|
107 | + ], |
|
108 | + 'settings.general.notification_message' => [ |
|
109 | + 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
110 | + 'depends_on' => [ |
|
111 | + 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
112 | + ], |
|
113 | + 'description' => __( |
|
114 | + 'To restore the default text, save an empty template. '. |
|
115 | + 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
116 | + '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
117 | + '<br><code>{review_title}</code> The review title'. |
|
118 | + '<br><code>{review_content}</code> The review content'. |
|
119 | + '<br><code>{review_author}</code> The review author'. |
|
120 | + '<br><code>{review_email}</code> The email of the review author'. |
|
121 | + '<br><code>{review_ip}</code> The IP address of the review author'. |
|
122 | + '<br><code>{review_link}</code> The link to edit/view a review', |
|
123 | + 'site-reviews' |
|
124 | + ), |
|
125 | + 'label' => __('Notification Template', 'site-reviews'), |
|
126 | + 'rows' => 10, |
|
127 | + 'type' => 'code', |
|
128 | + ], |
|
129 | + 'settings.reviews.date.format' => [ |
|
130 | + 'default' => '', |
|
131 | + 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
132 | + '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
133 | + ), |
|
134 | + 'label' => __('Date Format', 'site-reviews'), |
|
135 | + 'options' => [ |
|
136 | + '' => __('Use the default date format', 'site-reviews'), |
|
137 | + 'relative' => __('Use a relative date format', 'site-reviews'), |
|
138 | + 'custom' => __('Use a custom date format', 'site-reviews'), |
|
139 | + ], |
|
140 | + 'type' => 'select', |
|
141 | + ], |
|
142 | + 'settings.reviews.date.custom' => [ |
|
143 | + 'default' => get_option('date_format'), |
|
144 | + 'depends_on' => [ |
|
145 | + 'settings.reviews.date.format' => 'custom', |
|
146 | + ], |
|
147 | + 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
148 | + 'label' => __('Custom Date Format', 'site-reviews'), |
|
149 | + 'type' => 'text', |
|
150 | + ], |
|
151 | + 'settings.reviews.assigned_links' => [ |
|
152 | + 'default' => 'no', |
|
153 | + 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
154 | + 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
155 | + 'type' => 'yes_no', |
|
156 | + ], |
|
157 | + 'settings.reviews.avatars' => [ |
|
158 | + 'default' => 'no', |
|
159 | + 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
160 | + 'label' => __('Enable Avatars', 'site-reviews'), |
|
161 | + 'type' => 'yes_no', |
|
162 | + ], |
|
163 | + 'settings.reviews.avatars_regenerate' => [ |
|
164 | + 'default' => 'no', |
|
165 | + 'depends_on' => [ |
|
166 | + 'settings.reviews.avatars' => 'yes', |
|
167 | + ], |
|
168 | + 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
169 | + 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
170 | + 'type' => 'yes_no', |
|
171 | + ], |
|
172 | + 'settings.reviews.avatars_size' => [ |
|
173 | + 'default' => 40, |
|
174 | + 'depends_on' => [ |
|
175 | + 'settings.reviews.avatars' => 'yes', |
|
176 | + ], |
|
177 | + 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
178 | + 'label' => __('Avatar Size', 'site-reviews'), |
|
179 | + 'type' => 'number', |
|
180 | + ], |
|
181 | + 'settings.reviews.excerpts' => [ |
|
182 | + 'default' => 'yes', |
|
183 | + 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
184 | + 'label' => __('Enable Excerpts', 'site-reviews'), |
|
185 | + 'type' => 'yes_no', |
|
186 | + ], |
|
187 | + 'settings.reviews.excerpts_length' => [ |
|
188 | + 'default' => 55, |
|
189 | + 'depends_on' => [ |
|
190 | + 'settings.reviews.excerpts' => 'yes', |
|
191 | + ], |
|
192 | + 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
193 | + 'label' => __('Excerpt Length', 'site-reviews'), |
|
194 | + 'type' => 'number', |
|
195 | + ], |
|
196 | + 'settings.reviews.fallback' => [ |
|
197 | + 'default' => 'no', |
|
198 | + 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
199 | + '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
200 | + '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
201 | + ), |
|
202 | + 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
203 | + 'type' => 'yes_no', |
|
204 | + ], |
|
205 | + 'settings.schema.type.default' => [ |
|
206 | + 'default' => 'LocalBusiness', |
|
207 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
208 | + 'label' => __('Default Schema Type', 'site-reviews'), |
|
209 | + 'options' => [ |
|
210 | + 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
211 | + 'Product' => __('Product', 'site-reviews'), |
|
212 | + 'custom' => __('Custom', 'site-reviews'), |
|
213 | + ], |
|
214 | + 'type' => 'select', |
|
215 | + ], |
|
216 | + 'settings.schema.type.custom' => [ |
|
217 | + 'default' => '', |
|
218 | + 'depends_on' => [ |
|
219 | + 'settings.schema.type.default' => 'custom', |
|
220 | + ], |
|
221 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
222 | + 'label' => __('Custom Schema Type', 'site-reviews'), |
|
223 | + 'type' => 'text', |
|
224 | + ], |
|
225 | + 'settings.schema.name.default' => [ |
|
226 | + 'default' => 'post', |
|
227 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
228 | + 'label' => __('Default Name', 'site-reviews'), |
|
229 | + 'options' => [ |
|
230 | + 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
231 | + 'custom' => __('Enter a custom title', 'site-reviews'), |
|
232 | + ], |
|
233 | + 'type' => 'select', |
|
234 | + ], |
|
235 | + 'settings.schema.name.custom' => [ |
|
236 | + 'default' => '', |
|
237 | + 'depends_on' => [ |
|
238 | + 'settings.schema.name.default' => 'custom', |
|
239 | + ], |
|
240 | + 'label' => __('Custom Name', 'site-reviews'), |
|
241 | + 'type' => 'text', |
|
242 | + ], |
|
243 | + 'settings.schema.description.default' => [ |
|
244 | + 'default' => 'post', |
|
245 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
246 | + 'label' => __('Default Description', 'site-reviews'), |
|
247 | + 'options' => [ |
|
248 | + 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
249 | + 'custom' => __('Enter a custom description', 'site-reviews'), |
|
250 | + ], |
|
251 | + 'type' => 'select', |
|
252 | + ], |
|
253 | + 'settings.schema.description.custom' => [ |
|
254 | + 'default' => '', |
|
255 | + 'depends_on' => [ |
|
256 | + 'settings.schema.description.default' => 'custom', |
|
257 | + ], |
|
258 | + 'label' => __('Custom Description', 'site-reviews'), |
|
259 | + 'type' => 'text', |
|
260 | + ], |
|
261 | + 'settings.schema.url.default' => [ |
|
262 | + 'default' => 'post', |
|
263 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
264 | + 'label' => __('Default URL', 'site-reviews'), |
|
265 | + 'options' => [ |
|
266 | + 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
267 | + 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
268 | + ], |
|
269 | + 'type' => 'select', |
|
270 | + ], |
|
271 | + 'settings.schema.url.custom' => [ |
|
272 | + 'default' => '', |
|
273 | + 'depends_on' => [ |
|
274 | + 'settings.schema.url.default' => 'custom', |
|
275 | + ], |
|
276 | + 'label' => __('Custom URL', 'site-reviews'), |
|
277 | + 'type' => 'text', |
|
278 | + ], |
|
279 | + 'settings.schema.image.default' => [ |
|
280 | + 'default' => 'post', |
|
281 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
282 | + 'label' => __('Default Image', 'site-reviews'), |
|
283 | + 'options' => [ |
|
284 | + 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
285 | + 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
286 | + ], |
|
287 | + 'type' => 'select', |
|
288 | + ], |
|
289 | + 'settings.schema.image.custom' => [ |
|
290 | + 'default' => '', |
|
291 | + 'depends_on' => [ |
|
292 | + 'settings.schema.image.default' => 'custom', |
|
293 | + ], |
|
294 | + 'label' => __('Custom Image URL', 'site-reviews'), |
|
295 | + 'type' => 'text', |
|
296 | + ], |
|
297 | + 'settings.schema.address' => [ |
|
298 | + 'default' => '', |
|
299 | + 'depends_on' => [ |
|
300 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
301 | + ], |
|
302 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
303 | + 'label' => __('Address', 'site-reviews'), |
|
304 | + 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
305 | + 'type' => 'text', |
|
306 | + ], |
|
307 | + 'settings.schema.telephone' => [ |
|
308 | + 'default' => '', |
|
309 | + 'depends_on' => [ |
|
310 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
311 | + ], |
|
312 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
313 | + 'label' => __('Telephone Number', 'site-reviews'), |
|
314 | + 'placeholder' => '+1 (877) 273-3049', |
|
315 | + 'type' => 'text', |
|
316 | + ], |
|
317 | + 'settings.schema.pricerange' => [ |
|
318 | + 'default' => '', |
|
319 | + 'depends_on' => [ |
|
320 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
321 | + ], |
|
322 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
323 | + 'label' => __('Price Range', 'site-reviews'), |
|
324 | + 'placeholder' => '$$-$$$', |
|
325 | + 'type' => 'text', |
|
326 | + ], |
|
327 | + 'settings.schema.offertype' => [ |
|
328 | + 'default' => 'AggregateOffer', |
|
329 | + 'depends_on' => [ |
|
330 | + 'settings.schema.type.default' => 'Product', |
|
331 | + ], |
|
332 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
333 | + 'label' => __('Offer Type', 'site-reviews'), |
|
334 | + 'options' => [ |
|
335 | + 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
336 | + 'Offer' => __('Offer', 'site-reviews'), |
|
337 | + ], |
|
338 | + 'type' => 'select', |
|
339 | + ], |
|
340 | + 'settings.schema.price' => [ |
|
341 | + 'default' => '', |
|
342 | + 'depends_on' => [ |
|
343 | + 'settings.schema.type.default' => 'Product', |
|
344 | + 'settings.schema.offertype' => 'Offer', |
|
345 | + ], |
|
346 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
347 | + 'label' => __('Price', 'site-reviews'), |
|
348 | + 'placeholder' => '50.00', |
|
349 | + 'type' => 'text', |
|
350 | + ], |
|
351 | + 'settings.schema.lowprice' => [ |
|
352 | + 'default' => '', |
|
353 | + 'depends_on' => [ |
|
354 | + 'settings.schema.type.default' => 'Product', |
|
355 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
356 | + ], |
|
357 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
358 | + 'label' => __('Low Price', 'site-reviews'), |
|
359 | + 'placeholder' => '10.00', |
|
360 | + 'type' => 'text', |
|
361 | + ], |
|
362 | + 'settings.schema.highprice' => [ |
|
363 | + 'default' => '', |
|
364 | + 'depends_on' => [ |
|
365 | + 'settings.schema.type.default' => 'Product', |
|
366 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
367 | + ], |
|
368 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
369 | + 'label' => __('High Price', 'site-reviews'), |
|
370 | + 'placeholder' => '100.00', |
|
371 | + 'type' => 'text', |
|
372 | + ], |
|
373 | + 'settings.schema.pricecurrency' => [ |
|
374 | + 'default' => '', |
|
375 | + 'depends_on' => [ |
|
376 | + 'settings.schema.type.default' => 'Product', |
|
377 | + ], |
|
378 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
379 | + 'label' => __('Price Currency', 'site-reviews'), |
|
380 | + 'placeholder' => 'USD', |
|
381 | + 'type' => 'text', |
|
382 | + ], |
|
383 | + 'settings.submissions.required' => [ |
|
384 | + 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
385 | + 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
386 | + 'label' => __('Required Fields', 'site-reviews'), |
|
387 | + 'options' => [ |
|
388 | + 'rating' => __('Rating', 'site-reviews'), |
|
389 | + 'title' => __('Title', 'site-reviews'), |
|
390 | + 'content' => __('Review', 'site-reviews'), |
|
391 | + 'name' => __('Name', 'site-reviews'), |
|
392 | + 'email' => __('Email', 'site-reviews'), |
|
393 | + 'terms' => __('Terms', 'site-reviews'), |
|
394 | + ], |
|
395 | + 'type' => 'checkbox', |
|
396 | + ], |
|
397 | + 'settings.submissions.recaptcha.integration' => [ |
|
398 | + 'default' => '', |
|
399 | + 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
400 | + 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
401 | + 'options' => [ |
|
402 | + '' => 'Do not use reCAPTCHA', |
|
403 | + 'all' => 'Use reCAPTCHA', |
|
404 | + 'guest' => 'Use reCAPTCHA only for guest users', |
|
405 | + ], |
|
406 | + 'type' => 'select', |
|
407 | + ], |
|
408 | + 'settings.submissions.recaptcha.key' => [ |
|
409 | + 'default' => '', |
|
410 | + 'depends_on' => [ |
|
411 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
412 | + ], |
|
413 | + 'label' => __('Site Key', 'site-reviews'), |
|
414 | + 'type' => 'text', |
|
415 | + ], |
|
416 | + 'settings.submissions.recaptcha.secret' => [ |
|
417 | + 'default' => '', |
|
418 | + 'depends_on' => [ |
|
419 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
420 | + ], |
|
421 | + 'label' => __('Site Secret', 'site-reviews'), |
|
422 | + 'type' => 'text', |
|
423 | + ], |
|
424 | + 'settings.submissions.recaptcha.position' => [ |
|
425 | + 'default' => 'bottomleft', |
|
426 | + 'depends_on' => [ |
|
427 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
428 | + ], |
|
429 | + 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
430 | + 'label' => __('Badge Position', 'site-reviews'), |
|
431 | + 'options' => [ |
|
432 | + 'bottomleft' => 'Bottom Left', |
|
433 | + 'bottomright' => 'Bottom Right', |
|
434 | + 'inline' => 'Inline', |
|
435 | + ], |
|
436 | + 'type' => 'select', |
|
437 | + ], |
|
438 | + 'settings.submissions.akismet' => [ |
|
439 | + 'default' => 'no', |
|
440 | + 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
441 | + 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
442 | + 'type' => 'yes_no', |
|
443 | + ], |
|
444 | + 'settings.submissions.blacklist.integration' => [ |
|
445 | + 'default' => '', |
|
446 | + 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
447 | + '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
448 | + ), |
|
449 | + 'label' => __('Blacklist', 'site-reviews'), |
|
450 | + 'options' => [ |
|
451 | + '' => 'Use the Site Reviews Blacklist', |
|
452 | + 'comments' => 'Use the WordPress Comment Blacklist', |
|
453 | + ], |
|
454 | + 'type' => 'select', |
|
455 | + ], |
|
456 | + 'settings.submissions.blacklist.entries' => [ |
|
457 | + 'default' => '', |
|
458 | + 'depends_on' => [ |
|
459 | + 'settings.submissions.blacklist.integration' => [''], |
|
460 | + ], |
|
461 | + 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
462 | + 'label' => __('Review Blacklist', 'site-reviews'), |
|
463 | + 'rows' => 10, |
|
464 | + 'type' => 'code', |
|
465 | + ], |
|
466 | + 'settings.submissions.blacklist.action' => [ |
|
467 | + 'default' => 'unapprove', |
|
468 | + 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
469 | + 'label' => __('Blacklist Action', 'site-reviews'), |
|
470 | + 'options' => [ |
|
471 | + 'unapprove' => __('Require approval', 'site-reviews'), |
|
472 | + 'reject' => __('Reject submission', 'site-reviews'), |
|
473 | + ], |
|
474 | + 'type' => 'select', |
|
475 | + ], |
|
476 | 476 | ]; |