Skip to content

Commit

Permalink
Ensure [bw_fields] shortcode is expanded within query loops for both …
Browse files Browse the repository at this point in the history
…shortcode and paragraph blocks #28
  • Loading branch information
bobbingwide committed Mar 11, 2023
1 parent b9c82bf commit 4cfe9e0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ function fizzie_front_page_template( $template ) {
}
add_filter( 'frontpage_template', 'fizzie_front_page_template' );

/**
* Filters the rendered shortcode block.
*
* @param $content
* @param $parsed_block
* @param $block
* @return mixed|string
*/
function fizzie_render_block_core_shortcode( $content, $parsed_block, $block ) {
$content = do_shortcode( $content );
return $content;
}

add_filter( 'render_block_core/shortcode', 'fizzie_render_block_core_shortcode', 10, 3, );
add_filter( 'render_block_core/paragraph', 'fizzie_render_block_core_shortcode', 10, 3, );



require_once __DIR__ . '/includes/block-overrides.php';

Expand Down
2 changes: 2 additions & 0 deletions includes/block-overrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
require_once __DIR__ . '/navigation-link.php';
//require_once __DIR__ . '/post-hierarchical-terms.php';
//require_once __DIR__ . '/block.php';
//require_once __DIR__ . '/shortcode.php';

/**
* Hook into register_block_types_args before WP_Block_Supports
Expand All @@ -49,5 +50,6 @@ function fizzie_register_block_type_args( $args ) {
$args = fizzie_maybe_override_block( $args,'core/navigation-link', 'render_block_core_navigation_link' );
//$args = fizzie_maybe_override_block( $args,'core/post-hierarchical-terms', 'render_block_core_post_hierarchical_terms' );
//$args = fizzie_maybe_override_block( $args,'core/block', 'render_block_core_block' );
//$args = fizzie_maybe_override_block( $args,'core/shortcode', 'render_block_core_shortcode' );
return $args;
}
18 changes: 18 additions & 0 deletions includes/shortcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* Overrides core/shortcode to expand the shortcodes in the block.
*
* Hack until a solution is delivered in Gutenberg for 43053 or 35676
*
* @param $attributes
* @param $content
* @param $block
*
* @return string
*/
function fizzie_render_block_core_shortcode( $attributes, $content, $block ) {
bw_trace2();
$html = do_shortcode( $content );
return $html;
}

0 comments on commit 4cfe9e0

Please sign in to comment.