@@ -6,33 +6,33 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected $guarded = [ |
|
13 | - 'fallback', |
|
14 | - 'title', |
|
15 | - ]; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected $guarded = [ |
|
13 | + 'fallback', |
|
14 | + 'title', |
|
15 | + ]; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - protected function defaults() |
|
21 | - { |
|
22 | - return [ |
|
23 | - 'assigned_to' => '', |
|
24 | - 'category' => '', |
|
25 | - 'class' => '', |
|
26 | - 'count' => 5, |
|
27 | - 'fallback' => '', |
|
28 | - 'hide' => [], |
|
29 | - 'id' => '', |
|
30 | - 'offset' => '', |
|
31 | - 'pagination' => false, |
|
32 | - 'rating' => 0, |
|
33 | - 'schema' => false, |
|
34 | - 'title' => '', |
|
35 | - 'type' => 'local', |
|
36 | - ]; |
|
37 | - } |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + protected function defaults() |
|
21 | + { |
|
22 | + return [ |
|
23 | + 'assigned_to' => '', |
|
24 | + 'category' => '', |
|
25 | + 'class' => '', |
|
26 | + 'count' => 5, |
|
27 | + 'fallback' => '', |
|
28 | + 'hide' => [], |
|
29 | + 'id' => '', |
|
30 | + 'offset' => '', |
|
31 | + 'pagination' => false, |
|
32 | + 'rating' => 0, |
|
33 | + 'schema' => false, |
|
34 | + 'title' => '', |
|
35 | + 'type' => 'local', |
|
36 | + ]; |
|
37 | + } |
|
38 | 38 | } |
@@ -6,60 +6,60 @@ |
||
6 | 6 | |
7 | 7 | class DefaultsManager |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function defaults() |
|
13 | - { |
|
14 | - $settings = $this->settings(); |
|
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
17 | - 'version' => '', |
|
18 | - 'version_upgraded_from' => '', |
|
19 | - ]); |
|
20 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function defaults() |
|
13 | + { |
|
14 | + $settings = $this->settings(); |
|
15 | + $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | + return wp_parse_args($defaults, [ |
|
17 | + 'version' => '', |
|
18 | + 'version_upgraded_from' => '', |
|
19 | + ]); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return array |
|
24 | - */ |
|
25 | - public function get() |
|
26 | - { |
|
27 | - return glsr(Helper::class)->convertDotNotationArray($this->defaults()); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @return array |
|
24 | + */ |
|
25 | + public function get() |
|
26 | + { |
|
27 | + return glsr(Helper::class)->convertDotNotationArray($this->defaults()); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function set() |
|
34 | - { |
|
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = glsr(Helper::class)->removeEmptyArrayValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | - return $defaultSettings; |
|
41 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function set() |
|
34 | + { |
|
35 | + $settings = glsr(OptionManager::class)->all(); |
|
36 | + $currentSettings = glsr(Helper::class)->removeEmptyArrayValues($settings); |
|
37 | + $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | + $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | + update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | + return $defaultSettings; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function settings() |
|
47 | - { |
|
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function settings() |
|
47 | + { |
|
48 | + $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | + return $this->normalize($settings); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - protected function normalize(array $settings) |
|
56 | - { |
|
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
59 | - return; |
|
60 | - } |
|
61 | - $setting['default'] = ''; |
|
62 | - }); |
|
63 | - return $settings; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + protected function normalize(array $settings) |
|
56 | + { |
|
57 | + array_walk($settings, function (&$setting) { |
|
58 | + if (isset($setting['default'])) { |
|
59 | + return; |
|
60 | + } |
|
61 | + $setting['default'] = ''; |
|
62 | + }); |
|
63 | + return $settings; |
|
64 | + } |
|
65 | 65 | } |
@@ -9,113 +9,113 @@ |
||
9 | 9 | |
10 | 10 | class SettingsController extends Controller |
11 | 11 | { |
12 | - /** |
|
13 | - * @param mixed $input |
|
14 | - * @return array |
|
15 | - * @callback register_setting |
|
16 | - */ |
|
17 | - public function callbackRegisterSettings($input) |
|
18 | - { |
|
19 | - $settings = glsr(Helper::class)->consolidateArray($input); |
|
20 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
21 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
22 | - $options = $this->sanitizeGeneral($input, $options); |
|
23 | - $options = $this->sanitizeSubmissions($input, $options); |
|
24 | - $options = $this->sanitizeTranslations($input, $options); |
|
25 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
26 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
27 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
28 | - } |
|
29 | - return $options; |
|
30 | - } |
|
31 | - return $input; |
|
32 | - } |
|
12 | + /** |
|
13 | + * @param mixed $input |
|
14 | + * @return array |
|
15 | + * @callback register_setting |
|
16 | + */ |
|
17 | + public function callbackRegisterSettings($input) |
|
18 | + { |
|
19 | + $settings = glsr(Helper::class)->consolidateArray($input); |
|
20 | + if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
21 | + $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
22 | + $options = $this->sanitizeGeneral($input, $options); |
|
23 | + $options = $this->sanitizeSubmissions($input, $options); |
|
24 | + $options = $this->sanitizeTranslations($input, $options); |
|
25 | + $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
26 | + if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
27 | + glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
28 | + } |
|
29 | + return $options; |
|
30 | + } |
|
31 | + return $input; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @return void |
|
36 | - * @action admin_init |
|
37 | - */ |
|
38 | - public function registerSettings() |
|
39 | - { |
|
40 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
41 | - 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
42 | - ]); |
|
43 | - } |
|
34 | + /** |
|
35 | + * @return void |
|
36 | + * @action admin_init |
|
37 | + */ |
|
38 | + public function registerSettings() |
|
39 | + { |
|
40 | + register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
41 | + 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
42 | + ]); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - protected function sanitizeGeneral(array $input, array $options) |
|
49 | - { |
|
50 | - $inputForm = $input['settings']['general']; |
|
51 | - if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) { |
|
52 | - $options['settings']['general']['support']['multilingual'] = ''; |
|
53 | - } |
|
54 | - if ('' == trim($inputForm['notification_message'])) { |
|
55 | - $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message']; |
|
56 | - } |
|
57 | - $options['settings']['general']['notifications'] = glsr_get($inputForm, 'notifications', []); |
|
58 | - return $options; |
|
59 | - } |
|
45 | + /** |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + protected function sanitizeGeneral(array $input, array $options) |
|
49 | + { |
|
50 | + $inputForm = $input['settings']['general']; |
|
51 | + if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) { |
|
52 | + $options['settings']['general']['support']['multilingual'] = ''; |
|
53 | + } |
|
54 | + if ('' == trim($inputForm['notification_message'])) { |
|
55 | + $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message']; |
|
56 | + } |
|
57 | + $options['settings']['general']['notifications'] = glsr_get($inputForm, 'notifications', []); |
|
58 | + return $options; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - protected function sanitizeSubmissions(array $input, array $options) |
|
65 | - { |
|
66 | - $inputForm = $input['settings']['submissions']; |
|
67 | - $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
68 | - ? $inputForm['required'] |
|
69 | - : []; |
|
70 | - return $options; |
|
71 | - } |
|
61 | + /** |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + protected function sanitizeSubmissions(array $input, array $options) |
|
65 | + { |
|
66 | + $inputForm = $input['settings']['submissions']; |
|
67 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
68 | + ? $inputForm['required'] |
|
69 | + : []; |
|
70 | + return $options; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return array |
|
75 | - */ |
|
76 | - protected function sanitizeTranslations(array $input, array $options) |
|
77 | - { |
|
78 | - if (isset($input['settings']['strings'])) { |
|
79 | - $options['settings']['strings'] = array_values(array_filter($input['settings']['strings'])); |
|
80 | - $allowedTags = [ |
|
81 | - 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
82 | - 'span' => ['class' => []], |
|
83 | - ]; |
|
84 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
85 | - if (isset($string['s2'])) { |
|
86 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
87 | - } |
|
88 | - if (isset($string['p2'])) { |
|
89 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
90 | - } |
|
91 | - }); |
|
92 | - } |
|
93 | - return $options; |
|
94 | - } |
|
73 | + /** |
|
74 | + * @return array |
|
75 | + */ |
|
76 | + protected function sanitizeTranslations(array $input, array $options) |
|
77 | + { |
|
78 | + if (isset($input['settings']['strings'])) { |
|
79 | + $options['settings']['strings'] = array_values(array_filter($input['settings']['strings'])); |
|
80 | + $allowedTags = [ |
|
81 | + 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
82 | + 'span' => ['class' => []], |
|
83 | + ]; |
|
84 | + array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
85 | + if (isset($string['s2'])) { |
|
86 | + $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
87 | + } |
|
88 | + if (isset($string['p2'])) { |
|
89 | + $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
90 | + } |
|
91 | + }); |
|
92 | + } |
|
93 | + return $options; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - protected function hasMultilingualIntegration($integration) |
|
100 | - { |
|
101 | - if (!in_array($integration, ['polylang', 'wpml'])) { |
|
102 | - return false; |
|
103 | - } |
|
104 | - $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration); |
|
105 | - if (!glsr($integrationClass)->isActive()) { |
|
106 | - glsr(Notice::class)->addError(sprintf( |
|
107 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
108 | - constant($integrationClass.'::PLUGIN_NAME') |
|
109 | - )); |
|
110 | - return false; |
|
111 | - } elseif (!glsr($integrationClass)->isSupported()) { |
|
112 | - glsr(Notice::class)->addError(sprintf( |
|
113 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
114 | - constant($integrationClass.'::PLUGIN_NAME'), |
|
115 | - constant($integrationClass.'::SUPPORTED_VERSION') |
|
116 | - )); |
|
117 | - return false; |
|
118 | - } |
|
119 | - return true; |
|
120 | - } |
|
96 | + /** |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + protected function hasMultilingualIntegration($integration) |
|
100 | + { |
|
101 | + if (!in_array($integration, ['polylang', 'wpml'])) { |
|
102 | + return false; |
|
103 | + } |
|
104 | + $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration); |
|
105 | + if (!glsr($integrationClass)->isActive()) { |
|
106 | + glsr(Notice::class)->addError(sprintf( |
|
107 | + __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
108 | + constant($integrationClass.'::PLUGIN_NAME') |
|
109 | + )); |
|
110 | + return false; |
|
111 | + } elseif (!glsr($integrationClass)->isSupported()) { |
|
112 | + glsr(Notice::class)->addError(sprintf( |
|
113 | + __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
114 | + constant($integrationClass.'::PLUGIN_NAME'), |
|
115 | + constant($integrationClass.'::SUPPORTED_VERSION') |
|
116 | + )); |
|
117 | + return false; |
|
118 | + } |
|
119 | + return true; |
|
120 | + } |
|
121 | 121 | } |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | 11 | add_filter('plugins_loaded', function () { |
12 | - $hooks = array( |
|
13 | - 'glsr_calculate_ratings' => 1, |
|
14 | - 'glsr_create_review' => 2, |
|
15 | - 'glsr_debug' => 10, |
|
16 | - 'glsr_get' => 4, |
|
17 | - 'glsr_get_option' => 4, |
|
18 | - 'glsr_get_options' => 1, |
|
19 | - 'glsr_get_review' => 2, |
|
20 | - 'glsr_get_reviews' => 2, |
|
21 | - 'glsr_log' => 3, |
|
22 | - 'glsr_star_rating' => 2, |
|
23 | - ); |
|
24 | - foreach ($hooks as $function => $acceptedArgs) { |
|
25 | - add_filter($function, function () use ($function) { |
|
26 | - $args = func_get_args(); |
|
27 | - array_shift($args); // remove the fallback value |
|
28 | - return call_user_func_array($function, $args); |
|
29 | - }, 10, $acceptedArgs); |
|
30 | - } |
|
12 | + $hooks = array( |
|
13 | + 'glsr_calculate_ratings' => 1, |
|
14 | + 'glsr_create_review' => 2, |
|
15 | + 'glsr_debug' => 10, |
|
16 | + 'glsr_get' => 4, |
|
17 | + 'glsr_get_option' => 4, |
|
18 | + 'glsr_get_options' => 1, |
|
19 | + 'glsr_get_review' => 2, |
|
20 | + 'glsr_get_reviews' => 2, |
|
21 | + 'glsr_log' => 3, |
|
22 | + 'glsr_star_rating' => 2, |
|
23 | + ); |
|
24 | + foreach ($hooks as $function => $acceptedArgs) { |
|
25 | + add_filter($function, function () use ($function) { |
|
26 | + $args = func_get_args(); |
|
27 | + array_shift($args); // remove the fallback value |
|
28 | + return call_user_func_array($function, $args); |
|
29 | + }, 10, $acceptedArgs); |
|
30 | + } |
|
31 | 31 | }); |
32 | 32 | |
33 | 33 | /** |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function glsr($alias = null) |
37 | 37 | { |
38 | - $app = \GeminiLabs\SiteReviews\Application::load(); |
|
39 | - return !empty($alias) |
|
40 | - ? $app->make($alias) |
|
41 | - : $app; |
|
38 | + $app = \GeminiLabs\SiteReviews\Application::load(); |
|
39 | + return !empty($alias) |
|
40 | + ? $app->make($alias) |
|
41 | + : $app; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function glsr_array_column(array $array, $column) |
50 | 50 | { |
51 | - $result = array(); |
|
52 | - foreach ($array as $subarray) { |
|
53 | - $subarray = (array) $subarray; |
|
54 | - if (!isset($subarray[$column])) { |
|
55 | - continue; |
|
56 | - } |
|
57 | - $result[] = $subarray[$column]; |
|
58 | - } |
|
59 | - return $result; |
|
51 | + $result = array(); |
|
52 | + foreach ($array as $subarray) { |
|
53 | + $subarray = (array) $subarray; |
|
54 | + if (!isset($subarray[$column])) { |
|
55 | + continue; |
|
56 | + } |
|
57 | + $result[] = $subarray[$column]; |
|
58 | + } |
|
59 | + return $result; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function glsr_calculate_ratings() |
66 | 66 | { |
67 | - glsr('Controllers\AdminController')->routerCountReviews(false); |
|
68 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
67 | + glsr('Controllers\AdminController')->routerCountReviews(false); |
|
68 | + glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function glsr_create_review($reviewValues = array()) |
75 | 75 | { |
76 | - $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
77 | - glsr('Helper')->consolidateArray($reviewValues) |
|
78 | - ); |
|
79 | - return glsr('Database\ReviewManager')->create($review); |
|
76 | + $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
77 | + glsr('Helper')->consolidateArray($reviewValues) |
|
78 | + ); |
|
79 | + return glsr('Database\ReviewManager')->create($review); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function glsr_current_screen() |
86 | 86 | { |
87 | - if (function_exists('get_current_screen')) { |
|
88 | - $screen = get_current_screen(); |
|
89 | - } |
|
90 | - return empty($screen) |
|
91 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | - : $screen; |
|
87 | + if (function_exists('get_current_screen')) { |
|
88 | + $screen = get_current_screen(); |
|
89 | + } |
|
90 | + return empty($screen) |
|
91 | + ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | + : $screen; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | */ |
99 | 99 | function glsr_debug(...$vars) |
100 | 100 | { |
101 | - if (1 == count($vars)) { |
|
102 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
104 | - } else { |
|
105 | - echo '<div class="glsr-debug-group">'; |
|
106 | - foreach ($vars as $var) { |
|
107 | - glsr_debug($var); |
|
108 | - } |
|
109 | - echo '</div>'; |
|
110 | - } |
|
101 | + if (1 == count($vars)) { |
|
102 | + $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | + printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
104 | + } else { |
|
105 | + echo '<div class="glsr-debug-group">'; |
|
106 | + foreach ($vars as $var) { |
|
107 | + glsr_debug($var); |
|
108 | + } |
|
109 | + echo '</div>'; |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function glsr_get($array, $path = '', $fallback = '') |
120 | 120 | { |
121 | - return glsr('Helper')->dataGet($array, $path, $fallback); |
|
121 | + return glsr('Helper')->dataGet($array, $path, $fallback); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function glsr_get_option($path = '', $fallback = '', $cast = '') |
131 | 131 | { |
132 | - return is_string($path) |
|
133 | - ? glsr('Database\OptionManager')->get(glsr('Helper')->prefix('settings.', $path), $fallback, $cast) |
|
134 | - : $fallback; |
|
132 | + return is_string($path) |
|
133 | + ? glsr('Database\OptionManager')->get(glsr('Helper')->prefix('settings.', $path), $fallback, $cast) |
|
134 | + : $fallback; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function glsr_get_options() |
141 | 141 | { |
142 | - return glsr('Database\OptionManager')->get('settings'); |
|
142 | + return glsr('Database\OptionManager')->get('settings'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function glsr_get_review($post) |
150 | 150 | { |
151 | - if (is_numeric($post)) { |
|
152 | - $post = get_post($post); |
|
153 | - } |
|
154 | - if (!($post instanceof WP_Post)) { |
|
155 | - $post = new WP_Post((object) []); |
|
156 | - } |
|
157 | - return glsr('Database\ReviewManager')->single($post); |
|
151 | + if (is_numeric($post)) { |
|
152 | + $post = get_post($post); |
|
153 | + } |
|
154 | + if (!($post instanceof WP_Post)) { |
|
155 | + $post = new WP_Post((object) []); |
|
156 | + } |
|
157 | + return glsr('Database\ReviewManager')->single($post); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | function glsr_get_reviews($args = array()) |
164 | 164 | { |
165 | - return glsr('Database\ReviewManager')->get(glsr('Helper')->consolidateArray($args)); |
|
165 | + return glsr('Database\ReviewManager')->get(glsr('Helper')->consolidateArray($args)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function glsr_log() |
172 | 172 | { |
173 | - $args = func_get_args(); |
|
174 | - $console = glsr('Modules\Console'); |
|
175 | - if ($value = glsr_get($args, '0')) { |
|
176 | - return $console->debug($value, glsr_get($args, '1', [])); |
|
177 | - } |
|
178 | - return $console; |
|
173 | + $args = func_get_args(); |
|
174 | + $console = glsr('Modules\Console'); |
|
175 | + if ($value = glsr_get($args, '0')) { |
|
176 | + return $console->debug($value, glsr_get($args, '1', [])); |
|
177 | + } |
|
178 | + return $console; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,5 +183,5 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function glsr_star_rating($rating) |
185 | 185 | { |
186 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
186 | + return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
187 | 187 | } |
@@ -7,153 +7,153 @@ |
||
7 | 7 | |
8 | 8 | class OptionManager |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - protected $options; |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + protected $options; |
|
14 | 14 | |
15 | - /** |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public static function databaseKey($version = null) |
|
19 | - { |
|
20 | - if (null === $version) { |
|
21 | - $version = explode('.', glsr()->version); |
|
22 | - $version = array_shift($version); |
|
23 | - } |
|
24 | - return glsr(Helper::class)->snakeCase( |
|
25 | - Application::ID.'-v'.intval($version) |
|
26 | - ); |
|
27 | - } |
|
15 | + /** |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public static function databaseKey($version = null) |
|
19 | + { |
|
20 | + if (null === $version) { |
|
21 | + $version = explode('.', glsr()->version); |
|
22 | + $version = array_shift($version); |
|
23 | + } |
|
24 | + return glsr(Helper::class)->snakeCase( |
|
25 | + Application::ID.'-v'.intval($version) |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function all() |
|
33 | - { |
|
34 | - if (empty($this->options)) { |
|
35 | - $this->reset(); |
|
36 | - } |
|
37 | - return $this->options; |
|
38 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function all() |
|
33 | + { |
|
34 | + if (empty($this->options)) { |
|
35 | + $this->reset(); |
|
36 | + } |
|
37 | + return $this->options; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $path |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function delete($path) |
|
45 | - { |
|
46 | - $keys = explode('.', $path); |
|
47 | - $last = array_pop($keys); |
|
48 | - $options = $this->all(); |
|
49 | - $pointer = &$options; |
|
50 | - foreach ($keys as $key) { |
|
51 | - if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
52 | - continue; |
|
53 | - } |
|
54 | - $pointer = &$pointer[$key]; |
|
55 | - } |
|
56 | - unset($pointer[$last]); |
|
57 | - return $this->set($options); |
|
58 | - } |
|
40 | + /** |
|
41 | + * @param string $path |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function delete($path) |
|
45 | + { |
|
46 | + $keys = explode('.', $path); |
|
47 | + $last = array_pop($keys); |
|
48 | + $options = $this->all(); |
|
49 | + $pointer = &$options; |
|
50 | + foreach ($keys as $key) { |
|
51 | + if (!isset($pointer[$key]) || !is_array($pointer[$key])) { |
|
52 | + continue; |
|
53 | + } |
|
54 | + $pointer = &$pointer[$key]; |
|
55 | + } |
|
56 | + unset($pointer[$last]); |
|
57 | + return $this->set($options); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $path |
|
62 | - * @param mixed $fallback |
|
63 | - * @param string $cast |
|
64 | - * @return mixed |
|
65 | - */ |
|
66 | - public function get($path = '', $fallback = '', $cast = '') |
|
67 | - { |
|
68 | - $result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback); |
|
69 | - return glsr(Helper::class)->castTo($cast, $result); |
|
70 | - } |
|
60 | + /** |
|
61 | + * @param string $path |
|
62 | + * @param mixed $fallback |
|
63 | + * @param string $cast |
|
64 | + * @return mixed |
|
65 | + */ |
|
66 | + public function get($path = '', $fallback = '', $cast = '') |
|
67 | + { |
|
68 | + $result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback); |
|
69 | + return glsr(Helper::class)->castTo($cast, $result); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param string $path |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function getBool($path) |
|
77 | - { |
|
78 | - return glsr(Helper::class)->castTo('bool', $this->get($path)); |
|
79 | - } |
|
72 | + /** |
|
73 | + * @param string $path |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function getBool($path) |
|
77 | + { |
|
78 | + return glsr(Helper::class)->castTo('bool', $this->get($path)); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param string $path |
|
83 | - * @param mixed $fallback |
|
84 | - * @param string $cast |
|
85 | - * @return mixed |
|
86 | - */ |
|
87 | - public function getWP($path, $fallback = '', $cast = '') |
|
88 | - { |
|
89 | - $option = get_option($path, $fallback); |
|
90 | - if (empty($option)) { |
|
91 | - $option = $fallback; |
|
92 | - } |
|
93 | - return glsr(Helper::class)->castTo($cast, $option); |
|
94 | - } |
|
81 | + /** |
|
82 | + * @param string $path |
|
83 | + * @param mixed $fallback |
|
84 | + * @param string $cast |
|
85 | + * @return mixed |
|
86 | + */ |
|
87 | + public function getWP($path, $fallback = '', $cast = '') |
|
88 | + { |
|
89 | + $option = get_option($path, $fallback); |
|
90 | + if (empty($option)) { |
|
91 | + $option = $fallback; |
|
92 | + } |
|
93 | + return glsr(Helper::class)->castTo($cast, $option); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function json() |
|
100 | - { |
|
101 | - return json_encode($this->all()); |
|
102 | - } |
|
96 | + /** |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function json() |
|
100 | + { |
|
101 | + return json_encode($this->all()); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @return array |
|
106 | - */ |
|
107 | - public function normalize(array $options = []) |
|
108 | - { |
|
109 | - $options = wp_parse_args( |
|
110 | - glsr(Helper::class)->flattenArray($options), |
|
111 | - glsr(DefaultsManager::class)->defaults() |
|
112 | - ); |
|
113 | - array_walk($options, function (&$value) { |
|
114 | - if (!is_string($value)) { |
|
115 | - return; |
|
116 | - } |
|
117 | - $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
118 | - }); |
|
119 | - return glsr(Helper::class)->convertDotNotationArray($options); |
|
120 | - } |
|
104 | + /** |
|
105 | + * @return array |
|
106 | + */ |
|
107 | + public function normalize(array $options = []) |
|
108 | + { |
|
109 | + $options = wp_parse_args( |
|
110 | + glsr(Helper::class)->flattenArray($options), |
|
111 | + glsr(DefaultsManager::class)->defaults() |
|
112 | + ); |
|
113 | + array_walk($options, function (&$value) { |
|
114 | + if (!is_string($value)) { |
|
115 | + return; |
|
116 | + } |
|
117 | + $value = wp_kses($value, wp_kses_allowed_html('post')); |
|
118 | + }); |
|
119 | + return glsr(Helper::class)->convertDotNotationArray($options); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * @return bool |
|
124 | - */ |
|
125 | - public function isRecaptchaEnabled() |
|
126 | - { |
|
127 | - $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
128 | - return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
|
129 | - } |
|
122 | + /** |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | + public function isRecaptchaEnabled() |
|
126 | + { |
|
127 | + $integration = $this->get('settings.submissions.recaptcha.integration'); |
|
128 | + return 'all' == $integration || ('guest' == $integration && !is_user_logged_in()); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @return array |
|
133 | - */ |
|
134 | - public function reset() |
|
135 | - { |
|
136 | - $options = $this->getWP(static::databaseKey(), []); |
|
137 | - if (!is_array($options) || empty($options)) { |
|
138 | - delete_option(static::databaseKey()); |
|
139 | - $options = glsr()->defaults ?: []; |
|
140 | - } |
|
141 | - $this->options = $options; |
|
142 | - } |
|
131 | + /** |
|
132 | + * @return array |
|
133 | + */ |
|
134 | + public function reset() |
|
135 | + { |
|
136 | + $options = $this->getWP(static::databaseKey(), []); |
|
137 | + if (!is_array($options) || empty($options)) { |
|
138 | + delete_option(static::databaseKey()); |
|
139 | + $options = glsr()->defaults ?: []; |
|
140 | + } |
|
141 | + $this->options = $options; |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * @param string|array $pathOrOptions |
|
146 | - * @param mixed $value |
|
147 | - * @return bool |
|
148 | - */ |
|
149 | - public function set($pathOrOptions, $value = '') |
|
150 | - { |
|
151 | - if (is_string($pathOrOptions)) { |
|
152 | - $pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value); |
|
153 | - } |
|
154 | - if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
155 | - $this->reset(); |
|
156 | - } |
|
157 | - return $result; |
|
158 | - } |
|
144 | + /** |
|
145 | + * @param string|array $pathOrOptions |
|
146 | + * @param mixed $value |
|
147 | + * @return bool |
|
148 | + */ |
|
149 | + public function set($pathOrOptions, $value = '') |
|
150 | + { |
|
151 | + if (is_string($pathOrOptions)) { |
|
152 | + $pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value); |
|
153 | + } |
|
154 | + if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) { |
|
155 | + $this->reset(); |
|
156 | + } |
|
157 | + return $result; |
|
158 | + } |
|
159 | 159 | } |
@@ -14,69 +14,69 @@ |
||
14 | 14 | |
15 | 15 | class Filters implements HooksContract |
16 | 16 | { |
17 | - protected $admin; |
|
18 | - protected $app; |
|
19 | - protected $basename; |
|
20 | - protected $blocks; |
|
21 | - protected $editor; |
|
22 | - protected $listtable; |
|
23 | - protected $public; |
|
24 | - protected $rebusify; |
|
25 | - protected $translator; |
|
26 | - protected $welcome; |
|
17 | + protected $admin; |
|
18 | + protected $app; |
|
19 | + protected $basename; |
|
20 | + protected $blocks; |
|
21 | + protected $editor; |
|
22 | + protected $listtable; |
|
23 | + protected $public; |
|
24 | + protected $rebusify; |
|
25 | + protected $translator; |
|
26 | + protected $welcome; |
|
27 | 27 | |
28 | - public function __construct(Application $app) |
|
29 | - { |
|
30 | - $this->app = $app; |
|
31 | - $this->admin = $app->make(AdminController::class); |
|
32 | - $this->basename = plugin_basename($app->file); |
|
33 | - $this->blocks = $app->make(BlocksController::class); |
|
34 | - $this->editor = $app->make(EditorController::class); |
|
35 | - $this->listtable = $app->make(ListTableController::class); |
|
36 | - $this->public = $app->make(PublicController::class); |
|
37 | - $this->rebusify = $app->make(RebusifyController::class); |
|
38 | - $this->translator = $app->make(Translator::class); |
|
39 | - $this->welcome = $app->make(WelcomeController::class); |
|
40 | - } |
|
28 | + public function __construct(Application $app) |
|
29 | + { |
|
30 | + $this->app = $app; |
|
31 | + $this->admin = $app->make(AdminController::class); |
|
32 | + $this->basename = plugin_basename($app->file); |
|
33 | + $this->blocks = $app->make(BlocksController::class); |
|
34 | + $this->editor = $app->make(EditorController::class); |
|
35 | + $this->listtable = $app->make(ListTableController::class); |
|
36 | + $this->public = $app->make(PublicController::class); |
|
37 | + $this->rebusify = $app->make(RebusifyController::class); |
|
38 | + $this->translator = $app->make(Translator::class); |
|
39 | + $this->welcome = $app->make(WelcomeController::class); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function run() |
|
46 | - { |
|
47 | - add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
48 | - add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
49 | - add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
50 | - add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
51 | - add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
52 | - add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
53 | - add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
54 | - add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
55 | - add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
56 | - add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
57 | - add_filter('gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3); |
|
58 | - add_filter('gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4); |
|
59 | - add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
60 | - add_filter('bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2); |
|
61 | - add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
62 | - add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
63 | - add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
64 | - add_filter('display_post_states', [$this->listtable, 'filterPostStates'], 10, 2); |
|
65 | - add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
66 | - add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
67 | - add_filter('ngettext', [$this->listtable, 'filterStatusText'], 10, 5); |
|
68 | - add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
69 | - add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
70 | - add_filter('query_vars', [$this->public, 'filterQueryVars']); |
|
71 | - add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
72 | - add_filter('site-reviews/settings/callback', [$this->rebusify, 'filterSettingsCallback']); |
|
73 | - add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->rebusify, 'filterSettingsTableRow'], 10, 3); |
|
74 | - add_filter('gettext', [$this->translator, 'filterGettext'], 10, 3); |
|
75 | - add_filter('gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4); |
|
76 | - add_filter('ngettext', [$this->translator, 'filterNgettext'], 10, 5); |
|
77 | - add_filter('ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6); |
|
78 | - add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
79 | - add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
80 | - add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
81 | - } |
|
42 | + /** |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function run() |
|
46 | + { |
|
47 | + add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
48 | + add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
49 | + add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
50 | + add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
51 | + add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
52 | + add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
53 | + add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
54 | + add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
55 | + add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
56 | + add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
57 | + add_filter('gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3); |
|
58 | + add_filter('gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4); |
|
59 | + add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
60 | + add_filter('bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2); |
|
61 | + add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
62 | + add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
63 | + add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
64 | + add_filter('display_post_states', [$this->listtable, 'filterPostStates'], 10, 2); |
|
65 | + add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
66 | + add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
67 | + add_filter('ngettext', [$this->listtable, 'filterStatusText'], 10, 5); |
|
68 | + add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
69 | + add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
70 | + add_filter('query_vars', [$this->public, 'filterQueryVars']); |
|
71 | + add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
72 | + add_filter('site-reviews/settings/callback', [$this->rebusify, 'filterSettingsCallback']); |
|
73 | + add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->rebusify, 'filterSettingsTableRow'], 10, 3); |
|
74 | + add_filter('gettext', [$this->translator, 'filterGettext'], 10, 3); |
|
75 | + add_filter('gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4); |
|
76 | + add_filter('ngettext', [$this->translator, 'filterNgettext'], 10, 5); |
|
77 | + add_filter('ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6); |
|
78 | + add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
79 | + add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
80 | + add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
81 | + } |
|
82 | 82 | } |
@@ -8,241 +8,241 @@ |
||
8 | 8 | |
9 | 9 | class Field |
10 | 10 | { |
11 | - /** |
|
12 | - * @var array |
|
13 | - */ |
|
14 | - public $field; |
|
15 | - |
|
16 | - public function __construct(array $field = []) |
|
17 | - { |
|
18 | - $this->field = wp_parse_args($field, [ |
|
19 | - 'errors' => false, |
|
20 | - 'is_hidden' => false, |
|
21 | - 'is_multi' => false, |
|
22 | - 'is_public' => false, |
|
23 | - 'is_raw' => false, |
|
24 | - 'is_setting' => false, |
|
25 | - 'is_valid' => true, |
|
26 | - 'is_widget' => false, |
|
27 | - 'path' => '', |
|
28 | - ]); |
|
29 | - $this->normalize(); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function __toString() |
|
36 | - { |
|
37 | - return (string) $this->build(); |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * @return void|string |
|
42 | - */ |
|
43 | - public function build() |
|
44 | - { |
|
45 | - if (!$this->field['is_valid']) { |
|
46 | - return; |
|
47 | - } |
|
48 | - if ($this->field['is_raw']) { |
|
49 | - return glsr(Builder::class)->{$this->field['type']}($this->field); |
|
50 | - } |
|
51 | - if (!$this->field['is_setting']) { |
|
52 | - return $this->buildField(); |
|
53 | - } |
|
54 | - if (!$this->field['is_multi']) { |
|
55 | - return $this->buildSettingField(); |
|
56 | - } |
|
57 | - return $this->buildSettingMultiField(); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function render() |
|
64 | - { |
|
65 | - echo $this->build(); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - protected function buildField() |
|
72 | - { |
|
73 | - $field = glsr(Template::class)->build('templates/form/field_'.$this->field['type'], [ |
|
74 | - 'context' => [ |
|
75 | - 'class' => $this->getFieldClass(), |
|
76 | - 'errors' => $this->getFieldErrors(), |
|
77 | - 'field' => glsr(Builder::class)->raw($this->field), |
|
78 | - 'label' => glsr(Builder::class)->label([ |
|
79 | - 'class' => 'glsr-'.$this->field['type'].'-label', |
|
80 | - 'for' => $this->field['id'], |
|
81 | - 'is_public' => $this->field['is_public'], |
|
82 | - 'text' => $this->field['label'].'<span></span>', |
|
83 | - 'type' => $this->field['type'], |
|
84 | - ]), |
|
85 | - ], |
|
86 | - 'field' => $this->field, |
|
87 | - ]); |
|
88 | - return apply_filters('site-reviews/rendered/field', $field, $this->field['type'], $this->field); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - protected function buildSettingField() |
|
95 | - { |
|
96 | - return glsr(Template::class)->build('partials/form/table-row', [ |
|
97 | - 'context' => [ |
|
98 | - 'class' => $this->getFieldClass(), |
|
99 | - 'field' => glsr(Builder::class)->{$this->field['type']}($this->field), |
|
100 | - 'label' => glsr(Builder::class)->label($this->field['legend'], ['for' => $this->field['id']]), |
|
101 | - ], |
|
102 | - 'field' => $this->field, |
|
103 | - ]); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - protected function buildSettingMultiField() |
|
110 | - { |
|
111 | - $dependsOn = $this->getFieldDependsOn(); |
|
112 | - unset($this->field['data-depends']); |
|
113 | - return glsr(Template::class)->build('partials/form/table-row-multiple', [ |
|
114 | - 'context' => [ |
|
115 | - 'class' => $this->getFieldClass(), |
|
116 | - 'depends_on' => $dependsOn, |
|
117 | - 'field' => glsr(Builder::class)->{$this->field['type']}($this->field), |
|
118 | - 'label' => glsr(Builder::class)->label($this->field['legend'], ['for' => $this->field['id']]), |
|
119 | - 'legend' => $this->field['legend'], |
|
120 | - ], |
|
121 | - 'field' => $this->field, |
|
122 | - ]); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - protected function getFieldClass() |
|
129 | - { |
|
130 | - $classes = []; |
|
131 | - if (!empty($this->field['errors'])) { |
|
132 | - $classes[] = 'glsr-has-error'; |
|
133 | - } |
|
134 | - if ($this->field['is_hidden']) { |
|
135 | - $classes[] = 'hidden'; |
|
136 | - } |
|
137 | - if (!empty($this->field['required'])) { |
|
138 | - $classes[] = 'glsr-required'; |
|
139 | - } |
|
140 | - $classes = apply_filters('site-reviews/rendered/field/classes', $classes, $this->field); |
|
141 | - return implode(' ', $classes); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - protected function getFieldDependsOn() |
|
148 | - { |
|
149 | - return !empty($this->field['data-depends']) |
|
150 | - ? $this->field['data-depends'] |
|
151 | - : ''; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return void|string |
|
156 | - */ |
|
157 | - protected function getFieldErrors() |
|
158 | - { |
|
159 | - if (empty($this->field['errors']) || !is_array($this->field['errors'])) { |
|
160 | - return; |
|
161 | - } |
|
162 | - $errors = array_reduce($this->field['errors'], function ($carry, $error) { |
|
163 | - return $carry.glsr(Builder::class)->span($error, ['class' => 'glsr-field-error']); |
|
164 | - }); |
|
165 | - return glsr(Template::class)->build('templates/form/field-errors', [ |
|
166 | - 'context' => [ |
|
167 | - 'errors' => $errors, |
|
168 | - ], |
|
169 | - 'field' => $this->field, |
|
170 | - ]); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - protected function getFieldPrefix() |
|
177 | - { |
|
178 | - return $this->field['is_setting'] |
|
179 | - ? OptionManager::databaseKey() |
|
180 | - : Application::ID; |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * @return bool |
|
185 | - */ |
|
186 | - protected function isFieldValid() |
|
187 | - { |
|
188 | - $missingValues = []; |
|
189 | - $requiredValues = [ |
|
190 | - 'name', 'type', |
|
191 | - ]; |
|
192 | - foreach ($requiredValues as $value) { |
|
193 | - if (isset($this->field[$value])) { |
|
194 | - continue; |
|
195 | - } |
|
196 | - $missingValues[] = $value; |
|
197 | - $this->field['is_valid'] = false; |
|
198 | - } |
|
199 | - if (!empty($missingValues)) { |
|
200 | - glsr_log() |
|
201 | - ->warning('Field is missing: '.implode(', ', $missingValues)) |
|
202 | - ->debug($this->field); |
|
203 | - } |
|
204 | - return $this->field['is_valid']; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - protected function normalize() |
|
211 | - { |
|
212 | - if (!$this->isFieldValid()) { |
|
213 | - return; |
|
214 | - } |
|
215 | - $this->field['path'] = $this->field['name']; |
|
216 | - $className = glsr(Helper::class)->buildClassName($this->field['type'], __NAMESPACE__.'\Fields'); |
|
217 | - if (class_exists($className)) { |
|
218 | - $this->field = $className::merge($this->field); |
|
219 | - } |
|
220 | - $this->normalizeFieldId(); |
|
221 | - $this->normalizeFieldName(); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * @return void |
|
226 | - */ |
|
227 | - protected function normalizeFieldId() |
|
228 | - { |
|
229 | - if (isset($this->field['id']) || $this->field['is_raw']) { |
|
230 | - return; |
|
231 | - } |
|
232 | - $this->field['id'] = glsr(Helper::class)->convertPathToId( |
|
233 | - $this->field['path'], |
|
234 | - $this->getFieldPrefix() |
|
235 | - ); |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * @return void |
|
240 | - */ |
|
241 | - protected function normalizeFieldName() |
|
242 | - { |
|
243 | - $this->field['name'] = glsr(Helper::class)->convertPathToName( |
|
244 | - $this->field['path'], |
|
245 | - $this->getFieldPrefix() |
|
246 | - ); |
|
247 | - } |
|
11 | + /** |
|
12 | + * @var array |
|
13 | + */ |
|
14 | + public $field; |
|
15 | + |
|
16 | + public function __construct(array $field = []) |
|
17 | + { |
|
18 | + $this->field = wp_parse_args($field, [ |
|
19 | + 'errors' => false, |
|
20 | + 'is_hidden' => false, |
|
21 | + 'is_multi' => false, |
|
22 | + 'is_public' => false, |
|
23 | + 'is_raw' => false, |
|
24 | + 'is_setting' => false, |
|
25 | + 'is_valid' => true, |
|
26 | + 'is_widget' => false, |
|
27 | + 'path' => '', |
|
28 | + ]); |
|
29 | + $this->normalize(); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function __toString() |
|
36 | + { |
|
37 | + return (string) $this->build(); |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * @return void|string |
|
42 | + */ |
|
43 | + public function build() |
|
44 | + { |
|
45 | + if (!$this->field['is_valid']) { |
|
46 | + return; |
|
47 | + } |
|
48 | + if ($this->field['is_raw']) { |
|
49 | + return glsr(Builder::class)->{$this->field['type']}($this->field); |
|
50 | + } |
|
51 | + if (!$this->field['is_setting']) { |
|
52 | + return $this->buildField(); |
|
53 | + } |
|
54 | + if (!$this->field['is_multi']) { |
|
55 | + return $this->buildSettingField(); |
|
56 | + } |
|
57 | + return $this->buildSettingMultiField(); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function render() |
|
64 | + { |
|
65 | + echo $this->build(); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + protected function buildField() |
|
72 | + { |
|
73 | + $field = glsr(Template::class)->build('templates/form/field_'.$this->field['type'], [ |
|
74 | + 'context' => [ |
|
75 | + 'class' => $this->getFieldClass(), |
|
76 | + 'errors' => $this->getFieldErrors(), |
|
77 | + 'field' => glsr(Builder::class)->raw($this->field), |
|
78 | + 'label' => glsr(Builder::class)->label([ |
|
79 | + 'class' => 'glsr-'.$this->field['type'].'-label', |
|
80 | + 'for' => $this->field['id'], |
|
81 | + 'is_public' => $this->field['is_public'], |
|
82 | + 'text' => $this->field['label'].'<span></span>', |
|
83 | + 'type' => $this->field['type'], |
|
84 | + ]), |
|
85 | + ], |
|
86 | + 'field' => $this->field, |
|
87 | + ]); |
|
88 | + return apply_filters('site-reviews/rendered/field', $field, $this->field['type'], $this->field); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + protected function buildSettingField() |
|
95 | + { |
|
96 | + return glsr(Template::class)->build('partials/form/table-row', [ |
|
97 | + 'context' => [ |
|
98 | + 'class' => $this->getFieldClass(), |
|
99 | + 'field' => glsr(Builder::class)->{$this->field['type']}($this->field), |
|
100 | + 'label' => glsr(Builder::class)->label($this->field['legend'], ['for' => $this->field['id']]), |
|
101 | + ], |
|
102 | + 'field' => $this->field, |
|
103 | + ]); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + protected function buildSettingMultiField() |
|
110 | + { |
|
111 | + $dependsOn = $this->getFieldDependsOn(); |
|
112 | + unset($this->field['data-depends']); |
|
113 | + return glsr(Template::class)->build('partials/form/table-row-multiple', [ |
|
114 | + 'context' => [ |
|
115 | + 'class' => $this->getFieldClass(), |
|
116 | + 'depends_on' => $dependsOn, |
|
117 | + 'field' => glsr(Builder::class)->{$this->field['type']}($this->field), |
|
118 | + 'label' => glsr(Builder::class)->label($this->field['legend'], ['for' => $this->field['id']]), |
|
119 | + 'legend' => $this->field['legend'], |
|
120 | + ], |
|
121 | + 'field' => $this->field, |
|
122 | + ]); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + protected function getFieldClass() |
|
129 | + { |
|
130 | + $classes = []; |
|
131 | + if (!empty($this->field['errors'])) { |
|
132 | + $classes[] = 'glsr-has-error'; |
|
133 | + } |
|
134 | + if ($this->field['is_hidden']) { |
|
135 | + $classes[] = 'hidden'; |
|
136 | + } |
|
137 | + if (!empty($this->field['required'])) { |
|
138 | + $classes[] = 'glsr-required'; |
|
139 | + } |
|
140 | + $classes = apply_filters('site-reviews/rendered/field/classes', $classes, $this->field); |
|
141 | + return implode(' ', $classes); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + protected function getFieldDependsOn() |
|
148 | + { |
|
149 | + return !empty($this->field['data-depends']) |
|
150 | + ? $this->field['data-depends'] |
|
151 | + : ''; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return void|string |
|
156 | + */ |
|
157 | + protected function getFieldErrors() |
|
158 | + { |
|
159 | + if (empty($this->field['errors']) || !is_array($this->field['errors'])) { |
|
160 | + return; |
|
161 | + } |
|
162 | + $errors = array_reduce($this->field['errors'], function ($carry, $error) { |
|
163 | + return $carry.glsr(Builder::class)->span($error, ['class' => 'glsr-field-error']); |
|
164 | + }); |
|
165 | + return glsr(Template::class)->build('templates/form/field-errors', [ |
|
166 | + 'context' => [ |
|
167 | + 'errors' => $errors, |
|
168 | + ], |
|
169 | + 'field' => $this->field, |
|
170 | + ]); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + protected function getFieldPrefix() |
|
177 | + { |
|
178 | + return $this->field['is_setting'] |
|
179 | + ? OptionManager::databaseKey() |
|
180 | + : Application::ID; |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * @return bool |
|
185 | + */ |
|
186 | + protected function isFieldValid() |
|
187 | + { |
|
188 | + $missingValues = []; |
|
189 | + $requiredValues = [ |
|
190 | + 'name', 'type', |
|
191 | + ]; |
|
192 | + foreach ($requiredValues as $value) { |
|
193 | + if (isset($this->field[$value])) { |
|
194 | + continue; |
|
195 | + } |
|
196 | + $missingValues[] = $value; |
|
197 | + $this->field['is_valid'] = false; |
|
198 | + } |
|
199 | + if (!empty($missingValues)) { |
|
200 | + glsr_log() |
|
201 | + ->warning('Field is missing: '.implode(', ', $missingValues)) |
|
202 | + ->debug($this->field); |
|
203 | + } |
|
204 | + return $this->field['is_valid']; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + protected function normalize() |
|
211 | + { |
|
212 | + if (!$this->isFieldValid()) { |
|
213 | + return; |
|
214 | + } |
|
215 | + $this->field['path'] = $this->field['name']; |
|
216 | + $className = glsr(Helper::class)->buildClassName($this->field['type'], __NAMESPACE__.'\Fields'); |
|
217 | + if (class_exists($className)) { |
|
218 | + $this->field = $className::merge($this->field); |
|
219 | + } |
|
220 | + $this->normalizeFieldId(); |
|
221 | + $this->normalizeFieldName(); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * @return void |
|
226 | + */ |
|
227 | + protected function normalizeFieldId() |
|
228 | + { |
|
229 | + if (isset($this->field['id']) || $this->field['is_raw']) { |
|
230 | + return; |
|
231 | + } |
|
232 | + $this->field['id'] = glsr(Helper::class)->convertPathToId( |
|
233 | + $this->field['path'], |
|
234 | + $this->getFieldPrefix() |
|
235 | + ); |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * @return void |
|
240 | + */ |
|
241 | + protected function normalizeFieldName() |
|
242 | + { |
|
243 | + $this->field['name'] = glsr(Helper::class)->convertPathToName( |
|
244 | + $this->field['path'], |
|
245 | + $this->getFieldPrefix() |
|
246 | + ); |
|
247 | + } |
|
248 | 248 | } |
@@ -6,78 +6,78 @@ |
||
6 | 6 | |
7 | 7 | class Template |
8 | 8 | { |
9 | - /** |
|
10 | - * @param string $templatePath |
|
11 | - * @return void|string |
|
12 | - */ |
|
13 | - public function build($templatePath, array $data = []) |
|
14 | - { |
|
15 | - $data = $this->normalize($data); |
|
16 | - ob_start(); |
|
17 | - glsr()->render($templatePath, $data); |
|
18 | - $template = ob_get_clean(); |
|
19 | - $path = glsr(Helper::class)->removePrefix('templates/', $templatePath); |
|
20 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
21 | - $template = $this->interpolate($template, $data, $path); |
|
22 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
23 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
24 | - return $template; |
|
25 | - } |
|
9 | + /** |
|
10 | + * @param string $templatePath |
|
11 | + * @return void|string |
|
12 | + */ |
|
13 | + public function build($templatePath, array $data = []) |
|
14 | + { |
|
15 | + $data = $this->normalize($data); |
|
16 | + ob_start(); |
|
17 | + glsr()->render($templatePath, $data); |
|
18 | + $template = ob_get_clean(); |
|
19 | + $path = glsr(Helper::class)->removePrefix('templates/', $templatePath); |
|
20 | + $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
21 | + $template = $this->interpolate($template, $data, $path); |
|
22 | + $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
23 | + $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
24 | + return $template; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Interpolate context values into template placeholders. |
|
29 | - * @param string $template |
|
30 | - * @param string $templatePath |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function interpolate($template, array $data = [], $templatePath) |
|
34 | - { |
|
35 | - $context = $this->normalizeContext(glsr_get($data, 'context', [])); |
|
36 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
37 | - foreach ($context as $key => $value) { |
|
38 | - $template = strtr( |
|
39 | - $template, |
|
40 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
41 | - ); |
|
42 | - } |
|
43 | - return trim($template); |
|
44 | - } |
|
27 | + /** |
|
28 | + * Interpolate context values into template placeholders. |
|
29 | + * @param string $template |
|
30 | + * @param string $templatePath |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function interpolate($template, array $data = [], $templatePath) |
|
34 | + { |
|
35 | + $context = $this->normalizeContext(glsr_get($data, 'context', [])); |
|
36 | + $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
37 | + foreach ($context as $key => $value) { |
|
38 | + $template = strtr( |
|
39 | + $template, |
|
40 | + array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
41 | + ); |
|
42 | + } |
|
43 | + return trim($template); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param string $templatePath |
|
48 | - * @return void|string |
|
49 | - */ |
|
50 | - public function render($templatePath, array $data = []) |
|
51 | - { |
|
52 | - echo $this->build($templatePath, $data); |
|
53 | - } |
|
46 | + /** |
|
47 | + * @param string $templatePath |
|
48 | + * @return void|string |
|
49 | + */ |
|
50 | + public function render($templatePath, array $data = []) |
|
51 | + { |
|
52 | + echo $this->build($templatePath, $data); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - protected function normalize(array $data) |
|
59 | - { |
|
60 | - $arrayKeys = ['context', 'globals']; |
|
61 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
62 | - foreach ($arrayKeys as $key) { |
|
63 | - if (is_array($data[$key])) { |
|
64 | - continue; |
|
65 | - } |
|
66 | - $data[$key] = []; |
|
67 | - } |
|
68 | - return $data; |
|
69 | - } |
|
55 | + /** |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + protected function normalize(array $data) |
|
59 | + { |
|
60 | + $arrayKeys = ['context', 'globals']; |
|
61 | + $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
62 | + foreach ($arrayKeys as $key) { |
|
63 | + if (is_array($data[$key])) { |
|
64 | + continue; |
|
65 | + } |
|
66 | + $data[$key] = []; |
|
67 | + } |
|
68 | + return $data; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - protected function normalizeContext(array $context) |
|
75 | - { |
|
76 | - $context = array_filter($context, function ($value) { |
|
77 | - return !is_array($value) && !is_object($value); |
|
78 | - }); |
|
79 | - return array_map(function ($value) { |
|
80 | - return (string) $value; |
|
81 | - }, $context); |
|
82 | - } |
|
71 | + /** |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + protected function normalizeContext(array $context) |
|
75 | + { |
|
76 | + $context = array_filter($context, function ($value) { |
|
77 | + return !is_array($value) && !is_object($value); |
|
78 | + }); |
|
79 | + return array_map(function ($value) { |
|
80 | + return (string) $value; |
|
81 | + }, $context); |
|
82 | + } |
|
83 | 83 | } |
@@ -1,552 +1,552 @@ |
||
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 validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | - '<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>' |
|
62 | - ), |
|
63 | - 'label' => __('Blockchain Validation', 'site-reviews'), |
|
64 | - 'type' => 'yes_no', |
|
65 | - ], |
|
66 | - 'settings.general.rebusify_email' => [ |
|
67 | - 'default' => '', |
|
68 | - 'depends_on' => [ |
|
69 | - 'settings.general.rebusify' => ['yes'], |
|
70 | - ], |
|
71 | - 'description' => __('Enter your Rebusify account email here.', 'site-reviews'), |
|
72 | - 'label' => __('Rebusify Email', 'site-reviews'), |
|
73 | - 'type' => 'email', |
|
74 | - ], |
|
75 | - 'settings.general.rebusify_serial' => [ |
|
76 | - 'default' => '', |
|
77 | - 'depends_on' => [ |
|
78 | - 'settings.general.rebusify' => ['yes'], |
|
79 | - ], |
|
80 | - 'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'), |
|
81 | - 'label' => __('Rebusify Serial Key', 'site-reviews'), |
|
82 | - 'type' => 'password', |
|
83 | - ], |
|
84 | - 'settings.general.notifications' => [ |
|
85 | - 'default' => [], |
|
86 | - 'label' => __('Notifications', 'site-reviews'), |
|
87 | - 'options' => [ |
|
88 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
92 | - ], |
|
93 | - 'type' => 'checkbox', |
|
94 | - ], |
|
95 | - 'settings.general.notification_email' => [ |
|
96 | - 'default' => '', |
|
97 | - 'depends_on' => [ |
|
98 | - 'settings.general.notifications' => ['custom'], |
|
99 | - ], |
|
100 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
102 | - 'type' => 'text', |
|
103 | - ], |
|
104 | - 'settings.general.notification_slack' => [ |
|
105 | - 'default' => '', |
|
106 | - 'depends_on' => [ |
|
107 | - 'settings.general.notifications' => ['slack'], |
|
108 | - ], |
|
109 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
111 | - ), |
|
112 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
113 | - 'type' => 'text', |
|
114 | - ], |
|
115 | - 'settings.general.notification_message' => [ |
|
116 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
117 | - 'depends_on' => [ |
|
118 | - 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
119 | - ], |
|
120 | - 'description' => __( |
|
121 | - 'To restore the default text, save an empty template. '. |
|
122 | - '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:'. |
|
123 | - '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
124 | - '<br><code>{review_title}</code> The review title'. |
|
125 | - '<br><code>{review_content}</code> The review content'. |
|
126 | - '<br><code>{review_author}</code> The review author'. |
|
127 | - '<br><code>{review_email}</code> The email of the review author'. |
|
128 | - '<br><code>{review_ip}</code> The IP address of the review author'. |
|
129 | - '<br><code>{review_link}</code> The link to edit/view a review', |
|
130 | - 'site-reviews' |
|
131 | - ), |
|
132 | - 'label' => __('Notification Template', 'site-reviews'), |
|
133 | - 'rows' => 10, |
|
134 | - 'type' => 'code', |
|
135 | - ], |
|
136 | - 'settings.reviews.date.format' => [ |
|
137 | - 'default' => '', |
|
138 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
140 | - ), |
|
141 | - 'label' => __('Date Format', 'site-reviews'), |
|
142 | - 'options' => [ |
|
143 | - '' => __('Use the default date format', 'site-reviews'), |
|
144 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
146 | - ], |
|
147 | - 'type' => 'select', |
|
148 | - ], |
|
149 | - 'settings.reviews.date.custom' => [ |
|
150 | - 'default' => get_option('date_format'), |
|
151 | - 'depends_on' => [ |
|
152 | - 'settings.reviews.date.format' => 'custom', |
|
153 | - ], |
|
154 | - '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'), |
|
155 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
156 | - 'type' => 'text', |
|
157 | - ], |
|
158 | - 'settings.reviews.name.format' => [ |
|
159 | - 'default' => '', |
|
160 | - 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | - 'label' => __('Name Format', 'site-reviews'), |
|
162 | - 'options' => [ |
|
163 | - '' => __('Use the name as given', 'site-reviews'), |
|
164 | - 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | - 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | - 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | - 'initials' => __('Convert to all initials', 'site-reviews'), |
|
168 | - ], |
|
169 | - 'type' => 'select', |
|
170 | - ], |
|
171 | - 'settings.reviews.name.initial' => [ |
|
172 | - 'default' => '', |
|
173 | - 'depends_on' => [ |
|
174 | - 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
|
175 | - ], |
|
176 | - 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | - 'label' => __('Initial Format', 'site-reviews'), |
|
178 | - 'options' => [ |
|
179 | - '' => __('Initial with a space', 'site-reviews'), |
|
180 | - 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | - 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
182 | - ], |
|
183 | - 'type' => 'select', |
|
184 | - ], |
|
185 | - 'settings.reviews.assigned_links' => [ |
|
186 | - 'default' => 'no', |
|
187 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
189 | - 'type' => 'yes_no', |
|
190 | - ], |
|
191 | - 'settings.reviews.avatars' => [ |
|
192 | - 'default' => 'no', |
|
193 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
195 | - 'type' => 'yes_no', |
|
196 | - ], |
|
197 | - 'settings.reviews.avatars_regenerate' => [ |
|
198 | - 'default' => 'no', |
|
199 | - 'depends_on' => [ |
|
200 | - 'settings.reviews.avatars' => 'yes', |
|
201 | - ], |
|
202 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
204 | - 'type' => 'yes_no', |
|
205 | - ], |
|
206 | - 'settings.reviews.avatars_size' => [ |
|
207 | - 'default' => 40, |
|
208 | - 'depends_on' => [ |
|
209 | - 'settings.reviews.avatars' => 'yes', |
|
210 | - ], |
|
211 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
213 | - 'type' => 'number', |
|
214 | - ], |
|
215 | - 'settings.reviews.excerpts' => [ |
|
216 | - 'default' => 'yes', |
|
217 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
219 | - 'type' => 'yes_no', |
|
220 | - ], |
|
221 | - 'settings.reviews.excerpts_length' => [ |
|
222 | - 'default' => 55, |
|
223 | - 'depends_on' => [ |
|
224 | - 'settings.reviews.excerpts' => 'yes', |
|
225 | - ], |
|
226 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
228 | - 'type' => 'number', |
|
229 | - ], |
|
230 | - 'settings.reviews.fallback' => [ |
|
231 | - 'default' => 'yes', |
|
232 | - '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'), |
|
233 | - '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
235 | - ), |
|
236 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
237 | - 'type' => 'yes_no', |
|
238 | - ], |
|
239 | - 'settings.schema.type.default' => [ |
|
240 | - 'default' => 'LocalBusiness', |
|
241 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
242 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
243 | - 'options' => [ |
|
244 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
245 | - 'Product' => __('Product', 'site-reviews'), |
|
246 | - 'custom' => __('Custom', 'site-reviews'), |
|
247 | - ], |
|
248 | - 'type' => 'select', |
|
249 | - ], |
|
250 | - 'settings.schema.type.custom' => [ |
|
251 | - 'default' => '', |
|
252 | - 'depends_on' => [ |
|
253 | - 'settings.schema.type.default' => 'custom', |
|
254 | - ], |
|
255 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
256 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
257 | - 'type' => 'text', |
|
258 | - ], |
|
259 | - 'settings.schema.name.default' => [ |
|
260 | - 'default' => 'post', |
|
261 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
262 | - 'label' => __('Default Name', 'site-reviews'), |
|
263 | - 'options' => [ |
|
264 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
265 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
266 | - ], |
|
267 | - 'type' => 'select', |
|
268 | - ], |
|
269 | - 'settings.schema.name.custom' => [ |
|
270 | - 'default' => '', |
|
271 | - 'depends_on' => [ |
|
272 | - 'settings.schema.name.default' => 'custom', |
|
273 | - ], |
|
274 | - 'label' => __('Custom Name', 'site-reviews'), |
|
275 | - 'type' => 'text', |
|
276 | - ], |
|
277 | - 'settings.schema.description.default' => [ |
|
278 | - 'default' => 'post', |
|
279 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
280 | - 'label' => __('Default Description', 'site-reviews'), |
|
281 | - 'options' => [ |
|
282 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
283 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
284 | - ], |
|
285 | - 'type' => 'select', |
|
286 | - ], |
|
287 | - 'settings.schema.description.custom' => [ |
|
288 | - 'default' => '', |
|
289 | - 'depends_on' => [ |
|
290 | - 'settings.schema.description.default' => 'custom', |
|
291 | - ], |
|
292 | - 'label' => __('Custom Description', 'site-reviews'), |
|
293 | - 'type' => 'text', |
|
294 | - ], |
|
295 | - 'settings.schema.url.default' => [ |
|
296 | - 'default' => 'post', |
|
297 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
298 | - 'label' => __('Default URL', 'site-reviews'), |
|
299 | - 'options' => [ |
|
300 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
301 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
302 | - ], |
|
303 | - 'type' => 'select', |
|
304 | - ], |
|
305 | - 'settings.schema.url.custom' => [ |
|
306 | - 'default' => '', |
|
307 | - 'depends_on' => [ |
|
308 | - 'settings.schema.url.default' => 'custom', |
|
309 | - ], |
|
310 | - 'label' => __('Custom URL', 'site-reviews'), |
|
311 | - 'type' => 'text', |
|
312 | - ], |
|
313 | - 'settings.schema.image.default' => [ |
|
314 | - 'default' => 'post', |
|
315 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
316 | - 'label' => __('Default Image', 'site-reviews'), |
|
317 | - 'options' => [ |
|
318 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
319 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
320 | - ], |
|
321 | - 'type' => 'select', |
|
322 | - ], |
|
323 | - 'settings.schema.image.custom' => [ |
|
324 | - 'default' => '', |
|
325 | - 'depends_on' => [ |
|
326 | - 'settings.schema.image.default' => 'custom', |
|
327 | - ], |
|
328 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
329 | - 'type' => 'text', |
|
330 | - ], |
|
331 | - 'settings.schema.address' => [ |
|
332 | - 'default' => '', |
|
333 | - 'depends_on' => [ |
|
334 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
335 | - ], |
|
336 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
337 | - 'label' => __('Address', 'site-reviews'), |
|
338 | - 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
339 | - 'type' => 'text', |
|
340 | - ], |
|
341 | - 'settings.schema.telephone' => [ |
|
342 | - 'default' => '', |
|
343 | - 'depends_on' => [ |
|
344 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
345 | - ], |
|
346 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
347 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
348 | - 'placeholder' => '+1 (877) 273-3049', |
|
349 | - 'type' => 'text', |
|
350 | - ], |
|
351 | - 'settings.schema.pricerange' => [ |
|
352 | - 'default' => '', |
|
353 | - 'depends_on' => [ |
|
354 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
355 | - ], |
|
356 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
357 | - 'label' => __('Price Range', 'site-reviews'), |
|
358 | - 'placeholder' => '$$-$$$', |
|
359 | - 'type' => 'text', |
|
360 | - ], |
|
361 | - 'settings.schema.offertype' => [ |
|
362 | - 'default' => 'AggregateOffer', |
|
363 | - 'depends_on' => [ |
|
364 | - 'settings.schema.type.default' => 'Product', |
|
365 | - ], |
|
366 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
367 | - 'label' => __('Offer Type', 'site-reviews'), |
|
368 | - 'options' => [ |
|
369 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
370 | - 'Offer' => __('Offer', 'site-reviews'), |
|
371 | - ], |
|
372 | - 'type' => 'select', |
|
373 | - ], |
|
374 | - 'settings.schema.price' => [ |
|
375 | - 'default' => '', |
|
376 | - 'depends_on' => [ |
|
377 | - 'settings.schema.type.default' => 'Product', |
|
378 | - 'settings.schema.offertype' => 'Offer', |
|
379 | - ], |
|
380 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
381 | - 'label' => __('Price', 'site-reviews'), |
|
382 | - 'placeholder' => '50.00', |
|
383 | - 'type' => 'text', |
|
384 | - ], |
|
385 | - 'settings.schema.lowprice' => [ |
|
386 | - 'default' => '', |
|
387 | - 'depends_on' => [ |
|
388 | - 'settings.schema.type.default' => 'Product', |
|
389 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
390 | - ], |
|
391 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
392 | - 'label' => __('Low Price', 'site-reviews'), |
|
393 | - 'placeholder' => '10.00', |
|
394 | - 'type' => 'text', |
|
395 | - ], |
|
396 | - 'settings.schema.highprice' => [ |
|
397 | - 'default' => '', |
|
398 | - 'depends_on' => [ |
|
399 | - 'settings.schema.type.default' => 'Product', |
|
400 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
401 | - ], |
|
402 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
403 | - 'label' => __('High Price', 'site-reviews'), |
|
404 | - 'placeholder' => '100.00', |
|
405 | - 'type' => 'text', |
|
406 | - ], |
|
407 | - 'settings.schema.pricecurrency' => [ |
|
408 | - 'default' => '', |
|
409 | - 'depends_on' => [ |
|
410 | - 'settings.schema.type.default' => 'Product', |
|
411 | - ], |
|
412 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
413 | - 'label' => __('Price Currency', 'site-reviews'), |
|
414 | - 'placeholder' => 'USD', |
|
415 | - 'type' => 'text', |
|
416 | - ], |
|
417 | - 'settings.submissions.required' => [ |
|
418 | - 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
419 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
420 | - 'label' => __('Required Fields', 'site-reviews'), |
|
421 | - 'options' => [ |
|
422 | - 'rating' => __('Rating', 'site-reviews'), |
|
423 | - 'title' => __('Title', 'site-reviews'), |
|
424 | - 'content' => __('Review', 'site-reviews'), |
|
425 | - 'name' => __('Name', 'site-reviews'), |
|
426 | - 'email' => __('Email', 'site-reviews'), |
|
427 | - 'terms' => __('Terms', 'site-reviews'), |
|
428 | - ], |
|
429 | - 'type' => 'checkbox', |
|
430 | - ], |
|
431 | - 'settings.submissions.limit' => [ |
|
432 | - 'default' => '', |
|
433 | - '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'), |
|
434 | - 'label' => __('Limit Reviews', 'site-reviews'), |
|
435 | - 'options' => [ |
|
436 | - '' => __('No Limit', 'site-reviews'), |
|
437 | - 'email' => __('By Email Address', 'site-reviews'), |
|
438 | - 'ip_address' => __('By IP Address', 'site-reviews'), |
|
439 | - 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
440 | - ], |
|
441 | - 'type' => 'select', |
|
442 | - ], |
|
443 | - 'settings.submissions.limit_whitelist.email' => [ |
|
444 | - 'default' => '', |
|
445 | - 'depends_on' => [ |
|
446 | - 'settings.submissions.limit' => ['email'], |
|
447 | - ], |
|
448 | - 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
449 | - 'label' => __('Email Whitelist', 'site-reviews'), |
|
450 | - 'rows' => 5, |
|
451 | - 'type' => 'code', |
|
452 | - ], |
|
453 | - 'settings.submissions.limit_whitelist.ip_address' => [ |
|
454 | - 'default' => '', |
|
455 | - 'depends_on' => [ |
|
456 | - 'settings.submissions.limit' => ['ip_address'], |
|
457 | - ], |
|
458 | - 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
459 | - 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
460 | - 'rows' => 5, |
|
461 | - 'type' => 'code', |
|
462 | - ], |
|
463 | - 'settings.submissions.limit_whitelist.username' => [ |
|
464 | - 'default' => '', |
|
465 | - 'depends_on' => [ |
|
466 | - 'settings.submissions.limit' => ['username'], |
|
467 | - ], |
|
468 | - 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
469 | - 'label' => __('Username Whitelist', 'site-reviews'), |
|
470 | - 'rows' => 5, |
|
471 | - 'type' => 'code', |
|
472 | - ], |
|
473 | - 'settings.submissions.recaptcha.integration' => [ |
|
474 | - 'default' => '', |
|
475 | - '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'), |
|
476 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
477 | - 'options' => [ |
|
478 | - '' => 'Do not use reCAPTCHA', |
|
479 | - 'all' => 'Use reCAPTCHA', |
|
480 | - 'guest' => 'Use reCAPTCHA only for guest users', |
|
481 | - ], |
|
482 | - 'type' => 'select', |
|
483 | - ], |
|
484 | - 'settings.submissions.recaptcha.key' => [ |
|
485 | - 'default' => '', |
|
486 | - 'depends_on' => [ |
|
487 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
488 | - ], |
|
489 | - 'label' => __('Site Key', 'site-reviews'), |
|
490 | - 'type' => 'text', |
|
491 | - ], |
|
492 | - 'settings.submissions.recaptcha.secret' => [ |
|
493 | - 'default' => '', |
|
494 | - 'depends_on' => [ |
|
495 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
496 | - ], |
|
497 | - 'label' => __('Site Secret', 'site-reviews'), |
|
498 | - 'type' => 'text', |
|
499 | - ], |
|
500 | - 'settings.submissions.recaptcha.position' => [ |
|
501 | - 'default' => 'bottomleft', |
|
502 | - 'depends_on' => [ |
|
503 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
504 | - ], |
|
505 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
506 | - 'label' => __('Badge Position', 'site-reviews'), |
|
507 | - 'options' => [ |
|
508 | - 'bottomleft' => 'Bottom Left', |
|
509 | - 'bottomright' => 'Bottom Right', |
|
510 | - 'inline' => 'Inline', |
|
511 | - ], |
|
512 | - 'type' => 'select', |
|
513 | - ], |
|
514 | - 'settings.submissions.akismet' => [ |
|
515 | - 'default' => 'no', |
|
516 | - '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'), |
|
517 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
518 | - 'type' => 'yes_no', |
|
519 | - ], |
|
520 | - 'settings.submissions.blacklist.integration' => [ |
|
521 | - 'default' => '', |
|
522 | - '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'), |
|
523 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
524 | - ), |
|
525 | - 'label' => __('Blacklist', 'site-reviews'), |
|
526 | - 'options' => [ |
|
527 | - '' => 'Use the Site Reviews Blacklist', |
|
528 | - 'comments' => 'Use the WordPress Comment Blacklist', |
|
529 | - ], |
|
530 | - 'type' => 'select', |
|
531 | - ], |
|
532 | - 'settings.submissions.blacklist.entries' => [ |
|
533 | - 'default' => '', |
|
534 | - 'depends_on' => [ |
|
535 | - 'settings.submissions.blacklist.integration' => [''], |
|
536 | - ], |
|
537 | - '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'), |
|
538 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
539 | - 'rows' => 10, |
|
540 | - 'type' => 'code', |
|
541 | - ], |
|
542 | - 'settings.submissions.blacklist.action' => [ |
|
543 | - 'default' => 'unapprove', |
|
544 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
545 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
546 | - 'options' => [ |
|
547 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
548 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
549 | - ], |
|
550 | - 'type' => 'select', |
|
551 | - ], |
|
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 validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | + '<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>' |
|
62 | + ), |
|
63 | + 'label' => __('Blockchain Validation', 'site-reviews'), |
|
64 | + 'type' => 'yes_no', |
|
65 | + ], |
|
66 | + 'settings.general.rebusify_email' => [ |
|
67 | + 'default' => '', |
|
68 | + 'depends_on' => [ |
|
69 | + 'settings.general.rebusify' => ['yes'], |
|
70 | + ], |
|
71 | + 'description' => __('Enter your Rebusify account email here.', 'site-reviews'), |
|
72 | + 'label' => __('Rebusify Email', 'site-reviews'), |
|
73 | + 'type' => 'email', |
|
74 | + ], |
|
75 | + 'settings.general.rebusify_serial' => [ |
|
76 | + 'default' => '', |
|
77 | + 'depends_on' => [ |
|
78 | + 'settings.general.rebusify' => ['yes'], |
|
79 | + ], |
|
80 | + 'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'), |
|
81 | + 'label' => __('Rebusify Serial Key', 'site-reviews'), |
|
82 | + 'type' => 'password', |
|
83 | + ], |
|
84 | + 'settings.general.notifications' => [ |
|
85 | + 'default' => [], |
|
86 | + 'label' => __('Notifications', 'site-reviews'), |
|
87 | + 'options' => [ |
|
88 | + 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | + 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | + 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | + 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
92 | + ], |
|
93 | + 'type' => 'checkbox', |
|
94 | + ], |
|
95 | + 'settings.general.notification_email' => [ |
|
96 | + 'default' => '', |
|
97 | + 'depends_on' => [ |
|
98 | + 'settings.general.notifications' => ['custom'], |
|
99 | + ], |
|
100 | + 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | + 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
102 | + 'type' => 'text', |
|
103 | + ], |
|
104 | + 'settings.general.notification_slack' => [ |
|
105 | + 'default' => '', |
|
106 | + 'depends_on' => [ |
|
107 | + 'settings.general.notifications' => ['slack'], |
|
108 | + ], |
|
109 | + 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | + '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
111 | + ), |
|
112 | + 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
113 | + 'type' => 'text', |
|
114 | + ], |
|
115 | + 'settings.general.notification_message' => [ |
|
116 | + 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
117 | + 'depends_on' => [ |
|
118 | + 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
119 | + ], |
|
120 | + 'description' => __( |
|
121 | + 'To restore the default text, save an empty template. '. |
|
122 | + '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:'. |
|
123 | + '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
124 | + '<br><code>{review_title}</code> The review title'. |
|
125 | + '<br><code>{review_content}</code> The review content'. |
|
126 | + '<br><code>{review_author}</code> The review author'. |
|
127 | + '<br><code>{review_email}</code> The email of the review author'. |
|
128 | + '<br><code>{review_ip}</code> The IP address of the review author'. |
|
129 | + '<br><code>{review_link}</code> The link to edit/view a review', |
|
130 | + 'site-reviews' |
|
131 | + ), |
|
132 | + 'label' => __('Notification Template', 'site-reviews'), |
|
133 | + 'rows' => 10, |
|
134 | + 'type' => 'code', |
|
135 | + ], |
|
136 | + 'settings.reviews.date.format' => [ |
|
137 | + 'default' => '', |
|
138 | + 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | + '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
140 | + ), |
|
141 | + 'label' => __('Date Format', 'site-reviews'), |
|
142 | + 'options' => [ |
|
143 | + '' => __('Use the default date format', 'site-reviews'), |
|
144 | + 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | + 'custom' => __('Use a custom date format', 'site-reviews'), |
|
146 | + ], |
|
147 | + 'type' => 'select', |
|
148 | + ], |
|
149 | + 'settings.reviews.date.custom' => [ |
|
150 | + 'default' => get_option('date_format'), |
|
151 | + 'depends_on' => [ |
|
152 | + 'settings.reviews.date.format' => 'custom', |
|
153 | + ], |
|
154 | + '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'), |
|
155 | + 'label' => __('Custom Date Format', 'site-reviews'), |
|
156 | + 'type' => 'text', |
|
157 | + ], |
|
158 | + 'settings.reviews.name.format' => [ |
|
159 | + 'default' => '', |
|
160 | + 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | + 'label' => __('Name Format', 'site-reviews'), |
|
162 | + 'options' => [ |
|
163 | + '' => __('Use the name as given', 'site-reviews'), |
|
164 | + 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | + 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | + 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | + 'initials' => __('Convert to all initials', 'site-reviews'), |
|
168 | + ], |
|
169 | + 'type' => 'select', |
|
170 | + ], |
|
171 | + 'settings.reviews.name.initial' => [ |
|
172 | + 'default' => '', |
|
173 | + 'depends_on' => [ |
|
174 | + 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
|
175 | + ], |
|
176 | + 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | + 'label' => __('Initial Format', 'site-reviews'), |
|
178 | + 'options' => [ |
|
179 | + '' => __('Initial with a space', 'site-reviews'), |
|
180 | + 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | + 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
182 | + ], |
|
183 | + 'type' => 'select', |
|
184 | + ], |
|
185 | + 'settings.reviews.assigned_links' => [ |
|
186 | + 'default' => 'no', |
|
187 | + 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | + 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
189 | + 'type' => 'yes_no', |
|
190 | + ], |
|
191 | + 'settings.reviews.avatars' => [ |
|
192 | + 'default' => 'no', |
|
193 | + 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | + 'label' => __('Enable Avatars', 'site-reviews'), |
|
195 | + 'type' => 'yes_no', |
|
196 | + ], |
|
197 | + 'settings.reviews.avatars_regenerate' => [ |
|
198 | + 'default' => 'no', |
|
199 | + 'depends_on' => [ |
|
200 | + 'settings.reviews.avatars' => 'yes', |
|
201 | + ], |
|
202 | + 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | + 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
204 | + 'type' => 'yes_no', |
|
205 | + ], |
|
206 | + 'settings.reviews.avatars_size' => [ |
|
207 | + 'default' => 40, |
|
208 | + 'depends_on' => [ |
|
209 | + 'settings.reviews.avatars' => 'yes', |
|
210 | + ], |
|
211 | + 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | + 'label' => __('Avatar Size', 'site-reviews'), |
|
213 | + 'type' => 'number', |
|
214 | + ], |
|
215 | + 'settings.reviews.excerpts' => [ |
|
216 | + 'default' => 'yes', |
|
217 | + 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | + 'label' => __('Enable Excerpts', 'site-reviews'), |
|
219 | + 'type' => 'yes_no', |
|
220 | + ], |
|
221 | + 'settings.reviews.excerpts_length' => [ |
|
222 | + 'default' => 55, |
|
223 | + 'depends_on' => [ |
|
224 | + 'settings.reviews.excerpts' => 'yes', |
|
225 | + ], |
|
226 | + 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | + 'label' => __('Excerpt Length', 'site-reviews'), |
|
228 | + 'type' => 'number', |
|
229 | + ], |
|
230 | + 'settings.reviews.fallback' => [ |
|
231 | + 'default' => 'yes', |
|
232 | + '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'), |
|
233 | + '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | + '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
235 | + ), |
|
236 | + 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
237 | + 'type' => 'yes_no', |
|
238 | + ], |
|
239 | + 'settings.schema.type.default' => [ |
|
240 | + 'default' => 'LocalBusiness', |
|
241 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
242 | + 'label' => __('Default Schema Type', 'site-reviews'), |
|
243 | + 'options' => [ |
|
244 | + 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
245 | + 'Product' => __('Product', 'site-reviews'), |
|
246 | + 'custom' => __('Custom', 'site-reviews'), |
|
247 | + ], |
|
248 | + 'type' => 'select', |
|
249 | + ], |
|
250 | + 'settings.schema.type.custom' => [ |
|
251 | + 'default' => '', |
|
252 | + 'depends_on' => [ |
|
253 | + 'settings.schema.type.default' => 'custom', |
|
254 | + ], |
|
255 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
256 | + 'label' => __('Custom Schema Type', 'site-reviews'), |
|
257 | + 'type' => 'text', |
|
258 | + ], |
|
259 | + 'settings.schema.name.default' => [ |
|
260 | + 'default' => 'post', |
|
261 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
262 | + 'label' => __('Default Name', 'site-reviews'), |
|
263 | + 'options' => [ |
|
264 | + 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
265 | + 'custom' => __('Enter a custom title', 'site-reviews'), |
|
266 | + ], |
|
267 | + 'type' => 'select', |
|
268 | + ], |
|
269 | + 'settings.schema.name.custom' => [ |
|
270 | + 'default' => '', |
|
271 | + 'depends_on' => [ |
|
272 | + 'settings.schema.name.default' => 'custom', |
|
273 | + ], |
|
274 | + 'label' => __('Custom Name', 'site-reviews'), |
|
275 | + 'type' => 'text', |
|
276 | + ], |
|
277 | + 'settings.schema.description.default' => [ |
|
278 | + 'default' => 'post', |
|
279 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
280 | + 'label' => __('Default Description', 'site-reviews'), |
|
281 | + 'options' => [ |
|
282 | + 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
283 | + 'custom' => __('Enter a custom description', 'site-reviews'), |
|
284 | + ], |
|
285 | + 'type' => 'select', |
|
286 | + ], |
|
287 | + 'settings.schema.description.custom' => [ |
|
288 | + 'default' => '', |
|
289 | + 'depends_on' => [ |
|
290 | + 'settings.schema.description.default' => 'custom', |
|
291 | + ], |
|
292 | + 'label' => __('Custom Description', 'site-reviews'), |
|
293 | + 'type' => 'text', |
|
294 | + ], |
|
295 | + 'settings.schema.url.default' => [ |
|
296 | + 'default' => 'post', |
|
297 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
298 | + 'label' => __('Default URL', 'site-reviews'), |
|
299 | + 'options' => [ |
|
300 | + 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
301 | + 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
302 | + ], |
|
303 | + 'type' => 'select', |
|
304 | + ], |
|
305 | + 'settings.schema.url.custom' => [ |
|
306 | + 'default' => '', |
|
307 | + 'depends_on' => [ |
|
308 | + 'settings.schema.url.default' => 'custom', |
|
309 | + ], |
|
310 | + 'label' => __('Custom URL', 'site-reviews'), |
|
311 | + 'type' => 'text', |
|
312 | + ], |
|
313 | + 'settings.schema.image.default' => [ |
|
314 | + 'default' => 'post', |
|
315 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
316 | + 'label' => __('Default Image', 'site-reviews'), |
|
317 | + 'options' => [ |
|
318 | + 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
319 | + 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
320 | + ], |
|
321 | + 'type' => 'select', |
|
322 | + ], |
|
323 | + 'settings.schema.image.custom' => [ |
|
324 | + 'default' => '', |
|
325 | + 'depends_on' => [ |
|
326 | + 'settings.schema.image.default' => 'custom', |
|
327 | + ], |
|
328 | + 'label' => __('Custom Image URL', 'site-reviews'), |
|
329 | + 'type' => 'text', |
|
330 | + ], |
|
331 | + 'settings.schema.address' => [ |
|
332 | + 'default' => '', |
|
333 | + 'depends_on' => [ |
|
334 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
335 | + ], |
|
336 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
337 | + 'label' => __('Address', 'site-reviews'), |
|
338 | + 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
339 | + 'type' => 'text', |
|
340 | + ], |
|
341 | + 'settings.schema.telephone' => [ |
|
342 | + 'default' => '', |
|
343 | + 'depends_on' => [ |
|
344 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
345 | + ], |
|
346 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
347 | + 'label' => __('Telephone Number', 'site-reviews'), |
|
348 | + 'placeholder' => '+1 (877) 273-3049', |
|
349 | + 'type' => 'text', |
|
350 | + ], |
|
351 | + 'settings.schema.pricerange' => [ |
|
352 | + 'default' => '', |
|
353 | + 'depends_on' => [ |
|
354 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
355 | + ], |
|
356 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
357 | + 'label' => __('Price Range', 'site-reviews'), |
|
358 | + 'placeholder' => '$$-$$$', |
|
359 | + 'type' => 'text', |
|
360 | + ], |
|
361 | + 'settings.schema.offertype' => [ |
|
362 | + 'default' => 'AggregateOffer', |
|
363 | + 'depends_on' => [ |
|
364 | + 'settings.schema.type.default' => 'Product', |
|
365 | + ], |
|
366 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
367 | + 'label' => __('Offer Type', 'site-reviews'), |
|
368 | + 'options' => [ |
|
369 | + 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
370 | + 'Offer' => __('Offer', 'site-reviews'), |
|
371 | + ], |
|
372 | + 'type' => 'select', |
|
373 | + ], |
|
374 | + 'settings.schema.price' => [ |
|
375 | + 'default' => '', |
|
376 | + 'depends_on' => [ |
|
377 | + 'settings.schema.type.default' => 'Product', |
|
378 | + 'settings.schema.offertype' => 'Offer', |
|
379 | + ], |
|
380 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
381 | + 'label' => __('Price', 'site-reviews'), |
|
382 | + 'placeholder' => '50.00', |
|
383 | + 'type' => 'text', |
|
384 | + ], |
|
385 | + 'settings.schema.lowprice' => [ |
|
386 | + 'default' => '', |
|
387 | + 'depends_on' => [ |
|
388 | + 'settings.schema.type.default' => 'Product', |
|
389 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
390 | + ], |
|
391 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
392 | + 'label' => __('Low Price', 'site-reviews'), |
|
393 | + 'placeholder' => '10.00', |
|
394 | + 'type' => 'text', |
|
395 | + ], |
|
396 | + 'settings.schema.highprice' => [ |
|
397 | + 'default' => '', |
|
398 | + 'depends_on' => [ |
|
399 | + 'settings.schema.type.default' => 'Product', |
|
400 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
401 | + ], |
|
402 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
403 | + 'label' => __('High Price', 'site-reviews'), |
|
404 | + 'placeholder' => '100.00', |
|
405 | + 'type' => 'text', |
|
406 | + ], |
|
407 | + 'settings.schema.pricecurrency' => [ |
|
408 | + 'default' => '', |
|
409 | + 'depends_on' => [ |
|
410 | + 'settings.schema.type.default' => 'Product', |
|
411 | + ], |
|
412 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
413 | + 'label' => __('Price Currency', 'site-reviews'), |
|
414 | + 'placeholder' => 'USD', |
|
415 | + 'type' => 'text', |
|
416 | + ], |
|
417 | + 'settings.submissions.required' => [ |
|
418 | + 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
419 | + 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
420 | + 'label' => __('Required Fields', 'site-reviews'), |
|
421 | + 'options' => [ |
|
422 | + 'rating' => __('Rating', 'site-reviews'), |
|
423 | + 'title' => __('Title', 'site-reviews'), |
|
424 | + 'content' => __('Review', 'site-reviews'), |
|
425 | + 'name' => __('Name', 'site-reviews'), |
|
426 | + 'email' => __('Email', 'site-reviews'), |
|
427 | + 'terms' => __('Terms', 'site-reviews'), |
|
428 | + ], |
|
429 | + 'type' => 'checkbox', |
|
430 | + ], |
|
431 | + 'settings.submissions.limit' => [ |
|
432 | + 'default' => '', |
|
433 | + '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'), |
|
434 | + 'label' => __('Limit Reviews', 'site-reviews'), |
|
435 | + 'options' => [ |
|
436 | + '' => __('No Limit', 'site-reviews'), |
|
437 | + 'email' => __('By Email Address', 'site-reviews'), |
|
438 | + 'ip_address' => __('By IP Address', 'site-reviews'), |
|
439 | + 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
440 | + ], |
|
441 | + 'type' => 'select', |
|
442 | + ], |
|
443 | + 'settings.submissions.limit_whitelist.email' => [ |
|
444 | + 'default' => '', |
|
445 | + 'depends_on' => [ |
|
446 | + 'settings.submissions.limit' => ['email'], |
|
447 | + ], |
|
448 | + 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
449 | + 'label' => __('Email Whitelist', 'site-reviews'), |
|
450 | + 'rows' => 5, |
|
451 | + 'type' => 'code', |
|
452 | + ], |
|
453 | + 'settings.submissions.limit_whitelist.ip_address' => [ |
|
454 | + 'default' => '', |
|
455 | + 'depends_on' => [ |
|
456 | + 'settings.submissions.limit' => ['ip_address'], |
|
457 | + ], |
|
458 | + 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
459 | + 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
460 | + 'rows' => 5, |
|
461 | + 'type' => 'code', |
|
462 | + ], |
|
463 | + 'settings.submissions.limit_whitelist.username' => [ |
|
464 | + 'default' => '', |
|
465 | + 'depends_on' => [ |
|
466 | + 'settings.submissions.limit' => ['username'], |
|
467 | + ], |
|
468 | + 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
469 | + 'label' => __('Username Whitelist', 'site-reviews'), |
|
470 | + 'rows' => 5, |
|
471 | + 'type' => 'code', |
|
472 | + ], |
|
473 | + 'settings.submissions.recaptcha.integration' => [ |
|
474 | + 'default' => '', |
|
475 | + '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'), |
|
476 | + 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
477 | + 'options' => [ |
|
478 | + '' => 'Do not use reCAPTCHA', |
|
479 | + 'all' => 'Use reCAPTCHA', |
|
480 | + 'guest' => 'Use reCAPTCHA only for guest users', |
|
481 | + ], |
|
482 | + 'type' => 'select', |
|
483 | + ], |
|
484 | + 'settings.submissions.recaptcha.key' => [ |
|
485 | + 'default' => '', |
|
486 | + 'depends_on' => [ |
|
487 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
488 | + ], |
|
489 | + 'label' => __('Site Key', 'site-reviews'), |
|
490 | + 'type' => 'text', |
|
491 | + ], |
|
492 | + 'settings.submissions.recaptcha.secret' => [ |
|
493 | + 'default' => '', |
|
494 | + 'depends_on' => [ |
|
495 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
496 | + ], |
|
497 | + 'label' => __('Site Secret', 'site-reviews'), |
|
498 | + 'type' => 'text', |
|
499 | + ], |
|
500 | + 'settings.submissions.recaptcha.position' => [ |
|
501 | + 'default' => 'bottomleft', |
|
502 | + 'depends_on' => [ |
|
503 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
504 | + ], |
|
505 | + 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
506 | + 'label' => __('Badge Position', 'site-reviews'), |
|
507 | + 'options' => [ |
|
508 | + 'bottomleft' => 'Bottom Left', |
|
509 | + 'bottomright' => 'Bottom Right', |
|
510 | + 'inline' => 'Inline', |
|
511 | + ], |
|
512 | + 'type' => 'select', |
|
513 | + ], |
|
514 | + 'settings.submissions.akismet' => [ |
|
515 | + 'default' => 'no', |
|
516 | + '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'), |
|
517 | + 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
518 | + 'type' => 'yes_no', |
|
519 | + ], |
|
520 | + 'settings.submissions.blacklist.integration' => [ |
|
521 | + 'default' => '', |
|
522 | + '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'), |
|
523 | + '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
524 | + ), |
|
525 | + 'label' => __('Blacklist', 'site-reviews'), |
|
526 | + 'options' => [ |
|
527 | + '' => 'Use the Site Reviews Blacklist', |
|
528 | + 'comments' => 'Use the WordPress Comment Blacklist', |
|
529 | + ], |
|
530 | + 'type' => 'select', |
|
531 | + ], |
|
532 | + 'settings.submissions.blacklist.entries' => [ |
|
533 | + 'default' => '', |
|
534 | + 'depends_on' => [ |
|
535 | + 'settings.submissions.blacklist.integration' => [''], |
|
536 | + ], |
|
537 | + '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'), |
|
538 | + 'label' => __('Review Blacklist', 'site-reviews'), |
|
539 | + 'rows' => 10, |
|
540 | + 'type' => 'code', |
|
541 | + ], |
|
542 | + 'settings.submissions.blacklist.action' => [ |
|
543 | + 'default' => 'unapprove', |
|
544 | + 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
545 | + 'label' => __('Blacklist Action', 'site-reviews'), |
|
546 | + 'options' => [ |
|
547 | + 'unapprove' => __('Require approval', 'site-reviews'), |
|
548 | + 'reject' => __('Reject submission', 'site-reviews'), |
|
549 | + ], |
|
550 | + 'type' => 'select', |
|
551 | + ], |
|
552 | 552 | ]; |