Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin: Deprecate gutenberg_prepare_blocks_for_js #13457

Merged
merged 1 commit into from
Jan 25, 2019
Merged
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
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.