From 89c73eb957c8a5efb902d99e33d1be61bce3b9f0 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:19 +0100 Subject: [PATCH 01/28] Administration: Replace some ternaries with null coalescing operator. --- src/wp-admin/includes/ajax-actions.php | 28 +++++++++---------- .../includes/class-wp-community-events.php | 2 +- .../includes/class-wp-links-list-table.php | 2 +- src/wp-admin/includes/class-wp-list-table.php | 20 ++++++------- src/wp-admin/includes/class-wp-screen.php | 2 +- src/wp-admin/includes/credits.php | 2 +- src/wp-admin/includes/meta-boxes.php | 4 +-- src/wp-admin/options-privacy.php | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 3c5dab31b500b..36f41664d1ecc 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -1790,7 +1790,7 @@ function wp_ajax_closed_postboxes() { $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); $hidden = array_filter( $hidden ); - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + $page = $_POST['page'] ?? ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); @@ -1821,7 +1821,7 @@ function wp_ajax_closed_postboxes() { */ function wp_ajax_hidden_columns() { check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + $page = $_POST['page'] ?? ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); @@ -1970,13 +1970,13 @@ function wp_ajax_menu_locations_save() { function wp_ajax_meta_box_order() { check_ajax_referer( 'meta-box-order' ); $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; - $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; + $page_columns = $_POST['page_columns'] ?? 'auto'; if ( 'auto' !== $page_columns ) { $page_columns = (int) $page_columns; } - $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + $page = $_POST['page'] ?? ''; if ( sanitize_key( $page ) != $page ) { wp_die( 0 ); @@ -2034,8 +2034,8 @@ function wp_ajax_get_permalink() { function wp_ajax_sample_permalink() { check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; - $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; - $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; + $title = $_POST['new_title'] ?? ''; + $slug = $_POST['new_slug'] ?? null; wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); } @@ -2374,7 +2374,7 @@ function wp_ajax_save_widget() { $error = '

' . __( 'An error has occurred. Please reload the page and try again.' ) . '

'; $sidebars = wp_get_sidebars_widgets(); - $sidebar = isset( $sidebars[ $sidebar_id ] ) ? $sidebars[ $sidebar_id ] : array(); + $sidebar = $sidebars[ $sidebar_id ] ?? array(); // Delete. if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { @@ -3334,12 +3334,12 @@ function wp_ajax_send_attachment_to_editor() { remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); if ( str_starts_with( $post->post_mime_type, 'image' ) ) { - $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; - $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; - $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; + $align = $attachment['align'] ?? 'none'; + $size = $attachment['image-size'] ?? 'medium'; + $alt = $attachment['image_alt'] ?? ''; // No whitespace-only captions. - $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; + $caption = $attachment['post_excerpt'] ?? ''; if ( '' === trim( $caption ) ) { $caption = ''; } @@ -3349,7 +3349,7 @@ function wp_ajax_send_attachment_to_editor() { } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { $html = stripslashes_deep( $_POST['html'] ); } else { - $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; + $html = $attachment['post_title'] ?? ''; $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized. if ( ! empty( $url ) ) { @@ -3402,7 +3402,7 @@ function wp_ajax_send_link_to_editor() { $link_text = wp_basename( $src ); } - $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); + $post = get_post( $_POST['post_id'] ?? 0 ); // Ping WordPress for an embed. $check_embed = $wp_embed->run_shortcode( '[embed]' . $src . '[/embed]' ); @@ -3627,7 +3627,7 @@ function wp_ajax_query_themes() { } } - $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; + $old_filter = $args['browse'] ?? 'search'; /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */ $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); diff --git a/src/wp-admin/includes/class-wp-community-events.php b/src/wp-admin/includes/class-wp-community-events.php index 09557c86a4782..39f1d95460eb3 100644 --- a/src/wp-admin/includes/class-wp-community-events.php +++ b/src/wp-admin/includes/class-wp-community-events.php @@ -122,7 +122,7 @@ public function get_events( $location_search = '', $timezone = '' ) { } elseif ( ! isset( $response_body['location'], $response_body['events'] ) ) { $response_error = new WP_Error( 'api-invalid-response', - isset( $response_body['error'] ) ? $response_body['error'] : __( 'Unknown API error.' ) + $response_body['error'] ?? __( 'Unknown API error.' ) ); } diff --git a/src/wp-admin/includes/class-wp-links-list-table.php b/src/wp-admin/includes/class-wp-links-list-table.php index f29cf7b3e237e..3f3850cb72649 100644 --- a/src/wp-admin/includes/class-wp-links-list-table.php +++ b/src/wp-admin/includes/class-wp-links-list-table.php @@ -29,7 +29,7 @@ public function __construct( $args = array() ) { parent::__construct( array( 'plural' => 'bookmarks', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); } diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index b8631d17a2d7b..ff0404d5be122 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -1401,11 +1401,11 @@ public function print_column_headers( $with_id = true ) { } if ( isset( $sortable[ $column_key ] ) ) { - $orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : ''; - $desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false; - $abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : ''; - $orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : ''; - $initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : ''; + $orderby = $sortable[ $column_key ][0] ?? ''; + $desc_first = $sortable[ $column_key ][1] ?? false; + $abbr = $sortable[ $column_key ][2] ?? ''; + $orderby_text = $sortable[ $column_key ][3] ?? ''; + $initial_order = $sortable[ $column_key ][4] ?? ''; /* * We're in the initial view and there's no $_GET['orderby'] then check if the @@ -1521,11 +1521,11 @@ public function print_table_description() { foreach ( array_keys( $columns ) as $column_key ) { if ( isset( $sortable[ $column_key ] ) ) { - $orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : ''; - $desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false; - $abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : ''; - $orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : ''; - $initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : ''; + $orderby = $sortable[ $column_key ][0] ?? ''; + $desc_first = $sortable[ $column_key ][1] ?? false; + $abbr = $sortable[ $column_key ][2] ?? ''; + $orderby_text = $sortable[ $column_key ][3] ?? ''; + $initial_order = $sortable[ $column_key ][4] ?? ''; if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { return; diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index 739a182ded075..a29d2b18daee3 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -1252,7 +1252,7 @@ public function render_per_page_options() { } if ( 'edit_comments_per_page' === $option ) { - $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; + $comment_status = $_REQUEST['comment_status'] ?? 'all'; /** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */ $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status ); diff --git a/src/wp-admin/includes/credits.php b/src/wp-admin/includes/credits.php index 907ee93c0bae3..bc61d73cf71cb 100644 --- a/src/wp-admin/includes/credits.php +++ b/src/wp-admin/includes/credits.php @@ -123,7 +123,7 @@ function wp_credits_section_title( $group_data = array() ) { * @param string $slug The current group to display. */ function wp_credits_section_list( $credits = array(), $slug = '' ) { - $group_data = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array(); + $group_data = $credits['groups'][ $slug ] ?? array(); $credits_data = $credits['data']; if ( ! count( $group_data ) ) { return; diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 7d0e1def8b19f..afc7b11a06894 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -1271,7 +1271,7 @@ function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) { _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented. } - $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; + $link_rel = $link->link_rel ?? ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; $link_rels = preg_split( '/\s+/', $link_rel ); // Mark the specified value as checked if it matches the current link's relationship. @@ -1488,7 +1488,7 @@ function link_advanced_meta_box( $link ) { - + diff --git a/src/wp-admin/options-privacy.php b/src/wp-admin/options-privacy.php index 5c22d39d5df67..9898aaddf7e97 100644 --- a/src/wp-admin/options-privacy.php +++ b/src/wp-admin/options-privacy.php @@ -30,7 +30,7 @@ static function( $body_class ) { } ); -$action = isset( $_POST['action'] ) ? $_POST['action'] : ''; +$action = $_POST['action'] ?? ''; get_current_screen()->add_help_tab( array( From 1c8248c0272168db6bbdb76e96e1334c6920b87c Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:25 +0100 Subject: [PATCH 02/28] Bootstrap/Load: Replace some ternaries with null coalescing operator. --- src/wp-includes/class-wp-paused-extensions-storage.php | 2 +- src/wp-includes/error-protection.php | 2 +- src/wp-includes/load.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wp-paused-extensions-storage.php b/src/wp-includes/class-wp-paused-extensions-storage.php index 4658277289e49..aea7fc1eb816b 100644 --- a/src/wp-includes/class-wp-paused-extensions-storage.php +++ b/src/wp-includes/class-wp-paused-extensions-storage.php @@ -161,7 +161,7 @@ public function get_all() { $paused_extensions = (array) get_option( $option_name, array() ); - return isset( $paused_extensions[ $this->type ] ) ? $paused_extensions[ $this->type ] : array(); + return $paused_extensions[ $this->type ] ?? array(); } /** diff --git a/src/wp-includes/error-protection.php b/src/wp-includes/error-protection.php index 08c4159665862..b9cff7073df53 100644 --- a/src/wp-includes/error-protection.php +++ b/src/wp-includes/error-protection.php @@ -46,7 +46,7 @@ function wp_paused_themes() { */ function wp_get_extension_error_description( $error ) { $constants = get_defined_constants( true ); - $constants = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal']; + $constants = $constants['Core'] ?? $constants['internal']; $core_errors = array(); foreach ( $constants as $constant => $value ) { diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 9324eed562ff0..de31f79ba5f33 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -13,7 +13,7 @@ * @return string The HTTP protocol. Default: HTTP/1.0. */ function wp_get_server_protocol() { - $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : ''; + $protocol = $_SERVER['SERVER_PROTOCOL'] ?? ''; if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) { $protocol = 'HTTP/1.0'; @@ -115,7 +115,7 @@ function wp_populate_basic_auth_from_authorization_header() { } // From our prior conditional, one of these must be set. - $header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; + $header = $_SERVER['HTTP_AUTHORIZATION'] ?? $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; // Test to make sure the pattern matches expected. if ( ! preg_match( '%^Basic [a-z\d/+]*={0,2}$%i', $header ) ) { From f55e7cba12d2b307aea452f239f17c14212288e5 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:27 +0100 Subject: [PATCH 03/28] Comments: Replace some ternaries with null coalescing operator. --- src/wp-admin/edit-comments.php | 4 ++-- .../includes/class-wp-comments-list-table.php | 14 +++++++------- src/wp-includes/class-wp-comment-query.php | 12 ++++++------ src/wp-includes/comment.php | 6 +++--- src/wp-trackback.php | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index d7f14f2cd09aa..f14a2b52c6fa8 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -331,7 +331,7 @@ } if ( $spammed > 0 ) { - $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; + $ids = $_REQUEST['ids'] ?? 0; $messages[] = sprintf( /* translators: %s: Number of comments. */ @@ -353,7 +353,7 @@ } if ( $trashed > 0 ) { - $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; + $ids = $_REQUEST['ids'] ?? 0; $messages[] = sprintf( /* translators: %s: Number of comments. */ diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 7d87ae9aabdc4..fba5eb0bfa54c 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -49,7 +49,7 @@ public function __construct( $args = array() ) { 'plural' => 'comments', 'singular' => 'comment', 'ajax' => true, - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); } @@ -93,7 +93,7 @@ public function prepare_items() { $mode = get_user_setting( 'posts_list_mode', 'list' ); } - $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; + $comment_status = $_REQUEST['comment_status'] ?? 'all'; if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) { $comment_status = 'all'; @@ -101,14 +101,14 @@ public function prepare_items() { $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; - $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; + $search = $_REQUEST['s'] ?? ''; $post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : ''; - $user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : ''; + $user_id = $_REQUEST['user_id'] ?? ''; - $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : ''; - $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : ''; + $orderby = $_REQUEST['orderby'] ?? ''; + $order = $_REQUEST['order'] ?? ''; $comments_per_page = $this->get_per_page( $comment_status ); @@ -140,7 +140,7 @@ public function prepare_items() { ); $args = array( - 'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status, + 'status' => $status_map[ $comment_status ] ?? $comment_status, 'search' => $search, 'user_id' => $user_id, 'offset' => $start, diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index 40f283896653e..9654ba6bd58ae 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -932,12 +932,12 @@ protected function get_comment_ids() { */ $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); - $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; - $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; - $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; - $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : ''; - $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : ''; - $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; + $fields = $clauses['fields'] ?? ''; + $join = $clauses['join'] ?? ''; + $where = $clauses['where'] ?? ''; + $orderby = $clauses['orderby'] ?? ''; + $limits = $clauses['limits'] ?? ''; + $groupby = $clauses['groupby'] ?? ''; $this->filtered_where_clause = $where; diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 604ede7c876a7..a6536a355ba8c 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2109,7 +2109,7 @@ function wp_filter_comment( $commentdata ) { * * @param string $comment_agent The comment author's browser user agent. */ - $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); + $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( $commentdata['comment_agent'] ?? '' ) ); /** This filter is documented in wp-includes/comment.php */ $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] ); /** @@ -2227,7 +2227,7 @@ function wp_new_comment( $commentdata, $wp_error = false ) { } if ( ! isset( $commentdata['comment_agent'] ) ) { - $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; + $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'] ?? ''; } /** @@ -2501,7 +2501,7 @@ function wp_update_comment( $commentarr, $wp_error = false ) { $filter_comment = false; if ( ! has_filter( 'pre_comment_content', 'wp_filter_kses' ) ) { - $filter_comment = ! user_can( isset( $comment['user_id'] ) ? $comment['user_id'] : 0, 'unfiltered_html' ); + $filter_comment = ! user_can( $comment['user_id'] ?? 0, 'unfiltered_html' ); } if ( $filter_comment ) { diff --git a/src/wp-trackback.php b/src/wp-trackback.php index 670d9c457bc81..b670339093aae 100644 --- a/src/wp-trackback.php +++ b/src/wp-trackback.php @@ -50,8 +50,8 @@ function trackback_response( $error = 0, $error_message = '' ) { $post_id = (int) $post_id[ count( $post_id ) - 1 ]; } -$trackback_url = isset( $_POST['url'] ) ? $_POST['url'] : ''; -$charset = isset( $_POST['charset'] ) ? $_POST['charset'] : ''; +$trackback_url = $_POST['url'] ?? ''; +$charset = $_POST['charset'] ?? ''; // These three are stripslashed here so they can be properly escaped after mb_convert_encoding(). $title = isset( $_POST['title'] ) ? wp_unslash( $_POST['title'] ) : ''; From 7a5503559f08923fbad5e17cb0c1d4e5313f3627 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:30 +0100 Subject: [PATCH 04/28] Customize: Replace some ternaries with null coalescing operator. --- src/wp-includes/class-wp-customize-manager.php | 14 +++++++------- src/wp-includes/class-wp-customize-nav-menus.php | 2 +- src/wp-includes/class-wp-customize-setting.php | 2 +- src/wp-includes/class-wp-customize-widgets.php | 2 +- .../class-wp-customize-header-image-setting.php | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 4f8aae8fbdc65..440b5bc7e19bd 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -1219,9 +1219,9 @@ public function import_theme_starter_content( $starter_content = array() ) { $sidebars_widgets = isset( $starter_content['widgets'] ) && ! empty( $this->widgets ) ? $starter_content['widgets'] : array(); $attachments = isset( $starter_content['attachments'] ) && ! empty( $this->nav_menus ) ? $starter_content['attachments'] : array(); $posts = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array(); - $options = isset( $starter_content['options'] ) ? $starter_content['options'] : array(); $nav_menus = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array(); - $theme_mods = isset( $starter_content['theme_mods'] ) ? $starter_content['theme_mods'] : array(); + $options = $starter_content['options'] ?? array(); + $theme_mods = $starter_content['theme_mods'] ?? array(); // Widgets. $max_widget_numbers = array(); @@ -1488,7 +1488,7 @@ public function import_theme_starter_content( $starter_content = array() ) { $this->set_post_value( $nav_menu_setting_id, array( - 'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location, + 'name' => $nav_menu['name'] ?? $nav_menu_location, ) ); $this->pending_starter_content_settings_ids[] = $nav_menu_setting_id; @@ -5227,10 +5227,10 @@ public function register_controls() { 'label' => __( 'Logo' ), 'section' => 'title_tagline', 'priority' => 8, - 'height' => isset( $custom_logo_args[0]['height'] ) ? $custom_logo_args[0]['height'] : null, - 'width' => isset( $custom_logo_args[0]['width'] ) ? $custom_logo_args[0]['width'] : null, - 'flex_height' => isset( $custom_logo_args[0]['flex-height'] ) ? $custom_logo_args[0]['flex-height'] : null, - 'flex_width' => isset( $custom_logo_args[0]['flex-width'] ) ? $custom_logo_args[0]['flex-width'] : null, + 'height' => $custom_logo_args[0]['height'] ?? null, + 'width' => $custom_logo_args[0]['width'] ?? null, + 'flex_height' => $custom_logo_args[0]['flex-height'] ?? null, + 'flex_width' => $custom_logo_args[0]['flex-width'] ?? null, 'button_labels' => array( 'select' => __( 'Select logo' ), 'change' => __( 'Change logo' ), diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php index bbda8b51b3795..b3cb912ded071 100644 --- a/src/wp-includes/class-wp-customize-nav-menus.php +++ b/src/wp-includes/class-wp-customize-nav-menus.php @@ -1250,7 +1250,7 @@ protected function print_post_type_container( $available_item_type ) { -
    +
      multidimensional( $root, $keys ); diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index 41a57dc66bbe1..0d84c599ed5d9 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -1099,7 +1099,7 @@ public function get_available_widgets() { $available_widget = array_merge( $available_widget, array( - 'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null, + 'temp_id' => $args['_temp_id'] ?? null, 'is_multi' => $is_multi_widget, 'control_tpl' => $control_tpl, 'multi_number' => ( 'multi' === $args['_add'] ) ? $args['_multi_num'] : false, diff --git a/src/wp-includes/customize/class-wp-customize-header-image-setting.php b/src/wp-includes/customize/class-wp-customize-header-image-setting.php index 80333a54128af..0834b378d3a6e 100644 --- a/src/wp-includes/customize/class-wp-customize-header-image-setting.php +++ b/src/wp-includes/customize/class-wp-customize-header-image-setting.php @@ -40,8 +40,8 @@ public function update( $value ) { if ( empty( $custom_image_header ) ) { require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php'; $args = get_theme_support( 'custom-header' ); - $admin_head_callback = isset( $args[0]['admin-head-callback'] ) ? $args[0]['admin-head-callback'] : null; - $admin_preview_callback = isset( $args[0]['admin-preview-callback'] ) ? $args[0]['admin-preview-callback'] : null; + $admin_head_callback = $args[0]['admin-head-callback'] ?? null; + $admin_preview_callback = $args[0]['admin-preview-callback'] ?? null; $custom_image_header = new Custom_Image_Header( $admin_head_callback, $admin_preview_callback ); } From 1156840c0b12de84769041374971ca2d5cd5abf2 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:32 +0100 Subject: [PATCH 05/28] Editor: Replace some ternaries with null coalescing operator. --- src/wp-admin/edit-form-advanced.php | 2 +- src/wp-admin/site-editor.php | 2 +- src/wp-includes/block-supports/dimensions.php | 2 +- src/wp-includes/block-supports/elements.php | 4 ++-- src/wp-includes/block-supports/layout.php | 18 +++++++------- src/wp-includes/block-supports/shadow.php | 2 +- src/wp-includes/block-supports/spacing.php | 2 +- src/wp-includes/block-supports/typography.php | 24 +++++++++---------- src/wp-includes/block-template-utils.php | 10 ++++---- src/wp-includes/block-template.php | 4 ++-- src/wp-includes/blocks.php | 4 ++-- src/wp-includes/class-wp-block-type.php | 2 +- src/wp-includes/class-wp-theme-json.php | 20 ++++++++-------- 13 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 12344df3ba57a..f4c23e078e1ed 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -76,7 +76,7 @@ */ $post_ID = isset( $post_ID ) ? (int) $post_ID : 0; $user_ID = isset( $user_ID ) ? (int) $user_ID : 0; -$action = isset( $action ) ? $action : ''; +$action = $action ?? ''; if ( (int) get_option( 'page_for_posts' ) === $post->ID && empty( $post->post_content ) ) { add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php index 6c4efd2a50c2b..eca962e310e58 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -130,7 +130,7 @@ static function( $classes ) { wp_add_inline_script( 'wp-blocks', - sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( isset( $editor_settings['blockCategories'] ) ? $editor_settings['blockCategories'] : array() ) ), + sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( $editor_settings['blockCategories'] ?? array() ) ), 'after' ); diff --git a/src/wp-includes/block-supports/dimensions.php b/src/wp-includes/block-supports/dimensions.php index 7951f8d881a89..b0e460b662e5a 100644 --- a/src/wp-includes/block-supports/dimensions.php +++ b/src/wp-includes/block-supports/dimensions.php @@ -60,7 +60,7 @@ function wp_apply_dimensions_support( $block_type, $block_attributes ) { // phpc // Width support to be added in near future. $has_min_height_support = block_has_support( $block_type, array( 'dimensions', 'minHeight' ), false ); - $block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null; + $block_styles = $block_attributes['style'] ?? null; if ( ! $block_styles ) { return $attributes; diff --git a/src/wp-includes/block-supports/elements.php b/src/wp-includes/block-supports/elements.php index fa2536908ca6e..4be5f14f3f2fd 100644 --- a/src/wp-includes/block-supports/elements.php +++ b/src/wp-includes/block-supports/elements.php @@ -88,7 +88,7 @@ function wp_render_elements_support( $block_content, $block ) { */ function wp_render_elements_support_styles( $pre_render, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); - $element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null; + $element_block_styles = $block['attrs']['style']['elements'] ?? null; /* * For now we only care about link color. @@ -99,7 +99,7 @@ function wp_render_elements_support_styles( $pre_render, $block ) { return null; } $class_name = wp_get_elements_class_name( $block ); - $link_block_styles = isset( $element_block_styles['link'] ) ? $element_block_styles['link'] : null; + $link_block_styles = $element_block_styles['link'] ?? null; wp_style_engine_get_styles( $link_block_styles, diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 1eb1d777152ad..e497bff4ad0a3 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -235,13 +235,13 @@ function wp_register_layout_support( $block_type ) { * @return string CSS styles on success. Else, empty string. */ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em', $block_spacing = null ) { - $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default'; + $layout_type = $layout['type'] ?? 'default'; $layout_styles = array(); if ( 'default' === $layout_type ) { if ( $has_block_gap_support ) { if ( is_array( $gap_value ) ) { - $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; + $gap_value = $gap_value['top'] ?? null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { // Get spacing CSS variable from preset value if provided. @@ -271,9 +271,9 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false } } } elseif ( 'constrained' === $layout_type ) { - $content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : ''; - $wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : ''; - $justify_content = isset( $layout['justifyContent'] ) ? $layout['justifyContent'] : 'center'; + $content_size = $layout['contentSize'] ?? ''; + $wide_size = $layout['wideSize'] ?? ''; + $justify_content = $layout['justifyContent'] ?? 'center'; $all_max_width_value = $content_size ? $content_size : $wide_size; $wide_max_width_value = $wide_size ? $wide_size : $content_size; @@ -350,7 +350,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false if ( $has_block_gap_support ) { if ( is_array( $gap_value ) ) { - $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; + $gap_value = $gap_value['top'] ?? null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { // Get spacing CSS variable from preset value if provided. @@ -380,7 +380,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false } } } elseif ( 'flex' === $layout_type ) { - $layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] : 'horizontal'; + $layout_orientation = $layout['orientation'] ?? 'horizontal'; $justify_content_options = array( 'left' => 'flex-start', @@ -599,7 +599,7 @@ function wp_render_layout_support_flag( $block_content, $block ) { $global_settings = wp_get_global_settings(); $fallback_layout = ! empty( _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) ) ? _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) : _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() ); - $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $fallback_layout; + $used_layout = $block['attrs']['layout'] ?? $fallback_layout; $class_names = array(); $layout_definitions = wp_get_layout_definitions(); @@ -769,7 +769,7 @@ function wp_render_layout_support_flag( $block_content, $block ) { * @return string Filtered block content. */ function wp_restore_group_inner_container( $block_content, $block ) { - $tag_name = isset( $block['attrs']['tagName'] ) ? $block['attrs']['tagName'] : 'div'; + $tag_name = $block['attrs']['tagName'] ?? 'div'; $group_with_inner_container_regex = sprintf( '/(^\s*<%1$s\b[^>]*wp-block-group(\s|")[^>]*>)(\s*]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/U', preg_quote( $tag_name, '/' ) diff --git a/src/wp-includes/block-supports/shadow.php b/src/wp-includes/block-supports/shadow.php index 7a710c5222d92..46faa95d656ee 100644 --- a/src/wp-includes/block-supports/shadow.php +++ b/src/wp-includes/block-supports/shadow.php @@ -59,7 +59,7 @@ function wp_apply_shadow_support( $block_type, $block_attributes ) { $shadow_block_styles = array(); $preset_shadow = array_key_exists( 'shadow', $block_attributes ) ? "var:preset|shadow|{$block_attributes['shadow']}" : null; - $custom_shadow = isset( $block_attributes['style']['shadow'] ) ? $block_attributes['style']['shadow'] : null; + $custom_shadow = $block_attributes['style']['shadow'] ?? null; $shadow_block_styles['shadow'] = $preset_shadow ? $preset_shadow : $custom_shadow; $attributes = array(); diff --git a/src/wp-includes/block-supports/spacing.php b/src/wp-includes/block-supports/spacing.php index ea9b39822de1b..07ec1189692cd 100644 --- a/src/wp-includes/block-supports/spacing.php +++ b/src/wp-includes/block-supports/spacing.php @@ -52,7 +52,7 @@ function wp_apply_spacing_support( $block_type, $block_attributes ) { $attributes = array(); $has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false ); $has_margin_support = block_has_support( $block_type, array( 'spacing', 'margin' ), false ); - $block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null; + $block_styles = $block_attributes['style'] ?? null; if ( ! $block_styles ) { return $attributes; diff --git a/src/wp-includes/block-supports/typography.php b/src/wp-includes/block-supports/typography.php index 78c8b0a2ffd0d..ec1c768d9420f 100644 --- a/src/wp-includes/block-supports/typography.php +++ b/src/wp-includes/block-supports/typography.php @@ -394,11 +394,11 @@ function wp_get_typography_value_and_unit( $raw_value, $options = array() ) { * @return string|null A font-size value using clamp() on success, otherwise null. */ function wp_get_computed_fluid_typography_value( $args = array() ) { - $maximum_viewport_width_raw = isset( $args['maximum_viewport_width'] ) ? $args['maximum_viewport_width'] : null; - $minimum_viewport_width_raw = isset( $args['minimum_viewport_width'] ) ? $args['minimum_viewport_width'] : null; - $maximum_font_size_raw = isset( $args['maximum_font_size'] ) ? $args['maximum_font_size'] : null; - $minimum_font_size_raw = isset( $args['minimum_font_size'] ) ? $args['minimum_font_size'] : null; - $scale_factor = isset( $args['scale_factor'] ) ? $args['scale_factor'] : null; + $maximum_viewport_width_raw = $args['maximum_viewport_width'] ?? null; + $minimum_viewport_width_raw = $args['minimum_viewport_width'] ?? null; + $maximum_font_size_raw = $args['maximum_font_size'] ?? null; + $minimum_font_size_raw = $args['minimum_font_size'] ?? null; + $scale_factor = $args['scale_factor'] ?? null; // Normalizes the minimum font size in order to use the value for calculations. $minimum_font_size = wp_get_typography_value_and_unit( $minimum_font_size_raw ); @@ -407,7 +407,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) { * We get a 'preferred' unit to keep units consistent when calculating, * otherwise the result will not be accurate. */ - $font_size_unit = isset( $minimum_font_size['unit'] ) ? $minimum_font_size['unit'] : 'rem'; + $font_size_unit = $minimum_font_size['unit'] ?? 'rem'; // Normalizes the maximum font size in order to use the value for calculations. $maximum_font_size = wp_get_typography_value_and_unit( @@ -498,8 +498,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph // Checks if fluid font sizes are activated. $global_settings = wp_get_global_settings(); - $typography_settings = isset( $global_settings['typography'] ) ? $global_settings['typography'] : array(); - $layout_settings = isset( $global_settings['layout'] ) ? $global_settings['layout'] : array(); + $typography_settings = $global_settings['typography'] ?? array(); + $layout_settings = $global_settings['layout'] ?? array(); if ( isset( $typography_settings['fluid'] ) && @@ -517,7 +517,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph : array(); // Defaults. - $default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px'; + $default_maximum_viewport_width = $layout_settings['wideSize'] ?? '1600px'; $default_minimum_viewport_width = '320px'; $default_minimum_font_size_factor_max = 0.75; $default_minimum_font_size_factor_min = 0.25; @@ -527,7 +527,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph $default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px'; // Font sizes. - $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null; + $fluid_font_size_settings = $preset['fluid'] ?? null; // A font size has explicitly bypassed fluid calculations. if ( false === $fluid_font_size_settings ) { @@ -535,8 +535,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph } // Try to grab explicit min and max fluid font sizes. - $minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null; - $maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null; + $minimum_font_size_raw = $fluid_font_size_settings['min'] ?? null; + $maximum_font_size_raw = $fluid_font_size_settings['max'] ?? null; // Font sizes. $preferred_size = wp_get_typography_value_and_unit( $preset['size'] ); diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index c00628fc1b257..d321bc884f5c0 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -322,10 +322,10 @@ function _get_block_templates_files( $template_type, $query = array() ) { } // Prepare metadata from $query. - $slugs_to_include = isset( $query['slug__in'] ) ? $query['slug__in'] : array(); - $slugs_to_skip = isset( $query['slug__not_in'] ) ? $query['slug__not_in'] : array(); - $area = isset( $query['area'] ) ? $query['area'] : null; - $post_type = isset( $query['post_type'] ) ? $query['post_type'] : ''; + $slugs_to_include = $query['slug__in'] ?? array(); + $slugs_to_skip = $query['slug__not_in'] ?? array(); + $area = $query['area'] ?? null; + $post_type = $query['post_type'] ?? ''; $stylesheet = get_stylesheet(); $template = get_template(); @@ -954,7 +954,7 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' ) return $templates; } - $post_type = isset( $query['post_type'] ) ? $query['post_type'] : ''; + $post_type = $query['post_type'] ?? ''; $wp_query_args = array( 'post_status' => array( 'auto-draft', 'draft', 'publish' ), 'post_type' => $template_type, diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php index 794aec91203aa..0fb216d55be45 100644 --- a/src/wp-includes/block-template.php +++ b/src/wp-includes/block-template.php @@ -308,10 +308,10 @@ function _resolve_template_for_new_post( $wp_query ) { remove_filter( 'pre_get_posts', '_resolve_template_for_new_post' ); // Pages. - $page_id = isset( $wp_query->query['page_id'] ) ? $wp_query->query['page_id'] : null; + $page_id = $wp_query->query['page_id'] ?? null; // Posts, including custom post types. - $p = isset( $wp_query->query['p'] ) ? $wp_query->query['p'] : null; + $p = $wp_query->query['p'] ?? null; $post_id = $page_id ? $page_id : $p; $post = get_post( $post_id ); diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 347839f09a1e1..6b2a88c626b69 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -165,12 +165,12 @@ function register_block_script_handle( $metadata, $field_name, $index = 0 ) { } $script_asset = require $script_asset_path; - $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); + $script_dependencies = $script_asset['dependencies'] ?? array(); $result = wp_register_script( $script_handle, $script_uri, $script_dependencies, - isset( $script_asset['version'] ) ? $script_asset['version'] : false + $script_asset['version'] ?? false ); if ( ! $result ) { return false; diff --git a/src/wp-includes/class-wp-block-type.php b/src/wp-includes/class-wp-block-type.php index 1fb8894164a7b..7d4932e6dbf19 100644 --- a/src/wp-includes/class-wp-block-type.php +++ b/src/wp-includes/class-wp-block-type.php @@ -322,7 +322,7 @@ public function __get( $name ) { if ( count( $this->{$new_name} ) > 1 ) { return $this->{$new_name}; } - return isset( $this->{$new_name}[0] ) ? $this->{$new_name}[0] : null; + return $this->{$new_name}[0] ?? null; } /** diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 00172b4579de9..cc529f277c604 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1185,8 +1185,8 @@ public function get_custom_templates() { foreach ( $this->theme_json['customTemplates'] as $item ) { if ( isset( $item['name'] ) ) { $custom_templates[ $item['name'] ] = array( - 'title' => isset( $item['title'] ) ? $item['title'] : '', - 'postTypes' => isset( $item['postTypes'] ) ? $item['postTypes'] : array( 'page' ), + 'title' => $item['title'] ?? '', + 'postTypes' => $item['postTypes'] ?? array( 'page' ), ); } } @@ -1209,8 +1209,8 @@ public function get_template_parts() { foreach ( $this->theme_json['templateParts'] as $item ) { if ( isset( $item['name'] ) ) { $template_parts[ $item['name'] ] = array( - 'title' => isset( $item['title'] ) ? $item['title'] : '', - 'area' => isset( $item['area'] ) ? $item['area'] : '', + 'title' => $item['title'] ?? '', + 'area' => $item['area'] ?? '', ); } } @@ -1276,7 +1276,7 @@ protected function get_layout_styles( $block_metadata ) { } } - $selector = isset( $block_metadata['selector'] ) ? $block_metadata['selector'] : ''; + $selector = $block_metadata['selector'] ?? ''; $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; $has_fallback_gap_support = ! $has_block_gap_support; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback gap styles support. $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); @@ -2394,7 +2394,7 @@ static function( $pseudo_selector ) use ( $selector ) { ) ); - $pseudo_selector = isset( $pseudo_matches[0] ) ? $pseudo_matches[0] : null; + $pseudo_selector = $pseudo_matches[0] ?? null; /* * If the current selector is a pseudo selector that's defined in the allow list for the current @@ -2491,9 +2491,9 @@ public function get_root_layout_rules( $selector, $block_metadata ) { * as custom properties on the body element so all blocks can use them. */ if ( isset( $settings['layout']['contentSize'] ) || isset( $settings['layout']['wideSize'] ) ) { - $content_size = isset( $settings['layout']['contentSize'] ) ? $settings['layout']['contentSize'] : $settings['layout']['wideSize']; + $content_size = $settings['layout']['contentSize'] ?? $settings['layout']['wideSize']; $content_size = static::is_safe_css_declaration( 'max-width', $content_size ) ? $content_size : 'initial'; - $wide_size = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize']; + $wide_size = $settings['layout']['wideSize'] ?? $settings['layout']['contentSize']; $wide_size = static::is_safe_css_declaration( 'max-width', $wide_size ) ? $wide_size : 'initial'; $css .= '--wp--style--global--content-size: ' . $content_size . ';'; $css .= '--wp--style--global--wide-size: ' . $wide_size . ';'; @@ -3712,8 +3712,8 @@ private static function convert_variables_to_value( $styles, $values ) { $fallback, ), array( - isset( $values[ $key_in_values ] ) ? $values[ $key_in_values ] : $rule_to_replace, - isset( $values[ $fallback ] ) ? $values[ $fallback ] : $fallback, + $values[ $key_in_values ] ?? $rule_to_replace, + $values[ $fallback ] ?? $fallback, ), $resolved_style ); From a02852f29e1eaf1671d357fd1b1350f4c0d66b7e Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:33 +0100 Subject: [PATCH 06/28] Formatting: Replace some ternaries with null coalescing operator. --- src/wp-includes/formatting.php | 10 +++++----- src/wp-includes/kses.php | 2 +- src/wp-includes/shortcodes.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 9ce636edd5b1d..d73f235061fa9 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -961,7 +961,7 @@ function _wp_specialchars( $text, $quote_style = ENT_NOQUOTES, $charset = false, static $_charset = null; if ( ! isset( $_charset ) ) { $alloptions = wp_load_alloptions(); - $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; + $_charset = $alloptions['blog_charset'] ?? ''; } $charset = $_charset; } @@ -2632,8 +2632,8 @@ function force_balance_tags( $text ) { $tag_name = $regex[2]; $tag = strtolower( $tag_name ); $is_single_tag = in_array( $tag, $single_tags, true ); - $pre_attribute_ws = isset( $regex[4] ) ? $regex[4] : ''; - $attributes = trim( isset( $regex[5] ) ? $regex[5] : $regex[3] ); + $pre_attribute_ws = $regex[4] ?? ''; + $attributes = trim( $regex[5] ?? $regex[3] ); $has_self_closer = str_ends_with( $attributes, '/' ); $newtext .= $tagqueue; @@ -5256,10 +5256,10 @@ function wp_sprintf( $pattern, ...$args ) { // Find numbered arguments or take the next one in order. if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) { $index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments. - $arg = isset( $args[ $index ] ) ? $args[ $index ] : ''; + $arg = $args[ $index ] ?? ''; $fragment = str_replace( "%{$matches[1]}$", '%', $fragment ); } else { - $arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : ''; + $arg = $args[ $arg_index ] ?? ''; ++$arg_index; } diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 31bc2b5e7a921..75d425d8fadbc 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2680,7 +2680,7 @@ function _wp_kses_allow_pdf_objects( $url ) { // If the URL host matches the current site's media URL, it's safe. $upload_info = wp_upload_dir( null, false ); $parsed_url = wp_parse_url( $upload_info['url'] ); - $upload_host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : ''; + $upload_host = $parsed_url['host'] ?? ''; $upload_port = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : ''; if ( str_starts_with( $url, "http://$upload_host$upload_port/" ) diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 538b6e79daca0..4c0ec76df3d57 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -390,7 +390,7 @@ function do_shortcode_tag( $m ) { return $return; } - $content = isset( $m[5] ) ? $m[5] : null; + $content = $m[5] ?? null; $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; From ecc8fcf19a97fb8ae5669eaea477f87be8e2fd73 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:35 +0100 Subject: [PATCH 07/28] Filesystem API: Replace some ternaries with null coalescing operator. --- src/wp-admin/includes/file.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index b9f58b32a7099..ed39aa041d444 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -908,12 +908,12 @@ function wp_handle_upload_error( &$file, $message ) { } // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false; - $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true; - $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true; + $test_form = $overrides['test_form'] ?? true; + $test_size = $overrides['test_size'] ?? true; // If you override this, you must provide $ext and $type!! - $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true; - $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : null; + $test_type = $overrides['test_type'] ?? true; + $mimes = $overrides['mimes'] ?? null; // A correct form post will pass this test. if ( $test_form && ( ! isset( $_POST['action'] ) || $_POST['action'] !== $action ) ) { @@ -2414,12 +2414,12 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false, return $credentials; } - $hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : ''; - $username = isset( $credentials['username'] ) ? $credentials['username'] : ''; - $public_key = isset( $credentials['public_key'] ) ? $credentials['public_key'] : ''; - $private_key = isset( $credentials['private_key'] ) ? $credentials['private_key'] : ''; - $port = isset( $credentials['port'] ) ? $credentials['port'] : ''; - $connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : ''; + $hostname = $credentials['hostname'] ?? ''; + $username = $credentials['username'] ?? ''; + $public_key = $credentials['public_key'] ?? ''; + $private_key = $credentials['private_key'] ?? ''; + $port = $credentials['port'] ?? ''; + $connection_type = $credentials['connection_type'] ?? ''; if ( $error ) { $error_string = __( 'Error: Could not connect to the server. Please verify the settings are correct.' ); From 6e30d28a4866517081f196ae70b988112cd080e2 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:37 +0100 Subject: [PATCH 08/28] General: Replace some ternaries with null coalescing operator. --- src/wp-includes/functions.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index adf8b86170f15..b2f1878868179 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -945,7 +945,7 @@ function do_enclose( $content, $post ) { $headers = wp_get_http_headers( $url ); if ( $headers ) { $len = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0; - $type = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : ''; + $type = $headers['Content-Type'] ?? ''; $allowed_types = array( 'video', 'audio' ); // Check to see if we can figure out the mime type from the extension. @@ -3297,7 +3297,7 @@ function wp_get_image_mime( $file ) { $imagesize = @getimagesize( $file ); } - $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; + $mime = $imagesize['mime'] ?? false; } else { $mime = false; } @@ -3591,7 +3591,7 @@ function wp_nonce_ays( $action ) { get_bloginfo( 'name' ) ); - $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; + $redirect_to = $_REQUEST['redirect_to'] ?? ''; $html = $title; $html .= '

      '; @@ -5935,8 +5935,8 @@ function _doing_it_wrong( $function_name, $message, $version ) { * @return bool Whether the server is running lighttpd < 1.5.0. */ function is_lighttpd_before_150() { - $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' ); - $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : ''; + $server_parts = explode( '/', $_SERVER['SERVER_SOFTWARE'] ?? '' ); + $server_parts[1] = $server_parts[1] ?? ''; return ( 'lighttpd' === $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ) ); } @@ -6902,9 +6902,9 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar while ( $tortoise && - ( $evanescent_hare = isset( $override[ $hare ] ) ? $override[ $hare ] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) + ( $evanescent_hare = $override[ $hare ] ?? call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) && - ( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) + ( $hare = $override[ $evanescent_hare ] ?? call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) ) { if ( $_return_loop ) { $return[ $tortoise ] = true; @@ -6918,7 +6918,7 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar } // Increment tortoise by one step. - $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); + $tortoise = $override[ $tortoise ] ?? call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); } return false; @@ -7019,7 +7019,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) { $caller[] = "{$call['function']}('{$call['args'][0]}')"; } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) { - $filename = isset( $call['args'][0] ) ? $call['args'][0] : ''; + $filename = $call['args'][0] ?? ''; $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')"; } else { $caller[] = $call['function']; From 778318e6c5e51cb59fcd297074e1c880cbd25509 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:39 +0100 Subject: [PATCH 09/28] HTTP: Replace some ternaries with null coalescing operator. --- src/wp-includes/class-wp-http-cookie.php | 10 +++++----- src/wp-includes/class-wp-http-ixr-client.php | 2 +- src/wp-includes/class-wp-http-requests-response.php | 8 ++++---- src/wp-includes/class-wp-http.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/wp-includes/class-wp-http-cookie.php b/src/wp-includes/class-wp-http-cookie.php index 8f55e4486cfda..cfdf4da1dd2c6 100644 --- a/src/wp-includes/class-wp-http-cookie.php +++ b/src/wp-includes/class-wp-http-cookie.php @@ -114,7 +114,7 @@ public function __construct( $data, $requested_url = '' ) { if ( isset( $parsed_url['host'] ) ) { $this->domain = $parsed_url['host']; } - $this->path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '/'; + $this->path = $parsed_url['path'] ?? '/'; if ( ! str_ends_with( $this->path, '/' ) ) { $this->path = dirname( $this->path ) . '/'; } @@ -190,12 +190,12 @@ public function test( $url ) { // Get details on the URL we're thinking about sending to. $url = parse_url( $url ); - $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' === $url['scheme'] ? 443 : 80 ); - $url['path'] = isset( $url['path'] ) ? $url['path'] : '/'; + $url['port'] = $url['port'] ?? ( 'https' === $url['scheme'] ? 443 : 80 ); + $url['path'] = $url['path'] ?? '/'; // Values to use for comparison against the URL. - $path = isset( $this->path ) ? $this->path : '/'; - $port = isset( $this->port ) ? $this->port : null; + $path = $this->path ?? '/'; + $port = $this->port ?? null; $domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] ); if ( false === stripos( $domain, '.' ) ) { $domain .= '.local'; diff --git a/src/wp-includes/class-wp-http-ixr-client.php b/src/wp-includes/class-wp-http-ixr-client.php index d45ca150eb2a6..41d31ca9d14ae 100644 --- a/src/wp-includes/class-wp-http-ixr-client.php +++ b/src/wp-includes/class-wp-http-ixr-client.php @@ -25,7 +25,7 @@ public function __construct( $server, $path = false, $port = false, $timeout = 1 $bits = parse_url( $server ); $this->scheme = $bits['scheme']; $this->server = $bits['host']; - $this->port = isset( $bits['port'] ) ? $bits['port'] : $port; + $this->port = $bits['port'] ?? $port; $this->path = ! empty( $bits['path'] ) ? $bits['path'] : '/'; // Make absolutely sure we have a path. diff --git a/src/wp-includes/class-wp-http-requests-response.php b/src/wp-includes/class-wp-http-requests-response.php index 821077656c84b..943a208f60aab 100644 --- a/src/wp-includes/class-wp-http-requests-response.php +++ b/src/wp-includes/class-wp-http-requests-response.php @@ -164,10 +164,10 @@ public function get_cookies() { array( 'name' => $cookie->name, 'value' => urldecode( $cookie->value ), - 'expires' => isset( $cookie->attributes['expires'] ) ? $cookie->attributes['expires'] : null, - 'path' => isset( $cookie->attributes['path'] ) ? $cookie->attributes['path'] : null, - 'domain' => isset( $cookie->attributes['domain'] ) ? $cookie->attributes['domain'] : null, - 'host_only' => isset( $cookie->flags['host-only'] ) ? $cookie->flags['host-only'] : null, + 'expires' => $cookie->attributes['expires'] ?? null, + 'path' => $cookie->attributes['path'] ?? null, + 'domain' => $cookie->attributes['domain'] ?? null, + 'host_only' => $cookie->flags['host-only'] ?? null, ) ); } diff --git a/src/wp-includes/class-wp-http.php b/src/wp-includes/class-wp-http.php index e1d37878a140f..1ddc58f8c3664 100644 --- a/src/wp-includes/class-wp-http.php +++ b/src/wp-includes/class-wp-http.php @@ -670,7 +670,7 @@ public static function processResponse( $response ) { // phpcs:ignore WordPress. return array( 'headers' => $response[0], - 'body' => isset( $response[1] ) ? $response[1] : '', + 'body' => $response[1] ?? '', ); } From 7573156bca4b6f6a1319a7de59be378ff8b16a28 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:42 +0100 Subject: [PATCH 10/28] I18N: Replace some ternaries with null coalescing operator. --- src/wp-includes/pomo/po.php | 2 +- src/wp-includes/pomo/translations.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index 89d827c2550b9..b7bbd6eb7dfea 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -166,7 +166,7 @@ public static function unpoify( $input_string ) { } } else { $previous_is_backslash = false; - $unpoified .= isset( $escapes[ $char ] ) ? $escapes[ $char ] : $char; + $unpoified .= $escapes[ $char ] ?? $char; } } } diff --git a/src/wp-includes/pomo/translations.php b/src/wp-includes/pomo/translations.php index d3a1d3cbd09a9..cdebeb443c837 100644 --- a/src/wp-includes/pomo/translations.php +++ b/src/wp-includes/pomo/translations.php @@ -81,7 +81,7 @@ public function set_headers( $headers ) { * @param string $header */ public function get_header( $header ) { - return isset( $this->headers[ $header ] ) ? $this->headers[ $header ] : false; + return $this->headers[ $header ] ?? false; } /** @@ -89,7 +89,7 @@ public function get_header( $header ) { */ public function translate_entry( &$entry ) { $key = $entry->key(); - return isset( $this->entries[ $key ] ) ? $this->entries[ $key ] : false; + return $this->entries[ $key ] ?? false; } /** From 9b00d0499e3218267a9c3a5247b41b08f73fd4ea Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:43 +0100 Subject: [PATCH 11/28] Media: Replace some ternaries with null coalescing operator. --- .../includes/class-custom-image-header.php | 6 +++--- .../includes/class-wp-media-list-table.php | 2 +- src/wp-admin/includes/image-edit.php | 8 ++++---- src/wp-admin/includes/media.php | 14 +++++++------- src/wp-admin/upload.php | 4 ++-- src/wp-includes/embed.php | 2 +- src/wp-includes/media.php | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/wp-admin/includes/class-custom-image-header.php b/src/wp-admin/includes/class-custom-image-header.php index f1361440fa9cd..cf8c2ee3f07ff 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -1338,7 +1338,7 @@ final public function create_attachment_object( $cropped, $parent_attachment_id * @return int Attachment ID. */ final public function insert_attachment( $attachment, $cropped ) { - $parent_id = isset( $attachment['post_parent'] ) ? $attachment['post_parent'] : null; + $parent_id = $attachment['post_parent'] ?? null; unset( $attachment['post_parent'] ); $attachment_id = wp_insert_attachment( $attachment, $cropped ); @@ -1571,8 +1571,8 @@ public function get_uploaded_header_images() { foreach ( $header_images as &$header_image ) { $header_meta = get_post_meta( $header_image['attachment_id'] ); - $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; - $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; + $header_image['timestamp'] = $header_meta[ $timestamp_key ] ?? ''; + $header_image['alt_text'] = $header_meta[ $alt_text_key ] ?? ''; } return $header_images; diff --git a/src/wp-admin/includes/class-wp-media-list-table.php b/src/wp-admin/includes/class-wp-media-list-table.php index 68dc685cf9233..e87061351f18d 100644 --- a/src/wp-admin/includes/class-wp-media-list-table.php +++ b/src/wp-admin/includes/class-wp-media-list-table.php @@ -47,7 +47,7 @@ public function __construct( $args = array() ) { parent::__construct( array( 'plural' => 'media', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); } diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index 72a6d07c0193e..d8e22dbba6661 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -108,8 +108,8 @@ function wp_image_editor( $post_id, $msg = false ) { - - + +

      @@ -153,10 +153,10 @@ function wp_image_editor( $post_id, $msg = false ) { _e( 'scale height' ); ?> - + - +
      diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 0910693fc9810..13a01b9014611 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -830,7 +830,7 @@ function media_upload_form_handler() { if ( isset( $send_id ) ) { $attachment = wp_unslash( $_POST['attachments'][ $send_id ] ); - $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; + $html = $attachment['post_title'] ?? ''; if ( ! empty( $attachment['url'] ) ) { $rel = ''; @@ -1556,7 +1556,7 @@ function get_media_items( $post_id, $errors ) { continue; } - $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) ); + $item = get_media_item( $id, array( 'errors' => $errors[ $id ] ?? null ) ); if ( $item ) { $output .= "\n
      $item\n
      "; @@ -2102,8 +2102,8 @@ function media_upload_form( $errors = null ) { $upload_action_url = admin_url( 'async-upload.php' ); $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0; - $_type = isset( $type ) ? $type : ''; - $_tab = isset( $tab ) ? $tab : ''; + $_type = $type ?? ''; + $_tab = $tab ?? ''; $max_upload_size = wp_max_upload_size(); if ( ! $max_upload_size ) { @@ -2845,7 +2845,7 @@ function media_upload_library_form( $errors ) { $arc_result = $wpdb->get_results( $arc_query ); $month_count = count( $arc_result ); - $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; + $selected_month = $_GET['m'] ?? 0; if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> @@ -3640,7 +3640,7 @@ function wp_read_video_metadata( $file ) { wp_add_id3_tag_data( $metadata, $data ); - $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null; + $file_format = $metadata['fileformat'] ?? null; /** * Filters the array of metadata retrieved from a video. @@ -3723,7 +3723,7 @@ function wp_read_audio_metadata( $file ) { wp_add_id3_tag_data( $metadata, $data ); - $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null; + $file_format = $metadata['fileformat'] ?? null; /** * Filters the array of metadata retrieved from an audio file. diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index 29a8c4de8d193..7ab16e4378e4c 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -87,7 +87,7 @@ $message .= sprintf( ' %2$s', - esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ), + esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( $_GET['ids'] ?? '' ), 'bulk-media' ) ), __( 'Undo' ) ); @@ -117,7 +117,7 @@ $messages[3] = __( 'Error saving media file.' ); $messages[4] = __( 'Media file moved to the Trash.' ) . sprintf( ' %2$s', - esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ), + esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( $_GET['ids'] ?? '' ), 'bulk-media' ) ), __( 'Undo' ) ); $messages[5] = __( 'Media file restored from the Trash.' ); diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index d75939cce6b56..65cd3b8e1282e 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -674,7 +674,7 @@ function get_oembed_response_data_for_url( $url, $args ) { return false; } - $width = isset( $args['width'] ) ? $args['width'] : 0; + $width = $args['width'] ?? 0; $data = get_oembed_response_data( $post_id, $width ); diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index db5565e385678..d1b17a4558480 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -1166,7 +1166,7 @@ function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f */ function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) { $image = wp_get_attachment_image_src( $attachment_id, $size, $icon ); - return isset( $image[0] ) ? $image[0] : false; + return $image[0] ?? false; } /** @@ -1986,7 +1986,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) { */ $filtered_loading_attr = apply_filters( 'wp_img_tag_add_loading_attr', - isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false, + $optimization_attrs['loading'] ?? false, $image, $context ); @@ -2005,7 +2005,7 @@ function wp_img_tag_add_loading_optimization_attrs( $image, $context ) { * is only intended for the specific scenario where the above filtered caused the problem. */ if ( isset( $optimization_attrs['fetchpriority'] ) && 'high' === $optimization_attrs['fetchpriority'] && - ( isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false ) !== $filtered_loading_attr && + ( $optimization_attrs['loading'] ?? false ) !== $filtered_loading_attr && 'lazy' === $filtered_loading_attr ) { _doing_it_wrong( @@ -2204,7 +2204,7 @@ function wp_iframe_tag_add_loading_attr( $iframe, $context ) { return $iframe; } - $value = isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false; + $value = $optimization_attrs['loading'] ?? false; /** * Filters the `loading` attribute value to add to an iframe. Default `lazy`. From 5bcd2f2265b20296eacd05003e56a29aa91b0edd Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:45 +0100 Subject: [PATCH 12/28] Menus: Replace some ternaries with null coalescing operator. --- src/wp-admin/includes/nav-menu.php | 36 +++++++++++++++--------------- src/wp-admin/nav-menus.php | 2 +- src/wp-includes/nav-menu.php | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 1ace5cdd43618..55c0ca1dc9310 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -22,10 +22,10 @@ */ function _wp_ajax_menu_quick_search( $request = array() ) { $args = array(); - $type = isset( $request['type'] ) ? $request['type'] : ''; - $object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; - $query = isset( $request['q'] ) ? $request['q'] : ''; - $response_format = isset( $request['response-format'] ) ? $request['response-format'] : ''; + $type = $request['type'] ?? ''; + $object_type = $request['object_type'] ?? ''; + $query = $request['q'] ?? ''; + $response_format = $request['response-format'] ?? ''; if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) { $response_format = 'json'; @@ -1166,19 +1166,19 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { } $args = array( - 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), - 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), - 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), - 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), - 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), - 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), - 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), - 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), - 'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), - 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), - 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), - 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), - 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), + 'menu-item-db-id' => $_item_object_data['menu-item-db-id'] ?? '', + 'menu-item-object-id' => $_item_object_data['menu-item-object-id'] ?? '', + 'menu-item-object' => $_item_object_data['menu-item-object'] ?? '', + 'menu-item-parent-id' => $_item_object_data['menu-item-parent-id'] ?? '', + 'menu-item-position' => $_item_object_data['menu-item-position'] ?? '', + 'menu-item-type' => $_item_object_data['menu-item-type'] ?? '', + 'menu-item-title' => $_item_object_data['menu-item-title'] ?? '', + 'menu-item-url' => $_item_object_data['menu-item-url'] ?? '', + 'menu-item-description' => $_item_object_data['menu-item-description'] ?? '', + 'menu-item-attr-title' => $_item_object_data['menu-item-attr-title'] ?? '', + 'menu-item-target' => $_item_object_data['menu-item-target'] ?? '', + 'menu-item-classes' => $_item_object_data['menu-item-classes'] ?? '', + 'menu-item-xfn' => $_item_object_data['menu-item-xfn'] ?? '', ); $items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args ); @@ -1422,7 +1422,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte $args = array(); foreach ( $post_fields as $field ) { - $args[ $field ] = isset( $_POST[ $field ][ $_key ] ) ? $_POST[ $field ][ $_key ] : ''; + $args[ $field ] = $_POST[ $field ][ $_key ] ?? ''; } $menu_item_db_id = wp_update_nav_menu_item( diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index 1758bfe221e1c..3ac33de322e25 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -52,7 +52,7 @@ $num_locations = count( array_keys( $locations ) ); // Allowed actions: add, update, delete. -$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; +$action = $_REQUEST['action'] ?? 'edit'; /* * If a JSON blob of navigation menu data is found, expand it and inject it diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index b43e45601cb81..6d91bab880b8e 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -319,8 +319,8 @@ function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { $_menu = wp_get_nav_menu_object( $menu_id ); $args = array( - 'description' => ( isset( $menu_data['description'] ) ? $menu_data['description'] : '' ), - 'name' => ( isset( $menu_data['menu-name'] ) ? $menu_data['menu-name'] : '' ), + 'description' => $menu_data['description'] ?? '', + 'name' => $menu_data['menu-name'] ?? '', 'parent' => ( isset( $menu_data['parent'] ) ? (int) $menu_data['parent'] : 0 ), 'slug' => null, ); From c76d3a6c9f3ead85988bf9e208528289440501c4 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:46 +0100 Subject: [PATCH 13/28] Multisite: Replace some ternaries with null coalescing operator. --- .../includes/class-wp-ms-sites-list-table.php | 4 ++-- .../includes/class-wp-ms-themes-list-table.php | 6 +++--- .../includes/class-wp-ms-users-list-table.php | 2 +- src/wp-admin/my-sites.php | 2 +- src/wp-admin/network/edit.php | 2 +- src/wp-admin/network/site-themes.php | 2 +- src/wp-admin/network/themes.php | 2 +- src/wp-admin/network/upgrade.php | 2 +- src/wp-includes/class-wp-network-query.php | 12 ++++++------ src/wp-includes/class-wp-site-query.php | 12 ++++++------ 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php index ec48bf37c7b26..7d5f9248b0ffb 100644 --- a/src/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -44,7 +44,7 @@ public function __construct( $args = array() ) { parent::__construct( array( 'plural' => 'sites', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); } @@ -135,7 +135,7 @@ public function prepare_items() { } } - $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; + $order_by = $_REQUEST['orderby'] ?? ''; if ( 'registered' === $order_by ) { // 'registered' is a valid field name. } elseif ( 'lastupdated' === $order_by ) { diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php index 6dfe3fe71d07b..ee511484ba725 100644 --- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -48,11 +48,11 @@ public function __construct( $args = array() ) { parent::__construct( array( 'plural' => 'themes', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); - $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; + $status = $_REQUEST['theme_status'] ?? 'all'; if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled' ), true ) ) { $status = 'all'; } @@ -151,7 +151,7 @@ public function prepare_items() { $themes[ $filter ][ $key ] = $themes['all'][ $key ]; $theme_data = array( - 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true, + 'update_supported' => $theme->update_supported ?? true, ); // Extra info if known. array_merge() ensures $theme_data has precedence if keys collide. diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index 2e6772f69d1d3..0085a000ed76a 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -41,7 +41,7 @@ public function prepare_items() { $users_per_page = $this->get_items_per_page( 'users_network_per_page' ); - $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; + $role = $_REQUEST['role'] ?? ''; $paged = $this->get_pagenum(); diff --git a/src/wp-admin/my-sites.php b/src/wp-admin/my-sites.php index e395579ea2a89..5754acb967454 100644 --- a/src/wp-admin/my-sites.php +++ b/src/wp-admin/my-sites.php @@ -17,7 +17,7 @@ wp_die( __( 'Sorry, you are not allowed to access this page.' ) ); } -$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash'; +$action = $_POST['action'] ?? 'splash'; $blogs = get_blogs_of_user( $current_user->ID ); diff --git a/src/wp-admin/network/edit.php b/src/wp-admin/network/edit.php index f46896bd2b5be..f12251babeeb3 100644 --- a/src/wp-admin/network/edit.php +++ b/src/wp-admin/network/edit.php @@ -10,7 +10,7 @@ /** Load WordPress Administration Bootstrap */ require_once __DIR__ . '/admin.php'; -$action = ( isset( $_GET['action'] ) ) ? $_GET['action'] : ''; +$action = $_GET['action'] ?? ''; if ( empty( $action ) ) { wp_redirect( network_admin_url() ); diff --git a/src/wp-admin/network/site-themes.php b/src/wp-admin/network/site-themes.php index abca9f97209cc..3cdad8621afb7 100644 --- a/src/wp-admin/network/site-themes.php +++ b/src/wp-admin/network/site-themes.php @@ -29,7 +29,7 @@ $action = $wp_list_table->current_action(); -$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; +$s = $_REQUEST['s'] ?? ''; // Clean up request URI from temporary args for screen options/paging uri's to work as expected. $temp_args = array( 'enabled', 'disabled', 'error' ); diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php index 1ad21e97380cd..f2e96b502e1d4 100644 --- a/src/wp-admin/network/themes.php +++ b/src/wp-admin/network/themes.php @@ -19,7 +19,7 @@ $action = $wp_list_table->current_action(); -$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; +$s = $_REQUEST['s'] ?? ''; // Clean up request URI from temporary args for screen options/paging uri's to work as expected. $temp_args = array( diff --git a/src/wp-admin/network/upgrade.php b/src/wp-admin/network/upgrade.php index 55cbedd643c5a..665542d3ea05c 100644 --- a/src/wp-admin/network/upgrade.php +++ b/src/wp-admin/network/upgrade.php @@ -42,7 +42,7 @@ echo '
      '; echo '

      ' . __( 'Upgrade Network' ) . '

      '; -$action = isset( $_GET['action'] ) ? $_GET['action'] : 'show'; +$action = $_GET['action'] ?? 'show'; switch ( $action ) { case 'upgrade': diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php index 7199ec03a1a15..6ef17816dbd86 100644 --- a/src/wp-includes/class-wp-network-query.php +++ b/src/wp-includes/class-wp-network-query.php @@ -451,12 +451,12 @@ protected function get_network_ids() { */ $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) ); - $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; - $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; - $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; - $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : ''; - $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : ''; - $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; + $fields = $clauses['fields'] ?? ''; + $join = $clauses['join'] ?? ''; + $where = $clauses['where'] ?? ''; + $orderby = $clauses['orderby'] ?? ''; + $limits = $clauses['limits'] ?? ''; + $groupby = $clauses['groupby'] ?? ''; if ( $where ) { $where = 'WHERE ' . $where; diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php index 6598866162445..e716be3e0dccb 100644 --- a/src/wp-includes/class-wp-site-query.php +++ b/src/wp-includes/class-wp-site-query.php @@ -665,12 +665,12 @@ protected function get_site_ids() { */ $clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) ); - $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; - $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; - $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; - $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : ''; - $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : ''; - $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; + $fields = $clauses['fields'] ?? ''; + $join = $clauses['join'] ?? ''; + $where = $clauses['where'] ?? ''; + $orderby = $clauses['orderby'] ?? ''; + $limits = $clauses['limits'] ?? ''; + $groupby = $clauses['groupby'] ?? ''; if ( $where ) { $where = 'WHERE ' . $where; From b2c918d0ca2397f12fee58232cea47e140f6c69f Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:48 +0100 Subject: [PATCH 14/28] Options, Meta APIs: Replace some ternaries with null coalescing operator. --- src/wp-includes/option.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index 5d7cbc0b154c1..0e1446e1da82b 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -1185,7 +1185,7 @@ function wp_user_settings() { function get_user_setting( $name, $default_value = false ) { $all_user_settings = get_all_user_settings(); - return isset( $all_user_settings[ $name ] ) ? $all_user_settings[ $name ] : $default_value; + return $all_user_settings[ $name ] ?? $default_value; } /** From 8b168050458d64a2a00fb88e378bec2612f95b5b Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:50 +0100 Subject: [PATCH 15/28] Permalinks: Replace some ternaries with null coalescing operator. --- src/wp-includes/rewrite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php index 647977cc2041e..83dca2c43ddb8 100644 --- a/src/wp-includes/rewrite.php +++ b/src/wp-includes/rewrite.php @@ -579,7 +579,7 @@ function url_to_postid( $url ) { } else { // Chop off /path/to/blog. $home_path = parse_url( home_url( '/' ) ); - $home_path = isset( $home_path['path'] ) ? $home_path['path'] : ''; + $home_path = $home_path['path'] ?? ''; $url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) ); } From 7c13627975362b622dccd7940b4c968acd6ccc8e Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:51 +0100 Subject: [PATCH 16/28] Plugins: Replace some ternaries with null coalescing operator. --- .../includes/class-wp-plugin-install-list-table.php | 4 ++-- src/wp-admin/includes/class-wp-plugins-list-table.php | 8 ++++---- src/wp-admin/includes/plugin-install.php | 4 ++-- src/wp-includes/class-wp-hook.php | 2 +- src/wp-includes/pluggable.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php index 527e929cb05f1..9e6dd6dfd1402 100644 --- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -539,8 +539,8 @@ public function display_rows() { $author = ' ' . sprintf( __( 'By %s' ), $author ) . ''; } - $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null; - $requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null; + $requires_php = $plugin['requires_php'] ?? null; + $requires_wp = $plugin['requires'] ?? null; $compatible_php = is_php_version_compatible( $requires_php ); $compatible_wp = is_wp_version_compatible( $requires_wp ); diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index 56e76251dacc3..3fdbd02dddea1 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -42,7 +42,7 @@ public function __construct( $args = array() ) { parent::__construct( array( 'plural' => 'plugins', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); @@ -721,7 +721,7 @@ public function single_row( $item ) { list( $plugin_file, $plugin_data ) = $item; - $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_data['Name'] ); + $plugin_slug = $plugin_data['slug'] ?? sanitize_title( $plugin_data['Name'] ); $plugin_id_attr = $plugin_slug; // Ensure the ID attribute is unique. @@ -748,8 +748,8 @@ public function single_row( $item ) { $restrict_network_active = false; $restrict_network_only = false; - $requires_php = isset( $plugin_data['RequiresPHP'] ) ? $plugin_data['RequiresPHP'] : null; - $requires_wp = isset( $plugin_data['RequiresWP'] ) ? $plugin_data['RequiresWP'] : null; + $requires_php = $plugin_data['RequiresPHP'] ?? null; + $requires_wp = $plugin_data['RequiresWP'] ?? null; $compatible_php = is_php_version_compatible( $requires_php ); $compatible_wp = is_wp_version_compatible( $requires_wp ); diff --git a/src/wp-admin/includes/plugin-install.php b/src/wp-admin/includes/plugin-install.php index e2c8de32f883e..6406a2c9df9a4 100644 --- a/src/wp-admin/includes/plugin-install.php +++ b/src/wp-admin/includes/plugin-install.php @@ -809,8 +809,8 @@ function install_plugin_information() {
      requires_php ) ? $api->requires_php : null; - $requires_wp = isset( $api->requires ) ? $api->requires : null; + $requires_php = $api->requires_php ?? null; + $requires_wp = $api->requires ?? null; $compatible_php = is_php_version_compatible( $requires_php ); $compatible_wp = is_wp_version_compatible( $requires_wp ); diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php index 0f7dc4b7a3be6..89e7994fc497d 100644 --- a/src/wp-includes/class-wp-hook.php +++ b/src/wp-includes/class-wp-hook.php @@ -461,7 +461,7 @@ public function offsetExists( $offset ) { */ #[ReturnTypeWillChange] public function offsetGet( $offset ) { - return isset( $this->callbacks[ $offset ] ) ? $this->callbacks[ $offset ] : null; + return $this->callbacks[ $offset ] ?? null; } /** diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index ea422fce2f9e0..698cb828f8bc1 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -1622,7 +1622,7 @@ function wp_validate_redirect( $location, $fallback_url = '' ) { * @param string[] $hosts An array of allowed host names. * @param string $host The host name of the redirect destination; empty string if not set. */ - $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' ); + $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), $lp['host'] ?? '' ); if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) { $location = $fallback_url; From 69272376fe95713ab90e06ee2cf36adc1a7d9aa2 Mon Sep 17 00:00:00 2001 From: costdev Date: Sat, 22 Jul 2023 06:26:53 +0100 Subject: [PATCH 17/28] Posts, Post Types: Replace some ternaries with null coalescing operator. --- src/wp-admin/includes/class-wp-posts-list-table.php | 6 +++--- src/wp-admin/includes/post.php | 6 +++--- src/wp-includes/post-formats.php | 2 +- src/wp-includes/post-template.php | 10 +++++----- src/wp-includes/post.php | 12 ++++++------ src/wp-includes/revision.php | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index f3ef1d8e3102a..960df869c4c5e 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -76,7 +76,7 @@ public function __construct( $args = array() ) { parent::__construct( array( 'plural' => 'posts', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + 'screen' => $args['screen'] ?? null, ) ); @@ -532,7 +532,7 @@ protected function formats_dropdown( $post_type ) { return; } - $displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : ''; + $displayed_post_format = $_GET['post_format'] ?? ''; ?>