@@ -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'] ) |
@@ -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' ), |
@@ -14,14 +14,14 @@ |
||
14 | 14 | { |
15 | 15 | foreach( $command->popups as $slug => $label ) { |
16 | 16 | $buttonClass = glsr( Helper::class )->buildClassName( $slug.'-popup', 'Shortcodes' ); |
17 | - if( !class_exists( $buttonClass )) { |
|
18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass )); |
|
17 | + if( !class_exists( $buttonClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | $shortcode = glsr( $buttonClass )->register( $slug, [ |
22 | 22 | 'label' => $label, |
23 | 23 | 'title' => $label, |
24 | - ]); |
|
24 | + ] ); |
|
25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
26 | 26 | } |
27 | 27 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | $className = $this->camelCase( $name ); |
18 | 18 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
19 | - return !empty( $path ) |
|
19 | + return !empty($path) |
|
20 | 20 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
21 | 21 | : $className; |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function buildMethodName( $name, $prefix = '' ) |
30 | 30 | { |
31 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
31 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function buildPropertyName( $name ) |
39 | 39 | { |
40 | - return lcfirst( $this->buildClassName( $name )); |
|
40 | + return lcfirst( $this->buildClassName( $name ) ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function camelCase( $string ) |
48 | 48 | { |
49 | - $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ))); |
|
49 | + $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) ); |
|
50 | 50 | return str_replace( ' ', '', $string ); |
51 | 51 | } |
52 | 52 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function convertPathToId( $path, $prefix = '' ) |
80 | 80 | { |
81 | - return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix )); |
|
81 | + return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $levels = explode( '.', $path ); |
91 | 91 | return array_reduce( $levels, function( $result, $value ) { |
92 | - return $result.= '['.$value.']'; |
|
92 | + return $result .= '['.$value.']'; |
|
93 | 93 | }, $prefix ); |
94 | 94 | } |
95 | 95 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function convertStringToArray( $string, $callback = null ) |
102 | 102 | { |
103 | - $array = array_map( 'trim', explode( ',', $string )); |
|
103 | + $array = array_map( 'trim', explode( ',', $string ) ); |
|
104 | 104 | return $callback |
105 | 105 | ? array_filter( $array, $callback ) |
106 | 106 | : array_filter( $array ); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function dashCase( $string ) |
114 | 114 | { |
115 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
115 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function filterInput( $key, array $request = [] ) |
136 | 136 | { |
137 | - if( isset( $request[$key] )) { |
|
137 | + if( isset($request[$key]) ) { |
|
138 | 138 | return $request[$key]; |
139 | 139 | } |
140 | 140 | $variable = filter_input( INPUT_POST, $key ); |
141 | - if( is_null( $variable ) && isset( $_POST[$key] )) { |
|
141 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
142 | 142 | $variable = $_POST[$key]; |
143 | 143 | } |
144 | 144 | return $variable; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function filterInputArray( $key ) |
152 | 152 | { |
153 | 153 | $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
154 | - if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) { |
|
154 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
155 | 155 | $variable = $_POST[$key]; |
156 | 156 | } |
157 | 157 | return (array)$variable; |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | $result = []; |
168 | 168 | foreach( $array as $key => $value ) { |
169 | 169 | $newKey = ltrim( $prefix.'.'.$key, '.' ); |
170 | - if( $this->isIndexedFlatArray( $value )) { |
|
170 | + if( $this->isIndexedFlatArray( $value ) ) { |
|
171 | 171 | if( $flattenValue ) { |
172 | 172 | $value = '['.implode( ', ', $value ).']'; |
173 | 173 | } |
174 | 174 | } |
175 | - else if( is_array( $value )) { |
|
176 | - $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey )); |
|
175 | + else if( is_array( $value ) ) { |
|
176 | + $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) ); |
|
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | $result[$newKey] = $value; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | Whip::IPV4 => $cloudflareIps['v4'], |
193 | 193 | Whip::IPV6 => $cloudflareIps['v6'], |
194 | 194 | ], |
195 | - ]))->getValidIpAddress(); |
|
195 | + ] ))->getValidIpAddress(); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | $keys = explode( '.', $path ); |
207 | 207 | foreach( $keys as $key ) { |
208 | - if( !isset( $values[$key] )) { |
|
208 | + if( !isset($values[$key]) ) { |
|
209 | 209 | return $fallback; |
210 | 210 | } |
211 | 211 | $values = $values[$key]; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function isIndexedArray( $array ) |
221 | 221 | { |
222 | - if( !is_array( $array )) { |
|
222 | + if( !is_array( $array ) ) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | $current = 0; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function isIndexedFlatArray( $array ) |
240 | 240 | { |
241 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
241 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | return $this->isIndexedArray( $array ); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function prefixString( $string, $prefix = '' ) |
253 | 253 | { |
254 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
254 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function removePrefix( $prefix, $text ) { |
278 | 278 | return 0 === strpos( $text, $prefix ) |
279 | - ? substr( $text, strlen( $prefix )) |
|
279 | + ? substr( $text, strlen( $prefix ) ) |
|
280 | 280 | : $text; |
281 | 281 | } |
282 | 282 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function snakeCase( $string ) |
309 | 309 | { |
310 | - if( !ctype_lower( $string )) { |
|
310 | + if( !ctype_lower( $string ) ) { |
|
311 | 311 | $string = preg_replace( '/\s+/u', '', $string ); |
312 | 312 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
313 | 313 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -322,6 +322,6 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function startsWith( $needle, $haystack ) |
324 | 324 | { |
325 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
325 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
326 | 326 | } |
327 | 327 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->path( $possibleView.'.php' )))continue; |
|
58 | + if( !file_exists( glsr()->path( $possibleView.'.php' ) ) )continue; |
|
59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 60 | } |
61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function modifyField( Builder $instance ) |
90 | 90 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 93 | } |
94 | 94 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
109 | 109 | $key = $instance->tag.'_'.$args['type']; |
110 | - $classes = !isset( $this->fields[$key] ) |
|
110 | + $classes = !isset($this->fields[$key]) |
|
111 | 111 | ? $this->fields[$instance->tag] |
112 | 112 | : $this->fields[$key]; |
113 | 113 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $args = wp_parse_args( $instance->args, [ |
142 | 142 | 'is_public' => false, |
143 | 143 | 'is_raw' => false, |
144 | - ]); |
|
144 | + ] ); |
|
145 | 145 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
146 | 146 | return false; |
147 | 147 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | public function filterEnqueuedScripts( $tag, $handle ) |
33 | 33 | { |
34 | 34 | $scripts = [Application::ID.'/google-recaptcha']; |
35 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
35 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
36 | 36 | $tag = str_replace( ' src=', ' async src=', $tag ); |
37 | 37 | } |
38 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
38 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
39 | 39 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
40 | 40 | } |
41 | 41 | return $tag; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function filterFieldOrder( array $config ) |
50 | 50 | { |
51 | - $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config )); |
|
51 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
52 | 52 | return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
53 | 53 | } |
54 | 54 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function routerSubmitReview( array $request ) |
97 | 97 | { |
98 | 98 | $validated = glsr( ValidateReview::class )->validate( $request ); |
99 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
100 | - $this->execute( new CreateReview( $validated->request )); |
|
99 | + if( !empty($validated->error) || $validated->recaptchaIsUnset )return; |
|
100 | + $this->execute( new CreateReview( $validated->request ) ); |
|
101 | 101 | } |
102 | 102 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->validateBlacklist(); |
68 | 68 | $this->validateAkismet(); |
69 | 69 | $this->validateRecaptcha(); |
70 | - if( !empty( $this->error )) { |
|
70 | + if( !empty($this->error) ) { |
|
71 | 71 | $this->setSessionValues( 'message', $this->error ); |
72 | 72 | } |
73 | 73 | return $this; |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
92 | 92 | return static::RECAPTCHA_DISABLED; |
93 | 93 | } |
94 | - if( empty( $this->request['_recaptcha-token'] )) { |
|
95 | - return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 )) |
|
94 | + if( empty($this->request['_recaptcha-token']) ) { |
|
95 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
96 | 96 | ? static::RECAPTCHA_EMPTY |
97 | 97 | : static::RECAPTCHA_FAILED; |
98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function getRecaptchaTokenStatus() |
106 | 106 | { |
107 | - $endpoint = add_query_arg([ |
|
107 | + $endpoint = add_query_arg( [ |
|
108 | 108 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
109 | 109 | 'response' => $this->request['_recaptcha-token'], |
110 | 110 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
111 | 111 | ], static::RECAPTCHA_ENDPOINT ); |
112 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
112 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
113 | 113 | glsr_log()->error( $response->get_error_message() ); |
114 | 114 | return static::RECAPTCHA_FAILED; |
115 | 115 | } |
116 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
117 | - if( !empty( $response->success )) { |
|
116 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
117 | + if( !empty($response->success) ) { |
|
118 | 118 | return boolval( $response->success ) |
119 | 119 | ? static::RECAPTCHA_VALID |
120 | 120 | : static::RECAPTCHA_INVALID; |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | { |
133 | 133 | $rules = array_intersect_key( |
134 | 134 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
135 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
135 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
136 | 136 | ); |
137 | - $excluded = isset( $request['excluded'] ) |
|
137 | + $excluded = isset($request['excluded']) |
|
138 | 138 | ? explode( ',', $request['excluded'] ) |
139 | 139 | : []; |
140 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
140 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $rules = $this->getValidationRules( $request ); |
149 | 149 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
150 | - if( empty( $errors )) { |
|
150 | + if( empty($errors) ) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | $this->setSessionValues( 'errors', $errors ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
165 | 165 | { |
166 | 166 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
167 | - if( !empty( $loggedMessage )) { |
|
167 | + if( !empty($loggedMessage) ) { |
|
168 | 168 | glsr_log()->warning( $loggedMessage ); |
169 | 169 | glsr_log()->warning( $this->request ); |
170 | 170 | } |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty($this->error) )return; |
|
179 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
180 | 180 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
181 | 181 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
182 | 182 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function validateBlacklist() |
188 | 188 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
189 | + if( !empty($this->error) )return; |
|
190 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
191 | 191 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 192 | if( $blacklistAction == 'reject' ) { |
193 | 193 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function validateCustom() |
204 | 204 | { |
205 | - if( !empty( $this->error ))return; |
|
205 | + if( !empty($this->error) )return; |
|
206 | 206 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | 207 | if( $validated === true )return; |
208 | 208 | $this->setSessionValues( 'errors', [] ); |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function validateHoneyPot() |
219 | 219 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
220 | + if( !empty($this->error) )return; |
|
221 | + if( empty($this->request['gotcha']) )return; |
|
222 | 222 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 223 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 224 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function validateRecaptcha() |
230 | 230 | { |
231 | - if( !empty( $this->error ))return; |
|
231 | + if( !empty($this->error) )return; |
|
232 | 232 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
233 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return; |
|
234 | 234 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 235 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 236 | $this->recaptchaIsUnset = true; |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function validateRequest( array $request ) |
252 | 252 | { |
253 | - if( !$this->isRequestValid( $request )) { |
|
253 | + if( !$this->isRequestValid( $request ) ) { |
|
254 | 254 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
255 | 255 | return $request; |
256 | 256 | } |
257 | - if( empty( $request['title'] )) { |
|
257 | + if( empty($request['title']) ) { |
|
258 | 258 | $request['title'] = __( 'No Title', 'site-reviews' ); |
259 | 259 | } |
260 | 260 | return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function build( array $args = [] ) |
14 | 14 | { |
15 | - require_once( ABSPATH.'wp-admin/includes/template.php' ); |
|
15 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
16 | 16 | ob_start(); |
17 | 17 | wp_star_rating( $args ); |
18 | 18 | $stars = ob_get_clean(); |