@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function isBlacklisted( CreateReview $review ) |
14 | 14 | { |
15 | - $target = implode( "\n", array_filter([ |
|
15 | + $target = implode( "\n", array_filter( [ |
|
16 | 16 | $review->author, |
17 | 17 | $review->content, |
18 | 18 | $review->email, |
19 | 19 | $review->ipAddress, |
20 | 20 | $review->title, |
21 | - ])); |
|
22 | - return (bool) apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
21 | + ] ) ); |
|
22 | + return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
23 | 23 | $this->check( $target ), |
24 | 24 | $review |
25 | 25 | ); |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function check( $target ) |
33 | 33 | { |
34 | - $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' )); |
|
35 | - if( empty( $blacklist )) { |
|
34 | + $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) ); |
|
35 | + if( empty($blacklist) ) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | $lines = explode( "\n", $blacklist ); |
39 | - foreach( (array) $lines as $line ) { |
|
39 | + foreach( (array)$lines as $line ) { |
|
40 | 40 | $line = trim( $line ); |
41 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
42 | - $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
|
43 | - if( preg_match( $pattern, $target )) { |
|
41 | + if( empty($line) || 256 < strlen( $line ) )continue; |
|
42 | + $pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) ); |
|
43 | + if( preg_match( $pattern, $target ) ) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function createWebhookNotification( Command $command, array $args ) |
64 | 64 | { |
65 | 65 | $fields = []; |
66 | - $fields[] = ['title' => str_repeat( ':star:', (int) $command->rating )]; |
|
66 | + $fields[] = ['title' => str_repeat( ':star:', (int)$command->rating )]; |
|
67 | 67 | if( $command->title ) { |
68 | 68 | $fields[] = ['title' => $command->title]; |
69 | 69 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | if( $command->author ) { |
77 | 77 | $fields[] = ['value' => trim( $command->author.$command->email.' - '.$command->ipAddress )]; |
78 | 78 | } |
79 | - $fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ))]; |
|
80 | - return json_encode([ |
|
79 | + $fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ) )]; |
|
80 | + return json_encode( [ |
|
81 | 81 | 'icon_url' => glsr()->url.'assets/img/icon.png', |
82 | 82 | 'username' => glsr()->name, |
83 | 83 | 'attachments' => [[ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'fallback' => $this->createEmailNotification( $command, $args )->read( 'plaintext' ), |
87 | 87 | 'fields' => $fields, |
88 | 88 | ]], |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | protected function sendNotification( $post_id, Command $command ) |
116 | 116 | { |
117 | 117 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
118 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
119 | - $assignedToTitle = get_the_title( (int) $command->assignedTo ); |
|
118 | + if( !in_array( $notificationType, ['default', 'custom', 'webhook'] ) )return; |
|
119 | + $assignedToTitle = get_the_title( (int)$command->assignedTo ); |
|
120 | 120 | $notificationSubject = _nx( |
121 | 121 | 'New %s-star review', |
122 | 122 | 'New %s-star review of: %s', |
123 | - (int) empty( $assignedToTitle ), |
|
123 | + (int)empty($assignedToTitle), |
|
124 | 124 | 'The text is different depending on whether or not the review has been assigned to a post.', |
125 | 125 | 'site-reviews' |
126 | 126 | ); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | sprintf( $notificationSubject, $command->rating, $assignedToTitle ) |
130 | 130 | ); |
131 | 131 | $args = [ |
132 | - 'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ))), |
|
132 | + 'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ) ) ), |
|
133 | 133 | 'notification_title' => $notificationTitle, |
134 | 134 | 'notification_type' => $notificationType, |
135 | 135 | ]; |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $args['recipient'] = $args['notification_type'] === 'default' |
148 | 148 | ? get_option( 'admin_email' ) |
149 | 149 | : glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
150 | - $result = !empty( $args['recipient'] ) |
|
150 | + $result = !empty($args['recipient']) |
|
151 | 151 | ? $this->createEmailNotification( $command, $args )->send() |
152 | 152 | : false; |
153 | - if( !is_bool( $result )) { |
|
154 | - glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' )); |
|
153 | + if( !is_bool( $result ) ) { |
|
154 | + glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' ) ); |
|
155 | 155 | } |
156 | 156 | if( $result === false ) { |
157 | - glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' )); |
|
157 | + glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' ) ); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function sendWebhookNotification( Command $command, array $args ) |
165 | 165 | { |
166 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
166 | + if( !($endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )) )return; |
|
167 | 167 | $notification = $this->createWebhookNotification( $command, $args ); |
168 | 168 | $result = wp_remote_post( $endpoint, [ |
169 | 169 | 'method' => 'POST', |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | 'sslverify' => false, |
175 | 175 | 'headers' => ['Content-Type' => 'application/json'], |
176 | 176 | 'body' => apply_filters( 'site-reviews/webhook/notification', $notification, $command ), |
177 | - ]); |
|
178 | - if( is_wp_error( $result )) { |
|
177 | + ] ); |
|
178 | + if( is_wp_error( $result ) ) { |
|
179 | 179 | glsr_log()->error( $result->get_error_message() ); |
180 | 180 | } |
181 | 181 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function onCreateReview( $postData, $meta, $postId ) |
24 | 24 | { |
25 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
25 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
26 | 26 | $this->updateAssignedToPost( $review ); |
27 | 27 | } |
28 | 28 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function onDeleteReview( $postId ) |
34 | 34 | { |
35 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
35 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
36 | 36 | $review->post_status = 'deleted'; // important to change the post_status here first! |
37 | 37 | $this->updateAssignedToPost( $review ); |
38 | 38 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function saveAssignedToMetabox( $postId ) |
54 | 54 | { |
55 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
55 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
56 | 56 | $assignedTo = filter_input( INPUT_POST, 'assigned_to' ); |
57 | 57 | $assignedTo || $assignedTo = ''; |
58 | 58 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function saveResponseMetabox( $postId ) |
69 | 69 | { |
70 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return; |
|
70 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ) )return; |
|
71 | 71 | $response = filter_input( INPUT_POST, 'response' ); |
72 | 72 | $response || $response = ''; |
73 | 73 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
74 | 74 | 'a' => ['href' => [], 'title' => []], |
75 | 75 | 'em' => [], |
76 | 76 | 'strong' => [], |
77 | - ]))); |
|
77 | + ] ) ) ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function getAssignedToPostId( $postId ) |
85 | 85 | { |
86 | - $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true )); |
|
87 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
86 | + $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) ); |
|
87 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
88 | 88 | return $post->ID; |
89 | 89 | } |
90 | 90 | return false; |
@@ -120,22 +120,22 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function updateAssignedToPost( WP_Post $review ) |
122 | 122 | { |
123 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
124 | - $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
125 | - if( empty( $reviewIds ))return; |
|
123 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
124 | + $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
125 | + if( empty($reviewIds) )return; |
|
126 | 126 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
127 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
128 | - if( empty( $updatedReviewIds )) { |
|
127 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
128 | + if( empty($updatedReviewIds) ) { |
|
129 | 129 | delete_post_meta( $postId, static::META_RANKING ); |
130 | 130 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
131 | 131 | } |
132 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
133 | - $reviews = glsr( Database::class )->getReviews([ |
|
132 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
133 | + $reviews = glsr( Database::class )->getReviews( [ |
|
134 | 134 | 'count' => -1, |
135 | 135 | 'post__in' => $updatedReviewIds, |
136 | - ]); |
|
137 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results )); |
|
138 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results )); |
|
136 | + ] ); |
|
137 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) ); |
|
138 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) ); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if( $review->post_status != 'publish' ) { |
149 | 149 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
150 | 150 | } |
151 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
151 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
152 | 152 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
153 | 153 | } |
154 | 154 | } |
@@ -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 ); |
@@ -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 ); |
@@ -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'] ); |
@@ -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(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | 'name' => 'tripadvisor', |
13 | 13 | 'title' => 'Tripadvisor Reviews', |
14 | 14 | ], |
15 | - ]); |
|
15 | + ] ); |
|
16 | 16 | $template->render( 'partials/addons/addon', [ |
17 | 17 | 'context' => [ |
18 | 18 | 'description' => __( 'Sync your Yelp reviews and display them on your site.', 'site-reviews' ), |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | 'name' => 'yelp', |
21 | 21 | 'title' => 'Yelp Reviews', |
22 | 22 | ], |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | ?> |
25 | 25 | </div> |
26 | 26 | </div> |