Last active
May 12, 2019 10:50
-
-
Save adrianosferreira/3630781edc6f3326278f to your computer and use it in GitHub Desktop.
This will let Layouts work with Beaver page builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This will let Layouts work with Beaver page builder | |
* This will let you add Beaver elements in cell that contains post body | |
* Without this workaround it will display the Beaver elements on every cell because of the_content() | |
*/ | |
add_action( 'init', 'fix_beaver' ); | |
function fix_beaver(){ | |
$has_been_removed = false; | |
add_action( 'ddl_before_frontend_render_cell', function ( $cell, $renderer ){ | |
if( $cell->get_cell_type() === 'cell-content-template' || | |
strpos($cell->get_content()['content'], 'wpv-post-body') === false ){ | |
if( class_exists('FLBuilder') ){ | |
remove_filter( 'the_content', 'FLBuilder::render_content' ); | |
$has_been_removed = true; | |
} | |
} | |
} ); | |
add_action( 'ddl_after_frontend_render_cell', function( $cell, $renderer ){ | |
if( $has_been_removed ){ | |
add_filter( 'the_content', 'FLBuilder::render_content' ); | |
$has_been_removed = false; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment