: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$wrap_post_id = $main_post_id;
$wrap_selector = et_pb_is_pagebuilder_used( $wrap_post_id ) && ( et_is_builder_plugin_active() || et_builder_post_is_of_custom_post_type( $wrap_post_id ) );
$selector_prefix = ' ' . ET_BUILDER_CSS_PREFIX . $selector_prefix;
$output = get_post_meta( $page_id, '_et_pb_custom_css', true );
if ( isset( $page_settings['et_pb_light_text_color'] ) ) {
'%2$s .et_pb_bg_layout_dark { color: %1$s !important; }',
esc_html( $page_settings['et_pb_light_text_color'] ),
esc_html( $selector_prefix )
if ( isset( $page_settings['et_pb_dark_text_color'] ) ) {
'%2$s .et_pb_bg_layout_light { color: %1$s !important; }',
esc_html( $page_settings['et_pb_dark_text_color'] ),
esc_html( $selector_prefix )
if ( isset( $page_settings['et_pb_content_area_background_color'] ) ) {
$content_area_bg_selector = et_is_builder_plugin_active() ? $selector_prefix : ' .page.et_pb_pagebuilder_layout #main-content';
'%1$s { background-color: %2$s; }',
esc_html( $content_area_bg_selector ),
esc_html( $page_settings['et_pb_content_area_background_color'] )
if ( isset( $page_settings['et_pb_section_background_color'] ) ) {
'%2$s > .et_builder_inner_content > .et_pb_section { background-color: %1$s; }',
esc_html( $page_settings['et_pb_section_background_color'] ),
esc_html( $selector_prefix )
$overflow_x = $overflow->get_value_x( $page_settings, '', 'et_pb_' );
$overflow_y = $overflow->get_value_y( $page_settings, '', 'et_pb_' );
if ( ! empty( $overflow_x ) ) {
'%2$s .et_builder_inner_content { overflow-x: %1$s; }',
esc_html( $selector_prefix )
if ( ! empty( $overflow_y ) ) {
'%2$s .et_builder_inner_content { overflow-y: %1$s; }',
esc_html( $selector_prefix )
if ( isset( $page_settings['et_pb_page_z_index'] ) && '' !== $page_settings['et_pb_page_z_index'] ) {
'%2$s .et_builder_inner_content { z-index: %1$s; }',
esc_html( $page_settings['et_pb_page_z_index'] ),
esc_html( '.et-db #et-boc .et-l' . $selector_prefix )
return apply_filters( 'et_pb_page_custom_css', $output );
if ( ! function_exists( 'et_pb_video_oembed_data_parse' ) ) :
function et_pb_video_oembed_data_parse( $return, $data, $url ) {
if ( isset( $data->thumbnail_url ) ) {
return esc_url( str_replace( array('https://', 'http://'), '//', $data->thumbnail_url ), array('http') );
if ( ! function_exists( 'et_pb_check_oembed_provider' ) ):
function et_pb_check_oembed_provider( $url ) {
if ( version_compare( $GLOBALS['wp_version'], '5.3', '<' ) ) {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
require_once( ABSPATH . WPINC . '/class-wp-oembed.php' );
$oembed = _wp_oembed_get_object();
return $oembed->get_provider( esc_url( $url ), array( 'discover' => false ) );
* Get cached embedded item on page load.
* Use the item source as the key, so some modules with the same item can share it.
* @param string $url Item URL
* @param string $group Item group to set different cache for the same key
* @param boolean $is_cache Whether to use WordPress Object Cache or not
if ( ! function_exists( 'et_builder_get_oembed' ) ) :
function et_builder_get_oembed( $url, $group = 'video', $is_cache = true ) {
$item_src = esc_url( $url );
// Temporarily save embedded item on page load only. Use the item source as the
// key, so some modules with the same item can share it.
$item_embed = $is_cache ? wp_cache_get( $item_src, $group ) : false;
$item_embed = wp_oembed_get( $item_src );
wp_cache_set( $item_src, $item_embed, $group );
return apply_filters( 'et_builder_get_oembed', $item_embed, $url, $group, $is_cache );
if ( ! function_exists( 'et_pb_set_video_oembed_thumbnail_resolution' ) ) :
function et_pb_set_video_oembed_thumbnail_resolution( $image_src, $resolution = 'default' ) {
// Replace YouTube video thumbnails to high resolution if the high resolution image exists.
if ( 'high' === $resolution && false !== strpos( $image_src, 'hqdefault.jpg' ) ) {
$high_res_image_src = str_replace( 'hqdefault.jpg', 'maxresdefault.jpg', $image_src );
$protocol = is_ssl() ? 'https://' : 'http://';
$processed_image_url = esc_url( str_replace( '//', $protocol, $high_res_image_src ), array('http', 'https') );
$response = wp_remote_get( $processed_image_url, array( 'timeout' => 30 ) );
// Youtube doesn't guarantee that high res image exists for any video, so we need to check whether it exists and fallback to default image in case of error
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
return $high_res_image_src;
function et_builder_get_widget_areas_list() {
global $wp_registered_sidebars;
foreach ( $wp_registered_sidebars as $sidebar_key => $sidebar ) {
$widget_areas[ $sidebar_key ] = array(
'name' => $sidebar[ 'name' ]
return apply_filters( 'et_builder_get_widget_areas_list', $widget_areas );
if ( ! function_exists( 'et_builder_get_widget_areas' ) ) :
function et_builder_get_widget_areas() {
$wp_registered_sidebars = et_builder_get_widget_areas_list();
$et_pb_widgets = get_theme_mod( 'et_pb_widgets' );
$output = '<select name="et_pb_area" id="et_pb_area">';
foreach ( $wp_registered_sidebars as $id => $options ) {
'<%%= typeof( et_pb_area ) !== "undefined" && "%1$s" === et_pb_area ? " selected=\'selected\'" : "" %%>',
'<option value="%1$s"%2$s>%3$s</option>',
esc_html( $options['name'] )
if ( ! function_exists( 'et_pb_export_layouts_interface' ) ) :
function et_pb_export_layouts_interface() {
if ( ! current_user_can( 'export' ) )
wp_die( esc_html__( 'You do not have sufficient permissions to export the content of this site.', 'et_builder' ) );
<a href="<?php echo et_core_esc_wp( admin_url( 'edit-tags.php?taxonomy=layout_category' ) ); ?>" id="et_load_category_page"><?php esc_html_e( 'Manage Categories', 'et_builder' ); ?></a>
echo et_core_esc_previously( et_builder_portability_link( 'et_builder_layouts', array( 'class' => 'et-pb-portability-button' ) ) );
add_action( 'export_wp', 'et_pb_edit_export_query' );
function et_pb_edit_export_query() {
add_filter( 'query', 'et_pb_edit_export_query_filter' );
function et_pb_edit_export_query_filter( $query ) {
// Apply filter only once
remove_filter( 'query', 'et_pb_edit_export_query_filter') ;
et_core_nonce_verified_previously();
// ensure user can export
if ( ! current_user_can( 'export' ) ) {
$content = ! empty( $_GET['content'] ) ? sanitize_text_field( $_GET['content'] ) : '';
if ( ET_BUILDER_LAYOUT_POST_TYPE !== $content ) {
foreach ( $possible_types as $template_type ) {
$selected_type = 'et_pb_template_' . $template_type;
if ( isset( $_GET[ $selected_type ] ) ) {
$sql = " AND ( `{$wpdb->term_relationships}`.term_taxonomy_id = %d";
$sql .= " OR `{$wpdb->term_relationships}`.term_taxonomy_id = %d";
$sql_args[] = (int) $_GET[ $selected_type ];
INNER JOIN %3$s ON ( %4$s.ID = %3$s.object_id )
WHERE %4$s.post_type = "%1$s"
AND %4$s.post_status != "auto-draft"
ET_BUILDER_LAYOUT_POST_TYPE,
$wpdb->term_relationships,
$query = $wpdb->prepare( $sql, $sql_args ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- value of $sql was safely prepared above.
function et_pb_setup_theme(){
add_action( 'add_meta_boxes', 'et_pb_add_custom_box', 10, 2 );
add_action( 'add_meta_boxes', 'et_builder_prioritize_meta_box', 999999 );
add_filter( 'hidden_meta_boxes', 'et_pb_hidden_meta_boxes');
add_action( 'init', 'et_pb_setup_theme', 11 );
* Override metaboxes order to ensure Divi Builder metabox has top position.
* @param string $value Custom value.
function et_builder_override_meta_boxes_order( $value ) {
// Store the value on the first call;
$custom = false === $custom ? $value : $custom;
* Forcefully prioritize the Divi Builder metabox to be at the top.
* User drag&drop metabox order customizations are still supported.
* Required since not all plugins properly register their metaboxes in the add_meta_boxes hook.
function et_builder_prioritize_meta_box() {
$screen = get_current_screen();
// Only prioritize Divi Builder metabox if current post type has Divi Builder enabled
if ( ! in_array( $screen->post_type, et_builder_get_enabled_builder_post_types() ) ) {
$option_name = "meta-box-order_$page";
$custom = get_user_option( $option_name );
foreach ( $wp_meta_boxes as $page => $contexts ) {
foreach ( $contexts as $context => $priorities ) {
foreach ( $priorities as $priority => $boxes ) {
if ( ! isset( $boxes[ ET_BUILDER_LAYOUT_POST_TYPE ] ) ) {
$divi = $boxes[ ET_BUILDER_LAYOUT_POST_TYPE ];
unset( $boxes[ ET_BUILDER_LAYOUT_POST_TYPE ] );
$wp_meta_boxes[ $page ][ $context ][ $priority ] = array_merge( array( ET_BUILDER_LAYOUT_POST_TYPE => $divi ), $boxes );
// If our mbox is the first one in custom ordering
if ( is_array( $custom ) && 0 === strpos( $custom[ $context ], ET_BUILDER_LAYOUT_POST_TYPE ) ) {
// Find all metaboxes that are not included in custom order
$sorted = explode( ',', $custom[ $context ] );
$add = array_diff( array_keys( $boxes ), $sorted );
$custom[ $context ] = implode( ',', array_merge( array( ET_BUILDER_LAYOUT_POST_TYPE ), $add, array_slice( $sorted, 1 ) ) );
// Store the custom value
et_builder_override_meta_boxes_order( $custom );
// and override `get_user_option` so WP will use it.
add_filter( "get_user_option_{$option_name}", 'et_builder_override_meta_boxes_order' );
* The page builders require the WP Heartbeat script in order to function. We ensure the heartbeat
* is loaded with the page builders by scheduling this callback to run right before scripts
* are output to the footer. {@see 'admin_enqueue_scripts', 'wp_footer'}
function et_builder_maybe_ensure_heartbeat_script() {
// Don't perform any actions on 'wp_footer' if VB is not active
if ( 'wp_footer' === current_filter() && empty( $_GET['et_fb'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
// We have to check both 'registered' AND 'enqueued' to cover cases where heartbeat has been
// de-registered because 'enqueued' will return `true` for a de-registered script at this stage.
$heartbeat_okay = wp_script_is( 'heartbeat', 'registered' ) && wp_script_is( 'heartbeat', 'enqueued' );
$autosave_okay = wp_script_is( 'autosave', 'registered' ) && wp_script_is( 'autosave', 'enqueued' );
if ( '1' === et_()->array_get( $_GET, 'et_bfb', '0' ) ) {
// Do not enqueue WP autosave in the BFB iframe because it doesn't include #content / #excerpt / #title
// and will result in empty (browser) backups (note: still included in top window)
wp_dequeue_script( 'autosave' );
if ( $heartbeat_okay && $autosave_okay ) {
$suffix = SCRIPT_DEBUG ? '' : '.min';
if ( ! $heartbeat_okay ) {
$heartbeat_src = "/wp-includes/js/heartbeat{$suffix}.js";
// wp-hooks was introduced in WP 5.0
$deps = wp_script_is( 'wp-hooks', 'registered' ) ? array( 'jquery', 'wp-hooks' ) : array( 'jquery' );
wp_enqueue_script( 'heartbeat', $heartbeat_src, $deps, false, true );
wp_localize_script( 'heartbeat', 'heartbeatSettings', apply_filters( 'heartbeat_settings', array() ) );
if ( ! $autosave_okay ) {
$autosave_src = "/wp-includes/js/autosave{$suffix}.js";
wp_enqueue_script( 'autosave', $autosave_src, array( 'heartbeat' ), false, true );
// Enqueue dashicons in front-end if they are not enqueued (that happens when not logged in as admin)
function et_builder_maybe_enqueue_dashicons() {
if ( wp_style_is( 'dashicons' ) ) {
wp_enqueue_style( 'dashicons' );
add_action( 'admin_print_scripts-post-new.php', 'et_builder_maybe_ensure_heartbeat_script', 9 );
add_action( 'admin_print_scripts-post.php', 'et_builder_maybe_ensure_heartbeat_script', 9 );
add_action( 'wp_enqueue_scripts', 'et_builder_maybe_enqueue_dashicons', 19 );
add_action( 'wp_footer', 'et_builder_maybe_ensure_heartbeat_script', 19 );
function et_builder_set_post_type( $post_type = '' ) {
global $et_builder_post_type, $post;
$et_builder_post_type = ! empty( $post_type ) ? $post_type : $post->post_type;
* Saves Metabox settings.
* @since 3.29.2 Included check to verify if constant exists before use.
* Throws error otherwise from PHP7.2.x
function et_pb_metabox_settings_save_details( $post_id, $post ){
if ( 'post.php' !== $pagenow ) return $post_id;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// do not update builder post meta when Preview is loading.
if ( isset( $_POST['wp-preview'] ) && 'dopreview' === $_POST['wp-preview'] ) {
$post_type = get_post_type_object( $post->post_type );
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
if ( ! isset( $_POST['et_pb_settings_nonce'] ) || ! wp_verify_nonce( $_POST['et_pb_settings_nonce'], basename( __FILE__ ) ) )
if ( isset( $_POST['et_pb_use_builder'] ) ) {
$et_pb_use_builder_input = sanitize_text_field( $_POST['et_pb_use_builder'] );
update_post_meta( $post_id, '_et_pb_use_builder', $et_pb_use_builder_input );
if ( ! empty( $_POST['et_builder_version'] ) ) {
update_post_meta( $post_id, '_et_builder_version', sanitize_text_field( $_POST['et_builder_version'] ) );
$et_pb_show_page_creation_input = isset( $_POST['et_pb_show_page_creation'] ) ? sanitize_text_field( $_POST['et_pb_show_page_creation'] ) : false;
if ( 'on' === $et_pb_show_page_creation_input ) {
// Set page creation flow to on.
update_post_meta( $post_id, '_et_pb_show_page_creation', 'on' );
} elseif ( 'off' === $et_pb_show_page_creation_input ) {
// Delete page creation flow.
delete_post_meta( $post_id, '_et_pb_show_page_creation' );
} elseif ( false === $et_pb_show_page_creation_input && 'on' === $et_pb_use_builder_input ) {
$et_pb_show_page_creation_meta = get_post_meta( $post_id, '_et_pb_show_page_creation', true );
// Strip non-printable characters.
$post_content_cleaned = preg_replace('/[\x00-\x1F\x7F]/u', '', $post->post_content);
preg_match_all( '/\[et_pb_section(.*?)?\]\[et_pb_row(.*?)?\]\[et_pb_column(.*?)?\](.+?)\[\/et_pb_column\]\[\/et_pb_row\]\[\/et_pb_section\]/m', $post_content_cleaned, $matches );
if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
if ( 'on' === $et_pb_show_page_creation_meta ) {
// Set page creation flow to on.
update_post_meta( $post_id, '_et_pb_show_page_creation', 'off' );
delete_post_meta( $post_id, '_et_pb_show_page_creation' );
if ( 'on' !== $et_pb_use_builder_input ) {
if ( defined( 'ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY' ) ) {
delete_post_meta( $post_id, ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY );
delete_post_meta( $post_id, '_et_pb_use_builder' );
delete_post_meta( $post_id, '_et_builder_version' );
if ( defined( 'ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY' ) ) {
delete_post_meta( $post_id, ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY );