Skip to content

Commit 73c6530

Browse files
committed
Fix phpcs and eslint issues
1 parent 86a7dfe commit 73c6530

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

js/customize-object-selector-component.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ wp.customize.ObjectSelectorComponent = (function( api, $ ) {
4747
* @param {Boolean} args.show_add_buttons - Whether add buttons will be shown if available.
4848
* @returns {void}
4949
*/
50-
initialize: function initialize( args ) {
50+
initialize: function initialize( args ) { // eslint-disable-line complexity
5151
var component = this;
5252

5353
if ( ! args.model || 'function' !== typeof args.model.get ) {
@@ -429,8 +429,8 @@ wp.customize.ObjectSelectorComponent = (function( api, $ ) {
429429
var component = this, editButton, onSelect;
430430

431431
editButton = component.container.find( '.select2-selection__choice__edit' );
432-
onSelect = function( pageId ) {
433-
pageId = parseInt( pageId, 10 );
432+
onSelect = function( id ) {
433+
var pageId = parseInt( id, 10 );
434434
editButton.toggle( ! isNaN( pageId ) && 0 !== pageId && ! component.select2_options.multiple );
435435
};
436436
onSelect( component.model.get() );

php/class-plugin.php

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,32 @@ public function handle_ajax_object_selector_query() {
199199
global $wp_customize;
200200

201201
// Close output buffering to ensure that _ajax_wp_die_handler doesn't clobber the status_header(). See <https://core.trac.wordpress.org/ticket/35666#comment:6>.
202-
while ( 0 !== ob_get_level() ) {
202+
while ( 0 !== ob_get_level() ) {
203203
ob_end_clean();
204204
}
205205

206206
$nonce_query_var_name = 'customize_object_selector_query_nonce';
207207
if ( ! check_ajax_referer( static::OBJECT_SELECTOR_QUERY_AJAX_ACTION, $nonce_query_var_name, false ) ) {
208208
status_header( 400 );
209-
wp_send_json_error( array( 'code' => 'bad_nonce' ), 400 ); // Note: The redundant 400 status is needed until #35666 is resolved.
209+
wp_send_json_error(
210+
array(
211+
'code' => 'bad_nonce',
212+
),
213+
400 // Note: The redundant 400 status is needed until #35666 is resolved.
214+
);
210215
}
211216
if ( ! isset( $_POST['post_query_args'] ) ) {
212217
status_header( 400 );
213-
wp_send_json_error( array( 'code' => 'missing_post_query_args' ), 400 );
218+
wp_send_json_error( array(
219+
'code' => 'missing_post_query_args',
220+
), 400 );
214221
}
215222
$post_query_args = json_decode( wp_unslash( $_POST['post_query_args'] ), true );
216223
if ( ! is_array( $post_query_args ) ) {
217224
status_header( 400 );
218-
wp_send_json_error( array( 'code' => 'invalid_post_query_args' ), 400 );
225+
wp_send_json_error( array(
226+
'code' => 'invalid_post_query_args',
227+
), 400 );
219228
}
220229

221230
$post_query_args = $this->process_post_query_vars( $post_query_args );
@@ -322,14 +331,18 @@ public function process_post_query_vars( $post_query_vars ) {
322331
return new \WP_Error(
323332
'disallowed_query_var',
324333
__( 'Disallowed query var', 'customize-object-selector' ),
325-
array( 'query_vars' => array_values( $extra_query_vars ) )
334+
array(
335+
'query_vars' => array_values( $extra_query_vars ),
336+
)
326337
);
327338
}
328339
if ( ! empty( $post_query_vars['meta_compare'] ) && ! in_array( $post_query_vars['meta_compare'], $allowed_meta_query_compare_values, true ) ) {
329340
return new \WP_Error(
330341
'disallowed_meta_compare_query_var',
331342
__( 'Disallowed meta_compare query var', 'customize-object-selector' ),
332-
array( 'query_var' => $post_query_vars['meta_compare'] )
343+
array(
344+
'query_var' => $post_query_vars['meta_compare'],
345+
)
333346
);
334347
}
335348

@@ -341,7 +354,9 @@ public function process_post_query_vars( $post_query_vars ) {
341354
return new \WP_Error(
342355
'disallowed_meta_query_relation_var',
343356
__( 'Disallowed meta_query relation', 'customize-object-selector' ),
344-
array( 'query_vars' => array_values( $val ) )
357+
array(
358+
'query_vars' => array_values( $val ),
359+
)
345360
);
346361
}
347362
continue;
@@ -351,14 +366,18 @@ public function process_post_query_vars( $post_query_vars ) {
351366
return new \WP_Error(
352367
'disallowed_meta_query_var',
353368
__( 'Disallowed meta_query var', 'customize-object-selector' ),
354-
array( 'query_vars' => array_values( $extra_meta_query_vars ) )
369+
array(
370+
'query_vars' => array_values( $extra_meta_query_vars ),
371+
)
355372
);
356373
}
357374
if ( ! empty( $val['compare'] ) && ! in_array( $val['compare'], $allowed_meta_query_compare_values, true ) ) {
358375
return new \WP_Error(
359376
'disallowed_meta_compare_query_var',
360377
__( 'Disallowed meta_compare query var', 'customize-object-selector' ),
361-
array( 'query_vars' => $post_query_vars['meta_query']['compare'] )
378+
array(
379+
'query_vars' => $post_query_vars['meta_query']['compare'],
380+
)
362381
);
363382
}
364383
}
@@ -379,7 +398,9 @@ public function process_post_query_vars( $post_query_vars ) {
379398
return new \WP_Error(
380399
'bad_post_status',
381400
__( 'Bad post status', 'customize-object-selector' ),
382-
array( 'post_status' => $post_status )
401+
array(
402+
'post_status' => $post_status,
403+
)
383404
);
384405
}
385406
if ( ! empty( $post_status_object->publicly_queryable ) ) {
@@ -401,21 +422,27 @@ public function process_post_query_vars( $post_query_vars ) {
401422
return new \WP_Error(
402423
'bad_post_type',
403424
__( 'Bad post type', 'customize-object-selector' ),
404-
array( 'post_type' => $post_type )
425+
array(
426+
'post_type' => $post_type,
427+
)
405428
);
406429
}
407430
if ( ! current_user_can( $post_type_object->cap->read ) ) {
408431
return new \WP_Error(
409432
'cannot_query_posts',
410433
__( 'Cannot query posts', 'customize-object-selector' ),
411-
array( 'post_type' => $post_type )
434+
array(
435+
'post_type' => $post_type,
436+
)
412437
);
413438
}
414439
if ( $has_private_status && ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
415440
return new \WP_Error(
416441
'cannot_query_private_posts',
417442
__( 'Cannot query private posts', 'customize-object-selector' ),
418-
array( 'post_type' => $post_type )
443+
array(
444+
'post_type' => $post_type,
445+
)
419446
);
420447
}
421448
}
@@ -530,8 +557,11 @@ public function build_post_dropdown( $post_query_args ) {
530557
if ( in_array( $key, $unsupported_args, true ) ) {
531558
return new \WP_Error(
532559
'unsupported_dropdown_pages_arg',
560+
/* translators: placeholder is dropdown_pages argument */
533561
sprintf( __( 'Unsupported arg "%s" in dropdown_args or supplied by page_attributes_dropdown_pages_args filter', 'customize-object-selector' ), $key ),
534-
array( 'arg' => $key )
562+
array(
563+
'arg' => $key,
564+
)
535565
);
536566
}
537567
}

0 commit comments

Comments
 (0)