Skip to content

Commit

Permalink
ADDED: Support for guten blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
APL committed Mar 26, 2019
1 parent a4f9dbd commit 9a1bed6
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 0 deletions.
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_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_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

0 comments on commit 9a1bed6

Please sign in to comment.