@@ -7,284 +7,284 @@ |
||
7 | 7 | |
8 | 8 | final class Application extends Container |
9 | 9 | { |
10 | - const CAPABILITY = 'edit_others_posts'; |
|
11 | - const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
12 | - const ID = 'site-reviews'; |
|
13 | - const PAGED_QUERY_VAR = 'reviews-page'; |
|
14 | - const POST_TYPE = 'site-review'; |
|
15 | - const PREFIX = 'glsr_'; |
|
16 | - const TAXONOMY = 'site-review-category'; |
|
10 | + const CAPABILITY = 'edit_others_posts'; |
|
11 | + const CRON_EVENT = 'site-reviews/schedule/session/purge'; |
|
12 | + const ID = 'site-reviews'; |
|
13 | + const PAGED_QUERY_VAR = 'reviews-page'; |
|
14 | + const POST_TYPE = 'site-review'; |
|
15 | + const PREFIX = 'glsr_'; |
|
16 | + const TAXONOMY = 'site-review-category'; |
|
17 | 17 | |
18 | - public $defaults; |
|
19 | - public $deprecated = []; |
|
20 | - public $file; |
|
21 | - public $languages; |
|
22 | - public $mceShortcodes = []; //defined elsewhere |
|
23 | - public $name; |
|
24 | - public $reviewTypes; |
|
25 | - public $schemas = []; //defined elsewhere |
|
26 | - public $version; |
|
18 | + public $defaults; |
|
19 | + public $deprecated = []; |
|
20 | + public $file; |
|
21 | + public $languages; |
|
22 | + public $mceShortcodes = []; //defined elsewhere |
|
23 | + public $name; |
|
24 | + public $reviewTypes; |
|
25 | + public $schemas = []; //defined elsewhere |
|
26 | + public $version; |
|
27 | 27 | |
28 | - public function __construct() |
|
29 | - { |
|
30 | - static::$instance = $this; |
|
31 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
32 | - $plugin = get_file_data($this->file, [ |
|
33 | - 'languages' => 'Domain Path', |
|
34 | - 'name' => 'Plugin Name', |
|
35 | - 'version' => 'Version', |
|
36 | - ], 'plugin'); |
|
37 | - array_walk($plugin, function ($value, $key) { |
|
38 | - $this->$key = $value; |
|
39 | - }); |
|
40 | - } |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + static::$instance = $this; |
|
31 | + $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
32 | + $plugin = get_file_data($this->file, [ |
|
33 | + 'languages' => 'Domain Path', |
|
34 | + 'name' => 'Plugin Name', |
|
35 | + 'version' => 'Version', |
|
36 | + ], 'plugin'); |
|
37 | + array_walk($plugin, function ($value, $key) { |
|
38 | + $this->$key = $value; |
|
39 | + }); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function activate() |
|
46 | - { |
|
47 | - $this->make(DefaultsManager::class)->set(); |
|
48 | - $this->scheduleCronJob(); |
|
49 | - $this->upgrade(); |
|
50 | - } |
|
42 | + /** |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function activate() |
|
46 | + { |
|
47 | + $this->make(DefaultsManager::class)->set(); |
|
48 | + $this->scheduleCronJob(); |
|
49 | + $this->upgrade(); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function catchFatalError() |
|
56 | - { |
|
57 | - $error = error_get_last(); |
|
58 | - if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) { |
|
59 | - return; |
|
60 | - } |
|
61 | - glsr_log()->error($error['message']); |
|
62 | - } |
|
52 | + /** |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function catchFatalError() |
|
56 | + { |
|
57 | + $error = error_get_last(); |
|
58 | + if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) { |
|
59 | + return; |
|
60 | + } |
|
61 | + glsr_log()->error($error['message']); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $name |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function config($name) |
|
69 | - { |
|
70 | - $configFile = $this->path('config/'.$name.'.php'); |
|
71 | - $config = file_exists($configFile) |
|
72 | - ? include $configFile |
|
73 | - : []; |
|
74 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
75 | - } |
|
64 | + /** |
|
65 | + * @param string $name |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function config($name) |
|
69 | + { |
|
70 | + $configFile = $this->path('config/'.$name.'.php'); |
|
71 | + $config = file_exists($configFile) |
|
72 | + ? include $configFile |
|
73 | + : []; |
|
74 | + return apply_filters('site-reviews/config/'.$name, $config); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $property |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function constant($property, $className = 'static') |
|
82 | - { |
|
83 | - $constant = $className.'::'.$property; |
|
84 | - return defined($constant) |
|
85 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
86 | - : ''; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @param string $property |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function constant($property, $className = 'static') |
|
82 | + { |
|
83 | + $constant = $className.'::'.$property; |
|
84 | + return defined($constant) |
|
85 | + ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
86 | + : ''; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - public function deactivate() |
|
93 | - { |
|
94 | - $this->unscheduleCronJob(); |
|
95 | - } |
|
89 | + /** |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + public function deactivate() |
|
93 | + { |
|
94 | + $this->unscheduleCronJob(); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @param string $view |
|
99 | - * @return void|string |
|
100 | - */ |
|
101 | - public function file($view) |
|
102 | - { |
|
103 | - $view.= '.php'; |
|
104 | - $filePaths = []; |
|
105 | - if (glsr(Helper::class)->startsWith('templates/', $view)) { |
|
106 | - $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view)); |
|
107 | - } |
|
108 | - $filePaths[] = $this->path($view); |
|
109 | - $filePaths[] = $this->path('views/'.$view); |
|
110 | - foreach ($filePaths as $file) { |
|
111 | - if (!file_exists($file)) { |
|
112 | - continue; |
|
113 | - } |
|
114 | - return $file; |
|
115 | - } |
|
116 | - } |
|
97 | + /** |
|
98 | + * @param string $view |
|
99 | + * @return void|string |
|
100 | + */ |
|
101 | + public function file($view) |
|
102 | + { |
|
103 | + $view.= '.php'; |
|
104 | + $filePaths = []; |
|
105 | + if (glsr(Helper::class)->startsWith('templates/', $view)) { |
|
106 | + $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view)); |
|
107 | + } |
|
108 | + $filePaths[] = $this->path($view); |
|
109 | + $filePaths[] = $this->path('views/'.$view); |
|
110 | + foreach ($filePaths as $file) { |
|
111 | + if (!file_exists($file)) { |
|
112 | + continue; |
|
113 | + } |
|
114 | + return $file; |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @return array |
|
120 | - */ |
|
121 | - public function getDefaults() |
|
122 | - { |
|
123 | - if (empty($this->defaults)) { |
|
124 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
125 | - $this->upgrade(); |
|
126 | - } |
|
127 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
128 | - } |
|
118 | + /** |
|
119 | + * @return array |
|
120 | + */ |
|
121 | + public function getDefaults() |
|
122 | + { |
|
123 | + if (empty($this->defaults)) { |
|
124 | + $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
125 | + $this->upgrade(); |
|
126 | + } |
|
127 | + return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @return bool |
|
132 | - */ |
|
133 | - public function getPermission($page = '') |
|
134 | - { |
|
135 | - $permissions = [ |
|
136 | - 'addons' => 'install_plugins', |
|
137 | - 'settings' => 'manage_options', |
|
138 | - // 'welcome' => 'activate_plugins', |
|
139 | - ]; |
|
140 | - return glsr_get($permissions, $page, $this->constant('CAPABILITY')); |
|
141 | - } |
|
130 | + /** |
|
131 | + * @return bool |
|
132 | + */ |
|
133 | + public function getPermission($page = '') |
|
134 | + { |
|
135 | + $permissions = [ |
|
136 | + 'addons' => 'install_plugins', |
|
137 | + 'settings' => 'manage_options', |
|
138 | + // 'welcome' => 'activate_plugins', |
|
139 | + ]; |
|
140 | + return glsr_get($permissions, $page, $this->constant('CAPABILITY')); |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function hasPermission($page = '') |
|
147 | - { |
|
148 | - $isAdmin = $this->isAdmin(); |
|
149 | - return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page))); |
|
150 | - } |
|
143 | + /** |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function hasPermission($page = '') |
|
147 | + { |
|
148 | + $isAdmin = $this->isAdmin(); |
|
149 | + return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page))); |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public function init() |
|
156 | - { |
|
157 | - $this->make(Actions::class)->run(); |
|
158 | - $this->make(Filters::class)->run(); |
|
159 | - } |
|
152 | + /** |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public function init() |
|
156 | + { |
|
157 | + $this->make(Actions::class)->run(); |
|
158 | + $this->make(Filters::class)->run(); |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * @return bool |
|
163 | - */ |
|
164 | - public function isAdmin() |
|
165 | - { |
|
166 | - return is_admin() && !wp_doing_ajax(); |
|
167 | - } |
|
161 | + /** |
|
162 | + * @return bool |
|
163 | + */ |
|
164 | + public function isAdmin() |
|
165 | + { |
|
166 | + return is_admin() && !wp_doing_ajax(); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * @param string $file |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function path($file = '', $realpath = true) |
|
174 | - { |
|
175 | - $path = plugin_dir_path($this->file); |
|
176 | - if (!$realpath) { |
|
177 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
178 | - } |
|
179 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
180 | - return apply_filters('site-reviews/path', $path, $file); |
|
181 | - } |
|
169 | + /** |
|
170 | + * @param string $file |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function path($file = '', $realpath = true) |
|
174 | + { |
|
175 | + $path = plugin_dir_path($this->file); |
|
176 | + if (!$realpath) { |
|
177 | + $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
178 | + } |
|
179 | + $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
180 | + return apply_filters('site-reviews/path', $path, $file); |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * @return void |
|
185 | - */ |
|
186 | - public function registerAddons() |
|
187 | - { |
|
188 | - do_action('site-reviews/addon/register', $this); |
|
189 | - } |
|
183 | + /** |
|
184 | + * @return void |
|
185 | + */ |
|
186 | + public function registerAddons() |
|
187 | + { |
|
188 | + do_action('site-reviews/addon/register', $this); |
|
189 | + } |
|
190 | 190 | |
191 | - /** |
|
192 | - * @return void |
|
193 | - */ |
|
194 | - public function registerLanguages() |
|
195 | - { |
|
196 | - load_plugin_textdomain(static::ID, false, |
|
197 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
198 | - ); |
|
199 | - } |
|
191 | + /** |
|
192 | + * @return void |
|
193 | + */ |
|
194 | + public function registerLanguages() |
|
195 | + { |
|
196 | + load_plugin_textdomain(static::ID, false, |
|
197 | + trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
198 | + ); |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - public function registerReviewTypes() |
|
205 | - { |
|
206 | - $types = apply_filters('site-reviews/addon/types', []); |
|
207 | - $this->reviewTypes = wp_parse_args($types, [ |
|
208 | - 'local' => __('Local', 'site-reviews'), |
|
209 | - ]); |
|
210 | - } |
|
201 | + /** |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + public function registerReviewTypes() |
|
205 | + { |
|
206 | + $types = apply_filters('site-reviews/addon/types', []); |
|
207 | + $this->reviewTypes = wp_parse_args($types, [ |
|
208 | + 'local' => __('Local', 'site-reviews'), |
|
209 | + ]); |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @param string $view |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - public function render($view, array $data = []) |
|
217 | - { |
|
218 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
219 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
220 | - if (!file_exists($file)) { |
|
221 | - glsr_log()->error('File not found: '.$file); |
|
222 | - return; |
|
223 | - } |
|
224 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
225 | - extract($data); |
|
226 | - include $file; |
|
227 | - } |
|
212 | + /** |
|
213 | + * @param string $view |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + public function render($view, array $data = []) |
|
217 | + { |
|
218 | + $view = apply_filters('site-reviews/render/view', $view, $data); |
|
219 | + $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
220 | + if (!file_exists($file)) { |
|
221 | + glsr_log()->error('File not found: '.$file); |
|
222 | + return; |
|
223 | + } |
|
224 | + $data = apply_filters('site-reviews/views/data', $data, $view); |
|
225 | + extract($data); |
|
226 | + include $file; |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function scheduleCronJob() |
|
233 | - { |
|
234 | - if (wp_next_scheduled(static::CRON_EVENT)) { |
|
235 | - return; |
|
236 | - } |
|
237 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
238 | - } |
|
229 | + /** |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function scheduleCronJob() |
|
233 | + { |
|
234 | + if (wp_next_scheduled(static::CRON_EVENT)) { |
|
235 | + return; |
|
236 | + } |
|
237 | + wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * @param string $file |
|
242 | - * @return string |
|
243 | - */ |
|
244 | - public function themePath($file = '') |
|
245 | - { |
|
246 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
247 | - } |
|
240 | + /** |
|
241 | + * @param string $file |
|
242 | + * @return string |
|
243 | + */ |
|
244 | + public function themePath($file = '') |
|
245 | + { |
|
246 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - public function unscheduleCronJob() |
|
253 | - { |
|
254 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
255 | - } |
|
249 | + /** |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + public function unscheduleCronJob() |
|
253 | + { |
|
254 | + wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * @return void |
|
259 | - */ |
|
260 | - public function upgrade() |
|
261 | - { |
|
262 | - $this->make(Upgrader::class)->run(); |
|
263 | - } |
|
257 | + /** |
|
258 | + * @return void |
|
259 | + */ |
|
260 | + public function upgrade() |
|
261 | + { |
|
262 | + $this->make(Upgrader::class)->run(); |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * @param mixed $upgrader |
|
267 | - * @return void |
|
268 | - * @action upgrader_process_complete |
|
269 | - */ |
|
270 | - public function upgraded($upgrader, array $data) |
|
271 | - { |
|
272 | - if (array_key_exists('plugins', $data) |
|
273 | - && in_array(plugin_basename($this->file), $data['plugins']) |
|
274 | - && 'update' === $data['action'] |
|
275 | - && 'plugin' === $data['type'] |
|
276 | - ) { |
|
277 | - $this->upgrade(); |
|
278 | - } |
|
279 | - } |
|
265 | + /** |
|
266 | + * @param mixed $upgrader |
|
267 | + * @return void |
|
268 | + * @action upgrader_process_complete |
|
269 | + */ |
|
270 | + public function upgraded($upgrader, array $data) |
|
271 | + { |
|
272 | + if (array_key_exists('plugins', $data) |
|
273 | + && in_array(plugin_basename($this->file), $data['plugins']) |
|
274 | + && 'update' === $data['action'] |
|
275 | + && 'plugin' === $data['type'] |
|
276 | + ) { |
|
277 | + $this->upgrade(); |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * @param string $path |
|
283 | - * @return string |
|
284 | - */ |
|
285 | - public function url($path = '') |
|
286 | - { |
|
287 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
288 | - return apply_filters('site-reviews/url', $url, $path); |
|
289 | - } |
|
281 | + /** |
|
282 | + * @param string $path |
|
283 | + * @return string |
|
284 | + */ |
|
285 | + public function url($path = '') |
|
286 | + { |
|
287 | + $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
288 | + return apply_filters('site-reviews/url', $url, $path); |
|
289 | + } |
|
290 | 290 | } |
@@ -18,11 +18,11 @@ |
||
18 | 18 | defined('WPINC') || die; |
19 | 19 | |
20 | 20 | if (!class_exists('GL_Plugin_Check_v3')) { |
21 | - require_once __DIR__.'/activate.php'; |
|
21 | + require_once __DIR__.'/activate.php'; |
|
22 | 22 | } |
23 | 23 | $check = new GL_Plugin_Check_v3(__FILE__); |
24 | 24 | if (!$check->canProceed()) { |
25 | - return; |
|
25 | + return; |
|
26 | 26 | } |
27 | 27 | require_once __DIR__.'/autoload.php'; |
28 | 28 | require_once __DIR__.'/compatibility.php'; |
@@ -16,204 +16,204 @@ |
||
16 | 16 | |
17 | 17 | class ReviewManager |
18 | 18 | { |
19 | - /** |
|
20 | - * @return false|Review |
|
21 | - */ |
|
22 | - public function create(CreateReview $command) |
|
23 | - { |
|
24 | - $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command); |
|
25 | - $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command); |
|
26 | - $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues); |
|
27 | - unset($reviewValues['json']); // @todo remove the need for this |
|
28 | - $postValues = [ |
|
29 | - 'comment_status' => 'closed', |
|
30 | - 'meta_input' => $reviewValues, |
|
31 | - 'ping_status' => 'closed', |
|
32 | - 'post_content' => $reviewValues['_content'], |
|
33 | - 'post_date' => $reviewValues['_date'], |
|
34 | - 'post_date_gmt' => get_gmt_from_date($reviewValues['_date']), |
|
35 | - 'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'], |
|
36 | - 'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted), |
|
37 | - 'post_title' => $reviewValues['_title'], |
|
38 | - 'post_type' => Application::POST_TYPE, |
|
39 | - ]; |
|
40 | - $postId = wp_insert_post($postValues, true); |
|
41 | - if (is_wp_error($postId)) { |
|
42 | - glsr_log()->error($postId->get_error_message())->debug($postValues); |
|
43 | - return false; |
|
44 | - } |
|
45 | - $this->setTerms($postId, $command->category); |
|
46 | - $review = $this->single(get_post($postId)); |
|
47 | - do_action('site-reviews/review/created', $review, $command); |
|
48 | - return $review; |
|
49 | - } |
|
19 | + /** |
|
20 | + * @return false|Review |
|
21 | + */ |
|
22 | + public function create(CreateReview $command) |
|
23 | + { |
|
24 | + $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command); |
|
25 | + $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command); |
|
26 | + $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues); |
|
27 | + unset($reviewValues['json']); // @todo remove the need for this |
|
28 | + $postValues = [ |
|
29 | + 'comment_status' => 'closed', |
|
30 | + 'meta_input' => $reviewValues, |
|
31 | + 'ping_status' => 'closed', |
|
32 | + 'post_content' => $reviewValues['_content'], |
|
33 | + 'post_date' => $reviewValues['_date'], |
|
34 | + 'post_date_gmt' => get_gmt_from_date($reviewValues['_date']), |
|
35 | + 'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'], |
|
36 | + 'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted), |
|
37 | + 'post_title' => $reviewValues['_title'], |
|
38 | + 'post_type' => Application::POST_TYPE, |
|
39 | + ]; |
|
40 | + $postId = wp_insert_post($postValues, true); |
|
41 | + if (is_wp_error($postId)) { |
|
42 | + glsr_log()->error($postId->get_error_message())->debug($postValues); |
|
43 | + return false; |
|
44 | + } |
|
45 | + $this->setTerms($postId, $command->category); |
|
46 | + $review = $this->single(get_post($postId)); |
|
47 | + do_action('site-reviews/review/created', $review, $command); |
|
48 | + return $review; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $metaReviewId |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function delete($metaReviewId) |
|
56 | - { |
|
57 | - if ($postId = $this->getPostId($metaReviewId)) { |
|
58 | - wp_delete_post($postId, true); |
|
59 | - } |
|
60 | - } |
|
51 | + /** |
|
52 | + * @param string $metaReviewId |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function delete($metaReviewId) |
|
56 | + { |
|
57 | + if ($postId = $this->getPostId($metaReviewId)) { |
|
58 | + wp_delete_post($postId, true); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return object |
|
64 | - */ |
|
65 | - public function get(array $args = []) |
|
66 | - { |
|
67 | - $args = glsr(ReviewsDefaults::class)->merge($args); |
|
68 | - $metaQuery = glsr(QueryBuilder::class)->buildQuery( |
|
69 | - ['assigned_to', 'email', 'ip_address', 'type', 'rating'], |
|
70 | - $args |
|
71 | - ); |
|
72 | - $taxQuery = glsr(QueryBuilder::class)->buildQuery( |
|
73 | - ['category'], |
|
74 | - ['category' => $this->normalizeTermIds($args['category'])] |
|
75 | - ); |
|
76 | - $paged = glsr(QueryBuilder::class)->getPaged( |
|
77 | - wp_validate_boolean($args['pagination']) |
|
78 | - ); |
|
79 | - $parameters = [ |
|
80 | - 'meta_key' => '_pinned', |
|
81 | - 'meta_query' => $metaQuery, |
|
82 | - 'offset' => $args['offset'], |
|
83 | - 'order' => $args['order'], |
|
84 | - 'orderby' => 'meta_value '.$args['orderby'], |
|
85 | - 'paged' => glsr_get($args, 'paged', $paged), |
|
86 | - 'post__in' => $args['post__in'], |
|
87 | - 'post__not_in' => $args['post__not_in'], |
|
88 | - 'post_status' => 'publish', |
|
89 | - 'post_type' => Application::POST_TYPE, |
|
90 | - 'posts_per_page' => $args['count'], |
|
91 | - 'tax_query' => $taxQuery, |
|
92 | - ]; |
|
93 | - $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args); |
|
94 | - $query = new WP_Query($parameters); |
|
95 | - $results = array_map([$this, 'single'], $query->posts); |
|
96 | - $reviews = new Reviews($results, $query->max_num_pages, $args); |
|
97 | - return apply_filters('site-reviews/get/reviews', $reviews, $query); |
|
98 | - } |
|
62 | + /** |
|
63 | + * @return object |
|
64 | + */ |
|
65 | + public function get(array $args = []) |
|
66 | + { |
|
67 | + $args = glsr(ReviewsDefaults::class)->merge($args); |
|
68 | + $metaQuery = glsr(QueryBuilder::class)->buildQuery( |
|
69 | + ['assigned_to', 'email', 'ip_address', 'type', 'rating'], |
|
70 | + $args |
|
71 | + ); |
|
72 | + $taxQuery = glsr(QueryBuilder::class)->buildQuery( |
|
73 | + ['category'], |
|
74 | + ['category' => $this->normalizeTermIds($args['category'])] |
|
75 | + ); |
|
76 | + $paged = glsr(QueryBuilder::class)->getPaged( |
|
77 | + wp_validate_boolean($args['pagination']) |
|
78 | + ); |
|
79 | + $parameters = [ |
|
80 | + 'meta_key' => '_pinned', |
|
81 | + 'meta_query' => $metaQuery, |
|
82 | + 'offset' => $args['offset'], |
|
83 | + 'order' => $args['order'], |
|
84 | + 'orderby' => 'meta_value '.$args['orderby'], |
|
85 | + 'paged' => glsr_get($args, 'paged', $paged), |
|
86 | + 'post__in' => $args['post__in'], |
|
87 | + 'post__not_in' => $args['post__not_in'], |
|
88 | + 'post_status' => 'publish', |
|
89 | + 'post_type' => Application::POST_TYPE, |
|
90 | + 'posts_per_page' => $args['count'], |
|
91 | + 'tax_query' => $taxQuery, |
|
92 | + ]; |
|
93 | + $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args); |
|
94 | + $query = new WP_Query($parameters); |
|
95 | + $results = array_map([$this, 'single'], $query->posts); |
|
96 | + $reviews = new Reviews($results, $query->max_num_pages, $args); |
|
97 | + return apply_filters('site-reviews/get/reviews', $reviews, $query); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @param string $metaReviewId |
|
102 | - * @return int |
|
103 | - */ |
|
104 | - public function getPostId($metaReviewId) |
|
105 | - { |
|
106 | - return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId); |
|
107 | - } |
|
100 | + /** |
|
101 | + * @param string $metaReviewId |
|
102 | + * @return int |
|
103 | + */ |
|
104 | + public function getPostId($metaReviewId) |
|
105 | + { |
|
106 | + return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function getRatingCounts(array $args = []) |
|
113 | - { |
|
114 | - $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args); |
|
115 | - $counts = glsr(CountsManager::class)->get([ |
|
116 | - 'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']), |
|
117 | - 'term_ids' => $this->normalizeTermIds($args['category']), |
|
118 | - 'type' => $args['type'], |
|
119 | - ]); |
|
120 | - return glsr(CountsManager::class)->flatten($counts, [ |
|
121 | - 'min' => $args['rating'], |
|
122 | - ]); |
|
123 | - } |
|
109 | + /** |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function getRatingCounts(array $args = []) |
|
113 | + { |
|
114 | + $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args); |
|
115 | + $counts = glsr(CountsManager::class)->get([ |
|
116 | + 'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']), |
|
117 | + 'term_ids' => $this->normalizeTermIds($args['category']), |
|
118 | + 'type' => $args['type'], |
|
119 | + ]); |
|
120 | + return glsr(CountsManager::class)->flatten($counts, [ |
|
121 | + 'min' => $args['rating'], |
|
122 | + ]); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @param string $commaSeparatedTermIds |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - public function normalizeTermIds($commaSeparatedTermIds) |
|
130 | - { |
|
131 | - $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id'); |
|
132 | - return array_unique(array_map('intval', $termIds)); |
|
133 | - } |
|
125 | + /** |
|
126 | + * @param string $commaSeparatedTermIds |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + public function normalizeTermIds($commaSeparatedTermIds) |
|
130 | + { |
|
131 | + $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id'); |
|
132 | + return array_unique(array_map('intval', $termIds)); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @param string $commaSeparatedTermIds |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - public function normalizeTerms($commaSeparatedTermIds) |
|
140 | - { |
|
141 | - $terms = []; |
|
142 | - $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds); |
|
143 | - foreach ($termIds as $termId) { |
|
144 | - if (is_numeric($termId)) { |
|
145 | - $termId = intval($termId); |
|
146 | - } |
|
147 | - $term = term_exists($termId, Application::TAXONOMY); |
|
148 | - if (!isset($term['term_id'])) { |
|
149 | - continue; |
|
150 | - } |
|
151 | - $terms[] = $term; |
|
152 | - } |
|
153 | - return $terms; |
|
154 | - } |
|
135 | + /** |
|
136 | + * @param string $commaSeparatedTermIds |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + public function normalizeTerms($commaSeparatedTermIds) |
|
140 | + { |
|
141 | + $terms = []; |
|
142 | + $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds); |
|
143 | + foreach ($termIds as $termId) { |
|
144 | + if (is_numeric($termId)) { |
|
145 | + $termId = intval($termId); |
|
146 | + } |
|
147 | + $term = term_exists($termId, Application::TAXONOMY); |
|
148 | + if (!isset($term['term_id'])) { |
|
149 | + continue; |
|
150 | + } |
|
151 | + $terms[] = $term; |
|
152 | + } |
|
153 | + return $terms; |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * @param int $postId |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function revert($postId) |
|
161 | - { |
|
162 | - if (Application::POST_TYPE != get_post_field('post_type', $postId)) { |
|
163 | - return; |
|
164 | - } |
|
165 | - delete_post_meta($postId, '_edit_last'); |
|
166 | - $result = wp_update_post([ |
|
167 | - 'ID' => $postId, |
|
168 | - 'post_content' => glsr(Database::class)->get($postId, 'content'), |
|
169 | - 'post_date' => glsr(Database::class)->get($postId, 'date'), |
|
170 | - 'post_title' => glsr(Database::class)->get($postId, 'title'), |
|
171 | - ]); |
|
172 | - if (is_wp_error($result)) { |
|
173 | - glsr_log()->error($result->get_error_message()); |
|
174 | - return; |
|
175 | - } |
|
176 | - do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
|
177 | - } |
|
156 | + /** |
|
157 | + * @param int $postId |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function revert($postId) |
|
161 | + { |
|
162 | + if (Application::POST_TYPE != get_post_field('post_type', $postId)) { |
|
163 | + return; |
|
164 | + } |
|
165 | + delete_post_meta($postId, '_edit_last'); |
|
166 | + $result = wp_update_post([ |
|
167 | + 'ID' => $postId, |
|
168 | + 'post_content' => glsr(Database::class)->get($postId, 'content'), |
|
169 | + 'post_date' => glsr(Database::class)->get($postId, 'date'), |
|
170 | + 'post_title' => glsr(Database::class)->get($postId, 'title'), |
|
171 | + ]); |
|
172 | + if (is_wp_error($result)) { |
|
173 | + glsr_log()->error($result->get_error_message()); |
|
174 | + return; |
|
175 | + } |
|
176 | + do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * @return Review |
|
181 | - */ |
|
182 | - public function single(WP_Post $post) |
|
183 | - { |
|
184 | - if (Application::POST_TYPE != $post->post_type) { |
|
185 | - $post = new WP_Post((object) []); |
|
186 | - } |
|
187 | - $review = new Review($post); |
|
188 | - return apply_filters('site-reviews/get/review', $review, $post); |
|
189 | - } |
|
179 | + /** |
|
180 | + * @return Review |
|
181 | + */ |
|
182 | + public function single(WP_Post $post) |
|
183 | + { |
|
184 | + if (Application::POST_TYPE != $post->post_type) { |
|
185 | + $post = new WP_Post((object) []); |
|
186 | + } |
|
187 | + $review = new Review($post); |
|
188 | + return apply_filters('site-reviews/get/review', $review, $post); |
|
189 | + } |
|
190 | 190 | |
191 | - /** |
|
192 | - * @param bool $isBlacklisted |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - protected function getNewPostStatus(array $reviewValues, $isBlacklisted) |
|
196 | - { |
|
197 | - $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval'); |
|
198 | - return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted) |
|
199 | - ? 'pending' |
|
200 | - : 'publish'; |
|
201 | - } |
|
191 | + /** |
|
192 | + * @param bool $isBlacklisted |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + protected function getNewPostStatus(array $reviewValues, $isBlacklisted) |
|
196 | + { |
|
197 | + $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval'); |
|
198 | + return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted) |
|
199 | + ? 'pending' |
|
200 | + : 'publish'; |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * @param int $postId |
|
205 | - * @param string $termIds |
|
206 | - * @return void |
|
207 | - */ |
|
208 | - protected function setTerms($postId, $termIds) |
|
209 | - { |
|
210 | - $termIds = $this->normalizeTermIds($termIds); |
|
211 | - if (empty($termIds)) { |
|
212 | - return; |
|
213 | - } |
|
214 | - $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY); |
|
215 | - if (is_wp_error($termTaxonomyIds)) { |
|
216 | - glsr_log()->error($termTaxonomyIds->get_error_message()); |
|
217 | - } |
|
218 | - } |
|
203 | + /** |
|
204 | + * @param int $postId |
|
205 | + * @param string $termIds |
|
206 | + * @return void |
|
207 | + */ |
|
208 | + protected function setTerms($postId, $termIds) |
|
209 | + { |
|
210 | + $termIds = $this->normalizeTermIds($termIds); |
|
211 | + if (empty($termIds)) { |
|
212 | + return; |
|
213 | + } |
|
214 | + $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY); |
|
215 | + if (is_wp_error($termTaxonomyIds)) { |
|
216 | + glsr_log()->error($termTaxonomyIds->get_error_message()); |
|
217 | + } |
|
218 | + } |
|
219 | 219 | } |
@@ -19,104 +19,104 @@ |
||
19 | 19 | |
20 | 20 | class Actions implements HooksContract |
21 | 21 | { |
22 | - protected $about; |
|
23 | - protected $app; |
|
24 | - protected $blocks; |
|
25 | - protected $console; |
|
26 | - protected $editor; |
|
27 | - protected $listtable; |
|
28 | - protected $menu; |
|
29 | - protected $main; |
|
30 | - protected $public; |
|
31 | - protected $rebusify; |
|
32 | - protected $review; |
|
33 | - protected $router; |
|
34 | - protected $settings; |
|
35 | - protected $taxonomy; |
|
36 | - protected $welcome; |
|
22 | + protected $about; |
|
23 | + protected $app; |
|
24 | + protected $blocks; |
|
25 | + protected $console; |
|
26 | + protected $editor; |
|
27 | + protected $listtable; |
|
28 | + protected $menu; |
|
29 | + protected $main; |
|
30 | + protected $public; |
|
31 | + protected $rebusify; |
|
32 | + protected $review; |
|
33 | + protected $router; |
|
34 | + protected $settings; |
|
35 | + protected $taxonomy; |
|
36 | + protected $welcome; |
|
37 | 37 | |
38 | - public function __construct(Application $app ) { |
|
39 | - $this->app = $app; |
|
40 | - $this->admin = $app->make(AdminController::class); |
|
41 | - $this->blocks = $app->make(BlocksController::class); |
|
42 | - $this->console = $app->make(Console::class); |
|
43 | - $this->editor = $app->make(EditorController::class); |
|
44 | - $this->listtable = $app->make(ListTableController::class); |
|
45 | - $this->main = $app->make(MainController::class); |
|
46 | - $this->menu = $app->make(MenuController::class); |
|
47 | - $this->public = $app->make(PublicController::class); |
|
48 | - $this->rebusify = $app->make(RebusifyController::class); |
|
49 | - $this->review = $app->make(ReviewController::class); |
|
50 | - $this->router = $app->make(Router::class); |
|
51 | - $this->settings = $app->make(SettingsController::class); |
|
52 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
53 | - $this->welcome = $app->make(WelcomeController::class); |
|
54 | - } |
|
38 | + public function __construct(Application $app ) { |
|
39 | + $this->app = $app; |
|
40 | + $this->admin = $app->make(AdminController::class); |
|
41 | + $this->blocks = $app->make(BlocksController::class); |
|
42 | + $this->console = $app->make(Console::class); |
|
43 | + $this->editor = $app->make(EditorController::class); |
|
44 | + $this->listtable = $app->make(ListTableController::class); |
|
45 | + $this->main = $app->make(MainController::class); |
|
46 | + $this->menu = $app->make(MenuController::class); |
|
47 | + $this->public = $app->make(PublicController::class); |
|
48 | + $this->rebusify = $app->make(RebusifyController::class); |
|
49 | + $this->review = $app->make(ReviewController::class); |
|
50 | + $this->router = $app->make(Router::class); |
|
51 | + $this->settings = $app->make(SettingsController::class); |
|
52 | + $this->taxonomy = $app->make(TaxonomyController::class); |
|
53 | + $this->welcome = $app->make(WelcomeController::class); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function run() |
|
60 | - { |
|
61 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
62 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
63 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
64 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
65 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
66 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
67 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
68 | - add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
69 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
70 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
71 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
72 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
73 | - add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
74 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
75 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
76 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
77 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
78 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
79 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
80 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
81 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
82 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
83 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
84 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
85 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
86 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
87 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
88 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
89 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
90 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
91 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
92 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
93 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
94 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
95 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
96 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
97 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
98 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
99 | - add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
100 | - add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
101 | - add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
102 | - add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
103 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
104 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
105 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
106 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
107 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
108 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
109 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
110 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
111 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
112 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
113 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
114 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
115 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
116 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
117 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
118 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
119 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
120 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
121 | - } |
|
56 | + /** |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function run() |
|
60 | + { |
|
61 | + add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
62 | + add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
63 | + add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
64 | + add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
65 | + add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
66 | + add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
67 | + add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
68 | + add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
69 | + add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
70 | + add_action('init', [$this->blocks, 'registerBlocks']); |
|
71 | + add_action('admin_footer', [$this->console, 'logOnce']); |
|
72 | + add_action('wp_footer', [$this->console, 'logOnce']); |
|
73 | + add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
74 | + add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
75 | + add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
76 | + add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
77 | + add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
78 | + add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
79 | + add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
80 | + add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
81 | + add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
82 | + add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
83 | + add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
84 | + add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
85 | + add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
86 | + add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
87 | + add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
88 | + add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
89 | + add_action('init', [$this->main, 'registerPostType'], 8); |
|
90 | + add_action('init', [$this->main, 'registerShortcodes']); |
|
91 | + add_action('init', [$this->main, 'registerTaxonomy']); |
|
92 | + add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
93 | + add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
94 | + add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
95 | + add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
96 | + add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
97 | + add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
98 | + add_action('wp_footer', [$this->public, 'renderSchema']); |
|
99 | + add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
100 | + add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
101 | + add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
102 | + add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
103 | + add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
104 | + add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
105 | + add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
106 | + add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
107 | + add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
108 | + add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
109 | + add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
110 | + add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
111 | + add_action('init', [$this->router, 'routePublicPostRequest']); |
|
112 | + add_action('admin_init', [$this->settings, 'registerSettings']); |
|
113 | + add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
114 | + add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
115 | + add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
116 | + add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
117 | + add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
118 | + add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
119 | + add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
120 | + add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
121 | + } |
|
122 | 122 | } |
@@ -1,518 +1,518 @@ |
||
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.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.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://www.rebusify.com?ref=105">Rebusify Confidence System</a>' |
|
62 | - ), |
|
63 | - 'label' => __('Sync to Blockchain', 'site-reviews'), |
|
64 | - 'type' => 'yes_no', |
|
65 | - ], |
|
66 | - 'settings.general.rebusify_api_key' => [ |
|
67 | - 'default' => '', |
|
68 | - 'depends_on' => [ |
|
69 | - 'settings.general.rebusify' => ['yes'], |
|
70 | - ], |
|
71 | - 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
72 | - '<a href="https://rebusify.com?ref=105">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' => 'yes', |
|
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.limit' => [ |
|
398 | - 'default' => '', |
|
399 | - 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
400 | - 'label' => __('Limit Reviews', 'site-reviews'), |
|
401 | - 'options' => [ |
|
402 | - '' => __('No Limit', 'site-reviews'), |
|
403 | - 'email' => __('By Email Address', 'site-reviews'), |
|
404 | - 'ip_address' => __('By IP Address', 'site-reviews'), |
|
405 | - 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
406 | - ], |
|
407 | - 'type' => 'select', |
|
408 | - ], |
|
409 | - 'settings.submissions.limit_whitelist.email' => [ |
|
410 | - 'default' => '', |
|
411 | - 'depends_on' => [ |
|
412 | - 'settings.submissions.limit' => ['email'], |
|
413 | - ], |
|
414 | - 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
415 | - 'label' => __('Email Whitelist', 'site-reviews'), |
|
416 | - 'rows' => 5, |
|
417 | - 'type' => 'code', |
|
418 | - ], |
|
419 | - 'settings.submissions.limit_whitelist.ip_address' => [ |
|
420 | - 'default' => '', |
|
421 | - 'depends_on' => [ |
|
422 | - 'settings.submissions.limit' => ['ip_address'], |
|
423 | - ], |
|
424 | - 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
425 | - 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
426 | - 'rows' => 5, |
|
427 | - 'type' => 'code', |
|
428 | - ], |
|
429 | - 'settings.submissions.limit_whitelist.username' => [ |
|
430 | - 'default' => '', |
|
431 | - 'depends_on' => [ |
|
432 | - 'settings.submissions.limit' => ['username'], |
|
433 | - ], |
|
434 | - 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
435 | - 'label' => __('Username Whitelist', 'site-reviews'), |
|
436 | - 'rows' => 5, |
|
437 | - 'type' => 'code', |
|
438 | - ], |
|
439 | - 'settings.submissions.recaptcha.integration' => [ |
|
440 | - 'default' => '', |
|
441 | - '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'), |
|
442 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
443 | - 'options' => [ |
|
444 | - '' => 'Do not use reCAPTCHA', |
|
445 | - 'all' => 'Use reCAPTCHA', |
|
446 | - 'guest' => 'Use reCAPTCHA only for guest users', |
|
447 | - ], |
|
448 | - 'type' => 'select', |
|
449 | - ], |
|
450 | - 'settings.submissions.recaptcha.key' => [ |
|
451 | - 'default' => '', |
|
452 | - 'depends_on' => [ |
|
453 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
454 | - ], |
|
455 | - 'label' => __('Site Key', 'site-reviews'), |
|
456 | - 'type' => 'text', |
|
457 | - ], |
|
458 | - 'settings.submissions.recaptcha.secret' => [ |
|
459 | - 'default' => '', |
|
460 | - 'depends_on' => [ |
|
461 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
462 | - ], |
|
463 | - 'label' => __('Site Secret', 'site-reviews'), |
|
464 | - 'type' => 'text', |
|
465 | - ], |
|
466 | - 'settings.submissions.recaptcha.position' => [ |
|
467 | - 'default' => 'bottomleft', |
|
468 | - 'depends_on' => [ |
|
469 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
470 | - ], |
|
471 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
472 | - 'label' => __('Badge Position', 'site-reviews'), |
|
473 | - 'options' => [ |
|
474 | - 'bottomleft' => 'Bottom Left', |
|
475 | - 'bottomright' => 'Bottom Right', |
|
476 | - 'inline' => 'Inline', |
|
477 | - ], |
|
478 | - 'type' => 'select', |
|
479 | - ], |
|
480 | - 'settings.submissions.akismet' => [ |
|
481 | - 'default' => 'no', |
|
482 | - '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'), |
|
483 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
484 | - 'type' => 'yes_no', |
|
485 | - ], |
|
486 | - 'settings.submissions.blacklist.integration' => [ |
|
487 | - 'default' => '', |
|
488 | - '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'), |
|
489 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
490 | - ), |
|
491 | - 'label' => __('Blacklist', 'site-reviews'), |
|
492 | - 'options' => [ |
|
493 | - '' => 'Use the Site Reviews Blacklist', |
|
494 | - 'comments' => 'Use the WordPress Comment Blacklist', |
|
495 | - ], |
|
496 | - 'type' => 'select', |
|
497 | - ], |
|
498 | - 'settings.submissions.blacklist.entries' => [ |
|
499 | - 'default' => '', |
|
500 | - 'depends_on' => [ |
|
501 | - 'settings.submissions.blacklist.integration' => [''], |
|
502 | - ], |
|
503 | - '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'), |
|
504 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
505 | - 'rows' => 10, |
|
506 | - 'type' => 'code', |
|
507 | - ], |
|
508 | - 'settings.submissions.blacklist.action' => [ |
|
509 | - 'default' => 'unapprove', |
|
510 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
511 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
512 | - 'options' => [ |
|
513 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
514 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
515 | - ], |
|
516 | - 'type' => 'select', |
|
517 | - ], |
|
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.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.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://www.rebusify.com?ref=105">Rebusify Confidence System</a>' |
|
62 | + ), |
|
63 | + 'label' => __('Sync to Blockchain', 'site-reviews'), |
|
64 | + 'type' => 'yes_no', |
|
65 | + ], |
|
66 | + 'settings.general.rebusify_api_key' => [ |
|
67 | + 'default' => '', |
|
68 | + 'depends_on' => [ |
|
69 | + 'settings.general.rebusify' => ['yes'], |
|
70 | + ], |
|
71 | + 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
72 | + '<a href="https://rebusify.com?ref=105">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' => 'yes', |
|
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.limit' => [ |
|
398 | + 'default' => '', |
|
399 | + 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
400 | + 'label' => __('Limit Reviews', 'site-reviews'), |
|
401 | + 'options' => [ |
|
402 | + '' => __('No Limit', 'site-reviews'), |
|
403 | + 'email' => __('By Email Address', 'site-reviews'), |
|
404 | + 'ip_address' => __('By IP Address', 'site-reviews'), |
|
405 | + 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
406 | + ], |
|
407 | + 'type' => 'select', |
|
408 | + ], |
|
409 | + 'settings.submissions.limit_whitelist.email' => [ |
|
410 | + 'default' => '', |
|
411 | + 'depends_on' => [ |
|
412 | + 'settings.submissions.limit' => ['email'], |
|
413 | + ], |
|
414 | + 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
415 | + 'label' => __('Email Whitelist', 'site-reviews'), |
|
416 | + 'rows' => 5, |
|
417 | + 'type' => 'code', |
|
418 | + ], |
|
419 | + 'settings.submissions.limit_whitelist.ip_address' => [ |
|
420 | + 'default' => '', |
|
421 | + 'depends_on' => [ |
|
422 | + 'settings.submissions.limit' => ['ip_address'], |
|
423 | + ], |
|
424 | + 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
425 | + 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
426 | + 'rows' => 5, |
|
427 | + 'type' => 'code', |
|
428 | + ], |
|
429 | + 'settings.submissions.limit_whitelist.username' => [ |
|
430 | + 'default' => '', |
|
431 | + 'depends_on' => [ |
|
432 | + 'settings.submissions.limit' => ['username'], |
|
433 | + ], |
|
434 | + 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
435 | + 'label' => __('Username Whitelist', 'site-reviews'), |
|
436 | + 'rows' => 5, |
|
437 | + 'type' => 'code', |
|
438 | + ], |
|
439 | + 'settings.submissions.recaptcha.integration' => [ |
|
440 | + 'default' => '', |
|
441 | + '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'), |
|
442 | + 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
443 | + 'options' => [ |
|
444 | + '' => 'Do not use reCAPTCHA', |
|
445 | + 'all' => 'Use reCAPTCHA', |
|
446 | + 'guest' => 'Use reCAPTCHA only for guest users', |
|
447 | + ], |
|
448 | + 'type' => 'select', |
|
449 | + ], |
|
450 | + 'settings.submissions.recaptcha.key' => [ |
|
451 | + 'default' => '', |
|
452 | + 'depends_on' => [ |
|
453 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
454 | + ], |
|
455 | + 'label' => __('Site Key', 'site-reviews'), |
|
456 | + 'type' => 'text', |
|
457 | + ], |
|
458 | + 'settings.submissions.recaptcha.secret' => [ |
|
459 | + 'default' => '', |
|
460 | + 'depends_on' => [ |
|
461 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
462 | + ], |
|
463 | + 'label' => __('Site Secret', 'site-reviews'), |
|
464 | + 'type' => 'text', |
|
465 | + ], |
|
466 | + 'settings.submissions.recaptcha.position' => [ |
|
467 | + 'default' => 'bottomleft', |
|
468 | + 'depends_on' => [ |
|
469 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
470 | + ], |
|
471 | + 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
472 | + 'label' => __('Badge Position', 'site-reviews'), |
|
473 | + 'options' => [ |
|
474 | + 'bottomleft' => 'Bottom Left', |
|
475 | + 'bottomright' => 'Bottom Right', |
|
476 | + 'inline' => 'Inline', |
|
477 | + ], |
|
478 | + 'type' => 'select', |
|
479 | + ], |
|
480 | + 'settings.submissions.akismet' => [ |
|
481 | + 'default' => 'no', |
|
482 | + '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'), |
|
483 | + 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
484 | + 'type' => 'yes_no', |
|
485 | + ], |
|
486 | + 'settings.submissions.blacklist.integration' => [ |
|
487 | + 'default' => '', |
|
488 | + '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'), |
|
489 | + '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
490 | + ), |
|
491 | + 'label' => __('Blacklist', 'site-reviews'), |
|
492 | + 'options' => [ |
|
493 | + '' => 'Use the Site Reviews Blacklist', |
|
494 | + 'comments' => 'Use the WordPress Comment Blacklist', |
|
495 | + ], |
|
496 | + 'type' => 'select', |
|
497 | + ], |
|
498 | + 'settings.submissions.blacklist.entries' => [ |
|
499 | + 'default' => '', |
|
500 | + 'depends_on' => [ |
|
501 | + 'settings.submissions.blacklist.integration' => [''], |
|
502 | + ], |
|
503 | + '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'), |
|
504 | + 'label' => __('Review Blacklist', 'site-reviews'), |
|
505 | + 'rows' => 10, |
|
506 | + 'type' => 'code', |
|
507 | + ], |
|
508 | + 'settings.submissions.blacklist.action' => [ |
|
509 | + 'default' => 'unapprove', |
|
510 | + 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
511 | + 'label' => __('Blacklist Action', 'site-reviews'), |
|
512 | + 'options' => [ |
|
513 | + 'unapprove' => __('Require approval', 'site-reviews'), |
|
514 | + 'reject' => __('Reject submission', 'site-reviews'), |
|
515 | + ], |
|
516 | + 'type' => 'select', |
|
517 | + ], |
|
518 | 518 | ]; |