diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 12432e0140b1f..45849eb595f9c 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -344,12 +344,7 @@ public function get_pagination_arg( $key ) { if ( 'page' === $key ) { return $this->get_pagenum(); } - - if ( isset( $this->_pagination_args[ $key ] ) ) { - return $this->_pagination_args[ $key ]; - } - - return 0; + return $this->_pagination_args[ $key ] ?? 0; } /** diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index 62b29d51bdb4e..6bb8681cc612d 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -554,10 +554,7 @@ public function get_option( $option, $key = false ) { return null; } if ( $key ) { - if ( isset( $this->_options[ $option ][ $key ] ) ) { - return $this->_options[ $option ][ $key ]; - } - return null; + return $this->_options[ $option ][ $key ] ?? null; } return $this->_options[ $option ]; } diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index a3e5742d00283..610125b252ec0 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -1097,11 +1097,7 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) { * $_POST['action'] must be set and its value must equal $overrides['action'] * or this: */ - $action = 'wp_handle_upload'; - if ( isset( $overrides['action'] ) ) { - $action = $overrides['action']; - } - + $action = $overrides['action'] ?? 'wp_handle_upload'; return _wp_handle_upload( $file, $overrides, $time, $action ); } @@ -1128,11 +1124,7 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) { * $_POST['action'] must be set and its value must equal $overrides['action'] * or this: */ - $action = 'wp_handle_sideload'; - if ( isset( $overrides['action'] ) ) { - $action = $overrides['action']; - } - + $action = $overrides['action'] ?? 'wp_handle_sideload'; return _wp_handle_upload( $file, $overrides, $time, $action ); } diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index a9ca5553ad74b..460874ca52181 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -1971,44 +1971,25 @@ function get_admin_page_parent( $parent_page = '' ) { $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) { - if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) { - $parent_page = $_wp_real_parent_file[ $parent_page ]; - } - - return $parent_page; + return $_wp_real_parent_file[ $parent_page ] ?? $parent_page; } if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) { foreach ( (array) $menu as $parent_menu ) { if ( $parent_menu[2] === $plugin_page ) { $parent_file = $plugin_page; - - if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) { - $parent_file = $_wp_real_parent_file[ $parent_file ]; - } - - return $parent_file; + return $_wp_real_parent_file[ $parent_file ] ?? $parent_file; } } if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) ) { $parent_file = $plugin_page; - - if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) { - $parent_file = $_wp_real_parent_file[ $parent_file ]; - } - - return $parent_file; + return $_wp_real_parent_file[ $parent_file ] ?? $parent_file; } } if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) { $parent_file = $pagenow; - - if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) { - $parent_file = $_wp_real_parent_file[ $parent_file ]; - } - - return $parent_file; + return $_wp_real_parent_file[ $parent_file ] ?? $parent_file; } foreach ( array_keys( (array) $submenu ) as $parent_page ) { diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 60c799898580a..9efdb30157235 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -170,10 +170,7 @@ public function get_all_registered() { * @return array[] Array whose keys are block style names and whose values are block style properties. */ public function get_registered_styles_for_block( $block_name ) { - if ( isset( $this->registered_block_styles[ $block_name ] ) ) { - return $this->registered_block_styles[ $block_name ]; - } - return array(); + return $this->registered_block_styles[ $block_name ] ?? array(); } /** diff --git a/src/wp-includes/class-wp-comment.php b/src/wp-includes/class-wp-comment.php index b42523da375f7..db5ebcd2cf770 100644 --- a/src/wp-includes/class-wp-comment.php +++ b/src/wp-includes/class-wp-comment.php @@ -323,11 +323,7 @@ public function add_child( WP_Comment $child ) { * @return WP_Comment|false Returns the comment object if found, otherwise false. */ public function get_child( $child_id ) { - if ( isset( $this->children[ $child_id ] ) ) { - return $this->children[ $child_id ]; - } - - return false; + return $this->children[ $child_id ] ?? false; } /** diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index c3dc40bc88141..a3182c8697d50 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -477,10 +477,7 @@ public function query( $handle, $status = 'registered' ) { switch ( $status ) { case 'registered': case 'scripts': // Back compat. - if ( isset( $this->registered[ $handle ] ) ) { - return $this->registered[ $handle ]; - } - return false; + return $this->registered[ $handle ] ?? false; case 'enqueued': case 'queue': // Back compat. diff --git a/src/wp-includes/class-wp-plugin-dependencies.php b/src/wp-includes/class-wp-plugin-dependencies.php index e4dc4b0f40c0c..67110a8fd2374 100644 --- a/src/wp-includes/class-wp-plugin-dependencies.php +++ b/src/wp-includes/class-wp-plugin-dependencies.php @@ -200,11 +200,7 @@ public static function get_dependents( $slug ) { * @return array An array of dependency plugin slugs. */ public static function get_dependencies( $plugin_file ) { - if ( isset( self::$dependencies[ $plugin_file ] ) ) { - return self::$dependencies[ $plugin_file ]; - } - - return array(); + return self::$dependencies[ $plugin_file ] ?? array(); } /** @@ -354,12 +350,7 @@ public static function get_dependency_filepath( $slug ) { */ public static function get_dependency_data( $slug ) { $dependency_api_data = self::get_dependency_api_data(); - - if ( isset( $dependency_api_data[ $slug ] ) ) { - return $dependency_api_data[ $slug ]; - } - - return false; + return $dependency_api_data[ $slug ] ?? false; } /** diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index ad2dda78271a8..8edcf80b54400 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -1860,11 +1860,7 @@ public function set_404() { * @return mixed Contents of the query variable. */ public function get( $query_var, $default_value = '' ) { - if ( isset( $this->query_vars[ $query_var ] ) ) { - return $this->query_vars[ $query_var ]; - } - - return $default_value; + return $this->query_vars[ $query_var ] ?? $default_value; } /** @@ -4066,12 +4062,7 @@ public function get_queried_object() { */ public function get_queried_object_id() { $this->get_queried_object(); - - if ( isset( $this->queried_object_id ) ) { - return $this->queried_object_id; - } - - return 0; + return $this->queried_object_id ?? 0; } /** diff --git a/src/wp-includes/class-wp-user-meta-session-tokens.php b/src/wp-includes/class-wp-user-meta-session-tokens.php index ecbb23d4e871c..0a3961803ad1a 100644 --- a/src/wp-includes/class-wp-user-meta-session-tokens.php +++ b/src/wp-includes/class-wp-user-meta-session-tokens.php @@ -60,12 +60,7 @@ protected function prepare_session( $session ) { */ protected function get_session( $verifier ) { $sessions = $this->get_sessions(); - - if ( isset( $sessions[ $verifier ] ) ) { - return $sessions[ $verifier ]; - } - - return null; + return $sessions[ $verifier ] ?? null; } /** diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index d704dc70340bc..3815023924489 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -910,11 +910,7 @@ public function query() { * @return mixed */ public function get( $query_var ) { - if ( isset( $this->query_vars[ $query_var ] ) ) { - return $this->query_vars[ $query_var ]; - } - - return null; + return $this->query_vars[ $query_var ] ?? null; } /** diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 9027856763a25..938648ad47fa2 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -384,10 +384,7 @@ static function ( $item ) { } ) ); - if ( isset( $result[0] ) ) { - return $result[0]; - } - return ''; + return $result[0] ?? ''; } /** diff --git a/src/wp-includes/http.php b/src/wp-includes/http.php index b343bb69f572b..643efc0a16930 100644 --- a/src/wp-includes/http.php +++ b/src/wp-includes/http.php @@ -266,11 +266,7 @@ function wp_remote_retrieve_header( $response, $header ) { return ''; } - if ( isset( $response['headers'][ $header ] ) ) { - return $response['headers'][ $header ]; - } - - return ''; + return $response['headers'][ $header ] ?? ''; } /** diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index dc6de5c70c662..0b9d4038ed0d2 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -148,10 +148,7 @@ function register_nav_menu( $location, $description ) { */ function get_registered_nav_menus() { global $_wp_registered_nav_menus; - if ( isset( $_wp_registered_nav_menus ) ) { - return $_wp_registered_nav_menus; - } - return array(); + return $_wp_registered_nav_menus ?? array(); } /** diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index ec6ddd9372e4e..7979c119a986f 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -547,10 +547,7 @@ function wp_set_options_autoload( array $options, $autoload ) { */ function wp_set_option_autoload( $option, $autoload ) { $result = wp_set_option_autoload_values( array( $option => $autoload ) ); - if ( isset( $result[ $option ] ) ) { - return $result[ $option ]; - } - return false; + return $result[ $option ] ?? false; } /** diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index ae9900a704f11..e8f37ecc34f31 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -2322,12 +2322,7 @@ function remove_post_type_support( $post_type, $feature ) { */ function get_all_post_type_supports( $post_type ) { global $_wp_post_type_features; - - if ( isset( $_wp_post_type_features[ $post_type ] ) ) { - return $_wp_post_type_features[ $post_type ]; - } - - return array(); + return $_wp_post_type_features[ $post_type ] ?? array(); } /** diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index da44810d4b8dc..44343569a61b1 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -3042,10 +3042,7 @@ function get_theme_support( $feature, ...$args ) { case 'custom-logo': case 'custom-header': case 'custom-background': - if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) { - return $_wp_theme_features[ $feature ][0][ $args[0] ]; - } - return false; + return $_wp_theme_features[ $feature ][0][ $args[0] ] ?? false; default: return $_wp_theme_features[ $feature ];