Skip to content

Commit 56076b1

Browse files
committed
Code Modernization: Script Loader: Use null coalescing operator instead of isset() ternaries.
Developed as a subset of WordPress/wordpress-develop#10654 Initially developed in WordPress/wordpress-develop#4886 Follow-up to [61436], [61435], [61434], [61403], [61433], [61432], [61431], [61430], [61429], [61424], [61404], [61403]. Props costdev, westonruter. See #58874, #63430. Built from https://develop.svn.wordpress.org/trunk@61442 git-svn-id: http://core.svn.wordpress.org/trunk@60754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 2f96d11 commit 56076b1

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

wp-includes/class-wp-scripts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function do_item( $handle, $group = false ) {
450450
}
451451

452452
// Determine fetchpriority.
453-
$original_fetchpriority = isset( $obj->extra['fetchpriority'] ) ? $obj->extra['fetchpriority'] : null;
453+
$original_fetchpriority = $obj->extra['fetchpriority'] ?? null;
454454
if ( null === $original_fetchpriority || ! $this->is_valid_fetchpriority( $original_fetchpriority ) ) {
455455
$original_fetchpriority = 'auto';
456456
}

wp-includes/class-wp-styles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function do_item( $handle, $group = false ) {
203203
}
204204

205205
$rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
206-
$title = isset( $obj->extra['title'] ) ? $obj->extra['title'] : '';
206+
$title = $obj->extra['title'] ?? '';
207207

208208
$tag = sprintf(
209209
"<link rel='%s' id='%s-css'%s href='%s' media='%s' />\n",
@@ -230,7 +230,7 @@ public function do_item( $handle, $group = false ) {
230230

231231
if ( 'rtl' === $this->text_direction && isset( $obj->extra['rtl'] ) && $obj->extra['rtl'] ) {
232232
if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) {
233-
$suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : '';
233+
$suffix = $obj->extra['suffix'] ?? '';
234234
$rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $src, $ver, "$handle-rtl" ) );
235235
} else {
236236
$rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );

wp-includes/css/dist/index.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
*/
88

99
return array(
10-
array(
11-
'handle' => 'wp-preferences',
12-
'path' => 'preferences/style',
13-
'dependencies' => array('wp-components'),
14-
),
1510
array(
1611
'handle' => 'wp-nux',
1712
'path' => 'nux/style',
@@ -23,8 +18,8 @@
2318
'dependencies' => array('wp-components'),
2419
),
2520
array(
26-
'handle' => 'wp-commands',
27-
'path' => 'commands/style',
21+
'handle' => 'wp-preferences',
22+
'path' => 'preferences/style',
2823
'dependencies' => array('wp-components'),
2924
),
3025
array(
@@ -33,13 +28,18 @@
3328
'dependencies' => array('wp-block-editor', 'wp-components'),
3429
),
3530
array(
36-
'handle' => 'wp-widgets',
37-
'path' => 'widgets/style',
31+
'handle' => 'wp-patterns',
32+
'path' => 'patterns/style',
3833
'dependencies' => array('wp-block-editor', 'wp-components'),
3934
),
4035
array(
41-
'handle' => 'wp-patterns',
42-
'path' => 'patterns/style',
36+
'handle' => 'wp-commands',
37+
'path' => 'commands/style',
38+
'dependencies' => array('wp-components'),
39+
),
40+
array(
41+
'handle' => 'wp-widgets',
42+
'path' => 'widgets/style',
4343
'dependencies' => array('wp-block-editor', 'wp-components'),
4444
),
4545
array(

wp-includes/global-styles-and-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function wp_add_global_styles_for_blocks() {
283283

284284
if ( $can_use_cached ) {
285285
// Use the block name as the key for cached CSS data. Otherwise, use a hash of the metadata.
286-
$cache_node_key = isset( $metadata['name'] ) ? $metadata['name'] : md5( wp_json_encode( $metadata ) );
286+
$cache_node_key = $metadata['name'] ?? md5( wp_json_encode( $metadata ) );
287287

288288
if ( isset( $cached['blocks'][ $cache_node_key ] ) ) {
289289
$block_css = $cached['blocks'][ $cache_node_key ];

wp-includes/js/dist/script-modules/index.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,26 @@
77
*/
88

99
return array(
10+
array(
11+
'id' => '@wordpress/interactivity-router',
12+
'path' => 'interactivity-router/index',
13+
'asset' => 'interactivity-router/index.min.asset.php',
14+
),
15+
array(
16+
'id' => '@wordpress/interactivity-router/full-page',
17+
'path' => 'interactivity-router/full-page',
18+
'asset' => 'interactivity-router/full-page.min.asset.php',
19+
),
1020
array(
1121
'id' => '@wordpress/interactivity',
1222
'path' => 'interactivity/index',
1323
'asset' => 'interactivity/index.min.asset.php',
1424
),
25+
array(
26+
'id' => '@wordpress/abilities',
27+
'path' => 'abilities/index',
28+
'asset' => 'abilities/index.min.asset.php',
29+
),
1530
array(
1631
'id' => '@wordpress/latex-to-mathml',
1732
'path' => 'latex-to-mathml/index',
@@ -22,16 +37,6 @@
2237
'path' => 'latex-to-mathml/loader',
2338
'asset' => 'latex-to-mathml/loader.min.asset.php',
2439
),
25-
array(
26-
'id' => '@wordpress/interactivity-router',
27-
'path' => 'interactivity-router/index',
28-
'asset' => 'interactivity-router/index.min.asset.php',
29-
),
30-
array(
31-
'id' => '@wordpress/interactivity-router/full-page',
32-
'path' => 'interactivity-router/full-page',
33-
'asset' => 'interactivity-router/full-page.min.asset.php',
34-
),
3540
array(
3641
'id' => '@wordpress/a11y',
3742
'path' => 'a11y/index',
@@ -42,11 +47,6 @@
4247
'path' => 'core-abilities/index',
4348
'asset' => 'core-abilities/index.min.asset.php',
4449
),
45-
array(
46-
'id' => '@wordpress/abilities',
47-
'path' => 'abilities/index',
48-
'asset' => 'abilities/index.min.asset.php',
49-
),
5050
array(
5151
'id' => '@wordpress/route',
5252
'path' => 'route/index',

wp-includes/script-loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ function wp_localize_community_events() {
19841984

19851985
$user_id = get_current_user_id();
19861986
$saved_location = get_user_option( 'community-events-location', $user_id );
1987-
$saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
1987+
$saved_ip_address = $saved_location['ip'] ?? false;
19881988
$current_ip_address = WP_Community_Events::get_unsafe_client_ip();
19891989

19901990
/*

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-alpha-61441';
19+
$wp_version = '7.0-alpha-61442';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)