Created
August 13, 2019 16:13
-
-
Save kellymears/d0f55de50a1928727a4638d452f5b413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('rest_api_init', function () { | |
!function_exists('use_block_editor_for_post_type') && | |
require ABSPATH . 'wp-admin/includes/post.php'; | |
$postTypes = collect( | |
get_post_types_by_support(['editor']) | |
); | |
$postTypes->each(function ($postType) { | |
use_block_editor_for_post_type($postType) | |
&& register_rest_field($postType, 'blocks', [ | |
'get_callback' => function (array $post) { | |
return parse_blocks($post['content']['raw']); | |
} | |
]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment