Skip to content

Commit 6d60f73

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

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/wp-includes/formatting.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,8 +2642,8 @@ function force_balance_tags( $text ) {
26422642
$tag_name = $regex[2];
26432643
$tag = strtolower( $tag_name );
26442644
$is_single_tag = in_array( $tag, $single_tags, true );
2645-
$pre_attribute_ws = isset( $regex[4] ) ? $regex[4] : '';
2646-
$attributes = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] );
2645+
$pre_attribute_ws = $regex[4] ?? '';
2646+
$attributes = trim( $regex[5] ?? $regex[3] );
26472647
$has_self_closer = str_ends_with( $attributes, '/' );
26482648

26492649
$newtext .= $tagqueue;
@@ -5283,10 +5283,10 @@ function wp_sprintf( $pattern, ...$args ) {
52835283
// Find numbered arguments or take the next one in order.
52845284
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
52855285
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.
5286-
$arg = isset( $args[ $index ] ) ? $args[ $index ] : '';
5286+
$arg = $args[ $index ] ?? '';
52875287
$fragment = str_replace( "%{$matches[1]}$", '%', $fragment );
52885288
} else {
5289-
$arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : '';
5289+
$arg = $args[ $arg_index ] ?? '';
52905290
++$arg_index;
52915291
}
52925292

src/wp-includes/kses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,7 @@ function _wp_kses_allow_pdf_objects( $url ) {
30333033
// If the URL host matches the current site's media URL, it's safe.
30343034
$upload_info = wp_upload_dir( null, false );
30353035
$parsed_url = wp_parse_url( $upload_info['url'] );
3036-
$upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
3036+
$upload_host = $parsed_url['host'] ?? '';
30373037
$upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
30383038

30393039
if ( str_starts_with( $url, "http://$upload_host$upload_port/" )

src/wp-includes/shortcodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ function do_shortcode_tag( $m ) {
429429
return $return;
430430
}
431431

432-
$content = isset( $m[5] ) ? $m[5] : null;
432+
$content = $m[5] ?? null;
433433

434434
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
435435

0 commit comments

Comments
 (0)