From 9a1bed6ee49b978a6db08d3a929b4fbd1cc058ba Mon Sep 17 00:00:00 2001 From: APL Date: Tue, 26 Mar 2019 20:20:07 +0100 Subject: [PATCH 1/2] ADDED: Support for guten blocks --- includes/create_cpt_endpoints.php | 3 +++ includes/get_cpt_by_id.php | 1 + includes/get_cpt_by_slug.php | 1 + includes/get_page_by_id.php | 1 + includes/get_page_by_slug.php | 1 + includes/get_post_by_id.php | 1 + includes/get_post_by_slug.php | 1 + includes/get_posts_tax.php | 1 + includes/get_search.php | 1 + 9 files changed, 11 insertions(+) diff --git a/includes/create_cpt_endpoints.php b/includes/create_cpt_endpoints.php index 801eae0..3a6242e 100644 --- a/includes/create_cpt_endpoints.php +++ b/includes/create_cpt_endpoints.php @@ -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'); diff --git a/includes/get_cpt_by_id.php b/includes/get_cpt_by_id.php index 28b154d..4866ca2 100644 --- a/includes/get_cpt_by_id.php +++ b/includes/get_cpt_by_id.php @@ -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'); diff --git a/includes/get_cpt_by_slug.php b/includes/get_cpt_by_slug.php index 6c75593..8664d43 100644 --- a/includes/get_cpt_by_slug.php +++ b/includes/get_cpt_by_slug.php @@ -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'); diff --git a/includes/get_page_by_id.php b/includes/get_page_by_id.php index 6f66dc4..f935cae 100644 --- a/includes/get_page_by_id.php +++ b/includes/get_page_by_id.php @@ -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); /* * diff --git a/includes/get_page_by_slug.php b/includes/get_page_by_slug.php index 2775334..ad460f0 100644 --- a/includes/get_page_by_slug.php +++ b/includes/get_page_by_slug.php @@ -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'); diff --git a/includes/get_post_by_id.php b/includes/get_post_by_id.php index ea69b66..d3ccc4d 100644 --- a/includes/get_post_by_id.php +++ b/includes/get_post_by_id.php @@ -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'); diff --git a/includes/get_post_by_slug.php b/includes/get_post_by_slug.php index f6a3673..c4d6aba 100644 --- a/includes/get_post_by_slug.php +++ b/includes/get_post_by_slug.php @@ -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'); diff --git a/includes/get_posts_tax.php b/includes/get_posts_tax.php index 56cb872..4aad36a 100644 --- a/includes/get_posts_tax.php +++ b/includes/get_posts_tax.php @@ -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'); diff --git a/includes/get_search.php b/includes/get_search.php index 67d557c..6cdd23c 100644 --- a/includes/get_search.php +++ b/includes/get_search.php @@ -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'); From 47c764088cbcc6362346ca9686569e127f2384b1 Mon Sep 17 00:00:00 2001 From: APL Date: Wed, 27 Mar 2019 06:47:27 +0100 Subject: [PATCH 2/2] UPDATED: Typo in CPT files --- includes/get_cpt_by_id.php | 2 +- includes/get_cpt_by_slug.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/get_cpt_by_id.php b/includes/get_cpt_by_id.php index 4866ca2..f35bf85 100644 --- a/includes/get_cpt_by_id.php +++ b/includes/get_cpt_by_id.php @@ -56,7 +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->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'); diff --git a/includes/get_cpt_by_slug.php b/includes/get_cpt_by_slug.php index 8664d43..7204699 100644 --- a/includes/get_cpt_by_slug.php +++ b/includes/get_cpt_by_slug.php @@ -56,7 +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->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');