@@ -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 | } |
@@ -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 { |
@@ -86,7 +86,9 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function buildRecaptcha() |
| 88 | 88 | { |
| 89 | - if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
|
| 89 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
| 90 | + return; |
|
| 91 | + } |
|
| 90 | 92 | return glsr( Builder::class )->div([ |
| 91 | 93 | 'class' => 'glsr-recaptcha-holder', |
| 92 | 94 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
@@ -145,7 +147,9 @@ discard block |
||
| 145 | 147 | }, $hiddenFields ); |
| 146 | 148 | foreach( $fields as $field ) { |
| 147 | 149 | $index = array_search( $field->field['path'], $paths ); |
| 148 | - if( $index === false )continue; |
|
| 150 | + if( $index === false ) { |
|
| 151 | + continue; |
|
| 152 | + } |
|
| 149 | 153 | unset( $hiddenFields[$index] ); |
| 150 | 154 | } |
| 151 | 155 | return array_merge( $hiddenFields, $fields ); |
@@ -168,7 +172,9 @@ discard block |
||
| 168 | 172 | */ |
| 169 | 173 | protected function getRegisterText() |
| 170 | 174 | { |
| 171 | - if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' ))return; |
|
| 175 | + if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' )) { |
|
| 176 | + return; |
|
| 177 | + } |
|
| 172 | 178 | $registerLink = glsr( Builder::class )->a([ |
| 173 | 179 | 'href' => wp_registration_url(), |
| 174 | 180 | 'text' => __( 'register', 'site-reviews' ), |
@@ -229,7 +235,9 @@ discard block |
||
| 229 | 235 | */ |
| 230 | 236 | protected function normalizeFieldId( Field &$field ) |
| 231 | 237 | { |
| 232 | - if( empty( $this->args['id'] ) || empty( $field->field['id'] ))return; |
|
| 238 | + if( empty( $this->args['id'] ) || empty( $field->field['id'] )) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 233 | 241 | $field->field['id'].= '-'.$this->args['id']; |
| 234 | 242 | } |
| 235 | 243 | |
@@ -249,7 +257,9 @@ discard block |
||
| 249 | 257 | */ |
| 250 | 258 | protected function normalizeFieldErrors( Field &$field ) |
| 251 | 259 | { |
| 252 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 260 | + if( !array_key_exists( $field->field['path'], $this->errors )) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 253 | 263 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 254 | 264 | } |
| 255 | 265 | |
@@ -258,7 +268,9 @@ discard block |
||
| 258 | 268 | */ |
| 259 | 269 | protected function normalizeFieldRequired( Field &$field ) |
| 260 | 270 | { |
| 261 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 271 | + if( !in_array( $field->field['path'], $this->required )) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 262 | 274 | $field->field['required'] = true; |
| 263 | 275 | } |
| 264 | 276 | |
@@ -269,7 +281,9 @@ discard block |
||
| 269 | 281 | { |
| 270 | 282 | $normalizedFields = []; |
| 271 | 283 | foreach( $fields as $field ) { |
| 272 | - if( in_array( $field->field['path'], $this->args['hide'] ))continue; |
|
| 284 | + if( in_array( $field->field['path'], $this->args['hide'] )) { |
|
| 285 | + continue; |
|
| 286 | + } |
|
| 273 | 287 | $field->field['is_public'] = true; |
| 274 | 288 | $this->normalizeFieldClass( $field ); |
| 275 | 289 | $this->normalizeFieldErrors( $field ); |
@@ -286,7 +300,9 @@ discard block |
||
| 286 | 300 | */ |
| 287 | 301 | protected function normalizeFieldValue( Field &$field ) |
| 288 | 302 | { |
| 289 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 303 | + if( !array_key_exists( $field->field['path'], $this->values )) { |
|
| 304 | + return; |
|
| 305 | + } |
|
| 290 | 306 | if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
| 291 | 307 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 292 | 308 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | defined( 'WPINC' ) || die; |
| 20 | 20 | |
| 21 | -if( !class_exists( 'GL_Plugin_Check_v3' )) { |
|
| 21 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | 24 | $check = new GL_Plugin_Check_v3( __FILE__ ); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $app = new GeminiLabs\SiteReviews\Application; |
| 32 | 32 | $app->make( 'Provider' )->register( $app ); |
| 33 | -register_activation_hook( __FILE__, array( $app, 'activate' )); |
|
| 34 | -register_deactivation_hook( __FILE__, array( $app, 'deactivate' )); |
|
| 35 | -register_shutdown_function( array( $app, 'catchFatalError' )); |
|
| 33 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
| 34 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
| 35 | +register_shutdown_function( array( $app, 'catchFatalError' ) ); |
|
| 36 | 36 | $app->init(); |
@@ -22,7 +22,9 @@ |
||
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | 24 | $check = new GL_Plugin_Check_v3( __FILE__ ); |
| 25 | -if( !$check->canProceed() )return; |
|
| 25 | +if( !$check->canProceed() ) { |
|
| 26 | + return; |
|
| 27 | +} |
|
| 26 | 28 | require_once __DIR__.'/autoload.php'; |
| 27 | 29 | require_once __DIR__.'/compatibility.php'; |
| 28 | 30 | require_once __DIR__.'/deprecated.php'; |
@@ -30,25 +30,25 @@ discard block |
||
| 30 | 30 | public function __construct( $input ) |
| 31 | 31 | { |
| 32 | 32 | $this->request = $input; |
| 33 | - $this->ajax_request = isset( $input['_ajax_request'] ); |
|
| 33 | + $this->ajax_request = isset($input['_ajax_request']); |
|
| 34 | 34 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
| 35 | - $this->author = sanitize_text_field( $this->getUser( 'name' )); |
|
| 35 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
| 36 | 36 | $this->avatar = $this->getAvatar(); |
| 37 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
| 38 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
| 39 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
| 37 | + $this->blacklisted = isset($input['blacklisted']); |
|
| 38 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
| 39 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
| 40 | 40 | $this->custom = $this->getCustom(); |
| 41 | 41 | $this->date = $this->getDate( 'date' ); |
| 42 | - $this->email = sanitize_email( $this->getUser( 'email' )); |
|
| 43 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
| 42 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
| 43 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
| 44 | 44 | $this->ip_address = $this->get( 'ip_address' ); |
| 45 | - $this->post_id = intval( $this->get( '_post_id' )); |
|
| 46 | - $this->rating = intval( $this->get( 'rating' )); |
|
| 45 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
| 46 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
| 47 | 47 | $this->referer = $this->get( '_referer' ); |
| 48 | - $this->response = sanitize_textarea_field( $this->get( 'response' )); |
|
| 49 | - $this->terms = !empty( $input['terms'] ); |
|
| 50 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
| 51 | - $this->url = esc_url_raw( $this->get( 'url' )); |
|
| 48 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
| 49 | + $this->terms = !empty($input['terms']); |
|
| 50 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
| 51 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $avatar = $this->get( 'avatar' ); |
| 69 | 69 | return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) |
| 70 | - ? (string)get_avatar_url( $this->get( 'email' )) |
|
| 70 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
| 71 | 71 | : $avatar; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset ); |
| 85 | 85 | $custom = $this->request; |
| 86 | 86 | foreach( $unset as $value ) { |
| 87 | - unset( $custom[$value] ); |
|
| 87 | + unset($custom[$value]); |
|
| 88 | 88 | } |
| 89 | 89 | return $custom; |
| 90 | 90 | } |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function getDate( $key ) |
| 97 | 97 | { |
| 98 | - $date = strtotime( $this->get( $key )); |
|
| 98 | + $date = strtotime( $this->get( $key ) ); |
|
| 99 | 99 | if( $date === false ) { |
| 100 | 100 | $date = time(); |
| 101 | 101 | } |
| 102 | - return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date )); |
|
| 102 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | protected function getUser( $key ) |
| 110 | 110 | { |
| 111 | 111 | $value = $this->get( $key ); |
| 112 | - if( empty( $value )) { |
|
| 112 | + if( empty($value) ) { |
|
| 113 | 113 | $user = wp_get_current_user(); |
| 114 | 114 | $userValues = [ |
| 115 | 115 | 'email' => 'user_email', |
| 116 | 116 | 'name' => 'display_name', |
| 117 | 117 | ]; |
| 118 | - if( $user->exists() && array_key_exists( $key, $userValues )) { |
|
| 118 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
| 119 | 119 | return $user->{$userValues[$key]}; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -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,7 +240,7 @@ 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 | 245 | try { |
| 246 | 246 | $entry = $this->normalizeEntryString( $entry, $key ); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | protected function normalizeEntryString( array $entry, $key ) |
| 262 | 262 | { |
| 263 | - if( isset( $entry[$key] )) { |
|
| 263 | + if( isset($entry[$key]) ) { |
|
| 264 | 264 | $entry[$key] = $this->getEntryString( $entry, $key ); |
| 265 | 265 | } |
| 266 | 266 | return $entry; |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
| 275 | 275 | $strings = array_filter( $strings, 'is_array' ); |
| 276 | 276 | foreach( $strings as &$string ) { |
| 277 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
| 277 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
| 278 | 278 | $string = wp_parse_args( $string, $defaultString ); |
| 279 | 279 | } |
| 280 | 280 | return array_filter( $strings, function( $string ) { |
| 281 | - return !empty( $string['id'] ); |
|
| 281 | + return !empty($string['id']); |
|
| 282 | 282 | }); |
| 283 | 283 | } |
| 284 | 284 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function callbackRegisterSettings( $input ) |
| 19 | 19 | { |
| 20 | - if( !is_array( $input )) { |
|
| 20 | + if( !is_array( $input ) ) { |
|
| 21 | 21 | $input = ['settings' => []]; |
| 22 | 22 | } |
| 23 | 23 | if( key( $input ) == 'settings' ) { |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $options = $this->sanitizeSubmissions( $input, $options ); |
| 27 | 27 | $options = $this->sanitizeTranslations( $input, $options ); |
| 28 | 28 | if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
| 29 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
| 29 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
| 30 | 30 | } |
| 31 | 31 | return $options; |
| 32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
| 43 | 43 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
| 44 | - ]); |
|
| 44 | + ] ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | protected function sanitizeSubmissions( array $input, array $options ) |
| 67 | 67 | { |
| 68 | 68 | $inputForm = $input['settings']['submissions']; |
| 69 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
| 69 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
| 70 | 70 | ? $inputForm['required'] |
| 71 | 71 | : []; |
| 72 | 72 | return $options; |
@@ -77,17 +77,17 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | protected function sanitizeTranslations( array $input, array $options ) |
| 79 | 79 | { |
| 80 | - if( isset( $input['settings']['strings'] )) { |
|
| 81 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
| 80 | + if( isset($input['settings']['strings']) ) { |
|
| 81 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
| 82 | 82 | $allowedTags = [ |
| 83 | 83 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
| 84 | 84 | 'span' => ['class' => []], |
| 85 | 85 | ]; |
| 86 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
| 87 | - if( isset( $string['s2'] )) { |
|
| 86 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
| 87 | + if( isset($string['s2']) ) { |
|
| 88 | 88 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
| 89 | 89 | } |
| 90 | - if( isset( $string['p2'] )) { |
|
| 90 | + if( isset($string['p2']) ) { |
|
| 91 | 91 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
| 92 | 92 | } |
| 93 | 93 | }); |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | protected function isPolylangActiveAndSupported() |
| 102 | 102 | { |
| 103 | 103 | if( !glsr( Polylang::class )->isActive() ) { |
| 104 | - glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' )); |
|
| 104 | + glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) ); |
|
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | else if( !glsr( Polylang::class )->isSupported() ) { |
| 108 | - glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' )); |
|
| 108 | + glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) ); |
|
| 109 | 109 | return false; |
| 110 | 110 | } |
| 111 | 111 | return true; |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | // Database/ReviewManager.php |
| 6 | 6 | add_action( 'site-reviews/review/created', function( $review ) { |
| 7 | - if( has_action( 'site-reviews/local/review/create' )) { |
|
| 7 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
| 8 | 8 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
| 9 | 9 | do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
| 10 | 10 | } |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // Handlers/CreateReview.php |
| 14 | 14 | add_action( 'site-reviews/review/submitted', function( $review ) { |
| 15 | - if( has_action( 'site-reviews/local/review/submitted' )) { |
|
| 15 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
| 16 | 16 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
| 17 | 17 | do_action( 'site-reviews/local/review/submitted', null, $review ); |
| 18 | 18 | } |
| 19 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
| 19 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
| 20 | 20 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
| 21 | 21 | } |
| 22 | 22 | }, 9 ); |
| 23 | 23 | |
| 24 | 24 | // Database/ReviewManager.php |
| 25 | 25 | add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
| 26 | - if( has_filter( 'site-reviews/local/review' )) { |
|
| 26 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
| 27 | 27 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
| 28 | 28 | return apply_filters( 'site-reviews/local/review', $values, $command ); |
| 29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // Handlers/EnqueuePublicAssets.php |
| 34 | 34 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
| 35 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
| 35 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
| 36 | 36 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
| 37 | 37 | return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Modules/Rating.php |
| 43 | 43 | add_filter( 'site-reviews/rating/average', function( $average ) { |
| 44 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
| 44 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
| 45 | 45 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
| 46 | 46 | } |
| 47 | 47 | return $average; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Modules/Rating.php |
| 51 | 51 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
| 52 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
| 52 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
| 53 | 53 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
| 54 | 54 | } |
| 55 | 55 | return $ranking; |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // Modules/Html/Partials/SiteReviews.php |
| 59 | 59 | add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
| 60 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
| 60 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
| 61 | 61 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 62 | 62 | } |
| 63 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
| 63 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
| 64 | 64 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 65 | 65 | } |
| 66 | 66 | return $renderedFields; |
@@ -68,26 +68,26 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | // Modules/Html/Partials/SiteReviews.php |
| 70 | 70 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
| 71 | - if( has_filter( 'site-reviews/rendered/review' )) { |
|
| 71 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
| 72 | 72 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
| 73 | 73 | } |
| 74 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
| 74 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
| 75 | 75 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 76 | 76 | } |
| 77 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
| 77 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
| 78 | 78 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 79 | 79 | } |
| 80 | - if( has_filter( 'site-reviews/rendered/review-form/login-register' )) { |
|
| 80 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
| 81 | 81 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
| 82 | 82 | } |
| 83 | - if( has_filter( 'site-reviews/reviews/navigation_links' )) { |
|
| 83 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
| 84 | 84 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
| 85 | 85 | } |
| 86 | 86 | return $review; |
| 87 | 87 | }, 9 ); |
| 88 | 88 | |
| 89 | 89 | add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
| 90 | - if( has_filter( 'site-reviews/validate/review/submission' )) { |
|
| 90 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
| 91 | 91 | glsr_log()->warning( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
| 92 | 92 | return apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
| 93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | }, 9, 2 ); |
| 96 | 96 | |
| 97 | 97 | add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
| 98 | - if( has_filter( 'site-reviews/addon/views/file' )) { |
|
| 98 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
| 99 | 99 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
| 100 | 100 | $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
| 101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | }, 9, 3 ); |
| 104 | 104 | |
| 105 | 105 | add_action( 'wp_footer', function() { |
| 106 | - $notices = array_keys( array_flip( glsr()->deprecated )); |
|
| 106 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
| 107 | 107 | natsort( $notices ); |
| 108 | 108 | foreach( $notices as $notice ) { |
| 109 | 109 | glsr_log()->warning( $notice ); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function saveAssignedToMetabox( $postId ) |
| 14 | 14 | { |
| 15 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 16 | - $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' )); |
|
| 15 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
| 16 | + $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ) ); |
|
| 17 | 17 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function saveResponseMetabox( $postId ) |
| 25 | 25 | { |
| 26 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 27 | - $response = strval( glsr( Helper::class )->filterInput( 'response' )); |
|
| 26 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) )return; |
|
| 27 | + $response = strval( glsr( Helper::class )->filterInput( 'response' ) ); |
|
| 28 | 28 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 29 | 29 | 'a' => ['href' => [], 'title' => []], |
| 30 | 30 | 'em' => [], |
| 31 | 31 | 'strong' => [], |
| 32 | - ]))); |
|
| 32 | + ] ) ) ); |
|
| 33 | 33 | } |
| 34 | 34 | } |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function saveAssignedToMetabox( $postId ) |
| 14 | 14 | { |
| 15 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 15 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 16 | + return; |
|
| 17 | + } |
|
| 16 | 18 | $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' )); |
| 17 | 19 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 18 | 20 | } |
@@ -23,7 +25,9 @@ discard block |
||
| 23 | 25 | */ |
| 24 | 26 | public function saveResponseMetabox( $postId ) |
| 25 | 27 | { |
| 26 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 28 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 27 | 31 | $response = strval( glsr( Helper::class )->filterInput( 'response' )); |
| 28 | 32 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 29 | 33 | 'a' => ['href' => [], 'title' => []], |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | global $menu, $typenow; |
| 24 | 24 | foreach( $menu as $key => $value ) { |
| 25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 25 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 26 | 26 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 27 | 27 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
| 28 | 28 | 'class' => 'pending-count', |
| 29 | - ]); |
|
| 29 | + ] ); |
|
| 30 | 30 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
| 31 | 31 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
| 32 | - ]); |
|
| 32 | + ] ); |
|
| 33 | 33 | $menu[$key][0] .= ' '.$awaitingModeration; |
| 34 | 34 | if( $typenow === Application::POST_TYPE ) { |
| 35 | - $menu[$key][4].= ' current'; |
|
| 35 | + $menu[$key][4] .= ' current'; |
|
| 36 | 36 | } |
| 37 | 37 | break; |
| 38 | 38 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | 'tools' => __( 'Tools', 'site-reviews' ), |
| 50 | 50 | 'addons' => __( 'Add-ons', 'site-reviews' ), |
| 51 | 51 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
| 52 | - ]); |
|
| 52 | + ] ); |
|
| 53 | 53 | foreach( $pages as $slug => $title ) { |
| 54 | 54 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
| 55 | 55 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
| 56 | - if( !is_callable( $callback ))continue; |
|
| 56 | + if( !is_callable( $callback ) )continue; |
|
| 57 | 57 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback ); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $this->renderPage( 'addons', [ |
| 69 | 69 | 'template' => glsr( Template::class ), |
| 70 | - ]); |
|
| 70 | + ] ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -84,16 +84,16 @@ discard block |
||
| 84 | 84 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
| 85 | 85 | 'functions' => __( 'Functions', 'site-reviews' ), |
| 86 | 86 | 'addons' => __( 'Addons', 'site-reviews' ), |
| 87 | - ]); |
|
| 87 | + ] ); |
|
| 88 | 88 | $addons = apply_filters( 'site-reviews/addon/documentation', [] ); |
| 89 | 89 | ksort( $addons ); |
| 90 | - if( empty( $addons )) { |
|
| 91 | - unset( $tabs['addons'] ); |
|
| 90 | + if( empty($addons) ) { |
|
| 91 | + unset($tabs['addons']); |
|
| 92 | 92 | } |
| 93 | 93 | $this->renderPage( 'documentation', [ |
| 94 | 94 | 'addons' => $addons, |
| 95 | 95 | 'tabs' => $tabs, |
| 96 | - ]); |
|
| 96 | + ] ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -111,18 +111,18 @@ discard block |
||
| 111 | 111 | 'translations' => __( 'Translations', 'site-reviews' ), |
| 112 | 112 | 'addons' => __( 'Addons', 'site-reviews' ), |
| 113 | 113 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
| 114 | - ]); |
|
| 115 | - if( empty( glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' ))) { |
|
| 116 | - unset( $tabs['addons'] ); |
|
| 114 | + ] ); |
|
| 115 | + if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' )) ) { |
|
| 116 | + unset($tabs['addons']); |
|
| 117 | 117 | } |
| 118 | - if( empty( glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' ))) { |
|
| 119 | - unset( $tabs['licenses'] ); |
|
| 118 | + if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' )) ) { |
|
| 119 | + unset($tabs['licenses']); |
|
| 120 | 120 | } |
| 121 | 121 | $this->renderPage( 'settings', [ |
| 122 | 122 | 'notices' => $this->getNotices(), |
| 123 | 123 | 'settings' => glsr( Settings::class ), |
| 124 | 124 | 'tabs' => $tabs, |
| 125 | - ]); |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -137,24 +137,24 @@ discard block |
||
| 137 | 137 | 'sync' => __( 'Sync Reviews', 'site-reviews' ), |
| 138 | 138 | 'console' => __( 'Console', 'site-reviews' ), |
| 139 | 139 | 'system-info' => __( 'System Info', 'site-reviews' ), |
| 140 | - ]); |
|
| 141 | - if( !apply_filters( 'site-reviews/addon/sync/enable', false )) { |
|
| 142 | - unset( $tabs['sync'] ); |
|
| 140 | + ] ); |
|
| 141 | + if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) { |
|
| 142 | + unset($tabs['sync']); |
|
| 143 | 143 | } |
| 144 | 144 | $this->renderPage( 'tools', [ |
| 145 | 145 | 'data' => [ |
| 146 | 146 | 'context' => [ |
| 147 | 147 | 'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ), |
| 148 | - 'console' => strval( glsr( Console::class )), |
|
| 148 | + 'console' => strval( glsr( Console::class ) ), |
|
| 149 | 149 | 'id' => Application::ID, |
| 150 | - 'system' => strval( glsr( System::class )), |
|
| 150 | + 'system' => strval( glsr( System::class ) ), |
|
| 151 | 151 | ], |
| 152 | 152 | 'services' => apply_filters( 'site-reviews/addon/sync/services', [] ), |
| 153 | 153 | ], |
| 154 | 154 | 'notices' => $this->getNotices(), |
| 155 | 155 | 'tabs' => $tabs, |
| 156 | 156 | 'template' => glsr( Template::class ), |
| 157 | - ]); |
|
| 157 | + ] ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | return glsr( Builder::class )->div( glsr( Notice::class )->get(), [ |
| 177 | 177 | 'id' => 'glsr-notices', |
| 178 | - ]); |
|
| 178 | + ] ); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | global $menu, $typenow; |
| 24 | 24 | foreach( $menu as $key => $value ) { |
| 25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 25 | + if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) { |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 26 | 28 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 27 | 29 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
| 28 | 30 | 'class' => 'pending-count', |
@@ -53,7 +55,9 @@ discard block |
||
| 53 | 55 | foreach( $pages as $slug => $title ) { |
| 54 | 56 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
| 55 | 57 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
| 56 | - if( !is_callable( $callback ))continue; |
|
| 58 | + if( !is_callable( $callback )) { |
|
| 59 | + continue; |
|
| 60 | + } |
|
| 57 | 61 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback ); |
| 58 | 62 | } |
| 59 | 63 | } |