Skip to content

Commit

Permalink
Ensure that allowed_block_types is executed only when the post if def…
Browse files Browse the repository at this point in the history
…ined
  • Loading branch information
gziolo committed Mar 25, 2021
1 parent e9bd52b commit 8296b33
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,27 @@
*
* @since 5.8.0
*
* @param WP_Post $post Global post object.
* @global WP_Post $post Global post object.
*
* @return array The default block editor settings.
*/
function get_default_block_editor_settings( $post = null ) {
/**
* Filters the allowed block types for the editor, defaulting to true (all
* block types supported).
*
* @since 5.0.0
*
* @param bool|array $allowed_block_types Array of block type slugs, or
* boolean to enable/disable all.
* @param WP_Post $post The post resource data.
*/
$allowed_block_types = apply_filters( 'allowed_block_types', true, $post );
function get_default_block_editor_settings() {
global $post;

$allowed_block_types = true;
if ( ! empty( $post ) ) {
/**
* Filters the allowed block types for the editor, defaulting to true (all
* block types supported).
*
* @since 5.0.0
*
* @param bool|array $allowed_block_types Array of block type slugs, or
* boolean to enable/disable all.
* @param WP_Post $post The post resource data.
*/
$allowed_block_types = apply_filters( 'allowed_block_types', $allowed_block_types, $post );
}

// Media settings.
$max_upload_size = wp_max_upload_size();
Expand All @@ -41,10 +46,10 @@ function get_default_block_editor_settings( $post = null ) {
$image_size_names = apply_filters(
'image_size_names_choose',
array(
'thumbnail' => __( 'Thumbnail' ),
'medium' => __( 'Medium' ),
'large' => __( 'Large' ),
'full' => __( 'Full Size' ),
'thumbnail' => __( 'Thumbnail', 'gutenberg' ),
'medium' => __( 'Medium', 'gutenberg' ),
'large' => __( 'Large', 'gutenberg' ),
'full' => __( 'Full Size', 'gutenberg' ),
)
);

Expand Down

0 comments on commit 8296b33

Please sign in to comment.