@@ -7,7 +7,7 @@ |
||
7 | 7 | <p>{{ data.s1 }}</p> |
8 | 8 | </div> |
9 | 9 | <p class="row-actions"> |
10 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
10 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
11 | 11 | </p> |
12 | 12 | </td> |
13 | 13 | <td class="glsr-string-td2"> |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <p>{{ data.p1 }}</p> |
9 | 9 | </div> |
10 | 10 | <p class="row-actions"> |
11 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
11 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
12 | 12 | </p> |
13 | 13 | </td> |
14 | 14 | <td class="glsr-string-td2"> |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | $filenames = []; |
21 | 21 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
22 | 22 | foreach( $iterator as $fileinfo ) { |
23 | - if( !$fileinfo->isFile() )continue; |
|
23 | + if( !$fileinfo->isFile() ) { |
|
24 | + continue; |
|
25 | + } |
|
24 | 26 | $filenames[] = $fileinfo->getFilename(); |
25 | 27 | } |
26 | 28 | natsort( $filenames ); |
@@ -28,7 +30,9 @@ discard block |
||
28 | 30 | $className = str_replace( '.php', '', $file ); |
29 | 31 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
30 | 32 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
33 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' )) { |
|
34 | + return; |
|
35 | + } |
|
32 | 36 | glsr( 'Modules\\Upgrader\\'.$className ); |
33 | 37 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
34 | 38 | }); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $className = str_replace( '.php', '', $file ); |
25 | 25 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
26 | 26 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
27 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
27 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
28 | 28 | glsr( 'Modules\\Upgrader\\'.$className ); |
29 | 29 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
30 | 30 | }); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | add_action( 'admin_init', function() { |
60 | 60 | glsr( AdminController::class )->routerCountReviews( false ); |
61 | - glsr_log()->info( __( 'Calculated rating counts.', 'site-reviews' )); |
|
61 | + glsr_log()->info( __( 'Calculated rating counts.', 'site-reviews' ) ); |
|
62 | 62 | }); |
63 | 63 | } |
64 | 64 |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function filterAttributes( array $allowedAttributeKeys ) |
124 | 124 | { |
125 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
125 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
134 | 134 | $wildcards = []; |
135 | 135 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
136 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
136 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
137 | 137 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
138 | 138 | }, ARRAY_FILTER_USE_KEY ); |
139 | 139 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | protected function getPermanentAttributes() |
148 | 148 | { |
149 | 149 | $permanentAttributes = []; |
150 | - if( array_key_exists( 'value', $this->attributes )) { |
|
150 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
151 | 151 | $permanentAttributes['value'] = $this->attributes['value']; |
152 | 152 | } |
153 | 153 | return $permanentAttributes; |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | protected function normalizeBooleanAttributes() |
200 | 200 | { |
201 | 201 | foreach( $this->attributes as $key => $value ) { |
202 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
202 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
203 | 203 | $key = $value; |
204 | 204 | $value = true; |
205 | 205 | } |
206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
207 | 207 | $this->attributes[$key] = wp_validate_boolean( $value ); |
208 | 208 | } |
209 | 209 | } |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | protected function normalizeDataAttributes() |
215 | 215 | { |
216 | 216 | foreach( $this->attributes as $key => $value ) { |
217 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
217 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
218 | 218 | $key = $value; |
219 | 219 | $value = ''; |
220 | 220 | } |
221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
222 | - if( is_array( $value )) { |
|
223 | - $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
|
221 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
222 | + if( is_array( $value ) ) { |
|
223 | + $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
224 | 224 | } |
225 | 225 | $this->attributes[$key] = $value; |
226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | protected function normalizeStringAttributes() |
233 | 233 | { |
234 | 234 | foreach( $this->attributes as $key => $value ) { |
235 | - if( !is_string( $value ))continue; |
|
235 | + if( !is_string( $value ) )continue; |
|
236 | 236 | $this->attributes[$key] = trim( $value ); |
237 | 237 | } |
238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | if( $method != 'input' )return; |
247 | 247 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
248 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
248 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
249 | 249 | $this->attributes['type'] = 'text'; |
250 | 250 | } |
251 | 251 | } |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | $permanentAttributes = $this->getPermanentAttributes(); |
260 | 260 | foreach( $this->attributes as $key => $value ) { |
261 | 261 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
262 | - unset( $attributes[$key] ); |
|
262 | + unset($attributes[$key]); |
|
263 | 263 | } |
264 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
264 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
265 | 265 | $permanentAttributes[$key] = $value; |
266 | - unset( $attributes[$key] ); |
|
266 | + unset($attributes[$key]); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
@@ -203,7 +203,9 @@ discard block |
||
203 | 203 | $key = $value; |
204 | 204 | $value = true; |
205 | 205 | } |
206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
207 | + continue; |
|
208 | + } |
|
207 | 209 | $this->attributes[$key] = wp_validate_boolean( $value ); |
208 | 210 | } |
209 | 211 | } |
@@ -218,7 +220,9 @@ discard block |
||
218 | 220 | $key = $value; |
219 | 221 | $value = ''; |
220 | 222 | } |
221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
223 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
224 | + continue; |
|
225 | + } |
|
222 | 226 | if( is_array( $value )) { |
223 | 227 | $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
224 | 228 | } |
@@ -232,7 +236,9 @@ discard block |
||
232 | 236 | protected function normalizeStringAttributes() |
233 | 237 | { |
234 | 238 | foreach( $this->attributes as $key => $value ) { |
235 | - if( !is_string( $value ))continue; |
|
239 | + if( !is_string( $value )) { |
|
240 | + continue; |
|
241 | + } |
|
236 | 242 | $this->attributes[$key] = trim( $value ); |
237 | 243 | } |
238 | 244 | } |
@@ -243,7 +249,9 @@ discard block |
||
243 | 249 | */ |
244 | 250 | protected function normalizeInputType( $method ) |
245 | 251 | { |
246 | - if( $method != 'input' )return; |
|
252 | + if( $method != 'input' ) { |
|
253 | + return; |
|
254 | + } |
|
247 | 255 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
248 | 256 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
249 | 257 | $this->attributes['type'] = 'text'; |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | { |
75 | 75 | $this->newSettings = $this->getNewSettings(); |
76 | 76 | $this->oldSettings = $this->getOldSettings(); |
77 | - if( empty( $this->oldSettings ))return; |
|
77 | + if( empty($this->oldSettings) )return; |
|
78 | 78 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
79 | + if( empty($this->oldSettings[$old]) )continue; |
|
80 | 80 | $this->newSettings[$new] = $this->oldSettings[$old]; |
81 | 81 | } |
82 | 82 | $this->migrateNotificationSettings(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $this->migrateRequiredSettings(); |
85 | 85 | $oldSettings = glsr( Helper::class )->convertDotNotationArray( $this->oldSettings ); |
86 | 86 | $newSettings = glsr( Helper::class )->convertDotNotationArray( $this->newSettings ); |
87 | - if( isset( $oldSettings['settings']['strings'] ) && is_array( $oldSettings['settings']['strings'] )) { |
|
87 | + if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) { |
|
88 | 88 | $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
89 | 89 | } |
90 | 90 | glsr( OptionManager::class )->set( $newSettings ); |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | protected function getOldSettings() |
118 | 118 | { |
119 | 119 | $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' ); |
120 | - $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] )); |
|
121 | - if( !empty( $settings )) { |
|
120 | + $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] ) ); |
|
121 | + if( !empty($settings) ) { |
|
122 | 122 | $settings = wp_parse_args( $settings, $defaults ); |
123 | 123 | } |
124 | 124 | return $settings; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
152 | 152 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
153 | 153 | ]; |
154 | - if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] )) { |
|
154 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
155 | 155 | $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
156 | 156 | } |
157 | 157 | if( $this->oldSettings['settings.reviews-form.recaptcha.integration'] == 'invisible-recaptcha' ) { |
@@ -74,9 +74,13 @@ discard block |
||
74 | 74 | { |
75 | 75 | $this->newSettings = $this->getNewSettings(); |
76 | 76 | $this->oldSettings = $this->getOldSettings(); |
77 | - if( empty( $this->oldSettings ))return; |
|
77 | + if( empty( $this->oldSettings )) { |
|
78 | + return; |
|
79 | + } |
|
78 | 80 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
81 | + if( empty( $this->oldSettings[$old] )) { |
|
82 | + continue; |
|
83 | + } |
|
80 | 84 | $this->newSettings[$new] = $this->oldSettings[$old]; |
81 | 85 | } |
82 | 86 | $this->migrateNotificationSettings(); |
@@ -136,7 +140,9 @@ discard block |
||
136 | 140 | ]; |
137 | 141 | $this->newSettings['settings.general.notifications'] = []; |
138 | 142 | foreach( $notifications as $old => $new ) { |
139 | - if( $this->oldSettings['settings.general.notification'] != $old )continue; |
|
143 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
144 | + continue; |
|
145 | + } |
|
140 | 146 | $this->newSettings['settings.general.notifications'][] = $new; |
141 | 147 | } |
142 | 148 | } |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | public function fields() |
14 | 14 | { |
15 | 15 | return [[ |
16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
17 | 17 | 'minWidth' => 320, |
18 | 18 | 'type' => 'container', |
19 | - ],[ |
|
19 | + ], [ |
|
20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
21 | 21 | 'name' => 'title', |
22 | 22 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
23 | 23 | 'type' => 'textbox', |
24 | - ],[ |
|
24 | + ], [ |
|
25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
26 | 26 | 'maxLength' => 5, |
27 | 27 | 'name' => 'count', |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | 'text' => '10', |
30 | 30 | 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
31 | 31 | 'type' => 'textbox', |
32 | - ],[ |
|
32 | + ], [ |
|
33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
34 | 34 | 'name' => 'rating', |
35 | 35 | 'options' => [ |
36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
41 | - '0' => esc_html( __( 'Unrated', 'site-reviews' )), |
|
36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
41 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
42 | 42 | ], |
43 | 43 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
44 | 44 | 'type' => 'listbox', |
45 | - ],[ |
|
45 | + ], [ |
|
46 | 46 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
47 | 47 | 'name' => 'pagination', |
48 | 48 | 'options' => [ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'name' => 'assigned_to', |
61 | 61 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
62 | 62 | 'type' => 'textbox', |
63 | - ],[ |
|
63 | + ], [ |
|
64 | 64 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
65 | 65 | 'name' => 'schema', |
66 | 66 | 'options' => [ |
@@ -69,49 +69,49 @@ discard block |
||
69 | 69 | ], |
70 | 70 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
71 | 71 | 'type' => 'listbox', |
72 | - ],[ |
|
72 | + ], [ |
|
73 | 73 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
74 | 74 | 'name' => 'class', |
75 | 75 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
76 | 76 | 'type' => 'textbox', |
77 | - ],[ |
|
77 | + ], [ |
|
78 | 78 | 'columns' => 2, |
79 | 79 | 'items' => [[ |
80 | 80 | 'name' => 'hide_assigned_to', |
81 | 81 | 'text' => esc_html__( 'Assigned To', 'site-reviews' ), |
82 | 82 | 'tooltip' => __( 'Hide the assigned to link?', 'site-reviews' ), |
83 | 83 | 'type' => 'checkbox', |
84 | - ],[ |
|
84 | + ], [ |
|
85 | 85 | 'name' => 'hide_author', |
86 | 86 | 'text' => esc_html__( 'Author', 'site-reviews' ), |
87 | 87 | 'tooltip' => __( 'Hide the review author?', 'site-reviews' ), |
88 | 88 | 'type' => 'checkbox', |
89 | - ],[ |
|
89 | + ], [ |
|
90 | 90 | 'name' => 'hide_avatar', |
91 | 91 | 'text' => esc_html__( 'Avatar', 'site-reviews' ), |
92 | 92 | 'tooltip' => __( 'Hide the reviewer avatar if shown?', 'site-reviews' ), |
93 | 93 | 'type' => 'checkbox', |
94 | - ],[ |
|
94 | + ], [ |
|
95 | 95 | 'name' => 'hide_content', |
96 | 96 | 'text' => esc_html__( 'Content', 'site-reviews' ), |
97 | 97 | 'tooltip' => __( 'Hide the review content?', 'site-reviews' ), |
98 | 98 | 'type' => 'checkbox', |
99 | - ],[ |
|
99 | + ], [ |
|
100 | 100 | 'name' => 'hide_date', |
101 | 101 | 'text' => esc_html__( 'Date', 'site-reviews' ), |
102 | 102 | 'tooltip' => __( 'Hide the review date?', 'site-reviews' ), |
103 | 103 | 'type' => 'checkbox', |
104 | - ],[ |
|
104 | + ], [ |
|
105 | 105 | 'name' => 'hide_rating', |
106 | 106 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
107 | 107 | 'tooltip' => __( 'Hide the review rating?', 'site-reviews' ), |
108 | 108 | 'type' => 'checkbox', |
109 | - ],[ |
|
109 | + ], [ |
|
110 | 110 | 'name' => 'hide_response', |
111 | 111 | 'text' => esc_html__( 'Response', 'site-reviews' ), |
112 | 112 | 'tooltip' => __( 'Hide the review response?', 'site-reviews' ), |
113 | 113 | 'type' => 'checkbox', |
114 | - ],[ |
|
114 | + ], [ |
|
115 | 115 | 'name' => 'hide_title', |
116 | 116 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
117 | 117 | 'tooltip' => __( 'Hide the review title?', 'site-reviews' ), |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
122 | 122 | 'spacing' => 5, |
123 | 123 | 'type' => 'container', |
124 | - ],[ |
|
124 | + ], [ |
|
125 | 125 | 'hidden' => true, |
126 | 126 | 'name' => 'id', |
127 | 127 | 'type' => 'textbox', |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function getTerms() |
135 | 135 | { |
136 | 136 | $terms = glsr( Database::class )->getTerms(); |
137 | - if( empty( $terms )) { |
|
137 | + if( empty($terms) ) { |
|
138 | 138 | return []; |
139 | 139 | } |
140 | 140 | return [ |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | return [[ |
16 | 16 | 'type' => 'container', |
17 | 17 | 'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
18 | - ],[ |
|
18 | + ], [ |
|
19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
20 | 20 | 'name' => 'title', |
21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
22 | 22 | 'type' => 'textbox', |
23 | - ],[ |
|
23 | + ], [ |
|
24 | 24 | 'label' => esc_html__( 'Description', 'site-reviews' ), |
25 | 25 | 'minHeight' => 60, |
26 | 26 | 'minWidth' => 240, |
@@ -35,39 +35,39 @@ discard block |
||
35 | 35 | 'name' => 'assign_to', |
36 | 36 | 'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ), |
37 | 37 | 'type' => 'textbox', |
38 | - ],[ |
|
38 | + ], [ |
|
39 | 39 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
40 | 40 | 'name' => 'class', |
41 | 41 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
42 | 42 | 'type' => 'textbox', |
43 | - ],[ |
|
43 | + ], [ |
|
44 | 44 | 'columns' => 2, |
45 | 45 | 'items' => [[ |
46 | 46 | 'name' => 'hide_content', |
47 | 47 | 'text' => esc_html__( 'Content', 'site-reviews' ), |
48 | 48 | 'tooltip' => __( 'Hide the content field?', 'site-reviews' ), |
49 | 49 | 'type' => 'checkbox', |
50 | - ],[ |
|
50 | + ], [ |
|
51 | 51 | 'name' => 'hide_email', |
52 | 52 | 'text' => esc_html__( 'Email', 'site-reviews' ), |
53 | 53 | 'tooltip' => __( 'Hide the email field?', 'site-reviews' ), |
54 | 54 | 'type' => 'checkbox', |
55 | - ],[ |
|
55 | + ], [ |
|
56 | 56 | 'name' => 'hide_name', |
57 | 57 | 'text' => esc_html__( 'Name', 'site-reviews' ), |
58 | 58 | 'tooltip' => __( 'Hide the name field?', 'site-reviews' ), |
59 | 59 | 'type' => 'checkbox', |
60 | - ],[ |
|
60 | + ], [ |
|
61 | 61 | 'name' => 'hide_rating', |
62 | 62 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
63 | 63 | 'tooltip' => __( 'Hide the rating field?', 'site-reviews' ), |
64 | 64 | 'type' => 'checkbox', |
65 | - ],[ |
|
65 | + ], [ |
|
66 | 66 | 'name' => 'hide_terms', |
67 | 67 | 'text' => esc_html__( 'Terms', 'site-reviews' ), |
68 | 68 | 'tooltip' => __( 'Hide the terms field?', 'site-reviews' ), |
69 | 69 | 'type' => 'checkbox', |
70 | - ],[ |
|
70 | + ], [ |
|
71 | 71 | 'name' => 'hide_title', |
72 | 72 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
73 | 73 | 'tooltip' => __( 'Hide the title field?', 'site-reviews' ), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'layout' => 'grid', |
78 | 78 | 'spacing' => 5, |
79 | 79 | 'type' => 'container', |
80 | - ],[ |
|
80 | + ], [ |
|
81 | 81 | 'hidden' => true, |
82 | 82 | 'name' => 'id', |
83 | 83 | 'type' => 'textbox', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function getTerms() |
91 | 91 | { |
92 | 92 | $terms = glsr( Database::class )->getTerms(); |
93 | - if( empty( $terms )) { |
|
93 | + if( empty($terms) ) { |
|
94 | 94 | return []; |
95 | 95 | } |
96 | 96 | return [ |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'label' => '['.$tag.']', |
48 | 48 | 'required' => $this->required, |
49 | 49 | 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | protected function generateFields( array $fields ) |
58 | 58 | { |
59 | 59 | $generatedFields = array_map( function( $field ) { |
60 | - if( empty( $field ))return; |
|
60 | + if( empty($field) )return; |
|
61 | 61 | $field = $this->normalize( $field ); |
62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
62 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return; |
|
63 | 63 | return $this->$method( $field ); |
64 | 64 | }, $fields ); |
65 | - return array_values( array_filter( $generatedFields )); |
|
65 | + return array_values( array_filter( $generatedFields ) ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | protected function getFields() |
72 | 72 | { |
73 | 73 | $fields = $this->generateFields( $this->fields() ); |
74 | - if( !empty( $this->errors )) { |
|
74 | + if( !empty($this->errors) ) { |
|
75 | 75 | $errors = []; |
76 | 76 | foreach( $this->required as $name => $alert ) { |
77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
77 | + if( false !== array_search( $name, array_column( $fields, 'name' ) ) )continue; |
|
78 | 78 | $errors[] = $this->errors[$name]; |
79 | 79 | } |
80 | 80 | $this->errors = $errors; |
81 | 81 | } |
82 | - return empty( $this->errors ) |
|
82 | + return empty($this->errors) |
|
83 | 83 | ? $fields |
84 | 84 | : $this->errors; |
85 | 85 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return wp_parse_args( $field, [ |
93 | 93 | 'items' => [], |
94 | 94 | 'type' => '', |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'tooltip' => '', |
111 | 111 | 'type' => '', |
112 | 112 | 'value' => '', |
113 | - ]); |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function normalizeContainer( array $field ) |
120 | 120 | { |
121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
121 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return; |
|
122 | 122 | $field['items'] = $this->generateFields( $field['items'] ); |
123 | 123 | return $field; |
124 | 124 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function normalizeField( array $field, array $defaults ) |
130 | 130 | { |
131 | - if( !$this->validate( $field ))return; |
|
131 | + if( !$this->validate( $field ) )return; |
|
132 | 132 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
133 | 133 | return $value !== ''; |
134 | 134 | }); |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | 'tooltip' => '', |
149 | 149 | 'type' => '', |
150 | 150 | 'value' => '', |
151 | - ]); |
|
152 | - if( !is_array( $listbox ))return; |
|
153 | - if( !array_key_exists( '', $listbox['options'] )) { |
|
151 | + ] ); |
|
152 | + if( !is_array( $listbox ) )return; |
|
153 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
154 | 154 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
155 | 155 | } |
156 | 156 | foreach( $listbox['options'] as $value => $text ) { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function normalizePost( array $field ) |
169 | 169 | { |
170 | - if( !is_array( $field['query_args'] )) { |
|
170 | + if( !is_array( $field['query_args'] ) ) { |
|
171 | 171 | $field['query_args'] = []; |
172 | 172 | } |
173 | 173 | $posts = get_posts( wp_parse_args( $field['query_args'], [ |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | 'orderby' => 'title', |
176 | 176 | 'post_type' => 'post', |
177 | 177 | 'posts_per_page' => 30, |
178 | - ])); |
|
179 | - if( !empty( $posts )) { |
|
178 | + ] ) ); |
|
179 | + if( !empty($posts) ) { |
|
180 | 180 | $options = []; |
181 | 181 | foreach( $posts as $post ) { |
182 | 182 | $options[$post->ID] = esc_html( $post->post_title ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'tooltip' => '', |
207 | 207 | 'type' => '', |
208 | 208 | 'value' => '', |
209 | - ]); |
|
209 | + ] ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function validate( array $field ) |
216 | 216 | { |
217 | - $args = shortcode_atts([ |
|
217 | + $args = shortcode_atts( [ |
|
218 | 218 | 'label' => '', |
219 | 219 | 'name' => false, |
220 | 220 | 'required' => false, |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | */ |
231 | 231 | protected function validateErrors( array $args ) |
232 | 232 | { |
233 | - if( !isset( $args['required']['error'] )) { |
|
233 | + if( !isset($args['required']['error']) ) { |
|
234 | 234 | return true; |
235 | 235 | } |
236 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
236 | + $this->errors[$args['name']] = $this->normalizeContainer( [ |
|
237 | 237 | 'html' => $args['required']['error'], |
238 | 238 | 'type' => 'container', |
239 | - ]); |
|
239 | + ] ); |
|
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | return true; |
250 | 250 | } |
251 | 251 | $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
252 | - if( isset( $args['required']['alert'] )) { |
|
252 | + if( isset($args['required']['alert']) ) { |
|
253 | 253 | $alert = $args['required']['alert']; |
254 | 254 | } |
255 | - else if( !empty( $args['label'] )) { |
|
255 | + else if( !empty($args['label']) ) { |
|
256 | 256 | $alert = sprintf( |
257 | 257 | esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
258 | 258 | str_replace( ':', '', $args['label'] ) |
@@ -57,9 +57,13 @@ discard block |
||
57 | 57 | protected function generateFields( array $fields ) |
58 | 58 | { |
59 | 59 | $generatedFields = array_map( function( $field ) { |
60 | - if( empty( $field ))return; |
|
60 | + if( empty( $field )) { |
|
61 | + return; |
|
62 | + } |
|
61 | 63 | $field = $this->normalize( $field ); |
62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
64 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ))) { |
|
65 | + return; |
|
66 | + } |
|
63 | 67 | return $this->$method( $field ); |
64 | 68 | }, $fields ); |
65 | 69 | return array_values( array_filter( $generatedFields )); |
@@ -74,7 +78,9 @@ discard block |
||
74 | 78 | if( !empty( $this->errors )) { |
75 | 79 | $errors = []; |
76 | 80 | foreach( $this->required as $name => $alert ) { |
77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
81 | + if( false !== array_search( $name, array_column( $fields, 'name' ))) { |
|
82 | + continue; |
|
83 | + } |
|
78 | 84 | $errors[] = $this->errors[$name]; |
79 | 85 | } |
80 | 86 | $this->errors = $errors; |
@@ -118,7 +124,9 @@ discard block |
||
118 | 124 | */ |
119 | 125 | protected function normalizeContainer( array $field ) |
120 | 126 | { |
121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
127 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field )) { |
|
128 | + return; |
|
129 | + } |
|
122 | 130 | $field['items'] = $this->generateFields( $field['items'] ); |
123 | 131 | return $field; |
124 | 132 | } |
@@ -128,7 +136,9 @@ discard block |
||
128 | 136 | */ |
129 | 137 | protected function normalizeField( array $field, array $defaults ) |
130 | 138 | { |
131 | - if( !$this->validate( $field ))return; |
|
139 | + if( !$this->validate( $field )) { |
|
140 | + return; |
|
141 | + } |
|
132 | 142 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
133 | 143 | return $value !== ''; |
134 | 144 | }); |
@@ -149,7 +159,9 @@ discard block |
||
149 | 159 | 'type' => '', |
150 | 160 | 'value' => '', |
151 | 161 | ]); |
152 | - if( !is_array( $listbox ))return; |
|
162 | + if( !is_array( $listbox )) { |
|
163 | + return; |
|
164 | + } |
|
153 | 165 | if( !array_key_exists( '', $listbox['options'] )) { |
154 | 166 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
155 | 167 | } |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | public function fields() |
13 | 13 | { |
14 | 14 | return [[ |
15 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
15 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
16 | 16 | 'minWidth' => 320, |
17 | 17 | 'type' => 'container', |
18 | - ],[ |
|
18 | + ], [ |
|
19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
20 | 20 | 'name' => 'title', |
21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 'name' => 'assigned_to', |
29 | 29 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
30 | 30 | 'type' => 'textbox', |
31 | - ],[ |
|
31 | + ], [ |
|
32 | 32 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
33 | 33 | 'name' => 'schema', |
34 | 34 | 'options' => [ |
@@ -37,34 +37,34 @@ discard block |
||
37 | 37 | ], |
38 | 38 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
39 | 39 | 'type' => 'listbox', |
40 | - ],[ |
|
40 | + ], [ |
|
41 | 41 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
42 | 42 | 'name' => 'class', |
43 | 43 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
44 | 44 | 'type' => 'textbox', |
45 | - ],[ |
|
45 | + ], [ |
|
46 | 46 | 'columns' => 2, |
47 | 47 | 'items' => [[ |
48 | 48 | 'type' => 'checkbox', |
49 | 49 | 'name' => 'hide_bars', |
50 | 50 | 'text' => esc_html__( 'Bars', 'site-reviews' ), |
51 | 51 | 'tooltip' => __( 'Hide the percentage bars?', 'site-reviews' ), |
52 | - ],[ |
|
52 | + ], [ |
|
53 | 53 | 'type' => 'checkbox', |
54 | 54 | 'name' => 'hide_if_empty', |
55 | 55 | 'text' => esc_html__( 'If Empty', 'site-reviews' ), |
56 | 56 | 'tooltip' => __( 'Hide the summary if no reviews are found?', 'site-reviews' ), |
57 | - ],[ |
|
57 | + ], [ |
|
58 | 58 | 'type' => 'checkbox', |
59 | 59 | 'name' => 'hide_rating', |
60 | 60 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
61 | 61 | 'tooltip' => __( 'Hide the rating?', 'site-reviews' ), |
62 | - ],[ |
|
62 | + ], [ |
|
63 | 63 | 'type' => 'checkbox', |
64 | 64 | 'name' => 'hide_stars', |
65 | 65 | 'text' => esc_html__( 'Stars', 'site-reviews' ), |
66 | 66 | 'tooltip' => __( 'Hide the stars?', 'site-reviews' ), |
67 | - ],[ |
|
67 | + ], [ |
|
68 | 68 | 'type' => 'checkbox', |
69 | 69 | 'name' => 'hide_summary', |
70 | 70 | 'text' => esc_html__( 'Summary', 'site-reviews' ), |