@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function routerChangeStatus( array $request ) |
| 24 | 24 | { |
| 25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
| 25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | public function routerClearConsole() |
| 32 | 32 | { |
| 33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
| 34 | - wp_send_json_success([ |
|
| 34 | + wp_send_json_success( [ |
|
| 35 | 35 | 'console' => glsr( Console::class )->get(), |
| 36 | 36 | 'notices' => glsr( Notice::class )->get(), |
| 37 | - ]); |
|
| 37 | + ] ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | public function routerCountReviews() |
| 44 | 44 | { |
| 45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
| 46 | - wp_send_json_success([ |
|
| 46 | + wp_send_json_success( [ |
|
| 47 | 47 | 'notices' => glsr( Notice::class )->get(), |
| 48 | - ]); |
|
| 48 | + ] ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $shortcode = $request['shortcode']; |
| 57 | 57 | $response = false; |
| 58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
| 58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
| 60 | - if( !empty( $data['errors'] )) { |
|
| 60 | + if( !empty($data['errors']) ) { |
|
| 61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
| 62 | 62 | } |
| 63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | public function routerFetchConsole() |
| 78 | 78 | { |
| 79 | 79 | glsr( AdminController::class )->routerFetchConsole(); |
| 80 | - wp_send_json_success([ |
|
| 80 | + wp_send_json_success( [ |
|
| 81 | 81 | 'console' => glsr( Console::class )->get(), |
| 82 | 82 | 'notices' => glsr( Notice::class )->get(), |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | public function routerSearchPosts( array $request ) |
| 90 | 90 | { |
| 91 | 91 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
| 92 | - wp_send_json_success([ |
|
| 92 | + wp_send_json_success( [ |
|
| 93 | 93 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 94 | 94 | 'items' => $results, |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function routerSearchTranslations( array $request ) |
| 102 | 102 | { |
| 103 | - if( empty( $request['exclude'] )) { |
|
| 103 | + if( empty($request['exclude']) ) { |
|
| 104 | 104 | $request['exclude'] = []; |
| 105 | 105 | } |
| 106 | 106 | $results = glsr( Translator::class ) |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | ->exclude() |
| 109 | 109 | ->exclude( $request['exclude'] ) |
| 110 | 110 | ->renderResults(); |
| 111 | - wp_send_json_success([ |
|
| 111 | + wp_send_json_success( [ |
|
| 112 | 112 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 113 | 113 | 'items' => $results, |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | 'errors' => glsr( Session::class )->get( $request['form_id'].'errors', false, true ), |
| 125 | 125 | 'message' => glsr( Session::class )->get( $request['form_id'].'message', '', true ), |
| 126 | 126 | 'recaptcha' => glsr( Session::class )->get( $request['form_id'].'recaptcha', false, true ), |
| 127 | - 'redirect' => trim( get_post_meta( intval( $request['post_id'] ), 'redirect_to', true )), |
|
| 127 | + 'redirect' => trim( get_post_meta( intval( $request['post_id'] ), 'redirect_to', true ) ), |
|
| 128 | 128 | ]; |
| 129 | - if( !wp_validate_boolean( $data['errors'] )) { |
|
| 129 | + if( !wp_validate_boolean( $data['errors'] ) ) { |
|
| 130 | 130 | glsr( Session::class )->clear(); |
| 131 | 131 | wp_send_json_success( $data ); |
| 132 | 132 | } |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function routerTogglePinned( array $request ) |
| 140 | 140 | { |
| 141 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
| 142 | - wp_send_json_success([ |
|
| 141 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
| 142 | + wp_send_json_success( [ |
|
| 143 | 143 | 'notices' => glsr( Notice::class )->get(), |
| 144 | 144 | 'pinned' => $isPinned, |
| 145 | - ]); |
|
| 145 | + ] ); |
|
| 146 | 146 | } |
| 147 | 147 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'response' => $this->buildResponse(), |
| 66 | 66 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
| 67 | 67 | ], |
| 68 | - ]); |
|
| 68 | + ] ); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'context' => [ |
| 78 | 78 | 'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ), |
| 79 | 79 | ], |
| 80 | - ]); |
|
| 80 | + ] ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | protected function buildRecaptcha() |
| 87 | 87 | { |
| 88 | 88 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
| 89 | - return glsr( Builder::class )->div([ |
|
| 89 | + return glsr( Builder::class )->div( [ |
|
| 90 | 90 | 'class' => 'glsr-recaptcha-holder', |
| 91 | 91 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
| 92 | - 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )), |
|
| 92 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
| 93 | 93 | 'data-size' => 'invisible', |
| 94 | - ]); |
|
| 94 | + ] ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function buildResponse() |
| 101 | 101 | { |
| 102 | - $classes = !empty( $this->errors ) |
|
| 102 | + $classes = !empty($this->errors) |
|
| 103 | 103 | ? glsr( StyleValidationDefaults::class )->defaults()['message_error_class'] |
| 104 | 104 | : ''; |
| 105 | 105 | return glsr( Template::class )->build( 'templates/form/response', [ |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | 'class' => $classes, |
| 108 | 108 | 'message' => wpautop( $this->message ), |
| 109 | 109 | ], |
| 110 | - 'has_errors' => !empty( $this->errors ), |
|
| 111 | - ]); |
|
| 110 | + 'has_errors' => !empty($this->errors), |
|
| 111 | + ] ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'context' => [ |
| 121 | 121 | 'text' => __( 'Submit your review', 'site-reviews' ), |
| 122 | 122 | ], |
| 123 | - ]); |
|
| 123 | + ] ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $fields = array_merge( |
| 140 | 140 | $this->getHiddenFields(), |
| 141 | 141 | [$this->getHoneypotField()], |
| 142 | - $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' )) |
|
| 142 | + $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ) |
|
| 143 | 143 | ); |
| 144 | 144 | return $fields; |
| 145 | 145 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function getLoginText() |
| 151 | 151 | { |
| 152 | - $loginLink = glsr( Builder::class )->a([ |
|
| 153 | - 'href' => wp_login_url( strval( get_permalink() )), |
|
| 152 | + $loginLink = glsr( Builder::class )->a( [ |
|
| 153 | + 'href' => wp_login_url( strval( get_permalink() ) ), |
|
| 154 | 154 | 'text' => __( 'logged in', 'site-reviews' ), |
| 155 | - ]); |
|
| 155 | + ] ); |
|
| 156 | 156 | return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink ); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | protected function getRegisterText() |
| 163 | 163 | { |
| 164 | 164 | if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return; |
| 165 | - $registerLink = glsr( Builder::class )->a([ |
|
| 165 | + $registerLink = glsr( Builder::class )->a( [ |
|
| 166 | 166 | 'href' => wp_registration_url(), |
| 167 | 167 | 'text' => __( 'register', 'site-reviews' ), |
| 168 | - ]); |
|
| 168 | + ] ); |
|
| 169 | 169 | return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink ); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -177,30 +177,30 @@ discard block |
||
| 177 | 177 | $fields = [[ |
| 178 | 178 | 'name' => 'action', |
| 179 | 179 | 'value' => 'submit-review', |
| 180 | - ],[ |
|
| 180 | + ], [ |
|
| 181 | 181 | 'name' => 'assign_to', |
| 182 | 182 | 'value' => $this->args['assign_to'], |
| 183 | - ],[ |
|
| 183 | + ], [ |
|
| 184 | 184 | 'name' => 'category', |
| 185 | 185 | 'value' => $this->args['category'], |
| 186 | - ],[ |
|
| 186 | + ], [ |
|
| 187 | 187 | 'name' => 'excluded', |
| 188 | 188 | 'value' => $this->args['excluded'], // @todo should default to "[]" |
| 189 | - ],[ |
|
| 189 | + ], [ |
|
| 190 | 190 | 'name' => 'form_id', |
| 191 | 191 | 'value' => $this->args['id'], |
| 192 | - ],[ |
|
| 192 | + ], [ |
|
| 193 | 193 | 'name' => 'nonce', |
| 194 | 194 | 'value' => wp_create_nonce( 'submit-review' ), |
| 195 | - ],[ |
|
| 195 | + ], [ |
|
| 196 | 196 | 'name' => 'post_id', |
| 197 | 197 | 'value' => get_the_ID(), |
| 198 | - ],[ |
|
| 198 | + ], [ |
|
| 199 | 199 | 'name' => 'referer', |
| 200 | - 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )), |
|
| 200 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
| 201 | 201 | ]]; |
| 202 | 202 | return array_map( function( $field ) { |
| 203 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
| 203 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
| 204 | 204 | }, $fields ); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function getHoneypotField() |
| 211 | 211 | { |
| 212 | - return new Field([ |
|
| 212 | + return new Field( [ |
|
| 213 | 213 | 'name' => 'gotcha', |
| 214 | 214 | 'type' => 'honeypot', |
| 215 | - ]); |
|
| 215 | + ] ); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | protected function normalizeFieldErrors( Field &$field ) |
| 222 | 222 | { |
| 223 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 223 | + if( !array_key_exists( $field->field['path'], $this->errors ) )return; |
|
| 224 | 224 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | protected function normalizeFieldRequired( Field &$field ) |
| 231 | 231 | { |
| 232 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 232 | + if( !in_array( $field->field['path'], $this->required ) )return; |
|
| 233 | 233 | $field->field['required'] = true; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | protected function normalizeFieldValue( Field &$field ) |
| 254 | 254 | { |
| 255 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 256 | - if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
|
| 255 | + if( !array_key_exists( $field->field['path'], $this->values ) )return; |
|
| 256 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
| 257 | 257 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 258 | 258 | } |
| 259 | 259 | else { |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | public function __construct( $input ) |
| 29 | 29 | { |
| 30 | 30 | $this->request = $input; |
| 31 | - $this->ajax_request = isset( $input['ajax_request'] ); |
|
| 31 | + $this->ajax_request = isset($input['ajax_request']); |
|
| 32 | 32 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
| 33 | - $this->author = sanitize_text_field( $this->get( 'name' )); |
|
| 34 | - $this->avatar = get_avatar_url( $this->get( 'email' )); |
|
| 35 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
| 36 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
| 37 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
| 33 | + $this->author = sanitize_text_field( $this->get( 'name' ) ); |
|
| 34 | + $this->avatar = get_avatar_url( $this->get( 'email' ) ); |
|
| 35 | + $this->blacklisted = isset($input['blacklisted']); |
|
| 36 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
| 37 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
| 38 | 38 | $this->custom = $this->getCustom(); |
| 39 | - $this->email = sanitize_email( $this->get( 'email' )); |
|
| 40 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
| 39 | + $this->email = sanitize_email( $this->get( 'email' ) ); |
|
| 40 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
| 41 | 41 | $this->ip_address = $this->get( 'ip_address' ); |
| 42 | - $this->post_id = intval( $this->get( 'post_id' )); |
|
| 43 | - $this->rating = intval( $this->get( 'rating' )); |
|
| 42 | + $this->post_id = intval( $this->get( 'post_id' ) ); |
|
| 43 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
| 44 | 44 | $this->referer = $this->get( 'referer' ); |
| 45 | - $this->terms = isset( $input['terms'] ); |
|
| 46 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
| 45 | + $this->terms = isset($input['terms']); |
|
| 46 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | protected function get( $key ) |
| 54 | 54 | { |
| 55 | - return isset( $this->request[$key] ) |
|
| 55 | + return isset($this->request[$key]) |
|
| 56 | 56 | ? (string)$this->request[$key] |
| 57 | 57 | : ''; |
| 58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | ]; |
| 70 | 70 | $custom = $this->request; |
| 71 | 71 | foreach( $unset as $value ) { |
| 72 | - unset( $custom[$value] ); |
|
| 72 | + unset($custom[$value]); |
|
| 73 | 73 | } |
| 74 | 74 | return $custom; |
| 75 | 75 | } |
@@ -17,15 +17,15 @@ discard block |
||
| 17 | 17 | $review = glsr( ReviewManager::class )->create( $command ); |
| 18 | 18 | if( !$review ) { |
| 19 | 19 | glsr( Session::class )->set( $command->form_id.'errors', [] ); |
| 20 | - glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' )); |
|
| 20 | + glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' ) ); |
|
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | - glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' )); |
|
| 23 | + glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' ) ); |
|
| 24 | 24 | glsr( Notification::class )->send( $review ); |
| 25 | 25 | do_action( 'site-reviews/local/review/submitted', null, $command ); // @compat |
| 26 | 26 | do_action( 'site-reviews/review/submitted', $review ); |
| 27 | 27 | if( $command->ajax_request )return; |
| 28 | - wp_safe_redirect( $this->getReferer( $command )); |
|
| 28 | + wp_safe_redirect( $this->getReferer( $command ) ); |
|
| 29 | 29 | exit; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | protected function getReferer( Command $command ) |
| 36 | 36 | { |
| 37 | - $referer = trim( get_post_meta( $command->post_id, 'redirect_to', true )); |
|
| 38 | - if( empty( $referer )) { |
|
| 37 | + $referer = trim( get_post_meta( $command->post_id, 'redirect_to', true ) ); |
|
| 38 | + if( empty($referer) ) { |
|
| 39 | 39 | $referer = $command->referer; |
| 40 | 40 | } |
| 41 | - if( empty( $referer )) { |
|
| 41 | + if( empty($referer) ) { |
|
| 42 | 42 | glsr_log()->warning( 'The form referer ($_SERVER[REQUEST_URI]) was empty.' )->info( $command ); |
| 43 | 43 | $referer = home_url(); |
| 44 | 44 | } |
@@ -24,7 +24,9 @@ |
||
| 24 | 24 | glsr( Notification::class )->send( $review ); |
| 25 | 25 | do_action( 'site-reviews/local/review/submitted', null, $command ); // @compat |
| 26 | 26 | do_action( 'site-reviews/review/submitted', $review ); |
| 27 | - if( $command->ajax_request )return; |
|
| 27 | + if( $command->ajax_request ) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 28 | 30 | wp_safe_redirect( $this->getReferer( $command )); |
| 29 | 31 | exit; |
| 30 | 32 | } |