Skip to content
Open
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
4 changes: 1 addition & 3 deletions src/wp-admin/includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
$widget_options = array();
}

if ( ! isset( $widget_options[ $widget_id ] ) ) {
$widget_options[ $widget_id ] = array();
}
$widget_options[ $widget_id ] ??= array();

$number = 1; // Hack to use wp_widget_rss_form().

Expand Down
4 changes: 1 addition & 3 deletions src/wp-admin/includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -1483,9 +1483,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
$auto_add = ! empty( $_POST['auto-add-pages'] );
$nav_menu_option = (array) get_option( 'nav_menu_options' );

if ( ! isset( $nav_menu_option['auto_add'] ) ) {
$nav_menu_option['auto_add'] = array();
}
$nav_menu_option['auto_add'] ??= array();

if ( $auto_add ) {
if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ) ) {
Expand Down
4 changes: 1 addition & 3 deletions src/wp-admin/includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -2335,9 +2335,7 @@ function get_block_editor_server_block_settings() {
continue;
}

if ( ! isset( $blocks[ $block_name ] ) ) {
$blocks[ $block_name ] = array();
}
$blocks[ $block_name ] ??= array();

$blocks[ $block_name ][ $key ] = $block_type->{ $field };
}
Expand Down
28 changes: 7 additions & 21 deletions src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1098,15 +1098,9 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan

$page = $screen->id;

if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
}
if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
$wp_meta_boxes[ $page ] = array();
}
if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
$wp_meta_boxes[ $page ][ $context ] = array();
}
$wp_meta_boxes ??= array();
$wp_meta_boxes[ $page ] ??= array();
$wp_meta_boxes[ $page ][ $context ] ??= array();

foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
Expand Down Expand Up @@ -1158,9 +1152,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
$priority = 'low';
}

if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
$wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
}
$wp_meta_boxes[ $page ][ $context ][ $priority ] ??= array();

$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
'id' => $id,
Expand Down Expand Up @@ -1502,15 +1494,9 @@ function remove_meta_box( $id, $screen, $context ) {

$page = $screen->id;

if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
}
if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
$wp_meta_boxes[ $page ] = array();
}
if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
$wp_meta_boxes[ $page ][ $context ] = array();
}
$wp_meta_boxes ??= array();
$wp_meta_boxes[ $page ] ??= array();
$wp_meta_boxes[ $page ][ $context ] ??= array();

foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
Expand Down
4 changes: 1 addition & 3 deletions src/wp-admin/includes/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ function wp_list_widgets() {
$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
$done[] = $widget['callback'];

if ( ! isset( $widget['params'][0] ) ) {
$widget['params'][0] = array();
}
$widget['params'][0] ??= array();

$args = array(
'widget_id' => $widget['id'],
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/block-supports/anchor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ function wp_register_anchor_support( WP_Block_Type $block_type ) {
return;
}

if ( ! isset( $block_type->attributes ) ) {
$block_type->attributes = array();
}
$block_type->attributes ??= array();

if ( ! array_key_exists( 'anchor', $block_type->attributes ) ) {
$block_type->attributes['anchor'] = array(
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1783,9 +1783,7 @@ function inject_ignored_hooked_blocks_metadata_attributes( $changes, $deprecated
$wrapper_block = parse_blocks( $wrapper_block_markup )[0];
$ignored_hooked_blocks = $wrapper_block['attrs']['metadata']['ignoredHookedBlocks'] ?? array();
if ( ! empty( $ignored_hooked_blocks ) ) {
if ( ! isset( $changes->meta_input ) ) {
$changes->meta_input = array();
}
$changes->meta_input ??= array();
$changes->meta_input['_wp_ignored_hooked_blocks'] = wp_json_encode( $ignored_hooked_blocks );
}
} else {
Expand Down
12 changes: 3 additions & 9 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,8 @@ function get_hooked_blocks() {
continue;
}
foreach ( $block_type->block_hooks as $anchor_block_type => $relative_position ) {
if ( ! isset( $hooked_blocks[ $anchor_block_type ] ) ) {
$hooked_blocks[ $anchor_block_type ] = array();
}
if ( ! isset( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ) ) {
$hooked_blocks[ $anchor_block_type ][ $relative_position ] = array();
}
$hooked_blocks[ $anchor_block_type ] ??= array();
$hooked_blocks[ $anchor_block_type ][ $relative_position ] ??= array();
$hooked_blocks[ $anchor_block_type ][ $relative_position ][] = $block_type->name;
}
}
Expand Down Expand Up @@ -1490,9 +1486,7 @@ function update_ignored_hooked_blocks_postmeta( $post ) {
$ignored_hooked_blocks = array_unique( array_merge( $ignored_hooked_blocks, $existing_ignored_hooked_blocks ) );
}

if ( ! isset( $post->meta_input ) ) {
$post->meta_input = array();
}
$post->meta_input ??= array();
$post->meta_input['_wp_ignored_hooked_blocks'] = json_encode( $ignored_hooked_blocks );
}

Expand Down
8 changes: 3 additions & 5 deletions src/wp-includes/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,9 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
}
$post_type_object = get_post_type_object( $object_subtype );
// Initialize empty array if it doesn't exist.
if ( ! isset( $post_type_object->capabilities ) ) {
$post_type_object->capabilities = array();
}
$post_type_capabilities = get_post_type_capabilities( $post_type_object );
$caps = map_meta_cap( $post_type_capabilities->edit_post, $user_id, $object_id );
$post_type_object->capabilities ??= array();
$post_type_capabilities = get_post_type_capabilities( $post_type_object );
$caps = map_meta_cap( $post_type_capabilities->edit_post, $user_id, $object_id );
break;
default:
// Handle meta capabilities for custom post types.
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-block-styles-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public function register( $block_name, $style_properties ) {
}

foreach ( $block_names as $name ) {
if ( ! isset( $this->registered_block_styles[ $name ] ) ) {
$this->registered_block_styles[ $name ] = array();
}
$this->registered_block_styles[ $name ] ??= array();
$this->registered_block_styles[ $name ][ $block_style_name ] = $style_properties;
}

Expand Down
16 changes: 4 additions & 12 deletions src/wp-includes/class-wp-customize-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2817,9 +2817,7 @@ public function save_changeset_post( $args = array() ) {

// Ensure that all post values are included in the changeset data.
foreach ( $post_values as $setting_id => $post_value ) {
if ( ! isset( $args['data'][ $setting_id ] ) ) {
$args['data'][ $setting_id ] = array();
}
$args['data'][ $setting_id ] ??= array();
if ( ! isset( $args['data'][ $setting_id ]['value'] ) ) {
$args['data'][ $setting_id ]['value'] = $post_value;
}
Expand All @@ -2846,9 +2844,7 @@ public function save_changeset_post( $args = array() ) {
unset( $data[ $changeset_setting_id ] );
} else {

if ( ! isset( $data[ $changeset_setting_id ] ) ) {
$data[ $changeset_setting_id ] = array();
}
$data[ $changeset_setting_id ] ??= array();

// Merge any additional setting params that have been supplied with the existing params.
$merged_setting_params = array_merge( $data[ $changeset_setting_id ], $setting_params );
Expand Down Expand Up @@ -3516,9 +3512,7 @@ public function _publish_changeset_values( $changeset_post_id ) {
preg_match( $namespace_pattern, $raw_setting_id, $matches )
);
if ( $is_theme_mod_setting ) {
if ( ! isset( $theme_mod_settings[ $matches['stylesheet'] ] ) ) {
$theme_mod_settings[ $matches['stylesheet'] ] = array();
}
$theme_mod_settings[ $matches['stylesheet'] ] ??= array();
$theme_mod_settings[ $matches['stylesheet'] ][ $matches['setting_id'] ] = $setting_params;

if ( $this->get_stylesheet() === $matches['stylesheet'] ) {
Expand Down Expand Up @@ -3665,9 +3659,7 @@ protected function update_stashed_theme_mod_settings( $inactive_theme_mod_settin

// Merge inactive theme mods with the stashed theme mod settings.
foreach ( $inactive_theme_mod_settings as $stylesheet => $theme_mod_settings ) {
if ( ! isset( $stashed_theme_mod_settings[ $stylesheet ] ) ) {
$stashed_theme_mod_settings[ $stylesheet ] = array();
}
$stashed_theme_mod_settings[ $stylesheet ] ??= array();

$stashed_theme_mod_settings[ $stylesheet ] = array_merge(
$stashed_theme_mod_settings[ $stylesheet ],
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-customize-nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,7 @@ public function insert_auto_draft_post( $postarr ) {
if ( empty( $postarr['post_name'] ) ) {
$postarr['post_name'] = sanitize_title( $postarr['post_title'] );
}
if ( ! isset( $postarr['meta_input'] ) ) {
$postarr['meta_input'] = array();
}
$postarr['meta_input'] ??= array();
$postarr['meta_input']['_customize_draft_post_name'] = $postarr['post_name'];
$postarr['meta_input']['_customize_changeset_uuid'] = $this->manager->changeset_uuid();
unset( $postarr['post_name'] );
Expand Down
8 changes: 2 additions & 6 deletions src/wp-includes/class-wp-customize-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ final public function id_data() {
*/
protected function aggregate_multidimensional() {
$id_base = $this->id_data['base'];
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
self::$aggregated_multidimensionals[ $this->type ] = array();
}
self::$aggregated_multidimensionals[ $this->type ] ??= array();
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ][ $id_base ] ) ) {
self::$aggregated_multidimensionals[ $this->type ][ $id_base ] = array(
'previewed_instances' => array(), // Calling preview() will add the $setting to the array.
Expand Down Expand Up @@ -887,9 +885,7 @@ final protected function multidimensional( &$root, $keys, $create = false ) {
// Account for an array overriding a string or object value.
$node = array();
}
if ( ! isset( $node[ $last ] ) ) {
$node[ $last ] = array();
}
$node[ $last ] ??= array();
}

if ( ! isset( $node[ $last ] ) ) {
Expand Down
10 changes: 3 additions & 7 deletions src/wp-includes/class-wp-customize-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,7 @@ public function get_available_widgets() {
$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
$done[] = $widget['callback'];

if ( ! isset( $widget['params'][0] ) ) {
$widget['params'][0] = array();
}
$widget['params'][0] ??= array();

$available_widget = $widget;
unset( $available_widget['callback'] ); // Not serializable to JSON.
Expand Down Expand Up @@ -1885,10 +1883,8 @@ public function filter_dynamic_sidebar_params( $params ) {
*/
public function filter_wp_kses_allowed_data_attributes( $allowed_html ) {
foreach ( array_keys( $this->before_widget_tags_seen ) as $tag_name ) {
if ( ! isset( $allowed_html[ $tag_name ] ) ) {
$allowed_html[ $tag_name ] = array();
}
$allowed_html[ $tag_name ] = array_merge(
$allowed_html[ $tag_name ] ??= array();
$allowed_html[ $tag_name ] = array_merge(
$allowed_html[ $tag_name ],
array_fill_keys(
array(
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,7 @@ public static function output_footer_assets() {
public static function add_editor_settings( $settings ) {
$global_styles_presets = self::get_all_global_styles_presets();
if ( ! empty( $global_styles_presets ) ) {
if ( ! isset( $settings['styles'] ) ) {
$settings['styles'] = array();
}
$settings['styles'] ??= array();

$settings['styles'][] = array(
// For the editor we can add all of the presets by default.
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-metadata-lazyloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ public function queue_objects( $object_type, $object_ids ) {

$type_settings = $this->settings[ $object_type ];

if ( ! isset( $this->pending_objects[ $object_type ] ) ) {
$this->pending_objects[ $object_type ] = array();
}
$this->pending_objects[ $object_type ] ??= array();

foreach ( $object_ids as $object_id ) {
// Keyed by ID for faster lookup.
Expand Down
10 changes: 3 additions & 7 deletions src/wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,7 @@ public function fill_query_vars( $query_vars ) {
);

foreach ( $array_keys as $key ) {
if ( ! isset( $query_vars[ $key ] ) ) {
$query_vars[ $key ] = array();
}
$query_vars[ $key ] ??= array();
}

return $query_vars;
Expand Down Expand Up @@ -1279,10 +1277,8 @@ public function parse_tax_query( &$query_vars ) {
}

if ( ! empty( $query_vars['category__and'] ) && 1 === count( (array) $query_vars['category__and'] ) ) {
$query_vars['category__and'] = (array) $query_vars['category__and'];
if ( ! isset( $query_vars['category__in'] ) ) {
$query_vars['category__in'] = array();
}
$query_vars['category__and'] = (array) $query_vars['category__and'];
$query_vars['category__in'] ??= array();
$query_vars['category__in'][] = absint( reset( $query_vars['category__and'] ) );
unset( $query_vars['category__and'] );
}
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-speculation-rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ public function add_rule( string $mode, string $id, array $rule ): bool {
}
}

if ( ! isset( $this->rules_by_mode[ $mode ] ) ) {
$this->rules_by_mode[ $mode ] = array();
}
$this->rules_by_mode[ $mode ] ??= array();

$this->rules_by_mode[ $mode ][ $id ] = $rule;
return true;
Expand Down
6 changes: 2 additions & 4 deletions src/wp-includes/class-wp-tax-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,8 @@ public function sanitize_query( $queries ) {
* $queried_terms array, for use in WP_Query.
*/
if ( ! empty( $cleaned_clause['taxonomy'] ) && 'NOT IN' !== $cleaned_clause['operator'] ) {
$taxonomy = $cleaned_clause['taxonomy'];
if ( ! isset( $this->queried_terms[ $taxonomy ] ) ) {
$this->queried_terms[ $taxonomy ] = array();
}
$taxonomy = $cleaned_clause['taxonomy'];
$this->queried_terms[ $taxonomy ] ??= array();

/*
* Backward compatibility: Only store the first
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -2511,9 +2511,7 @@ protected function get_css_variables( $nodes, $origins ) {

$target = static::get_feature_selector( $feature_selectors, $preset_metadata['path'][0], $selector );

if ( ! isset( $vars_by_selector[ $target ] ) ) {
$vars_by_selector[ $target ] = array();
}
$vars_by_selector[ $target ] ??= array();

foreach ( $values_by_slug as $slug => $value ) {
$vars_by_selector[ $target ][] = array(
Expand Down
6 changes: 2 additions & 4 deletions src/wp-includes/class-wp-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -1357,10 +1357,8 @@ public function get_post_templates() {
}

foreach ( $types as $type ) {
$type = sanitize_key( $type );
if ( ! isset( $post_templates[ $type ] ) ) {
$post_templates[ $type ] = array();
}
$type = sanitize_key( $type );
$post_templates[ $type ] ??= array();

$post_templates[ $type ][ $file ] = $headers['TemplateName'];
}
Expand Down
4 changes: 1 addition & 3 deletions src/wp-includes/class-wp-token-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ public static function from_array( array $mappings, int $key_length = 2 ): ?WP_T
} else {
$group = substr( $word, 0, $key_length );

if ( ! isset( $groups[ $group ] ) ) {
$groups[ $group ] = array();
}
$groups[ $group ] ??= array();

$groups[ $group ][] = array( substr( $word, $key_length ), $mapping );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,7 @@ protected function update( $value ) {
* @return array Save response data.
*/
public function amend_customize_save_response( $data ) {
if ( ! isset( $data['nav_menu_item_updates'] ) ) {
$data['nav_menu_item_updates'] = array();
}
$data['nav_menu_item_updates'] ??= array();

$data['nav_menu_item_updates'][] = array(
'post_id' => $this->post_id,
Expand Down
Loading
Loading