Skip to content

Commit

Permalink
Experimental: Remove gutenberg_initialize_editor (#53527)
Browse files Browse the repository at this point in the history
`git bisect` revealed that [the last known use of that function](https://github.com/WordPress/gutenberg/pull/47055/files#diff-bb9ee7c63178059379505a610c303b5b11c1bc38b0961ae3cee952c68d897256L110-L118) was in `lib/experimental/navigation-page.php`, which was removed in #47055, alongside a lot of other code. It was probably by oversight that `gutenberg_initialize_editor` was left behind.
  • Loading branch information
ockham authored Aug 10, 2023
1 parent 27f7eca commit 3f4b280
Showing 1 changed file with 0 additions and 67 deletions.
67 changes: 0 additions & 67 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,6 @@
* @package gutenberg
*/

/**
* Initialize a block-based editor.
*
* @param string $editor_name Editor name.
* @param string $editor_script_handle Editor script handle.
* @param array $settings {
* Elements to initialize a block-based editor.
*
* @type array $preload_paths Array of paths to preload.
* @type string $initializer_name Editor initialization function name.
* @type array $editor_settings Editor settings.
* }
* @return void
*/
function gutenberg_initialize_editor( $editor_name, $editor_script_handle, $settings ) {

$defaults = array(
'preload_paths' => array(),
'initializer_name' => 'initialize',
'editor_settings' => array(),
);

$settings = wp_parse_args( $settings, $defaults );

/**
* Preload common data by specifying an array of REST API paths that will be preloaded.
*
* Filters the array of paths that will be preloaded.
*
* @param string[] $preload_paths Array of paths to preload.
*/
$preload_paths = apply_filters( "{$editor_name}_preload_paths", $settings['preload_paths'] );

$preload_data = array_reduce(
$preload_paths,
'rest_preload_api_request',
array()
);

wp_add_inline_script(
'wp-api-fetch',
sprintf(
'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',
wp_json_encode( $preload_data )
),
'after'
);
wp_add_inline_script(
"wp-{$editor_script_handle}",
sprintf(
'wp.domReady( function() {
wp.%s.%s( "%s", %s );
} );',
lcfirst( str_replace( '-', '', ucwords( $editor_script_handle, '-' ) ) ),
$settings['initializer_name'],
str_replace( '_', '-', $editor_name ),
wp_json_encode( $settings['editor_settings'] )
)
);

// Preload server-registered block schemas.
wp_add_inline_script(
'wp-blocks',
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
);
}

/**
* Sets a global JS variable used to trigger the availability of each Gutenberg Experiment.
*/
Expand Down

0 comments on commit 3f4b280

Please sign in to comment.