@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) { |
33 | 33 | $reviews[] = $this->buildReview( $review ); |
34 | 34 | } |
35 | - if( !empty( $reviews )) { |
|
35 | + if( !empty($reviews) ) { |
|
36 | 36 | array_walk( $reviews, function( &$review ) { |
37 | - unset( $review['@context'] ); |
|
38 | - unset( $review['itemReviewed'] ); |
|
37 | + unset($review['@context']); |
|
38 | + unset($review['itemReviewed']); |
|
39 | 39 | }); |
40 | 40 | $schema['review'] = $reviews; |
41 | 41 | } |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | public function buildReview( $review ) |
50 | 50 | { |
51 | 51 | $schema = SchemaOrg::Review() |
52 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
52 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
53 | 53 | $schema->name( $review->title ); |
54 | 54 | }) |
55 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
55 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
56 | 56 | $schema->reviewBody( $review->content ); |
57 | 57 | }) |
58 | - ->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 )) |
|
58 | + ->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) ) |
|
59 | 59 | ->author( SchemaOrg::Person() |
60 | 60 | ->name( $review->author ) |
61 | 61 | ) |
62 | 62 | ->itemReviewed( $this->getSchemaType() |
63 | 63 | ->name( $this->getThingName() ) |
64 | 64 | ); |
65 | - if( !empty( $review->rating )) { |
|
65 | + if( !empty($review->rating) ) { |
|
66 | 66 | $schema->reviewRating( SchemaOrg::Rating() |
67 | 67 | ->ratingValue( $review->rating ) |
68 | 68 | ->bestRating( Rating::MAX_RATING ) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function buildSummary( $args = null ) |
80 | 80 | { |
81 | - if( is_array( $args )) { |
|
81 | + if( is_array( $args ) ) { |
|
82 | 82 | $this->args = $args; |
83 | 83 | } |
84 | 84 | $schema = $this->getSchemaType() |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ->image( $this->getThingImage() ) |
91 | 91 | ->url( $this->getThingUrl() ); |
92 | 92 | $count = $this->getReviewCount(); |
93 | - if( !empty( $count )) { |
|
93 | + if( !empty($count) ) { |
|
94 | 94 | $schema->aggregateRating( SchemaOrg::AggregateRating() |
95 | 95 | ->ratingValue( $this->getRatingValue() ) |
96 | 96 | ->reviewCount( $count ) |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas ) )return; |
|
112 | 112 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 113 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 114 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
115 | - )); |
|
115 | + ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function store( array $schema ) |
122 | 122 | { |
123 | - $schemas = (array) glsr()->schemas; |
|
123 | + $schemas = (array)glsr()->schemas; |
|
124 | 124 | $schemas[] = $schema; |
125 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
125 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function getReviews( $force = false ) |
149 | 149 | { |
150 | - if( !isset( $this->reviews ) || $force ) { |
|
150 | + if( !isset($this->reviews) || $force ) { |
|
151 | 151 | $args = wp_parse_args( ['count' => -1], $this->args ); |
152 | 152 | $this->reviews = glsr( Database::class )->getReviews( $args )->reviews; |
153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getSchemaOption( $option, $fallback ) |
163 | 163 | { |
164 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
164 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
165 | 165 | return $schemaOption; |
166 | 166 | } |
167 | 167 | $default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback ); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getDefaults() |
68 | 68 | { |
69 | - if( empty( $this->defaults )) { |
|
69 | + if( empty($this->defaults) ) { |
|
70 | 70 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
71 | 71 | $this->upgrade(); |
72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function hasPermission() |
80 | 80 | { |
81 | - return !$this->isAdmin() || ( $this->isAdmin() && current_user_can( static::CAPABILITY )); |
|
81 | + return !$this->isAdmin() || ($this->isAdmin() && current_user_can( static::CAPABILITY )); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
134 | 134 | $this->reviewTypes = wp_parse_args( $types, [ |
135 | 135 | 'local' => __( 'Local', 'site-reviews' ), |
136 | - ]); |
|
136 | + ] ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | public function render( $view, array $data = [] ) |
144 | 144 | { |
145 | 145 | $file = ''; |
146 | - if( glsr( Helper::class )->startsWith( $view, 'templates/' )) { |
|
146 | + if( glsr( Helper::class )->startsWith( $view, 'templates/' ) ) { |
|
147 | 147 | $file = str_replace( 'templates/', 'site-reviews/', $view ).'.php'; |
148 | 148 | $file = get_stylesheet_directory().'/'.$file; |
149 | 149 | } |
150 | - if( !file_exists( $file )) { |
|
150 | + if( !file_exists( $file ) ) { |
|
151 | 151 | $file = $this->path( 'views/'.$view.'.php' ); |
152 | 152 | } |
153 | 153 | $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
154 | - if( !file_exists( $file )) { |
|
154 | + if( !file_exists( $file ) ) { |
|
155 | 155 | glsr_log()->error( 'File not found: '.$file ); |
156 | 156 | return; |
157 | 157 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function scheduleCronJob() |
167 | 167 | { |
168 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
168 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
169 | 169 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function unscheduleCronJob() |
176 | 176 | { |
177 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
177 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -206,6 +206,6 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function url( $path = '' ) |
208 | 208 | { |
209 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
209 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
210 | 210 | } |
211 | 211 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
19 | - if( !isset( $request['action'] ))return; |
|
19 | + if( !isset($request['action']) )return; |
|
20 | 20 | $this->checkNonce( $request['action'] ); |
21 | 21 | switch( $request['action'] ) { |
22 | 22 | case 'clear-log': |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | public function routeAjaxRequest() |
43 | 43 | { |
44 | 44 | $request = $this->normalizeAjaxRequest(); |
45 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
45 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
46 | 46 | glsr_log()->error( 'Nonce check failed for ajax request' )->info( $request ); |
47 | 47 | wp_die( -1, 403 ); |
48 | 48 | } |
49 | 49 | $controller = glsr( AjaxController::class ); |
50 | 50 | $method = glsr( Helper::class )->buildMethodName( $request['action'] ); |
51 | - if( is_callable( [$controller, $method] )) { |
|
51 | + if( is_callable( [$controller, $method] ) ) { |
|
52 | 52 | call_user_func( [$controller, $method], $request ); |
53 | 53 | } |
54 | 54 | else { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function routeWebhookRequest() |
80 | 80 | { |
81 | - $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
|
81 | + $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID ) ); |
|
82 | 82 | if( !$request )return; |
83 | 83 | // @todo manage webhook here |
84 | 84 | } |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | protected function normalizeAjaxRequest() |
117 | 117 | { |
118 | 118 | $request = filter_input( INPUT_POST, 'request', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
119 | - if( isset( $request[Application::ID]['action'] )) { |
|
119 | + if( isset($request[Application::ID]['action']) ) { |
|
120 | 120 | $request = $request[Application::ID]; |
121 | 121 | } |
122 | - if( !isset( $request['action'] )) { |
|
122 | + if( !isset($request['action']) ) { |
|
123 | 123 | glsr_log()->error( 'The AJAX request must include an action' )->info( $request ); |
124 | 124 | wp_die(); |
125 | 125 | } |
126 | - if( !isset( $request['nonce'] )) { |
|
126 | + if( !isset($request['nonce']) ) { |
|
127 | 127 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
128 | 128 | wp_die(); |
129 | 129 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function get() |
110 | 110 | { |
111 | - return empty( $this->log ) |
|
111 | + return empty($this->log) |
|
112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
113 | 113 | : $this->log; |
114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
136 | 136 | $constants = (array)apply_filters( 'site-reviews/log-levels', $constants ); |
137 | - if( in_array( $level, $constants, true )) { |
|
137 | + if( in_array( $level, $constants, true ) ) { |
|
138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
140 | 140 | $this->reset(); |
141 | 141 | } |
142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | protected function getDebugInformation() |
187 | 187 | { |
188 | 188 | $caller = debug_backtrace( 0, 6 ); |
189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
190 | 190 | if( $index === false |
191 | - || !isset( $caller[$index+2]['class'] ) |
|
192 | - || !isset( $caller[$index+2]['function'] ) |
|
191 | + || !isset($caller[$index + 2]['class']) |
|
192 | + || !isset($caller[$index + 2]['function']) |
|
193 | 193 | )return; |
194 | 194 | return sprintf( '[%s()->%s:%s] ', |
195 | - $caller[$index+2]['class'], |
|
196 | - $caller[$index+2]['function'], |
|
197 | - $caller[$index+1]['line'] |
|
195 | + $caller[$index + 2]['class'], |
|
196 | + $caller[$index + 2]['function'], |
|
197 | + $caller[$index + 1]['line'] |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function interpolate( $message, $context = [] ) |
208 | 208 | { |
209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
210 | 210 | return print_r( $message, true ); |
211 | 211 | } |
212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if( $value instanceof DateTime ) { |
235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
236 | 236 | } |
237 | - else if( $this->isObjectOrArray( $value )) { |
|
237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
238 | 238 | $value = json_encode( $value ); |
239 | 239 | } |
240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->clear(); |
251 | 251 | file_put_contents( |
252 | 252 | $this->file, |
253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | $ipAddresses = array_fill_keys( ['v4', 'v6'], [] ); |
20 | 20 | foreach( array_keys( $ipAddresses ) as $version ) { |
21 | 21 | $response = wp_remote_get( 'https://www.cloudflare.com/ips-'.$version ); |
22 | - if( is_wp_error( $response )) { |
|
22 | + if( is_wp_error( $response ) ) { |
|
23 | 23 | glsr_log()->error( $response->get_error_message() ); |
24 | 24 | continue; |
25 | 25 | } |
26 | - $ipAddresses[$version] = array_filter( explode( PHP_EOL, wp_remote_retrieve_body( $response ))); |
|
26 | + $ipAddresses[$version] = array_filter( explode( PHP_EOL, wp_remote_retrieve_body( $response ) ) ); |
|
27 | 27 | } |
28 | 28 | set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME ); |
29 | 29 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | if( $test === false ) { |
58 | 58 | $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
59 | 59 | $test = !is_wp_error( $response ) |
60 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
60 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
61 | 61 | ? 'Works' |
62 | 62 | : 'Does not work'; |
63 | 63 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function buildClassName( $name, $path = '' ) |
16 | 16 | { |
17 | - $className = array_map( 'strtolower', (array)preg_split( '/[-_]/', $name )); |
|
17 | + $className = array_map( 'strtolower', (array)preg_split( '/[-_]/', $name ) ); |
|
18 | 18 | $className = array_map( 'ucfirst', $className ); |
19 | 19 | $className = implode( '', $className ); |
20 | 20 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
21 | - return !empty( $path ) |
|
21 | + return !empty($path) |
|
22 | 22 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
23 | 23 | : $className; |
24 | 24 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function buildMethodName( $name, $prefix = '' ) |
32 | 32 | { |
33 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
33 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function buildPropertyName( $name ) |
41 | 41 | { |
42 | - return lcfirst( $this->buildClassName( $name )); |
|
42 | + return lcfirst( $this->buildClassName( $name ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $levels = explode( '.', $path ); |
83 | 83 | return array_reduce( $levels, function( $result, $value ) { |
84 | - return $result.= '['.$value.']'; |
|
84 | + return $result .= '['.$value.']'; |
|
85 | 85 | }, $prefix ); |
86 | 86 | } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function dashCase( $string ) |
93 | 93 | { |
94 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
94 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | { |
116 | 116 | $result = []; |
117 | 117 | foreach( $array as $key => $value ) { |
118 | - $newKey = $prefix.( empty( $prefix ) ? '' : '.' ).$key; |
|
119 | - if( $this->isIndexedArray( $value )) { |
|
118 | + $newKey = $prefix.(empty($prefix) ? '' : '.').$key; |
|
119 | + if( $this->isIndexedArray( $value ) ) { |
|
120 | 120 | $value = '['.implode( ', ', $value ).']'; |
121 | 121 | } |
122 | - if( is_array( $value )) { |
|
123 | - $result = array_merge( $result, $this->flattenArray( $value, $newKey )); |
|
122 | + if( is_array( $value ) ) { |
|
123 | + $result = array_merge( $result, $this->flattenArray( $value, $newKey ) ); |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | $result[$newKey] = $value; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | Whip::IPV4 => $cloudflareIps['v4'], |
140 | 140 | Whip::IPV6 => $cloudflareIps['v6'], |
141 | 141 | ], |
142 | - ]))->getValidIpAddress(); |
|
142 | + ] ))->getValidIpAddress(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | $keys = explode( '.', $path ); |
154 | 154 | foreach( $keys as $key ) { |
155 | - if( !isset( $values[$key] )) { |
|
155 | + if( !isset($values[$key]) ) { |
|
156 | 156 | return $fallback; |
157 | 157 | } |
158 | 158 | $values = $values[$key]; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function isIndexedArray( $array ) |
168 | 168 | { |
169 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
169 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | $current = 0; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function prefixString( $string, $prefix = '' ) |
188 | 188 | { |
189 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
189 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function snakeCase( $string ) |
234 | 234 | { |
235 | - if( !ctype_lower( $string )) { |
|
235 | + if( !ctype_lower( $string ) ) { |
|
236 | 236 | $string = preg_replace( '/\s+/u', '', $string ); |
237 | 237 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
238 | 238 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -247,6 +247,6 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function startsWith( $needle, $haystack ) |
249 | 249 | { |
250 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
250 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
251 | 251 | } |
252 | 252 | } |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | public function __construct( $idBase, $name, $values ) |
16 | 16 | { |
17 | 17 | $controlOptions = $widgetOptions = []; |
18 | - if( isset( $values['class'] )) { |
|
18 | + if( isset($values['class']) ) { |
|
19 | 19 | $widgetOptions['classname'] = $values['class']; |
20 | 20 | } |
21 | - if( isset( $values['description'] )) { |
|
21 | + if( isset($values['description']) ) { |
|
22 | 22 | $widgetOptions['description'] = $values['description']; |
23 | 23 | } |
24 | - if( isset( $values['width'] )) { |
|
24 | + if( isset($values['width']) ) { |
|
25 | 25 | $controlOptions['width'] = $values['width']; |
26 | 26 | } |
27 | 27 | parent::__construct( $idBase, $name, $widgetOptions, $controlOptions ); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | protected function renderField( $tag, array $args = [] ) |
35 | 35 | { |
36 | 36 | $args = $this->normalizeFieldAttributes( $tag, $args ); |
37 | - $field = glsr( Html::class )->build( ['is_widget' => true] )->{$tag}( $args['name'], $args ); |
|
37 | + $field = glsr( Html::class )->build( ['is_widget' => true] )->{$tag}($args['name'], $args); |
|
38 | 38 | echo glsr( Html::class )->build( ['is_widget' => true] )->div( $field, [ |
39 | 39 | 'class' => 'glsr-field', |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function normalizeFieldAttributes( $tag, array $args ) |
48 | 48 | { |
49 | - if( empty( $args['value'] )) { |
|
49 | + if( empty($args['value']) ) { |
|
50 | 50 | $args['value'] = $this->widgetArgs[$args['name']]; |
51 | 51 | } |
52 | - if( empty( $this->widgetArgs['options'] ) && in_array( $tag, ['checkbox', 'radio'] )) { |
|
52 | + if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) { |
|
53 | 53 | $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] ); |
54 | 54 | } |
55 | 55 | $args['id'] = $this->get_field_id( $args['name'] ); |
@@ -50,9 +50,9 @@ |
||
50 | 50 | */ |
51 | 51 | protected function normalize( array $data ) |
52 | 52 | { |
53 | - $data = wp_parse_args( $data, array_fill_keys( ['context', 'globals'], [] )); |
|
53 | + $data = wp_parse_args( $data, array_fill_keys( ['context', 'globals'], [] ) ); |
|
54 | 54 | foreach( $data as $key => $value ) { |
55 | - if( is_array( $value ))continue; |
|
55 | + if( is_array( $value ) )continue; |
|
56 | 56 | $data[$key] = []; |
57 | 57 | } |
58 | 58 | $data['template'] = $this; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | $defaults = wp_parse_args( $this->defaults(), [ |
15 | 15 | 'name' => $this->builder->args['text'], |
16 | - ]); |
|
16 | + ] ); |
|
17 | 17 | $this->builder->args = wp_parse_args( $this->builder->args, $defaults ); |
18 | 18 | $this->builder->tag = 'input'; |
19 | 19 | return $this->builder->getOpeningTag(); |