.gitkeep
3 years ago
block-helpers.php
1 year ago
block-style-helpers.php
6 months ago
collection-helpers.php
2 days ago
cookie-helpers.php
1 year ago
kses-helpers.php
4 months ago
product-helpers.php
3 months ago
product-review-helpers.php
4 months ago
route-helper.php
2 years ago
state-helpers.php
2 years ago
template-helpers.php
4 months ago
block-helpers.php
43 lines
| 1 | <?php |
| 2 | if ( ! function_exists( 'sc_do_early_blocks' ) ) { |
| 3 | /** |
| 4 | * Run the early blocks. |
| 5 | * We need to remove the debug notice that is triggered by the `doing_it_wrong` function. |
| 6 | * |
| 7 | * We use this function in page builders that can sometimes render the blocks out of order, causing the debug notice to be displayed. |
| 8 | * |
| 9 | * @param string $content The content. |
| 10 | * |
| 11 | * @return string |
| 12 | */ |
| 13 | function sc_pre_render_blocks( $content ) { |
| 14 | add_filter( 'doing_it_wrong_trigger_error', 'sc_remove_interactivity_debug_notice', 10, 2 ); |
| 15 | |
| 16 | $content = do_blocks( $content ); |
| 17 | |
| 18 | remove_filter( 'doing_it_wrong_trigger_error', 'sc_remove_interactivity_debug_notice', 10 ); |
| 19 | |
| 20 | return $content; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | if ( ! function_exists( 'sc_remove_interactivity_debug_notice' ) ) { |
| 25 | /** |
| 26 | * Remove interactivity doing it wrong. |
| 27 | * |
| 28 | * This is because we need to render blocks out of order in order to |
| 29 | * add the attributes from bricks to the block. |
| 30 | * |
| 31 | * @param string $trigger Trigger. |
| 32 | * @param string $function_name Function name. |
| 33 | * |
| 34 | * @return string|false |
| 35 | */ |
| 36 | function sc_remove_interactivity_debug_notice( $trigger, $function_name ) { |
| 37 | if ( 'WP_Interactivity_API::evaluate' !== $function_name ) { |
| 38 | return $trigger; |
| 39 | } |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 |