@@ -58,7 +58,7 @@ |
||
| 58 | 58 | if( filter_input( INPUT_GET, 'context' ) == 'edit' ) { |
| 59 | 59 | $attributes = $this->normalize( $attributes ); |
| 60 | 60 | $this->filterShortcodeClass(); |
| 61 | - if( !$this->hasVisibleFields( $shortcode, $attributes )) { |
|
| 61 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
| 62 | 62 | $this->filterInterpolation(); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 92 | 92 | { |
| 93 | - if( empty( $this->email ))return; |
|
| 94 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 93 | + if( empty($this->email) )return; |
|
| 94 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
| 95 | 95 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 96 | 96 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 97 | 97 | } |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | $allowed = [ |
| 105 | 105 | 'bcc', 'cc', 'from', 'reply-to', |
| 106 | 106 | ]; |
| 107 | - $headers = array_intersect_key( $this->email, array_flip( $allowed )); |
|
| 107 | + $headers = array_intersect_key( $this->email, array_flip( $allowed ) ); |
|
| 108 | 108 | $headers = array_filter( $headers ); |
| 109 | 109 | foreach( $headers as $key => $value ) { |
| 110 | - unset( $headers[$key] ); |
|
| 110 | + unset($headers[$key]); |
|
| 111 | 111 | $headers[] = $key.': '.$value; |
| 112 | 112 | } |
| 113 | 113 | $headers[] = 'Content-Type: text/html'; |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | protected function buildHtmlMessage() |
| 121 | 121 | { |
| 122 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
| 123 | - if( !empty( $template )) { |
|
| 122 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
| 123 | + if( !empty($template) ) { |
|
| 124 | 124 | $message = glsr( Template::class )->interpolate( $template, $this->email['template-tags'], $this->email['template'] ); |
| 125 | 125 | } |
| 126 | 126 | else if( $this->email['template'] ) { |
| 127 | 127 | $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [ |
| 128 | 128 | 'context' => $this->email['template-tags'], |
| 129 | - ]); |
|
| 129 | + ] ); |
|
| 130 | 130 | } |
| 131 | - if( !isset( $message )) { |
|
| 131 | + if( !isset($message) ) { |
|
| 132 | 132 | $message = $this->email['message']; |
| 133 | 133 | } |
| 134 | 134 | $message = $this->email['before'].$message.$this->email['after']; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $message = str_replace( ']]>', ']]>', $message ); |
| 140 | 140 | $message = glsr( Template::class )->build( 'partials/email/index', [ |
| 141 | 141 | 'context' => ['message' => $message], |
| 142 | - ]); |
|
| 142 | + ] ); |
|
| 143 | 143 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | protected function normalize( array $email = [] ) |
| 150 | 150 | { |
| 151 | 151 | $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email ); |
| 152 | - if( empty( $email['reply-to'] )) { |
|
| 152 | + if( empty($email['reply-to']) ) { |
|
| 153 | 153 | $email['reply-to'] = $email['from']; |
| 154 | 154 | } |
| 155 | 155 | $this->email = apply_filters( 'site-reviews/email/compose', $email, $this ); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function build( array $args = [] ) |
| 48 | 48 | { |
| 49 | 49 | $this->args = $args; |
| 50 | - if( !is_user_logged_in() && glsr( OptionManager::class )->getBool( 'settings.general.require.login' )) { |
|
| 50 | + if( !is_user_logged_in() && glsr( OptionManager::class )->getBool( 'settings.general.require.login' ) ) { |
|
| 51 | 51 | return $this->buildLoginRegister(); |
| 52 | 52 | } |
| 53 | 53 | $this->errors = glsr( Session::class )->get( $args['id'].'errors', [], true ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | 'response' => $this->buildResponse(), |
| 67 | 67 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
| 68 | 68 | ], |
| 69 | - ]); |
|
| 69 | + ] ); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | 'context' => [ |
| 79 | 79 | 'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ), |
| 80 | 80 | ], |
| 81 | - ]); |
|
| 81 | + ] ); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | protected function buildRecaptcha() |
| 88 | 88 | { |
| 89 | 89 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
| 90 | - return glsr( Builder::class )->div([ |
|
| 90 | + return glsr( Builder::class )->div( [ |
|
| 91 | 91 | 'class' => 'glsr-recaptcha-holder', |
| 92 | 92 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
| 93 | - 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )), |
|
| 93 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
| 94 | 94 | 'data-size' => 'invisible', |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function buildResponse() |
| 102 | 102 | { |
| 103 | - $classes = !empty( $this->errors ) |
|
| 103 | + $classes = !empty($this->errors) |
|
| 104 | 104 | ? glsr( StyleValidationDefaults::class )->defaults()['message_error_class'] |
| 105 | 105 | : ''; |
| 106 | 106 | return glsr( Template::class )->build( 'templates/form/response', [ |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | 'class' => $classes, |
| 109 | 109 | 'message' => wpautop( $this->message ), |
| 110 | 110 | ], |
| 111 | - 'has_errors' => !empty( $this->errors ), |
|
| 112 | - ]); |
|
| 111 | + 'has_errors' => !empty($this->errors), |
|
| 112 | + ] ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'context' => [ |
| 122 | 122 | 'text' => __( 'Submit your review', 'site-reviews' ), |
| 123 | 123 | ], |
| 124 | - ]); |
|
| 124 | + ] ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $hiddenFields = $this->getHiddenFields(); |
| 141 | 141 | $hiddenFields[] = $this->getHoneypotField(); |
| 142 | - $fields = $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' )); |
|
| 142 | + $fields = $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ); |
|
| 143 | 143 | $paths = array_map( function( $obj ) { |
| 144 | 144 | return $obj->field['path']; |
| 145 | 145 | }, $hiddenFields ); |
| 146 | 146 | foreach( $fields as $field ) { |
| 147 | 147 | $index = array_search( $field->field['path'], $paths ); |
| 148 | 148 | if( $index === false )continue; |
| 149 | - unset( $hiddenFields[$index] ); |
|
| 149 | + unset($hiddenFields[$index]); |
|
| 150 | 150 | } |
| 151 | 151 | return array_merge( $hiddenFields, $fields ); |
| 152 | 152 | } |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function getLoginText() |
| 158 | 158 | { |
| 159 | - $loginLink = glsr( Builder::class )->a([ |
|
| 160 | - 'href' => wp_login_url( strval( get_permalink() )), |
|
| 159 | + $loginLink = glsr( Builder::class )->a( [ |
|
| 160 | + 'href' => wp_login_url( strval( get_permalink() ) ), |
|
| 161 | 161 | 'text' => __( 'logged in', 'site-reviews' ), |
| 162 | - ]); |
|
| 162 | + ] ); |
|
| 163 | 163 | return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink ); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | protected function getRegisterText() |
| 170 | 170 | { |
| 171 | - if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' ))return; |
|
| 172 | - $registerLink = glsr( Builder::class )->a([ |
|
| 171 | + if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' ) )return; |
|
| 172 | + $registerLink = glsr( Builder::class )->a( [ |
|
| 173 | 173 | 'href' => wp_registration_url(), |
| 174 | 174 | 'text' => __( 'register', 'site-reviews' ), |
| 175 | - ]); |
|
| 175 | + ] ); |
|
| 176 | 176 | return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink ); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -184,32 +184,32 @@ discard block |
||
| 184 | 184 | $fields = [[ |
| 185 | 185 | 'name' => '_action', |
| 186 | 186 | 'value' => 'submit-review', |
| 187 | - ],[ |
|
| 187 | + ], [ |
|
| 188 | 188 | 'name' => '_counter', |
| 189 | - ],[ |
|
| 189 | + ], [ |
|
| 190 | 190 | 'name' => '_nonce', |
| 191 | 191 | 'value' => wp_create_nonce( 'submit-review' ), |
| 192 | - ],[ |
|
| 192 | + ], [ |
|
| 193 | 193 | 'name' => '_post_id', |
| 194 | 194 | 'value' => get_the_ID(), |
| 195 | - ],[ |
|
| 195 | + ], [ |
|
| 196 | 196 | 'name' => '_referer', |
| 197 | - 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )), |
|
| 198 | - ],[ |
|
| 197 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
| 198 | + ], [ |
|
| 199 | 199 | 'name' => 'assign_to', |
| 200 | 200 | 'value' => $this->args['assign_to'], |
| 201 | - ],[ |
|
| 201 | + ], [ |
|
| 202 | 202 | 'name' => 'category', |
| 203 | 203 | 'value' => $this->args['category'], |
| 204 | - ],[ |
|
| 204 | + ], [ |
|
| 205 | 205 | 'name' => 'excluded', |
| 206 | 206 | 'value' => $this->args['hide'], |
| 207 | - ],[ |
|
| 207 | + ], [ |
|
| 208 | 208 | 'name' => 'form_id', |
| 209 | 209 | 'value' => $this->args['id'], |
| 210 | 210 | ]]; |
| 211 | 211 | return array_map( function( $field ) { |
| 212 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
| 212 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
| 213 | 213 | }, $fields ); |
| 214 | 214 | } |
| 215 | 215 | |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | protected function getHoneypotField() |
| 220 | 220 | { |
| 221 | - return new Field([ |
|
| 221 | + return new Field( [ |
|
| 222 | 222 | 'name' => 'gotcha', |
| 223 | 223 | 'type' => 'honeypot', |
| 224 | - ]); |
|
| 224 | + ] ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | protected function normalizeFieldId( Field &$field ) |
| 231 | 231 | { |
| 232 | - if( empty( $this->args['id'] ) || empty( $field->field['id'] ))return; |
|
| 233 | - $field->field['id'].= '-'.$this->args['id']; |
|
| 232 | + if( empty($this->args['id']) || empty($field->field['id']) )return; |
|
| 233 | + $field->field['id'] .= '-'.$this->args['id']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | protected function normalizeFieldClass( Field &$field ) |
| 240 | 240 | { |
| 241 | - if( !isset( $field->field['class'] )) { |
|
| 241 | + if( !isset($field->field['class']) ) { |
|
| 242 | 242 | $field->field['class'] = ''; |
| 243 | 243 | } |
| 244 | 244 | $field->field['class'] = trim( $field->field['class'].' glsr-field-control' ); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | protected function normalizeFieldErrors( Field &$field ) |
| 251 | 251 | { |
| 252 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 252 | + if( !array_key_exists( $field->field['path'], $this->errors ) )return; |
|
| 253 | 253 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function normalizeFieldRequired( Field &$field ) |
| 260 | 260 | { |
| 261 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 261 | + if( !in_array( $field->field['path'], $this->required ) )return; |
|
| 262 | 262 | $field->field['required'] = true; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | $normalizedFields = []; |
| 271 | 271 | foreach( $fields as $field ) { |
| 272 | - if( in_array( $field->field['path'], $this->args['hide'] ))continue; |
|
| 272 | + if( in_array( $field->field['path'], $this->args['hide'] ) )continue; |
|
| 273 | 273 | $field->field['is_public'] = true; |
| 274 | 274 | $this->normalizeFieldClass( $field ); |
| 275 | 275 | $this->normalizeFieldErrors( $field ); |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | protected function normalizeFieldValue( Field &$field ) |
| 288 | 288 | { |
| 289 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 290 | - if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
|
| 289 | + if( !array_key_exists( $field->field['path'], $this->values ) )return; |
|
| 290 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
| 291 | 291 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 292 | 292 | } |
| 293 | 293 | else { |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | 'post_type' => Application::POST_TYPE, |
| 38 | 38 | ]; |
| 39 | 39 | $postId = wp_insert_post( $postValues, true ); |
| 40 | - if( is_wp_error( $postId )) { |
|
| 40 | + if( is_wp_error( $postId ) ) { |
|
| 41 | 41 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | $this->setTerms( $postId, $command->category ); |
| 45 | - $review = $this->single( get_post( $postId )); |
|
| 45 | + $review = $this->single( get_post( $postId ) ); |
|
| 46 | 46 | do_action( 'site-reviews/review/created', $review, $command ); |
| 47 | 47 | return $review; |
| 48 | 48 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function delete( $metaReviewId ) |
| 55 | 55 | { |
| 56 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
| 56 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
| 57 | 57 | wp_delete_post( $postId, true ); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $paged = glsr( QueryBuilder::class )->getPaged( |
| 76 | 76 | wp_validate_boolean( $args['pagination'] ) |
| 77 | 77 | ); |
| 78 | - $query = new WP_Query([ |
|
| 78 | + $query = new WP_Query( [ |
|
| 79 | 79 | 'meta_key' => 'pinned', |
| 80 | 80 | 'meta_query' => $metaQuery, |
| 81 | 81 | 'offset' => $args['offset'], |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'post_type' => Application::POST_TYPE, |
| 89 | 89 | 'posts_per_page' => $args['count'], |
| 90 | 90 | 'tax_query' => $taxQuery, |
| 91 | - ]); |
|
| 91 | + ] ); |
|
| 92 | 92 | $results = array_map( [$this, 'single'], $query->posts ); |
| 93 | 93 | $reviews = new Reviews( $results, $query->max_num_pages, $args ); |
| 94 | 94 | return apply_filters( 'site-reviews/get/reviews', $reviews, $query ); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | public function normalizeTermIds( $commaSeparatedTermIds ) |
| 111 | 111 | { |
| 112 | 112 | $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
| 113 | - return array_unique( array_map( 'intval', $termIds )); |
|
| 113 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | $terms = []; |
| 123 | 123 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
| 124 | 124 | foreach( $termIds as $termId ) { |
| 125 | - if( is_numeric( $termId )) { |
|
| 125 | + if( is_numeric( $termId ) ) { |
|
| 126 | 126 | $termId = intval( $termId ); |
| 127 | 127 | } |
| 128 | 128 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 129 | - if( !isset( $term['term_id'] ))continue; |
|
| 129 | + if( !isset($term['term_id']) )continue; |
|
| 130 | 130 | $terms[] = $term; |
| 131 | 131 | } |
| 132 | 132 | return $terms; |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
| 142 | 142 | delete_post_meta( $postId, '_edit_last' ); |
| 143 | - $result = wp_update_post([ |
|
| 143 | + $result = wp_update_post( [ |
|
| 144 | 144 | 'ID' => $postId, |
| 145 | 145 | 'post_content' => get_post_meta( $postId, 'content', true ), |
| 146 | 146 | 'post_date' => get_post_meta( $postId, 'date', true ), |
| 147 | 147 | 'post_title' => get_post_meta( $postId, 'title', true ), |
| 148 | - ]); |
|
| 149 | - if( is_wp_error( $result )) { |
|
| 148 | + ] ); |
|
| 149 | + if( is_wp_error( $result ) ) { |
|
| 150 | 150 | glsr_log()->error( $result->get_error_message() ); |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
| 171 | 171 | { |
| 172 | 172 | $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' ); |
| 173 | - return $review['review_type'] == 'local' && ( $requireApproval || $isBlacklisted ) |
|
| 173 | + return $review['review_type'] == 'local' && ($requireApproval || $isBlacklisted) |
|
| 174 | 174 | ? 'pending' |
| 175 | 175 | : 'publish'; |
| 176 | 176 | } |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | protected function setTerms( $postId, $termIds ) |
| 184 | 184 | { |
| 185 | 185 | $termIds = $this->normalizeTermIds( $termIds ); |
| 186 | - if( empty( $termIds ))return; |
|
| 186 | + if( empty($termIds) )return; |
|
| 187 | 187 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
| 188 | - if( is_wp_error( $termTaxonomyIds )) { |
|
| 188 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
| 189 | 189 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | $this->reviews = $reviews; |
| 32 | 32 | $this->navigation = glsr( Partial::class )->build( 'pagination', [ |
| 33 | 33 | 'total' => $maxPageCount, |
| 34 | - ]); |
|
| 35 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 34 | + ] ); |
|
| 35 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'navigation' => $this->getNavigation(), |
| 59 | 59 | 'reviews' => $this->getReviews(), |
| 60 | 60 | ], |
| 61 | - ]); |
|
| 61 | + ] ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $defaults[] = 'glsr-ajax-pagination'; |
| 74 | 74 | } |
| 75 | 75 | $classes = explode( ' ', $this->args['class'] ); |
| 76 | - $classes = array_unique( array_merge( $defaults, $classes )); |
|
| 76 | + $classes = array_unique( array_merge( $defaults, $classes ) ); |
|
| 77 | 77 | return implode( ' ', $classes ); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function getReviews() |
| 94 | 94 | { |
| 95 | - return empty( $this->reviews ) |
|
| 95 | + return empty($this->reviews) |
|
| 96 | 96 | ? $this->getReviewsFallback() |
| 97 | 97 | : implode( PHP_EOL, $this->reviews ); |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected function getReviewsFallback() |
| 104 | 104 | { |
| 105 | - if( empty( $this->args['fallback'] ) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' )) { |
|
| 105 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
| 106 | 106 | $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
| 107 | 107 | } |
| 108 | 108 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | foreach( $this->reviews as $index => $review ) { |
| 86 | 86 | $renderedReviews[] = glsr( Template::class )->build( 'templates/review', [ |
| 87 | 87 | 'context' => $this->buildReview( $review )->values, |
| 88 | - ]); |
|
| 88 | + ] ); |
|
| 89 | 89 | } |
| 90 | 90 | return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args ); |
| 91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function generateSchema() |
| 97 | 97 | { |
| 98 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 98 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 99 | 99 | glsr( Schema::class )->store( |
| 100 | 100 | glsr( Schema::class )->build( $this->args ) |
| 101 | 101 | ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function isHidden( $key, $path = '' ) |
| 110 | 110 | { |
| 111 | - $isOptionEnabled = !empty( $path ) |
|
| 111 | + $isOptionEnabled = !empty($path) |
|
| 112 | 112 | ? $this->isOptionEnabled( $path ) |
| 113 | 113 | : true; |
| 114 | 114 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function buildOptionAssignedTo( $key, $value ) |
| 123 | 123 | { |
| 124 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 124 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
| 125 | 125 | $post = glsr( Polylang::class )->getPost( $value ); |
| 126 | - if( !( $post instanceof WP_Post ))return; |
|
| 126 | + if( !($post instanceof WP_Post) )return; |
|
| 127 | 127 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 128 | 128 | 'href' => get_the_permalink( $post->ID ), |
| 129 | - ]); |
|
| 129 | + ] ); |
|
| 130 | 130 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
| 131 | 131 | return '<span>'.$assignedTo.'</span>'; |
| 132 | 132 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | protected function buildOptionAuthor( $key, $value ) |
| 140 | 140 | { |
| 141 | - if( $this->isHidden( $key ))return; |
|
| 141 | + if( $this->isHidden( $key ) )return; |
|
| 142 | 142 | return '<span>'.$value.'</span>'; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function buildOptionAvatar( $key, $value ) |
| 151 | 151 | { |
| 152 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 152 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
| 153 | 153 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 154 | - return glsr( Builder::class )->img([ |
|
| 154 | + return glsr( Builder::class )->img( [ |
|
| 155 | 155 | 'height' => $size, |
| 156 | 156 | 'src' => $this->generateAvatar( $value ), |
| 157 | 157 | 'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ), |
| 158 | 158 | 'width' => $size, |
| 159 | - ]); |
|
| 159 | + ] ); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | protected function buildOptionContent( $key, $value ) |
| 168 | 168 | { |
| 169 | 169 | $text = $this->normalizeText( $value ); |
| 170 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 170 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
| 171 | 171 | return '<p>'.$text.'</p>'; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected function buildOptionDate( $key, $value ) |
| 180 | 180 | { |
| 181 | - if( $this->isHidden( $key ))return; |
|
| 181 | + if( $this->isHidden( $key ) )return; |
|
| 182 | 182 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 183 | 183 | if( $dateFormat == 'relative' ) { |
| 184 | 184 | $date = glsr( Date::class )->relative( $value ); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $format = $dateFormat == 'custom' |
| 188 | 188 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
| 189 | 189 | : (string)get_option( 'date_format' ); |
| 190 | - $date = date_i18n( $format, strtotime( $value )); |
|
| 190 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
| 191 | 191 | } |
| 192 | 192 | return '<span>'.$date.'</span>'; |
| 193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function buildOptionRating( $key, $value ) |
| 201 | 201 | { |
| 202 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 202 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 203 | 203 | return glsr_star_rating( $value ); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | protected function buildOptionResponse( $key, $value ) |
| 212 | 212 | { |
| 213 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 214 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
| 213 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 214 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
| 215 | 215 | $text = $this->normalizeText( $value ); |
| 216 | 216 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
| 217 | 217 | $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] ); |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function buildOptionTitle( $key, $value ) |
| 228 | 228 | { |
| 229 | - if( $this->isHidden( $key ))return; |
|
| 230 | - if( empty( $value )) { |
|
| 229 | + if( $this->isHidden( $key ) )return; |
|
| 230 | + if( empty($value) ) { |
|
| 231 | 231 | $value = __( 'No Title', 'site-reviews' ); |
| 232 | 232 | } |
| 233 | 233 | return '<h3>'.$value.'</h3>'; |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | return $avatarUrl; |
| 244 | 244 | } |
| 245 | 245 | $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id ); |
| 246 | - if( empty( $authorIdOrEmail )) { |
|
| 246 | + if( empty($authorIdOrEmail) ) { |
|
| 247 | 247 | $authorIdOrEmail = $this->current->email; |
| 248 | 248 | } |
| 249 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
| 249 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
| 250 | 250 | return $newAvatar; |
| 251 | 251 | } |
| 252 | 252 | return $avatarUrl; |
@@ -258,18 +258,18 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function getExcerpt( $text ) |
| 260 | 260 | { |
| 261 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
| 261 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
| 262 | 262 | $split = extension_loaded( 'intl' ) |
| 263 | 263 | ? $this->getExcerptIntlSplit( $text, $limit ) |
| 264 | 264 | : $this->getExcerptSplit( $text, $limit ); |
| 265 | 265 | $hiddenText = substr( $text, $split ); |
| 266 | - if( !empty( $hiddenText )) { |
|
| 266 | + if( !empty($hiddenText) ) { |
|
| 267 | 267 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
| 268 | 268 | 'class' => 'glsr-hidden glsr-hidden-text', |
| 269 | 269 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
| 270 | 270 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
| 271 | - ]); |
|
| 272 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
| 271 | + ] ); |
|
| 272 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
| 273 | 273 | } |
| 274 | 274 | return $text; |
| 275 | 275 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
| 285 | 285 | $words->setText( $text ); |
| 286 | 286 | $count = 0; |
| 287 | - foreach( $words as $offset ){ |
|
| 287 | + foreach( $words as $offset ) { |
|
| 288 | 288 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
| 289 | 289 | $count++; |
| 290 | 290 | if( $count != $limit )continue; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | protected function getExcerptSplit( $text, $limit ) |
| 302 | 302 | { |
| 303 | 303 | if( str_word_count( $text, 0 ) > $limit ) { |
| 304 | - $words = array_keys( str_word_count( $text, 2 )); |
|
| 304 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
| 305 | 305 | return $words[$limit]; |
| 306 | 306 | } |
| 307 | 307 | return strlen( $text ); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | protected function getOption( $path, $fallback = '' ) |
| 316 | 316 | { |
| 317 | - if( array_key_exists( $path, $this->options )) { |
|
| 317 | + if( array_key_exists( $path, $this->options ) ) { |
|
| 318 | 318 | return $this->options[$path]; |
| 319 | 319 | } |
| 320 | 320 | return $fallback; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | protected function isHiddenOrEmpty( $key, $value ) |
| 329 | 329 | { |
| 330 | - return $this->isHidden( $key ) || empty( $value ); |
|
| 330 | + return $this->isHidden( $key ) || empty($value); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -346,13 +346,13 @@ discard block |
||
| 346 | 346 | protected function normalizeText( $text ) |
| 347 | 347 | { |
| 348 | 348 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
| 349 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
| 349 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
| 350 | 350 | $text = str_replace( ']]>', ']]>', $text ); |
| 351 | 351 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
| 352 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
| 352 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
| 353 | 353 | $text = $this->getExcerpt( $text ); |
| 354 | 354 | } |
| 355 | - return wptexturize( nl2br( $text )); |
|
| 355 | + return wptexturize( nl2br( $text ) ); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -361,12 +361,12 @@ discard block |
||
| 361 | 361 | protected function wrap( array &$renderedFields, Review $review ) |
| 362 | 362 | { |
| 363 | 363 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
| 364 | - array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
|
| 364 | + array_walk( $renderedFields, function( &$value, $key ) use($review) { |
|
| 365 | 365 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
| 366 | - if( empty( $value ))return; |
|
| 366 | + if( empty($value) )return; |
|
| 367 | 367 | $value = glsr( Builder::class )->div( $value, [ |
| 368 | 368 | 'class' => 'glsr-review-'.$key, |
| 369 | - ]); |
|
| 369 | + ] ); |
|
| 370 | 370 | }); |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -57,59 +57,59 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function run() |
| 59 | 59 | { |
| 60 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 61 | - add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
| 62 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 63 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 64 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 65 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 66 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 67 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 68 | - add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
| 69 | - add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
| 70 | - add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
| 71 | - add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
| 72 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 73 | - add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
| 74 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 75 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 76 | - add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
| 77 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 78 | - add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
| 79 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 80 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 81 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 82 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 83 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 60 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 61 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
| 62 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 63 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 64 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 65 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 66 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 67 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 68 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
| 69 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
| 70 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
| 71 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
| 72 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 73 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
| 74 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 75 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 76 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
| 77 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 78 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
| 79 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 80 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 81 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 82 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 83 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 84 | 84 | add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
| 85 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 86 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 87 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 88 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 89 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 90 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 91 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 92 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 93 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 94 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 95 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 96 | - add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
| 97 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
| 98 | - add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
| 99 | - add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
| 100 | - add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
| 101 | - add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
| 102 | - add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
| 103 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 104 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 85 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 86 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 87 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 88 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 89 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 90 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 91 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 92 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 93 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 94 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 95 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 96 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
| 97 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
| 98 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
| 99 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
| 100 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
| 101 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
| 102 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
| 103 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 104 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 105 | 105 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
| 106 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 107 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
| 108 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 109 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
| 110 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
| 111 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
| 112 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
| 113 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
| 106 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 107 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
| 108 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 109 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
| 110 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
| 111 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
| 112 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
| 113 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
| 114 | 114 | } |
| 115 | 115 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $translations = $this->translations(); |
| 32 | 32 | $entries = $this->filter( $translations, $this->entries() )->results(); |
| 33 | - array_walk( $translations, function( &$entry ) use( $entries ) { |
|
| 33 | + array_walk( $translations, function( &$entry ) use($entries) { |
|
| 34 | 34 | $entry['desc'] = array_key_exists( $entry['id'], $entries ) |
| 35 | 35 | ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' ) |
| 36 | 36 | : ''; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function entries() |
| 45 | 45 | { |
| 46 | - if( !isset( $this->entries )) { |
|
| 46 | + if( !isset($this->entries) ) { |
|
| 47 | 47 | $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' ); |
| 48 | 48 | $entries = $this->extractEntriesFromPotFile( $potFile ); |
| 49 | 49 | $entries = apply_filters( 'site-reviews/translation/entries', $entries ); |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
| 90 | 90 | { |
| 91 | - if( !is_array( $entries )) { |
|
| 91 | + if( !is_array( $entries ) ) { |
|
| 92 | 92 | $entries = $this->results; |
| 93 | 93 | } |
| 94 | - if( !is_array( $filterWith )) { |
|
| 94 | + if( !is_array( $filterWith ) ) { |
|
| 95 | 95 | $filterWith = $this->translations(); |
| 96 | 96 | } |
| 97 | - $keys = array_flip( glsr_array_column( $filterWith, 'id' )); |
|
| 97 | + $keys = array_flip( glsr_array_column( $filterWith, 'id' ) ); |
|
| 98 | 98 | $this->results = $intersect |
| 99 | 99 | ? array_intersect_key( $entries, $keys ) |
| 100 | 100 | : array_diff_key( $entries, $keys ); |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | public function render( $template, array $entry ) |
| 109 | 109 | { |
| 110 | 110 | $data = array_combine( |
| 111 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
| 111 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
| 112 | 112 | $entry |
| 113 | 113 | ); |
| 114 | 114 | $data['data.class'] = $data['data.error'] = ''; |
| 115 | - if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' )) === false ) { |
|
| 115 | + if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' ) ) === false ) { |
|
| 116 | 116 | $data['data.class'] = 'is-invalid'; |
| 117 | 117 | $data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' ); |
| 118 | 118 | } |
| 119 | 119 | return glsr( Template::class )->build( 'partials/translations/'.$template, [ |
| 120 | 120 | 'context' => $data, |
| 121 | - ]); |
|
| 121 | + ] ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
| 151 | 151 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
| 152 | 152 | ]; |
| 153 | - $text = !empty( $data['p1'] ) |
|
| 153 | + $text = !empty($data['p1']) |
|
| 154 | 154 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
| 155 | 155 | : $data['s1']; |
| 156 | 156 | $rendered .= $this->render( 'result', [ |
| 157 | - 'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ), |
|
| 157 | + 'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ), |
|
| 158 | 158 | 'text' => wp_strip_all_tags( $text ), |
| 159 | - ]); |
|
| 159 | + ] ); |
|
| 160 | 160 | } |
| 161 | 161 | if( $resetAfterRender ) { |
| 162 | 162 | $this->reset(); |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | public function search( $needle = '' ) |
| 190 | 190 | { |
| 191 | 191 | $this->reset(); |
| 192 | - $needle = trim( strtolower( $needle )); |
|
| 192 | + $needle = trim( strtolower( $needle ) ); |
|
| 193 | 193 | foreach( $this->entries() as $key => $entry ) { |
| 194 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
| 195 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
| 194 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
| 195 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
| 196 | 196 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
| 197 | - if( in_array( $needle, [$single, $plural] )) { |
|
| 197 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
| 198 | 198 | $this->results[$key] = $entry; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | public function translations() |
| 213 | 213 | { |
| 214 | 214 | static $translations; |
| 215 | - if( empty( $translations )) { |
|
| 215 | + if( empty($translations) ) { |
|
| 216 | 216 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
| 217 | - $translations = isset( $settings['strings'] ) |
|
| 218 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
| 217 | + $translations = isset($settings['strings']) |
|
| 218 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
| 219 | 219 | : []; |
| 220 | 220 | } |
| 221 | 221 | return $translations; |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function getEntryString( array $entry, $key ) |
| 229 | 229 | { |
| 230 | - return isset( $entry[$key] ) |
|
| 231 | - ? implode( '', (array) $entry[$key] ) |
|
| 230 | + return isset($entry[$key]) |
|
| 231 | + ? implode( '', (array)$entry[$key] ) |
|
| 232 | 232 | : ''; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | $keys = [ |
| 241 | 241 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
| 242 | 242 | ]; |
| 243 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
| 243 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
| 244 | 244 | foreach( $keys as $key ) { |
| 245 | - if( is_array( $entry )) { |
|
| 245 | + if( is_array( $entry ) ) { |
|
| 246 | 246 | $entry = $this->normalizeEntryString( $entry, $key ); |
| 247 | 247 | continue; |
| 248 | 248 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function normalizeEntryString( array $entry, $key ) |
| 260 | 260 | { |
| 261 | - if( isset( $entry[$key] )) { |
|
| 261 | + if( isset($entry[$key]) ) { |
|
| 262 | 262 | $entry[$key] = $this->getEntryString( $entry, $key ); |
| 263 | 263 | } |
| 264 | 264 | return $entry; |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
| 273 | 273 | $strings = array_filter( $strings, 'is_array' ); |
| 274 | 274 | foreach( $strings as &$string ) { |
| 275 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
| 275 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
| 276 | 276 | $string = wp_parse_args( $string, $defaultString ); |
| 277 | 277 | } |
| 278 | 278 | return array_filter( $strings, function( $string ) { |
| 279 | - return !empty( $string['id'] ); |
|
| 279 | + return !empty($string['id']); |
|
| 280 | 280 | }); |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function get() |
| 112 | 112 | { |
| 113 | - return empty( $this->log ) |
|
| 113 | + return empty($this->log) |
|
| 114 | 114 | ? __( 'Console is empty', 'site-reviews' ) |
| 115 | 115 | : $this->log; |
| 116 | 116 | } |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | public function humanSize( $valueIfEmpty = null ) |
| 123 | 123 | { |
| 124 | 124 | $bytes = $this->size(); |
| 125 | - if( empty( $bytes ) && is_string( $valueIfEmpty )) { |
|
| 125 | + if( empty($bytes) && is_string( $valueIfEmpty ) ) { |
|
| 126 | 126 | return $valueIfEmpty; |
| 127 | 127 | } |
| 128 | - $exponent = floor( log( max( $bytes, 1 ), 1024 )); |
|
| 129 | - return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes','KB','MB','GB'][$exponent]; |
|
| 128 | + $exponent = floor( log( max( $bytes, 1 ), 1024 ) ); |
|
| 129 | + return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent]; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | public function log( $level, $message, array $context = [] ) |
| 150 | 150 | { |
| 151 | 151 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
| 152 | - if( in_array( $level, $constants, true )) { |
|
| 152 | + if( in_array( $level, $constants, true ) ) { |
|
| 153 | 153 | $entry = $this->buildLogEntry( $level, $message, $context ); |
| 154 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 154 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 155 | 155 | $this->reset(); |
| 156 | 156 | } |
| 157 | 157 | return $this; |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | public function logOnce() |
| 164 | 164 | { |
| 165 | 165 | $single = glsr( Session::class )->get( 'glsr_log_once', null, true ); |
| 166 | - if( !is_array( $single ))return; |
|
| 166 | + if( !is_array( $single ) )return; |
|
| 167 | 167 | foreach( $single as $message => $debug ) { |
| 168 | - if( !empty( $debug )) { |
|
| 169 | - $message.= PHP_EOL.print_r( $debug, 1 ); |
|
| 168 | + if( !empty($debug) ) { |
|
| 169 | + $message .= PHP_EOL.print_r( $debug, 1 ); |
|
| 170 | 170 | } |
| 171 | 171 | $this->log( static::RECURRING, $message ); |
| 172 | 172 | } |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | public function once( $message, $debug = '' ) |
| 192 | 192 | { |
| 193 | 193 | $once = glsr( Session::class )->get( 'glsr_log_once', [] ); |
| 194 | - if( !is_array( $once )) { |
|
| 194 | + if( !is_array( $once ) ) { |
|
| 195 | 195 | $once = []; |
| 196 | 196 | } |
| 197 | - if( !isset( $once[$message] )) { |
|
| 197 | + if( !isset($once[$message]) ) { |
|
| 198 | 198 | $once[$message] = $debug; |
| 199 | 199 | glsr( Session::class )->set( 'glsr_log_once', $once ); |
| 200 | 200 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | protected function interpolate( $message, $context = [] ) |
| 258 | 258 | { |
| 259 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
| 259 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
| 260 | 260 | return print_r( $message, true ); |
| 261 | 261 | } |
| 262 | 262 | $replace = []; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if( $value instanceof DateTime ) { |
| 285 | 285 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 286 | 286 | } |
| 287 | - else if( $this->isObjectOrArray( $value )) { |
|
| 287 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 288 | 288 | $value = json_encode( $value ); |
| 289 | 289 | } |
| 290 | 290 | return (string)$value; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $this->clear(); |
| 300 | 300 | file_put_contents( |
| 301 | 301 | $this->file, |
| 302 | - $this->buildLogEntry( 'info', __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' )) |
|
| 302 | + $this->buildLogEntry( 'info', __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' ) ) |
|
| 303 | 303 | ); |
| 304 | 304 | } |
| 305 | 305 | } |