Skip to content

Commit a00cc83

Browse files
committed
Code Modernization: Customize: Use null coalescing operator instead of isset() ternaries.
Developed as a subset of #10654 Initially developed in #4886 Follow-up to [61432], [61431], [61430], [61429], [61424], [61404], [61403]. Props costdev, westonruter. See #58874, #63430. git-svn-id: https://develop.svn.wordpress.org/trunk@61433 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 133fdbb commit a00cc83

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/wp-includes/class-wp-customize-nav-menus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ protected function print_post_type_container( $available_item_type ) {
12511251
</div>
12521252
<?php endif; ?>
12531253
<?php endif; ?>
1254-
<ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul>
1254+
<ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( $available_item_type['type_label'] ?? $available_item_type['type'] ); ?>"></ul>
12551255
</div>
12561256
</div>
12571257
<?php

src/wp-includes/class-wp-customize-setting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ final protected function multidimensional_replace( $root, $keys, $value ) {
941941
*/
942942
final protected function multidimensional_get( $root, $keys, $default_value = null ) {
943943
if ( empty( $keys ) ) { // If there are no keys, test the root.
944-
return isset( $root ) ? $root : $default_value;
944+
return $root ?? $default_value;
945945
}
946946

947947
$result = $this->multidimensional( $root, $keys );

src/wp-includes/class-wp-customize-widgets.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ public function output_widget_control_templates() {
924924
<span class="customize-action">
925925
<?php
926926
$panel = $this->manager->get_panel( 'widgets' );
927-
$panel_title = isset( $panel->title ) ? $panel->title : __( 'Widgets' );
927+
$panel_title = $panel->title ?? __( 'Widgets' );
928928
/* translators: &#9656; is the unicode right-pointing triangle. %s: Section title in the Customizer. */
929929
printf( __( 'Customizing &#9656; %s' ), esc_html( $panel_title ) );
930930
?>
@@ -1123,7 +1123,7 @@ public function get_available_widgets() {
11231123
$available_widget = array_merge(
11241124
$available_widget,
11251125
array(
1126-
'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
1126+
'temp_id' => $args['_temp_id'] ?? null,
11271127
'is_multi' => $is_multi_widget,
11281128
'control_tpl' => $control_tpl,
11291129
'multi_number' => ( 'multi' === $args['_add'] ) ? $args['_multi_num'] : false,

src/wp-includes/customize/class-wp-customize-header-image-setting.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function update( $value ) {
4040
if ( empty( $custom_image_header ) ) {
4141
require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php';
4242
$args = get_theme_support( 'custom-header' );
43-
$admin_head_callback = isset( $args[0]['admin-head-callback'] ) ? $args[0]['admin-head-callback'] : null;
44-
$admin_preview_callback = isset( $args[0]['admin-preview-callback'] ) ? $args[0]['admin-preview-callback'] : null;
43+
$admin_head_callback = $args[0]['admin-head-callback'] ?? null;
44+
$admin_preview_callback = $args[0]['admin-preview-callback'] ?? null;
4545
$custom_image_header = new Custom_Image_Header( $admin_head_callback, $admin_preview_callback );
4646
}
4747

src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function value() {
252252
// These properties are read-only and are part of the setting for use in the Customizer UI.
253253
if ( is_array( $value ) ) {
254254
$value_obj = (object) $value;
255-
$value['type_label'] = isset( $type_label ) ? $type_label : $this->get_type_label( $value_obj );
255+
$value['type_label'] = $type_label ?? $this->get_type_label( $value_obj );
256256
$value['original_title'] = $this->get_original_title( $value_obj );
257257
}
258258

0 commit comments

Comments
 (0)