Skip to content

Commit

Permalink
Issue #25 - refactor post content overrides into post-content.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Nov 14, 2020
1 parent 3a65a25 commit 7b03b40
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
36 changes: 2 additions & 34 deletions includes/block-overrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require_once __DIR__ . '/query-pagination.php';
require_once __DIR__ . '/query-loop.php';
require_once __DIR__ . '/post-excerpt.php';
require_once __DIR__ . '/post-content.php';



Expand All @@ -26,12 +27,8 @@ function fizzie_register_block_type_args( $args ) {
$args = fizzie_maybe_override_block( $args,'core/query-pagination', 'render_block_core_query_pagination');
$args = fizzie_maybe_override_block( $args,'core/query-loop', 'render_block_core_query_loop' );
$args = fizzie_maybe_override_block( $args,'core/post-excerpt', 'render_block_core_post_excerpt' );
$args = fizzie_maybe_override_block( $args,'core/post-content', 'render_block_core_post_content' );

if ( 'core/post-content' == $args['name'] ) {
if ( 'gutenberg_render_block_core_post_content' == $args['render_callback'] ) {
$args['render_callback'] = 'fizzie_render_block_core_post_content';
}
}

if ( 'core/template-part' == $args['name'] ) {
if ( 'gutenberg_render_block_core_template_part' == $args['render_callback'] ) {
Expand Down Expand Up @@ -68,36 +65,7 @@ function fizzie_register_block_type_args( $args ) {



/**
* Overrides core/post-content to return early in certain circumstances.
*
* Hack until a solution is delivered in Gutenberg.
*
* @param $attributes
* @param $content
* @param $block
* @return string
*/
function fizzie_render_block_core_post_content( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
/*
if ( 'revision' === $block->context['postType'] ) {
return '';
}
*/

if ( fizzie_process_this_content( get_the_ID() ) ) {
$html = gutenberg_render_block_core_post_content( $attributes, $content, $block );
fizzie_clear_processed_content( get_the_ID() );
} else {
$html = fizzie_report_recursion_error( get_the_ID() );
//$html .= $content;
}

return $html;
}



Expand Down
31 changes: 31 additions & 0 deletions includes/post-content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Overrides core/post-content to return early in certain circumstances.
*
* Hack until a solution is delivered in Gutenberg.
*
* @param $attributes
* @param $content
* @param $block
* @return string
*/
function fizzie_render_block_core_post_content( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
/*
if ( 'revision' === $block->context['postType'] ) {
return '';
}
*/

if ( fizzie_process_this_content( get_the_ID() ) ) {
$html = gutenberg_render_block_core_post_content( $attributes, $content, $block );
fizzie_clear_processed_content( get_the_ID() );
} else {
$html = fizzie_report_recursion_error( get_the_ID() );
//$html .= $content;
}

return $html;
}

0 comments on commit 7b03b40

Please sign in to comment.