Skip to content

Commit

Permalink
Replace array_merge with assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed May 3, 2024
1 parent 2c052a1 commit 3dc7e5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
6 changes: 2 additions & 4 deletions src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,8 @@ function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont
add_filter(
'scriptmoduledata_@wordpress/api-fetch',
function ( $data ) use ( $preload_data ) {
return array_merge(
$data,
array( 'preloadData' => $preload_data )
);
$data['preloadData'] = $preload_data;
return $data;
}
);
}
Expand Down
14 changes: 5 additions & 9 deletions src/wp-includes/script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,11 @@ function wp_register_default_script_modules(): void {
add_filter(
'scriptmoduledata_@wordpress/api-fetch',
function ( $data ) {
return array_merge(
$data,
array(
'rootURL' => sanitize_url( get_rest_url() ),
'nonce' => wp_installing() ? '' : wp_create_nonce( 'wp_rest' ),
'shouldRegisterMediaUploadMiddleware' => true,
'nonceEndpoint' => admin_url( 'admin-ajax.php?action=rest-nonce' ),
)
);
$data['rootURL'] = sanitize_url( get_rest_url() );
$data['nonce'] = wp_installing() ? '' : wp_create_nonce( 'wp_rest' );
$data['shouldRegisterMediaUploadMiddleware'] = true;
$data['nonceEndpoint'] = admin_url( 'admin-ajax.php?action=rest-nonce' );
return $data;
}
);
}
Expand Down
8 changes: 2 additions & 6 deletions src/wp-includes/theme-previews.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ function wp_attach_theme_preview_middleware() {
add_filter(
'scriptmoduledata_@wordpress/api-fetch',
function ( $data ) {
return array_merge(
$data,
array(
'themePreviewPath' => sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) ),
)
);
$data['themePreviewPath'] = sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) );
return $data;
}
);
}
Expand Down

0 comments on commit 3dc7e5f

Please sign in to comment.