| @@ -24,8 +24,19 @@ | ||
| 24 | 24 | return ''; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | if ( isset( $seen_refs[ $attributes['ref'] ] ) ) { |
| 28 | + if ( ! is_admin() ) { | |
| 29 | + trigger_error( | |
| 30 | + sprintf( | |
| 31 | + // translators: %s is the user-provided title of the reusable block. | |
| 32 | + __( 'Could not render Reusable Block <strong>%s</strong>: blocks cannot be rendered inside themselves.' ), | |
| 33 | + $reusable_block->post_title | |
| 34 | + ), | |
| 35 | + E_USER_WARNING | |
| 36 | + ); | |
| 37 | + } | |
| 38 | + | |
| 28 | 39 | // WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent |
| 29 | 40 | // is set in `wp_debug_mode()`. |
| 30 | 41 | $is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG && |
| 31 | 42 | defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY; |
| @@ -41,16 +52,11 @@ | ||
| 41 | 52 | } |
| 42 | 53 | |
| 43 | 54 | $seen_refs[ $attributes['ref'] ] = true; |
| 44 | 55 | |
| 45 | - // Handle embeds for reusable blocks. | |
| 46 | - global $wp_embed; | |
| 47 | - $content = $wp_embed->run_shortcode( $reusable_block->post_content ); | |
| 48 | - $content = $wp_embed->autoembed( $content ); | |
| 49 | - | |
| 50 | - $content = do_blocks( $content ); | |
| 56 | + $result = do_blocks( $reusable_block->post_content ); | |
| 51 | 57 | unset( $seen_refs[ $attributes['ref'] ] ); |
| 52 | - return $content; | |
| 58 | + return $result; | |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | 61 | /** |
| 56 | 62 | * Registers the `core/block` block. |