@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-login-register"> |
4 | 4 | <p>{{ text }}</p> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-reviews-wrap"> |
4 | 4 | <div class="{{ class }}" id="{{ id }}"> |
@@ -9,138 +9,138 @@ |
||
9 | 9 | |
10 | 10 | class Slack |
11 | 11 | { |
12 | - /** |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - public $endpoint; |
|
12 | + /** |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + public $endpoint; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - public $notification; |
|
17 | + /** |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + public $notification; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var Review |
|
24 | - */ |
|
25 | - public $review; |
|
22 | + /** |
|
23 | + * @var Review |
|
24 | + */ |
|
25 | + public $review; |
|
26 | 26 | |
27 | - public function __construct() |
|
28 | - { |
|
29 | - $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack'); |
|
30 | - } |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return Slack |
|
34 | - */ |
|
35 | - public function compose(Review $review, array $notification) |
|
36 | - { |
|
37 | - if (empty($this->endpoint)) { |
|
38 | - return $this; |
|
39 | - } |
|
40 | - $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification); |
|
41 | - $this->review = $review; |
|
42 | - $notification = [ |
|
43 | - 'icon_url' => $args['icon_url'], |
|
44 | - 'username' => $args['username'], |
|
45 | - 'attachments' => [[ |
|
46 | - 'actions' => $this->buildAction($args), |
|
47 | - 'pretext' => $args['pretext'], |
|
48 | - 'color' => $args['color'], |
|
49 | - 'fallback' => $args['fallback'], |
|
50 | - 'fields' => $this->buildFields(), |
|
51 | - ]], |
|
52 | - ]; |
|
53 | - $this->notification = apply_filters('site-reviews/slack/compose', $notification, $this); |
|
54 | - return $this; |
|
55 | - } |
|
32 | + /** |
|
33 | + * @return Slack |
|
34 | + */ |
|
35 | + public function compose(Review $review, array $notification) |
|
36 | + { |
|
37 | + if (empty($this->endpoint)) { |
|
38 | + return $this; |
|
39 | + } |
|
40 | + $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification); |
|
41 | + $this->review = $review; |
|
42 | + $notification = [ |
|
43 | + 'icon_url' => $args['icon_url'], |
|
44 | + 'username' => $args['username'], |
|
45 | + 'attachments' => [[ |
|
46 | + 'actions' => $this->buildAction($args), |
|
47 | + 'pretext' => $args['pretext'], |
|
48 | + 'color' => $args['color'], |
|
49 | + 'fallback' => $args['fallback'], |
|
50 | + 'fields' => $this->buildFields(), |
|
51 | + ]], |
|
52 | + ]; |
|
53 | + $this->notification = apply_filters('site-reviews/slack/compose', $notification, $this); |
|
54 | + return $this; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return WP_Error|array |
|
59 | - */ |
|
60 | - public function send() |
|
61 | - { |
|
62 | - if (empty($this->endpoint)) { |
|
63 | - return new WP_Error('slack', 'Slack notification was not sent: missing endpoint'); |
|
64 | - } |
|
65 | - return wp_remote_post($this->endpoint, [ |
|
66 | - 'blocking' => false, |
|
67 | - 'body' => json_encode($this->notification), |
|
68 | - 'headers' => ['Content-Type' => 'application/json'], |
|
69 | - 'httpversion' => '1.0', |
|
70 | - 'method' => 'POST', |
|
71 | - 'redirection' => 5, |
|
72 | - 'sslverify' => false, |
|
73 | - 'timeout' => 45, |
|
74 | - ]); |
|
75 | - } |
|
57 | + /** |
|
58 | + * @return WP_Error|array |
|
59 | + */ |
|
60 | + public function send() |
|
61 | + { |
|
62 | + if (empty($this->endpoint)) { |
|
63 | + return new WP_Error('slack', 'Slack notification was not sent: missing endpoint'); |
|
64 | + } |
|
65 | + return wp_remote_post($this->endpoint, [ |
|
66 | + 'blocking' => false, |
|
67 | + 'body' => json_encode($this->notification), |
|
68 | + 'headers' => ['Content-Type' => 'application/json'], |
|
69 | + 'httpversion' => '1.0', |
|
70 | + 'method' => 'POST', |
|
71 | + 'redirection' => 5, |
|
72 | + 'sslverify' => false, |
|
73 | + 'timeout' => 45, |
|
74 | + ]); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - protected function buildAction(array $args) |
|
81 | - { |
|
82 | - return [[ |
|
83 | - 'text' => $args['button_text'], |
|
84 | - 'type' => 'button', |
|
85 | - 'url' => $args['button_url'], |
|
86 | - ]]; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + protected function buildAction(array $args) |
|
81 | + { |
|
82 | + return [[ |
|
83 | + 'text' => $args['button_text'], |
|
84 | + 'type' => 'button', |
|
85 | + 'url' => $args['button_url'], |
|
86 | + ]]; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - protected function buildAuthorField() |
|
93 | - { |
|
94 | - $email = !empty($this->review->email) |
|
95 | - ? '<'.$this->review->email.'>' |
|
96 | - : ''; |
|
97 | - $author = trim(rtrim($this->review->author).' '.$email); |
|
98 | - return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))]; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + protected function buildAuthorField() |
|
93 | + { |
|
94 | + $email = !empty($this->review->email) |
|
95 | + ? '<'.$this->review->email.'>' |
|
96 | + : ''; |
|
97 | + $author = trim(rtrim($this->review->author).' '.$email); |
|
98 | + return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))]; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return array |
|
103 | - */ |
|
104 | - protected function buildContentField() |
|
105 | - { |
|
106 | - return !empty($this->review->content) |
|
107 | - ? ['value' => $this->review->content] |
|
108 | - : []; |
|
109 | - } |
|
101 | + /** |
|
102 | + * @return array |
|
103 | + */ |
|
104 | + protected function buildContentField() |
|
105 | + { |
|
106 | + return !empty($this->review->content) |
|
107 | + ? ['value' => $this->review->content] |
|
108 | + : []; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - protected function buildFields() |
|
115 | - { |
|
116 | - $fields = [ |
|
117 | - $this->buildStarsField(), |
|
118 | - $this->buildTitleField(), |
|
119 | - $this->buildContentField(), |
|
120 | - $this->buildAuthorField(), |
|
121 | - ]; |
|
122 | - return array_filter($fields); |
|
123 | - } |
|
111 | + /** |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + protected function buildFields() |
|
115 | + { |
|
116 | + $fields = [ |
|
117 | + $this->buildStarsField(), |
|
118 | + $this->buildTitleField(), |
|
119 | + $this->buildContentField(), |
|
120 | + $this->buildAuthorField(), |
|
121 | + ]; |
|
122 | + return array_filter($fields); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - protected function buildStarsField() |
|
129 | - { |
|
130 | - $solidStars = str_repeat('★', $this->review->rating); |
|
131 | - $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating)); |
|
132 | - $stars = $solidStars.$emptyStars; |
|
133 | - $stars = apply_filters('site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class)); |
|
134 | - return ['title' => $stars]; |
|
135 | - } |
|
125 | + /** |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + protected function buildStarsField() |
|
129 | + { |
|
130 | + $solidStars = str_repeat('★', $this->review->rating); |
|
131 | + $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating)); |
|
132 | + $stars = $solidStars.$emptyStars; |
|
133 | + $stars = apply_filters('site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class)); |
|
134 | + return ['title' => $stars]; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - protected function buildTitleField() |
|
141 | - { |
|
142 | - return !empty($this->review->title) |
|
143 | - ? ['title' => $this->review->title] |
|
144 | - : []; |
|
145 | - } |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + protected function buildTitleField() |
|
141 | + { |
|
142 | + return !empty($this->review->title) |
|
143 | + ? ['title' => $this->review->title] |
|
144 | + : []; |
|
145 | + } |
|
146 | 146 | } |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct() |
28 | 28 | { |
29 | - $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack'); |
|
29 | + $this->endpoint = glsr( OptionManager::class )->get( 'settings.general.notification_slack' ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @return Slack |
34 | 34 | */ |
35 | - public function compose(Review $review, array $notification) |
|
35 | + public function compose( Review $review, array $notification ) |
|
36 | 36 | { |
37 | - if (empty($this->endpoint)) { |
|
37 | + if( empty($this->endpoint) ) { |
|
38 | 38 | return $this; |
39 | 39 | } |
40 | - $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification); |
|
40 | + $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
|
41 | 41 | $this->review = $review; |
42 | 42 | $notification = [ |
43 | 43 | 'icon_url' => $args['icon_url'], |
44 | 44 | 'username' => $args['username'], |
45 | 45 | 'attachments' => [[ |
46 | - 'actions' => $this->buildAction($args), |
|
46 | + 'actions' => $this->buildAction( $args ), |
|
47 | 47 | 'pretext' => $args['pretext'], |
48 | 48 | 'color' => $args['color'], |
49 | 49 | 'fallback' => $args['fallback'], |
50 | 50 | 'fields' => $this->buildFields(), |
51 | 51 | ]], |
52 | 52 | ]; |
53 | - $this->notification = apply_filters('site-reviews/slack/compose', $notification, $this); |
|
53 | + $this->notification = apply_filters( 'site-reviews/slack/compose', $notification, $this ); |
|
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function send() |
61 | 61 | { |
62 | - if (empty($this->endpoint)) { |
|
63 | - return new WP_Error('slack', 'Slack notification was not sent: missing endpoint'); |
|
62 | + if( empty($this->endpoint) ) { |
|
63 | + return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' ); |
|
64 | 64 | } |
65 | - return wp_remote_post($this->endpoint, [ |
|
65 | + return wp_remote_post( $this->endpoint, [ |
|
66 | 66 | 'blocking' => false, |
67 | - 'body' => json_encode($this->notification), |
|
67 | + 'body' => json_encode( $this->notification ), |
|
68 | 68 | 'headers' => ['Content-Type' => 'application/json'], |
69 | 69 | 'httpversion' => '1.0', |
70 | 70 | 'method' => 'POST', |
71 | 71 | 'redirection' => 5, |
72 | 72 | 'sslverify' => false, |
73 | 73 | 'timeout' => 45, |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - protected function buildAction(array $args) |
|
80 | + protected function buildAction( array $args ) |
|
81 | 81 | { |
82 | 82 | return [[ |
83 | 83 | 'text' => $args['button_text'], |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $email = !empty($this->review->email) |
95 | 95 | ? '<'.$this->review->email.'>' |
96 | 96 | : ''; |
97 | - $author = trim(rtrim($this->review->author).' '.$email); |
|
98 | - return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))]; |
|
97 | + $author = trim( rtrim( $this->review->author ).' '.$email ); |
|
98 | + return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )]; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $this->buildContentField(), |
120 | 120 | $this->buildAuthorField(), |
121 | 121 | ]; |
122 | - return array_filter($fields); |
|
122 | + return array_filter( $fields ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildStarsField() |
129 | 129 | { |
130 | - $solidStars = str_repeat('★', $this->review->rating); |
|
131 | - $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating)); |
|
130 | + $solidStars = str_repeat( '★', $this->review->rating ); |
|
131 | + $emptyStars = str_repeat( '☆', max( 0, glsr()->constant( 'MAX_RATING', Rating::class ) - $this->review->rating ) ); |
|
132 | 132 | $stars = $solidStars.$emptyStars; |
133 | - $stars = apply_filters('site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class)); |
|
133 | + $stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant( 'MAX_RATING', Rating::class ) ); |
|
134 | 134 | return ['title' => $stars]; |
135 | 135 | } |
136 | 136 |
@@ -216,7 +216,8 @@ |
||
216 | 216 | if (!empty($field['label'])) { |
217 | 217 | $field['legend'] = $field['label']; |
218 | 218 | unset($field['label']); |
219 | - } else { |
|
219 | + } |
|
220 | + else { |
|
220 | 221 | $field['is_valid'] = false; |
221 | 222 | glsr_log()->warning('Setting field is missing a label')->debug($field); |
222 | 223 | } |
@@ -11,239 +11,239 @@ |
||
11 | 11 | |
12 | 12 | class Settings |
13 | 13 | { |
14 | - /** |
|
15 | - * @var array |
|
16 | - */ |
|
17 | - public $settings; |
|
18 | - |
|
19 | - /** |
|
20 | - * @param string $id |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function buildFields($id) |
|
24 | - { |
|
25 | - $this->settings = glsr(DefaultsManager::class)->settings(); |
|
26 | - $method = Helper::buildMethodName($id, 'getTemplateDataFor'); |
|
27 | - $data = !method_exists($this, $method) |
|
28 | - ? $this->getTemplateData($id) |
|
29 | - : $this->$method($id); |
|
30 | - return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - protected function getFieldDefault(array $field) |
|
37 | - { |
|
38 | - return Arr::get($field, 'default'); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - protected function getFieldNameForDependsOn($path) |
|
45 | - { |
|
46 | - $fieldName = Str::convertPathToName($path, OptionManager::databaseKey()); |
|
47 | - return $this->isMultiDependency($path) |
|
48 | - ? $fieldName.'[]' |
|
49 | - : $fieldName; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - protected function getSettingFields($path) |
|
56 | - { |
|
57 | - return array_filter($this->settings, function ($key) use ($path) { |
|
58 | - return Str::startsWith($path, $key); |
|
59 | - }, ARRAY_FILTER_USE_KEY); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - protected function getSettingRows(array $fields) |
|
66 | - { |
|
67 | - $rows = ''; |
|
68 | - foreach ($fields as $name => $field) { |
|
69 | - $field = wp_parse_args($field, [ |
|
70 | - 'is_setting' => true, |
|
71 | - 'name' => $name, |
|
72 | - ]); |
|
73 | - $rows.= new Field($this->normalize($field)); |
|
74 | - } |
|
75 | - return $rows; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $id |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - protected function getTemplateData($id) |
|
83 | - { |
|
84 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
85 | - return [ |
|
86 | - 'context' => [ |
|
87 | - 'rows' => $this->getSettingRows($fields), |
|
88 | - ], |
|
89 | - ]; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param string $id |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - protected function getTemplateDataForAddons($id) |
|
97 | - { |
|
98 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
99 | - $settings = Arr::convertFromDotNotation($fields); |
|
100 | - $settingKeys = array_keys($settings['settings']['addons']); |
|
101 | - $results = []; |
|
102 | - foreach ($settingKeys as $key) { |
|
103 | - $addonFields = array_filter($fields, function ($path) use ($key) { |
|
104 | - return Str::startsWith('settings.addons.'.$key, $path); |
|
105 | - }, ARRAY_FILTER_USE_KEY); |
|
106 | - $results[$key] = $this->getSettingRows($addonFields); |
|
107 | - } |
|
108 | - ksort($results); |
|
109 | - return [ |
|
110 | - 'settings' => $results, |
|
111 | - ]; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param string $id |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - protected function getTemplateDataForLicenses($id) |
|
119 | - { |
|
120 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
121 | - ksort($fields); |
|
122 | - return [ |
|
123 | - 'context' => [ |
|
124 | - 'rows' => $this->getSettingRows($fields), |
|
125 | - ], |
|
126 | - ]; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - protected function getTemplateDataForTranslations() |
|
133 | - { |
|
134 | - $translations = glsr(Translation::class)->renderAll(); |
|
135 | - $class = empty($translations) |
|
136 | - ? 'glsr-hidden' |
|
137 | - : ''; |
|
138 | - return [ |
|
139 | - 'context' => [ |
|
140 | - 'class' => $class, |
|
141 | - 'database_key' => OptionManager::databaseKey(), |
|
142 | - 'translations' => $translations, |
|
143 | - ], |
|
144 | - ]; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @param string $path |
|
149 | - * @param string|array $expectedValue |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - protected function isFieldHidden($path, $expectedValue) |
|
153 | - { |
|
154 | - $optionValue = glsr(OptionManager::class)->get( |
|
155 | - $path, |
|
156 | - Arr::get(glsr()->defaults, $path) |
|
157 | - ); |
|
158 | - if (is_array($expectedValue)) { |
|
159 | - return is_array($optionValue) |
|
160 | - ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
161 | - : !in_array($optionValue, $expectedValue); |
|
162 | - } |
|
163 | - return $optionValue != $expectedValue; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @return bool |
|
168 | - */ |
|
169 | - protected function isMultiDependency($path) |
|
170 | - { |
|
171 | - if (isset($this->settings[$path])) { |
|
172 | - $field = $this->settings[$path]; |
|
173 | - return ('checkbox' == $field['type'] && !empty($field['options'])) |
|
174 | - || !empty($field['multiple']); |
|
175 | - } |
|
176 | - return false; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * @return array |
|
181 | - */ |
|
182 | - protected function normalize(array $field) |
|
183 | - { |
|
184 | - $field = $this->normalizeDependsOn($field); |
|
185 | - $field = $this->normalizeLabelAndLegend($field); |
|
186 | - $field = $this->normalizeValue($field); |
|
187 | - return $field; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - protected function normalizeDependsOn(array $field) |
|
194 | - { |
|
195 | - if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
196 | - $isFieldHidden = false; |
|
197 | - $conditions = []; |
|
198 | - foreach ($field['depends_on'] as $path => $value) { |
|
199 | - $conditions[] = [ |
|
200 | - 'name' => $this->getFieldNameForDependsOn($path), |
|
201 | - 'value' => $value, |
|
202 | - ]; |
|
203 | - if ($this->isFieldHidden($path, $value)) { |
|
204 | - $isFieldHidden = true; |
|
205 | - } |
|
206 | - } |
|
207 | - $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
208 | - $field['is_hidden'] = $isFieldHidden; |
|
209 | - } |
|
210 | - return $field; |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * @return array |
|
215 | - */ |
|
216 | - protected function normalizeLabelAndLegend(array $field) |
|
217 | - { |
|
218 | - if (!empty($field['label'])) { |
|
219 | - $field['legend'] = $field['label']; |
|
220 | - unset($field['label']); |
|
221 | - } else { |
|
222 | - $field['is_valid'] = false; |
|
223 | - glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
224 | - } |
|
225 | - return $field; |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * @return array |
|
230 | - */ |
|
231 | - protected function normalizeValue(array $field) |
|
232 | - { |
|
233 | - if (!isset($field['value'])) { |
|
234 | - $field['value'] = glsr(OptionManager::class)->get( |
|
235 | - $field['name'], |
|
236 | - $this->getFieldDefault($field) |
|
237 | - ); |
|
238 | - } |
|
239 | - return $field; |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @return string |
|
244 | - */ |
|
245 | - protected function normalizeSettingPath($path) |
|
246 | - { |
|
247 | - return Str::prefix('settings.', rtrim($path, '.')); |
|
248 | - } |
|
14 | + /** |
|
15 | + * @var array |
|
16 | + */ |
|
17 | + public $settings; |
|
18 | + |
|
19 | + /** |
|
20 | + * @param string $id |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function buildFields($id) |
|
24 | + { |
|
25 | + $this->settings = glsr(DefaultsManager::class)->settings(); |
|
26 | + $method = Helper::buildMethodName($id, 'getTemplateDataFor'); |
|
27 | + $data = !method_exists($this, $method) |
|
28 | + ? $this->getTemplateData($id) |
|
29 | + : $this->$method($id); |
|
30 | + return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + protected function getFieldDefault(array $field) |
|
37 | + { |
|
38 | + return Arr::get($field, 'default'); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + protected function getFieldNameForDependsOn($path) |
|
45 | + { |
|
46 | + $fieldName = Str::convertPathToName($path, OptionManager::databaseKey()); |
|
47 | + return $this->isMultiDependency($path) |
|
48 | + ? $fieldName.'[]' |
|
49 | + : $fieldName; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + protected function getSettingFields($path) |
|
56 | + { |
|
57 | + return array_filter($this->settings, function ($key) use ($path) { |
|
58 | + return Str::startsWith($path, $key); |
|
59 | + }, ARRAY_FILTER_USE_KEY); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + protected function getSettingRows(array $fields) |
|
66 | + { |
|
67 | + $rows = ''; |
|
68 | + foreach ($fields as $name => $field) { |
|
69 | + $field = wp_parse_args($field, [ |
|
70 | + 'is_setting' => true, |
|
71 | + 'name' => $name, |
|
72 | + ]); |
|
73 | + $rows.= new Field($this->normalize($field)); |
|
74 | + } |
|
75 | + return $rows; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $id |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + protected function getTemplateData($id) |
|
83 | + { |
|
84 | + $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
85 | + return [ |
|
86 | + 'context' => [ |
|
87 | + 'rows' => $this->getSettingRows($fields), |
|
88 | + ], |
|
89 | + ]; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param string $id |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + protected function getTemplateDataForAddons($id) |
|
97 | + { |
|
98 | + $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
99 | + $settings = Arr::convertFromDotNotation($fields); |
|
100 | + $settingKeys = array_keys($settings['settings']['addons']); |
|
101 | + $results = []; |
|
102 | + foreach ($settingKeys as $key) { |
|
103 | + $addonFields = array_filter($fields, function ($path) use ($key) { |
|
104 | + return Str::startsWith('settings.addons.'.$key, $path); |
|
105 | + }, ARRAY_FILTER_USE_KEY); |
|
106 | + $results[$key] = $this->getSettingRows($addonFields); |
|
107 | + } |
|
108 | + ksort($results); |
|
109 | + return [ |
|
110 | + 'settings' => $results, |
|
111 | + ]; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param string $id |
|
116 | + * @return array |
|
117 | + */ |
|
118 | + protected function getTemplateDataForLicenses($id) |
|
119 | + { |
|
120 | + $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
121 | + ksort($fields); |
|
122 | + return [ |
|
123 | + 'context' => [ |
|
124 | + 'rows' => $this->getSettingRows($fields), |
|
125 | + ], |
|
126 | + ]; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + protected function getTemplateDataForTranslations() |
|
133 | + { |
|
134 | + $translations = glsr(Translation::class)->renderAll(); |
|
135 | + $class = empty($translations) |
|
136 | + ? 'glsr-hidden' |
|
137 | + : ''; |
|
138 | + return [ |
|
139 | + 'context' => [ |
|
140 | + 'class' => $class, |
|
141 | + 'database_key' => OptionManager::databaseKey(), |
|
142 | + 'translations' => $translations, |
|
143 | + ], |
|
144 | + ]; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @param string $path |
|
149 | + * @param string|array $expectedValue |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + protected function isFieldHidden($path, $expectedValue) |
|
153 | + { |
|
154 | + $optionValue = glsr(OptionManager::class)->get( |
|
155 | + $path, |
|
156 | + Arr::get(glsr()->defaults, $path) |
|
157 | + ); |
|
158 | + if (is_array($expectedValue)) { |
|
159 | + return is_array($optionValue) |
|
160 | + ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
161 | + : !in_array($optionValue, $expectedValue); |
|
162 | + } |
|
163 | + return $optionValue != $expectedValue; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @return bool |
|
168 | + */ |
|
169 | + protected function isMultiDependency($path) |
|
170 | + { |
|
171 | + if (isset($this->settings[$path])) { |
|
172 | + $field = $this->settings[$path]; |
|
173 | + return ('checkbox' == $field['type'] && !empty($field['options'])) |
|
174 | + || !empty($field['multiple']); |
|
175 | + } |
|
176 | + return false; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * @return array |
|
181 | + */ |
|
182 | + protected function normalize(array $field) |
|
183 | + { |
|
184 | + $field = $this->normalizeDependsOn($field); |
|
185 | + $field = $this->normalizeLabelAndLegend($field); |
|
186 | + $field = $this->normalizeValue($field); |
|
187 | + return $field; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + protected function normalizeDependsOn(array $field) |
|
194 | + { |
|
195 | + if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
196 | + $isFieldHidden = false; |
|
197 | + $conditions = []; |
|
198 | + foreach ($field['depends_on'] as $path => $value) { |
|
199 | + $conditions[] = [ |
|
200 | + 'name' => $this->getFieldNameForDependsOn($path), |
|
201 | + 'value' => $value, |
|
202 | + ]; |
|
203 | + if ($this->isFieldHidden($path, $value)) { |
|
204 | + $isFieldHidden = true; |
|
205 | + } |
|
206 | + } |
|
207 | + $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
208 | + $field['is_hidden'] = $isFieldHidden; |
|
209 | + } |
|
210 | + return $field; |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * @return array |
|
215 | + */ |
|
216 | + protected function normalizeLabelAndLegend(array $field) |
|
217 | + { |
|
218 | + if (!empty($field['label'])) { |
|
219 | + $field['legend'] = $field['label']; |
|
220 | + unset($field['label']); |
|
221 | + } else { |
|
222 | + $field['is_valid'] = false; |
|
223 | + glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
224 | + } |
|
225 | + return $field; |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * @return array |
|
230 | + */ |
|
231 | + protected function normalizeValue(array $field) |
|
232 | + { |
|
233 | + if (!isset($field['value'])) { |
|
234 | + $field['value'] = glsr(OptionManager::class)->get( |
|
235 | + $field['name'], |
|
236 | + $this->getFieldDefault($field) |
|
237 | + ); |
|
238 | + } |
|
239 | + return $field; |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @return string |
|
244 | + */ |
|
245 | + protected function normalizeSettingPath($path) |
|
246 | + { |
|
247 | + return Str::prefix('settings.', rtrim($path, '.')); |
|
248 | + } |
|
249 | 249 | } |
@@ -20,31 +20,31 @@ discard block |
||
20 | 20 | * @param string $id |
21 | 21 | * @return string |
22 | 22 | */ |
23 | - public function buildFields($id) |
|
23 | + public function buildFields( $id ) |
|
24 | 24 | { |
25 | - $this->settings = glsr(DefaultsManager::class)->settings(); |
|
26 | - $method = Helper::buildMethodName($id, 'getTemplateDataFor'); |
|
27 | - $data = !method_exists($this, $method) |
|
28 | - ? $this->getTemplateData($id) |
|
29 | - : $this->$method($id); |
|
30 | - return glsr(Template::class)->build('pages/settings/'.$id, $data); |
|
25 | + $this->settings = glsr( DefaultsManager::class )->settings(); |
|
26 | + $method = Helper::buildMethodName( $id, 'getTemplateDataFor' ); |
|
27 | + $data = !method_exists( $this, $method ) |
|
28 | + ? $this->getTemplateData( $id ) |
|
29 | + : $this->$method( $id ); |
|
30 | + return glsr( Template::class )->build( 'pages/settings/'.$id, $data ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @return string |
35 | 35 | */ |
36 | - protected function getFieldDefault(array $field) |
|
36 | + protected function getFieldDefault( array $field ) |
|
37 | 37 | { |
38 | - return Arr::get($field, 'default'); |
|
38 | + return Arr::get( $field, 'default' ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - protected function getFieldNameForDependsOn($path) |
|
44 | + protected function getFieldNameForDependsOn( $path ) |
|
45 | 45 | { |
46 | - $fieldName = Str::convertPathToName($path, OptionManager::databaseKey()); |
|
47 | - return $this->isMultiDependency($path) |
|
46 | + $fieldName = Str::convertPathToName( $path, OptionManager::databaseKey() ); |
|
47 | + return $this->isMultiDependency( $path ) |
|
48 | 48 | ? $fieldName.'[]' |
49 | 49 | : $fieldName; |
50 | 50 | } |
@@ -52,25 +52,25 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - protected function getSettingFields($path) |
|
55 | + protected function getSettingFields( $path ) |
|
56 | 56 | { |
57 | - return array_filter($this->settings, function ($key) use ($path) { |
|
58 | - return Str::startsWith($path, $key); |
|
59 | - }, ARRAY_FILTER_USE_KEY); |
|
57 | + return array_filter( $this->settings, function( $key ) use ($path) { |
|
58 | + return Str::startsWith( $path, $key ); |
|
59 | + }, ARRAY_FILTER_USE_KEY ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - protected function getSettingRows(array $fields) |
|
65 | + protected function getSettingRows( array $fields ) |
|
66 | 66 | { |
67 | 67 | $rows = ''; |
68 | - foreach ($fields as $name => $field) { |
|
69 | - $field = wp_parse_args($field, [ |
|
68 | + foreach( $fields as $name => $field ) { |
|
69 | + $field = wp_parse_args( $field, [ |
|
70 | 70 | 'is_setting' => true, |
71 | 71 | 'name' => $name, |
72 | - ]); |
|
73 | - $rows.= new Field($this->normalize($field)); |
|
72 | + ] ); |
|
73 | + $rows .= new Field( $this->normalize( $field ) ); |
|
74 | 74 | } |
75 | 75 | return $rows; |
76 | 76 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @param string $id |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - protected function getTemplateData($id) |
|
82 | + protected function getTemplateData( $id ) |
|
83 | 83 | { |
84 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
84 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
85 | 85 | return [ |
86 | 86 | 'context' => [ |
87 | - 'rows' => $this->getSettingRows($fields), |
|
87 | + 'rows' => $this->getSettingRows( $fields ), |
|
88 | 88 | ], |
89 | 89 | ]; |
90 | 90 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param string $id |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - protected function getTemplateDataForAddons($id) |
|
96 | + protected function getTemplateDataForAddons( $id ) |
|
97 | 97 | { |
98 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
99 | - $settings = Arr::convertFromDotNotation($fields); |
|
100 | - $settingKeys = array_keys($settings['settings']['addons']); |
|
98 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
99 | + $settings = Arr::convertFromDotNotation( $fields ); |
|
100 | + $settingKeys = array_keys( $settings['settings']['addons'] ); |
|
101 | 101 | $results = []; |
102 | - foreach ($settingKeys as $key) { |
|
103 | - $addonFields = array_filter($fields, function ($path) use ($key) { |
|
104 | - return Str::startsWith('settings.addons.'.$key, $path); |
|
105 | - }, ARRAY_FILTER_USE_KEY); |
|
106 | - $results[$key] = $this->getSettingRows($addonFields); |
|
102 | + foreach( $settingKeys as $key ) { |
|
103 | + $addonFields = array_filter( $fields, function( $path ) use ($key) { |
|
104 | + return Str::startsWith( 'settings.addons.'.$key, $path ); |
|
105 | + }, ARRAY_FILTER_USE_KEY ); |
|
106 | + $results[$key] = $this->getSettingRows( $addonFields ); |
|
107 | 107 | } |
108 | - ksort($results); |
|
108 | + ksort( $results ); |
|
109 | 109 | return [ |
110 | 110 | 'settings' => $results, |
111 | 111 | ]; |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @param string $id |
116 | 116 | * @return array |
117 | 117 | */ |
118 | - protected function getTemplateDataForLicenses($id) |
|
118 | + protected function getTemplateDataForLicenses( $id ) |
|
119 | 119 | { |
120 | - $fields = $this->getSettingFields($this->normalizeSettingPath($id)); |
|
121 | - ksort($fields); |
|
120 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
121 | + ksort( $fields ); |
|
122 | 122 | return [ |
123 | 123 | 'context' => [ |
124 | - 'rows' => $this->getSettingRows($fields), |
|
124 | + 'rows' => $this->getSettingRows( $fields ), |
|
125 | 125 | ], |
126 | 126 | ]; |
127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function getTemplateDataForTranslations() |
133 | 133 | { |
134 | - $translations = glsr(Translation::class)->renderAll(); |
|
134 | + $translations = glsr( Translation::class )->renderAll(); |
|
135 | 135 | $class = empty($translations) |
136 | 136 | ? 'glsr-hidden' |
137 | 137 | : ''; |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | * @param string|array $expectedValue |
150 | 150 | * @return bool |
151 | 151 | */ |
152 | - protected function isFieldHidden($path, $expectedValue) |
|
152 | + protected function isFieldHidden( $path, $expectedValue ) |
|
153 | 153 | { |
154 | - $optionValue = glsr(OptionManager::class)->get( |
|
154 | + $optionValue = glsr( OptionManager::class )->get( |
|
155 | 155 | $path, |
156 | - Arr::get(glsr()->defaults, $path) |
|
156 | + Arr::get( glsr()->defaults, $path ) |
|
157 | 157 | ); |
158 | - if (is_array($expectedValue)) { |
|
159 | - return is_array($optionValue) |
|
160 | - ? 0 === count(array_intersect($optionValue, $expectedValue)) |
|
161 | - : !in_array($optionValue, $expectedValue); |
|
158 | + if( is_array( $expectedValue ) ) { |
|
159 | + return is_array( $optionValue ) |
|
160 | + ? 0 === count( array_intersect( $optionValue, $expectedValue ) ) |
|
161 | + : !in_array( $optionValue, $expectedValue ); |
|
162 | 162 | } |
163 | 163 | return $optionValue != $expectedValue; |
164 | 164 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * @return bool |
168 | 168 | */ |
169 | - protected function isMultiDependency($path) |
|
169 | + protected function isMultiDependency( $path ) |
|
170 | 170 | { |
171 | - if (isset($this->settings[$path])) { |
|
171 | + if( isset($this->settings[$path]) ) { |
|
172 | 172 | $field = $this->settings[$path]; |
173 | 173 | return ('checkbox' == $field['type'] && !empty($field['options'])) |
174 | 174 | || !empty($field['multiple']); |
@@ -179,32 +179,32 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function normalize(array $field) |
|
182 | + protected function normalize( array $field ) |
|
183 | 183 | { |
184 | - $field = $this->normalizeDependsOn($field); |
|
185 | - $field = $this->normalizeLabelAndLegend($field); |
|
186 | - $field = $this->normalizeValue($field); |
|
184 | + $field = $this->normalizeDependsOn( $field ); |
|
185 | + $field = $this->normalizeLabelAndLegend( $field ); |
|
186 | + $field = $this->normalizeValue( $field ); |
|
187 | 187 | return $field; |
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - protected function normalizeDependsOn(array $field) |
|
193 | + protected function normalizeDependsOn( array $field ) |
|
194 | 194 | { |
195 | - if (!empty($field['depends_on']) && is_array($field['depends_on'])) { |
|
195 | + if( !empty($field['depends_on']) && is_array( $field['depends_on'] ) ) { |
|
196 | 196 | $isFieldHidden = false; |
197 | 197 | $conditions = []; |
198 | - foreach ($field['depends_on'] as $path => $value) { |
|
198 | + foreach( $field['depends_on'] as $path => $value ) { |
|
199 | 199 | $conditions[] = [ |
200 | - 'name' => $this->getFieldNameForDependsOn($path), |
|
200 | + 'name' => $this->getFieldNameForDependsOn( $path ), |
|
201 | 201 | 'value' => $value, |
202 | 202 | ]; |
203 | - if ($this->isFieldHidden($path, $value)) { |
|
203 | + if( $this->isFieldHidden( $path, $value ) ) { |
|
204 | 204 | $isFieldHidden = true; |
205 | 205 | } |
206 | 206 | } |
207 | - $field['data-depends'] = json_encode($conditions, JSON_HEX_APOS | JSON_HEX_QUOT); |
|
207 | + $field['data-depends'] = json_encode( $conditions, JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
208 | 208 | $field['is_hidden'] = $isFieldHidden; |
209 | 209 | } |
210 | 210 | return $field; |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @return array |
215 | 215 | */ |
216 | - protected function normalizeLabelAndLegend(array $field) |
|
216 | + protected function normalizeLabelAndLegend( array $field ) |
|
217 | 217 | { |
218 | - if (!empty($field['label'])) { |
|
218 | + if( !empty($field['label']) ) { |
|
219 | 219 | $field['legend'] = $field['label']; |
220 | 220 | unset($field['label']); |
221 | 221 | } else { |
222 | 222 | $field['is_valid'] = false; |
223 | - glsr_log()->warning('Setting field is missing a label')->debug($field); |
|
223 | + glsr_log()->warning( 'Setting field is missing a label' )->debug( $field ); |
|
224 | 224 | } |
225 | 225 | return $field; |
226 | 226 | } |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | /** |
229 | 229 | * @return array |
230 | 230 | */ |
231 | - protected function normalizeValue(array $field) |
|
231 | + protected function normalizeValue( array $field ) |
|
232 | 232 | { |
233 | - if (!isset($field['value'])) { |
|
234 | - $field['value'] = glsr(OptionManager::class)->get( |
|
233 | + if( !isset($field['value']) ) { |
|
234 | + $field['value'] = glsr( OptionManager::class )->get( |
|
235 | 235 | $field['name'], |
236 | - $this->getFieldDefault($field) |
|
236 | + $this->getFieldDefault( $field ) |
|
237 | 237 | ); |
238 | 238 | } |
239 | 239 | return $field; |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | /** |
243 | 243 | * @return string |
244 | 244 | */ |
245 | - protected function normalizeSettingPath($path) |
|
245 | + protected function normalizeSettingPath( $path ) |
|
246 | 246 | { |
247 | - return Str::prefix('settings.', rtrim($path, '.')); |
|
247 | + return Str::prefix( 'settings.', rtrim( $path, '.' ) ); |
|
248 | 248 | } |
249 | 249 | } |
@@ -4,13 +4,13 @@ |
||
4 | 4 | |
5 | 5 | class Hidden extends Field |
6 | 6 | { |
7 | - /** |
|
8 | - * @return array |
|
9 | - */ |
|
10 | - public static function required() |
|
11 | - { |
|
12 | - return [ |
|
13 | - 'is_raw' => true, |
|
14 | - ]; |
|
15 | - } |
|
7 | + /** |
|
8 | + * @return array |
|
9 | + */ |
|
10 | + public static function required() |
|
11 | + { |
|
12 | + return [ |
|
13 | + 'is_raw' => true, |
|
14 | + ]; |
|
15 | + } |
|
16 | 16 | } |
@@ -4,33 +4,33 @@ |
||
4 | 4 | |
5 | 5 | class Code extends Field |
6 | 6 | { |
7 | - /** |
|
8 | - * @return string|void |
|
9 | - */ |
|
10 | - public function build() |
|
11 | - { |
|
12 | - $this->builder->tag = 'textarea'; |
|
13 | - $this->mergeFieldArgs(); |
|
14 | - return $this->builder->getTag(); |
|
15 | - } |
|
7 | + /** |
|
8 | + * @return string|void |
|
9 | + */ |
|
10 | + public function build() |
|
11 | + { |
|
12 | + $this->builder->tag = 'textarea'; |
|
13 | + $this->mergeFieldArgs(); |
|
14 | + return $this->builder->getTag(); |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public static function defaults() |
|
21 | - { |
|
22 | - return [ |
|
23 | - 'class' => 'large-text code', |
|
24 | - ]; |
|
25 | - } |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public static function defaults() |
|
21 | + { |
|
22 | + return [ |
|
23 | + 'class' => 'large-text code', |
|
24 | + ]; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @return array |
|
29 | - */ |
|
30 | - public static function required() |
|
31 | - { |
|
32 | - return [ |
|
33 | - 'type' => 'textarea', |
|
34 | - ]; |
|
35 | - } |
|
27 | + /** |
|
28 | + * @return array |
|
29 | + */ |
|
30 | + public static function required() |
|
31 | + { |
|
32 | + return [ |
|
33 | + 'type' => 'textarea', |
|
34 | + ]; |
|
35 | + } |
|
36 | 36 | } |
@@ -4,13 +4,13 @@ |
||
4 | 4 | |
5 | 5 | class Text extends Field |
6 | 6 | { |
7 | - /** |
|
8 | - * @return array |
|
9 | - */ |
|
10 | - public static function defaults() |
|
11 | - { |
|
12 | - return [ |
|
13 | - 'class' => 'regular-text', |
|
14 | - ]; |
|
15 | - } |
|
7 | + /** |
|
8 | + * @return array |
|
9 | + */ |
|
10 | + public static function defaults() |
|
11 | + { |
|
12 | + return [ |
|
13 | + 'class' => 'regular-text', |
|
14 | + ]; |
|
15 | + } |
|
16 | 16 | } |
@@ -4,30 +4,30 @@ |
||
4 | 4 | |
5 | 5 | class Honeypot extends Field |
6 | 6 | { |
7 | - /** |
|
8 | - * @return string|void |
|
9 | - */ |
|
10 | - public function build() |
|
11 | - { |
|
12 | - $this->builder->args = wp_parse_args($this->builder->args, [ |
|
13 | - 'name' => $this->builder->args['text'], |
|
14 | - ]); |
|
15 | - $this->builder->tag = 'input'; |
|
16 | - $this->mergeFieldArgs(); |
|
17 | - return $this->builder->getOpeningTag(); |
|
18 | - } |
|
7 | + /** |
|
8 | + * @return string|void |
|
9 | + */ |
|
10 | + public function build() |
|
11 | + { |
|
12 | + $this->builder->args = wp_parse_args($this->builder->args, [ |
|
13 | + 'name' => $this->builder->args['text'], |
|
14 | + ]); |
|
15 | + $this->builder->tag = 'input'; |
|
16 | + $this->mergeFieldArgs(); |
|
17 | + return $this->builder->getOpeningTag(); |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return array |
|
22 | - */ |
|
23 | - public static function required() |
|
24 | - { |
|
25 | - return [ |
|
26 | - 'autocomplete' => 'off', |
|
27 | - 'is_raw' => true, |
|
28 | - 'style' => 'display:none!important', |
|
29 | - 'tabindex' => '-1', |
|
30 | - 'type' => 'text', |
|
31 | - ]; |
|
32 | - } |
|
20 | + /** |
|
21 | + * @return array |
|
22 | + */ |
|
23 | + public static function required() |
|
24 | + { |
|
25 | + return [ |
|
26 | + 'autocomplete' => 'off', |
|
27 | + 'is_raw' => true, |
|
28 | + 'style' => 'display:none!important', |
|
29 | + 'tabindex' => '-1', |
|
30 | + 'type' => 'text', |
|
31 | + ]; |
|
32 | + } |
|
33 | 33 | } |
@@ -9,9 +9,9 @@ |
||
9 | 9 | */ |
10 | 10 | public function build() |
11 | 11 | { |
12 | - $this->builder->args = wp_parse_args($this->builder->args, [ |
|
12 | + $this->builder->args = wp_parse_args( $this->builder->args, [ |
|
13 | 13 | 'name' => $this->builder->args['text'], |
14 | - ]); |
|
14 | + ] ); |
|
15 | 15 | $this->builder->tag = 'input'; |
16 | 16 | $this->mergeFieldArgs(); |
17 | 17 | return $this->builder->getOpeningTag(); |
@@ -4,38 +4,38 @@ |
||
4 | 4 | |
5 | 5 | class YesNo extends Field |
6 | 6 | { |
7 | - /** |
|
8 | - * @return string|void |
|
9 | - */ |
|
10 | - public function build() |
|
11 | - { |
|
12 | - $this->builder->tag = 'input'; |
|
13 | - $this->mergeFieldArgs(); |
|
14 | - return $this->builder->getTag(); |
|
15 | - } |
|
7 | + /** |
|
8 | + * @return string|void |
|
9 | + */ |
|
10 | + public function build() |
|
11 | + { |
|
12 | + $this->builder->tag = 'input'; |
|
13 | + $this->mergeFieldArgs(); |
|
14 | + return $this->builder->getTag(); |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public static function defaults() |
|
21 | - { |
|
22 | - return [ |
|
23 | - 'class' => 'inline', |
|
24 | - ]; |
|
25 | - } |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public static function defaults() |
|
21 | + { |
|
22 | + return [ |
|
23 | + 'class' => 'inline', |
|
24 | + ]; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @return array |
|
29 | - */ |
|
30 | - public static function required() |
|
31 | - { |
|
32 | - return [ |
|
33 | - 'is_multi' => true, |
|
34 | - 'options' => [ |
|
35 | - 'no' => __('No', 'site-reviews'), |
|
36 | - 'yes' => __('Yes', 'site-reviews'), |
|
37 | - ], |
|
38 | - 'type' => 'radio', |
|
39 | - ]; |
|
40 | - } |
|
27 | + /** |
|
28 | + * @return array |
|
29 | + */ |
|
30 | + public static function required() |
|
31 | + { |
|
32 | + return [ |
|
33 | + 'is_multi' => true, |
|
34 | + 'options' => [ |
|
35 | + 'no' => __('No', 'site-reviews'), |
|
36 | + 'yes' => __('Yes', 'site-reviews'), |
|
37 | + ], |
|
38 | + 'type' => 'radio', |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | } |
@@ -32,8 +32,8 @@ |
||
32 | 32 | return [ |
33 | 33 | 'is_multi' => true, |
34 | 34 | 'options' => [ |
35 | - 'no' => __('No', 'site-reviews'), |
|
36 | - 'yes' => __('Yes', 'site-reviews'), |
|
35 | + 'no' => __( 'No', 'site-reviews' ), |
|
36 | + 'yes' => __( 'Yes', 'site-reviews' ), |
|
37 | 37 | ], |
38 | 38 | 'type' => 'radio', |
39 | 39 | ]; |