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

ADDED: Support for guten blocks in the REST API #37

Merged
merged 2 commits into from Sep 27, 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
3 changes: 3 additions & 0 deletions includes/create_cpt_endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ function bre_build_cpt_endpoints() {
// show post content unless parameter is false
if( $content === null || $show_content === true ) {
$bre_post->content = apply_filters('the_content', get_the_content());

// get guten blocks and parse into array format
$bre_post->blocks = parse_blocks($post->post_content);
}

$bre_post->author = esc_html__(get_the_author(), 'text_domain');
Expand Down
1 change: 1 addition & 0 deletions includes/get_cpt_by_id.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function bre_build_single_cpt_endpoints() {
$bre_cpt_post->date_modified = get_the_modified_date('c');
$bre_cpt_post->excerpt = get_the_excerpt();
$bre_cpt_post->content = apply_filters('the_content', get_the_content());
$bre_cpt_post->blocks = parse_blocks($post->post_content);
$bre_cpt_post->author = esc_html__(get_the_author(), 'text_domain');
$bre_cpt_post->author_id = get_the_author_meta('ID');
$bre_cpt_post->author_nicename = get_the_author_meta('user_nicename');
Expand Down
1 change: 1 addition & 0 deletions includes/get_cpt_by_slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function bre_build_single_cpt_endpoints_slug() {
$bre_cpt_post->date_modified = get_the_modified_date('c');
$bre_cpt_post->excerpt = get_the_excerpt();
$bre_cpt_post->content = apply_filters('the_content', get_the_content());
$bre_cpt_post->blocks = parse_blocks($post->post_content);
$bre_cpt_post->author = esc_html__(get_the_author(), 'text_domain');
$bre_cpt_post->author_id = get_the_author_meta('ID');
$bre_cpt_post->author_nicename = get_the_author_meta('user_nicename');
Expand Down
1 change: 1 addition & 0 deletions includes/get_page_by_id.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function get_page_by_id( WP_REST_Request $request ){
}

$bre_page->content = apply_filters('the_content', get_the_content());
$bre_post->blocks = parse_blocks($post->post_content);

/*
*
Expand Down
1 change: 1 addition & 0 deletions includes/get_page_by_slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function get_page_by_slug( WP_REST_Request $request ){
$bre_post->date_modified = get_the_modified_date('c');
$bre_post->excerpt = get_the_excerpt();
$bre_post->content = apply_filters('the_content', get_the_content());
$bre_post->blocks = parse_blocks($post->post_content);
$bre_post->author = esc_html__(get_the_author(), 'text_domain');
$bre_post->author_id = get_the_author_meta('ID');
$bre_post->author_nicename = get_the_author_meta('user_nicename');
Expand Down
1 change: 1 addition & 0 deletions includes/get_post_by_id.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function get_post_by_id( $data ) {
$bre_post->date_modified = get_the_modified_date('c');
$bre_post->excerpt = get_the_excerpt();
$bre_post->content = apply_filters('the_content', get_the_content());
$bre_post->blocks = parse_blocks($post->post_content);
$bre_post->author = esc_html__(get_the_author(), 'text_domain');
$bre_post->author_id = get_the_author_meta('ID');
$bre_post->author_nicename = get_the_author_meta('user_nicename');
Expand Down
1 change: 1 addition & 0 deletions includes/get_post_by_slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function get_post_by_slug( WP_REST_Request $request ) {
$bre_post->date_modified = get_the_modified_date('c');
$bre_post->excerpt = get_the_excerpt();
$bre_post->content = apply_filters('the_content', get_the_content());
$bre_post->blocks = parse_blocks($post->post_content);
$bre_post->author = esc_html__(get_the_author(), 'text_domain');
$bre_post->author_id = get_the_author_meta('ID');
$bre_post->author_nicename = get_the_author_meta('user_nicename');
Expand Down
1 change: 1 addition & 0 deletions includes/get_posts_tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function bre_build_custom_tax_endpoint() {

if( $content === null || $show_content === true ){
$bre_tax_post->content = apply_filters('the_content', get_the_content());
$bre_post->blocks = parse_blocks($post->post_content);
}

$bre_tax_post->author = esc_html__(get_the_author(), 'text_domain');
Expand Down
1 change: 1 addition & 0 deletions includes/get_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function bre_get_search( WP_REST_Request $request ) {
// show post content unless parameter is false
if( $content === null || $show_content === true ) {
$bre_post->content = apply_filters('the_content', get_the_content());
$bre_post->blocks = parse_blocks($post->post_content);
}

$bre_post->author = esc_html__(get_the_author(), 'text_domain');
Expand Down