Skip to content

Commit

Permalink
Plugin: Deprecate gutenberg_prepare_blocks_for_js (#13457)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored Jan 25, 2019
1 parent 1748145 commit 59ebd4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The Gutenberg project's deprecation policy is intended to support backward compa
- The PHP function `register_tinymce_scripts` has been removed. Use [`wp_register_tinymce_scripts`](https://developer.wordpress.org/reference/functions/wp_register_tinymce_scripts/) instead.
- The PHP function `gutenberg_register_post_types` has been removed.
- The `gutenberg` theme support option has been removed. Use [`align-wide`](https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support/#wide-alignment) instead.
- The PHP function `gutenberg_prepare_blocks_for_js` has been removed. Use [`get_block_editor_server_block_settings`](https://developer.wordpress.org/reference/functions/get_block_editor_server_block_settings/) instead.

## 4.5.0
- `Dropdown.refresh()` has been deprecated as the contained `Popover` is now automatically refreshed.
Expand Down
24 changes: 5 additions & 19 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,28 +702,14 @@ function gutenberg_register_vendor_script( $handle, $src, $deps = array() ) {
* array of registered block data keyed by block name. Data includes properties
* of a block relevant for client registration.
*
* @deprecated 5.0.0 get_block_editor_server_block_settings
*
* @return array An associative array of registered block data.
*/
function gutenberg_prepare_blocks_for_js() {
$block_registry = WP_Block_Type_Registry::get_instance();
$blocks = array();
$keys_to_pick = array( 'title', 'description', 'icon', 'category', 'keywords', 'supports', 'attributes' );

foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
foreach ( $keys_to_pick as $key ) {
if ( ! isset( $block_type->{ $key } ) ) {
continue;
}

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

$blocks[ $block_name ][ $key ] = $block_type->{ $key };
}
}
_deprecated_function( __FUNCTION__, '5.0.0', 'get_block_editor_server_block_settings' );

return $blocks;
return get_block_editor_server_block_settings();
}

/**
Expand Down Expand Up @@ -1081,7 +1067,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
// Preload server-registered block schemas.
wp_add_inline_script(
'wp-blocks',
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . json_encode( gutenberg_prepare_blocks_for_js() ) . ');'
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . json_encode( get_block_editor_server_block_settings() ) . ');'
);

// Get admin url for handling meta boxes.
Expand Down
34 changes: 0 additions & 34 deletions phpunit/class-prepare-for-js-test.php

This file was deleted.

0 comments on commit 59ebd4f

Please sign in to comment.