* @param array $matches found matches.
function et_builder_get_global_code_replacement( $matches ) {
global $et_pb_global_code_replacements;
return array_shift( $et_pb_global_code_replacements );
if ( ! function_exists( 'et_builder_activate_bfb_auto_draft' ) ) {
* Force activate post_id which has auto-draft status
function et_builder_activate_bfb_auto_draft() {
et_core_security_check( 'edit_posts', 'et_enable_bfb_nonce' );
$post_id = ! empty( $_POST['et_post_id'] ) ? absint( $_POST['et_post_id'] ) : 0;
if ( 0 === $post_id || ! current_user_can( 'edit_post', $post_id ) ) {
// et_builder_activate_bfb_auto_draft() is executed when post title and content empty which means post_status is still lik. ely
// to be "auto-draft". "auto-draft" status returns 404 page; thus post status needs to be updated to "draft".
'post_status' => 'draft',
update_post_meta( $post_id, '_et_pb_use_builder', 'on' );
add_action( 'wp_ajax_et_builder_activate_bfb_auto_draft', 'et_builder_activate_bfb_auto_draft' );
if ( ! function_exists( 'et_builder_ajax_toggle_bfb' ) ) {
* Ajax Callback :: Switch To The New Divi Builder.
function et_builder_ajax_toggle_bfb() {
et_core_security_check( 'manage_options', 'et_builder_toggle_bfb', 'nonce', '_GET' );
$enable = isset( $_GET['enable'] ) && '1' === $_GET['enable'];
$redirect = isset( $_GET['redirect'] ) ? esc_url_raw( $_GET['redirect'] ) : '';
if ( empty( $redirect ) && isset( $_SERVER['HTTP_REFERER'] ) ) {
$redirect = esc_url_raw( $_SERVER['HTTP_REFERER'] );
if ( empty( $redirect ) ) {
$redirect = esc_url_raw( admin_url( '/' ) );
et_builder_toggle_bfb( $enable );
set_transient( 'et_builder_show_bfb_welcome_modal', true, 0 );
wp_safe_redirect( $redirect );
add_action( 'wp_ajax_et_builder_toggle_bfb', 'et_builder_ajax_toggle_bfb' );
* Return font weight select input element html.
function et_generate_font_weight_select_output() {
$all_weights = et_builder_get_font_weight_list();
foreach ( $all_weights as $number => $name ) {
'<label><input type="checkbox" name="et_font_weight[]" value="%1$s" />%2$s %3$s</label>',
* Return regular and specialty layouts.
function et_builder_get_columns() {
'1_6,1_6,1_6,1_6,1_6,1_6',
return apply_filters( 'et_builder_get_columns', $columns );
function et_builder_get_columns_layout() {
'<% if ( typeof et_pb_specialty !== \'undefined\' && et_pb_specialty === \'on\' ) { %>
<li data-layout="1_2,1_2" data-specialty="1,0" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_specialty_column"></div>
<li data-layout="1_2,1_2" data-specialty="0,1" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<li data-layout="1_4,3_4" data-specialty="0,1" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_3_4 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<li data-layout="3_4,1_4" data-specialty="1,0" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_3_4 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<li data-layout="1_4,1_2,1_4" data-specialty="0,1,0" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<li data-layout="1_2,1_4,1_4" data-specialty="1,0,0" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<li data-layout="1_4,1_4,1_2" data-specialty="0,0,1" data-specialty_columns="3">
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<div class="et_pb_variation et_pb_variation_1_3"></div>
<li data-layout="1_3,2_3" data-specialty="0,1" data-specialty_columns="4">
<div class="et_pb_layout_column et_pb_column_layout_1_3 et_pb_specialty_column"></div>
<div class="et_pb_layout_column et_pb_column_layout_2_3 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_variation et_pb_variation_1_4"></div>
<li data-layout="2_3,1_3" data-specialty="1,0" data-specialty_columns="4">
<div class="et_pb_layout_column et_pb_column_layout_2_3 et_pb_variations et_pb_3_variations">
<div class="et_pb_variation et_pb_variation_full"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation et_pb_variation_1_2"></div>
<div class="et_pb_variation_row">
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_variation et_pb_variation_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_3 et_pb_specialty_column"></div>
<% } else if ( typeof view !== \'undefined\' && typeof view.model.attributes.specialty_columns !== \'undefined\' ) { %>
<div class="et_pb_layout_column et_pb_column_layout_fullwidth"></div>
<li data-layout="1_2,1_2">
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<% if ( view.model.attributes.layout === "2_3" ) { %>
<li data-layout="1_4,1_4,1_4,1_4">
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<li data-layout="1_3,1_3,1_3">
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_fullwidth"></div>
<li data-layout="1_2,1_2">
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<li data-layout="1_3,1_3,1_3">
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<li data-layout="1_4,1_4,1_4,1_4">
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<li data-layout="1_5,1_5,1_5,1_5,1_5">
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<li data-layout="1_6,1_6,1_6,1_6,1_6,1_6">
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<li data-layout="2_5,3_5">
<div class="et_pb_layout_column et_pb_column_layout_2_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_3_5"></div>
<li data-layout="3_5,2_5">
<div class="et_pb_layout_column et_pb_column_layout_3_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_2_5"></div>
<li data-layout="1_3,2_3">
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_2_3"></div>
<li data-layout="2_3,1_3">
<div class="et_pb_layout_column et_pb_column_layout_2_3"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_3"></div>
<li data-layout="1_4,3_4">
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_3_4"></div>
<li data-layout="3_4,1_4">
<div class="et_pb_layout_column et_pb_column_layout_3_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<li data-layout="1_4,1_2,1_4">
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<li data-layout="1_5,3_5,1_5">
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_3_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<li data-layout="1_4,1_4,1_2">
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<li data-layout="1_2,1_4,1_4">
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_4"></div>
<li data-layout="1_5,1_5,3_5">
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_3_5"></div>
<li data-layout="3_5,1_5,1_5">
<div class="et_pb_layout_column et_pb_column_layout_3_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_5"></div>
<li data-layout="1_6,1_6,1_6,1_2">
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<li data-layout="1_2,1_6,1_6,1_6">
<div class="et_pb_layout_column et_pb_column_layout_1_2"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
<div class="et_pb_layout_column et_pb_column_layout_1_6"></div>
return apply_filters( 'et_builder_layout_columns', $layout_columns );
* Display meta box in admin screen.
function et_pb_pagebuilder_meta_box() {
do_action( 'et_pb_before_page_builder' );
if ( et_builder_bfb_enabled() ) {
$edit_page_id = get_the_ID();
$no_rtl_class = is_rtl() && 'on' === et_get_option( 'divi_disable_translations', 'off' ) ? 'et-fb-no-rtl' : '';
// Polylang creates copy of page and BFB should be loaded on page which is not saved yet and cannot be loaded on FE
// Therefore load the homepage and replace the content for BFB to make it load with content from other post.
if ( 'add' === get_current_screen()->action || (int) get_option( 'page_for_posts' ) === $edit_page_id ) {
$new_page_url = get_home_url();
$bfb_url = et_core_intentionally_unescaped( et_fb_get_bfb_url( $new_page_url, $is_new_page, $edit_page_id ), 'fixed_string' );
// If Admin is SSL but FE is not, we need to fix VB url or it won't work
// because trying to load insecure resource.
$bfb_url = set_url_scheme( $bfb_url, is_ssl() ? 'https' : 'http' );
// phpcs:disable WordPress.Security.EscapeOutput -- XSS safe.
<div class='et_divi_builder et-bfb-page-preloading et_divi_builder_bottom_margin'>
var iframe = document.body.appendChild(document.createElement('iframe'));
iframe.id = 'et-bfb-app-frame';
document.body.classList.add('et-db');
document.body.classList.add('et-bfb');
if ('' !== '{$no_rtl_class}') {
document.body.classList.add('{$no_rtl_class}');
document.addEventListener('DOMContentLoaded', function() {
var outer = jQuery('<div>', {id: 'et-boc', class: 'et-boc'});
var inner = jQuery('<div>', {class: 'et-l'});
var app = jQuery('<div>', {id: 'et-fb-app'});
jQuery('#wpwrap').wrap(outer);
jQuery('#et-bfb-app-frame').appendTo('#et_pb_layout .et_divi_builder');
iframe.src = '{$bfb_url}';
// Add first-visible classname to first visible metabox on #normal-sortables