Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/wp-admin/includes/class-wp-screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
}
Expand Down
12 changes: 2 additions & 10 deletions src/wp-admin/includes/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand All @@ -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 );
}

Expand Down
27 changes: 4 additions & 23 deletions src/wp-admin/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
5 changes: 1 addition & 4 deletions src/wp-includes/class-wp-block-styles-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/wp-includes/class-wp-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/wp-includes/class-wp-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 2 additions & 11 deletions src/wp-includes/class-wp-plugin-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down
13 changes: 2 additions & 11 deletions src/wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/wp-includes/class-wp-user-meta-session-tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/wp-includes/class-wp-user-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/wp-includes/global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,7 @@ static function ( $item ) {
}
)
);
if ( isset( $result[0] ) ) {
return $result[0];
}
return '';
return $result[0] ?? '';
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/wp-includes/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ?? '';
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/wp-includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/wp-includes/option.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/wp-includes/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
Loading