: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Modify raw post content for visual builder for layout content edit screen
* @param string $post_content
* @return string modified post content
public function modify_layout_content_visual_builder_raw_post_content( $post_content ) {
if ( self::is_layout_block_preview() ) {
// Explicitly set post_id value based on query string because layout block's edit
// window of CPT that has no frontend page such as reusable block's `wp_block` CPT
// might use other / last post loop for rendering visual builder structure since its
// own post data isn't publicly queryable
$post_id = intval( et_()->array_get( $_GET, 'et_post_id', get_the_ID() ) );
$block_id = sanitize_title( et_()->array_get( $_GET, 'blockId' ) );
$key = "_et_block_layout_preview_{$block_id}";
$post_content = wp_unslash( get_post_meta( $post_id, $key, true ) );
* Modify Theme Builder body layout that is used on layout block preview
public function modify_theme_builder_body_layout( $content ) {
// Skip if current request isn't layout block preview
if ( ! self::is_layout_block_preview() ) {
// Get `et_pb_post_content` shortcode inside layout by pulling regex and matching it.
// `et_pb_post_content` has to exist, otherwise `the_content()` won't be rendered; Return
// plain `et_pb_post_content` shortcode if current layout doesn't have any
$post_content_regex = get_shortcode_regex( et_theme_builder_get_post_content_modules() );
preg_match_all( "/$post_content_regex/", $content, $post_content_module, PREG_SET_ORDER );
$post_content_shortcode = et_()->array_get(
'[et_pb_post_content][/et_pb_post_content]'
// Return `et_pb_post_content` wrapped by section > row > column which has no unwanted
// styling. TB body layout might have any module imaginable while in context of layout block
// preview, only `et_pb_post_content` matters because its typography setting can override
// default typography styling
return '[et_pb_section admin_label="section" custom_padding="0px|0px|0px|0px"]
[et_pb_row admin_label="row" custom_padding="0px|0px|0px|0px" custom_margin="0px|0px|0px|0px" width="100%"]
[et_pb_column type="4_4"]'. $post_content_shortcode .'[/et_pb_column]
// Initialize ET_GB_Block_Layout
ET_GB_Block_Layout::instance();