: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'target' => 'et_pb_role_settings',
'view' => ( isset( $_GET['page'] ) && $_GET['page'] === "et_{$_shortname}_role_editor" ), // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
// Register the Builder Layouts Post Type portability.
et_core_portability_register( 'et_builder_layouts', array(
'name' => esc_html__( 'Divi Builder Layouts', 'et_builder' ),
'target' => ET_BUILDER_LAYOUT_POST_TYPE,
'view' => ( isset( $_GET['post_type'] ) && $_GET['post_type'] === ET_BUILDER_LAYOUT_POST_TYPE ), // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
if ( current_user_can( 'edit_posts' ) ) {
// Register the Builder individual layouts portability.
et_core_portability_register( 'et_builder', array(
'name' => esc_html__( 'Divi Builder Layout', 'et_builder' ),
'view' => ( function_exists( 'et_builder_should_load_framework' ) && et_builder_should_load_framework() ),
add_action( 'admin_init', 'et_pb_register_builder_portabilities' );
* Modify the portability export WP query.
* @return string New query.
function et_pb_modify_portability_export_wp_query( $query ) {
// Exclude predefined layout from export.
return array_merge( $query, array(
'key' => '_et_pb_predefined_layout',
'compare' => 'NOT EXISTS',
'key' => '_et_pb_predefined_layout',
add_filter( 'et_core_portability_export_wp_query_et_builder_layouts', 'et_pb_modify_portability_export_wp_query' );
* Check whether current page is pagebuilder preview page
function is_et_pb_preview() {
return ( 'true' === $wp_query->get( 'et_pb_preview' ) && isset( $_GET['et_pb_preview_nonce'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
if ( ! function_exists( 'et_pb_is_pagebuilder_used' ) ) :
function et_pb_is_pagebuilder_used( $page_id = 0 ) {
$page_id = et_core_page_resource_get_the_ID();
'on' === get_post_meta( $page_id, '_et_pb_use_builder', true ) ||
// Divi layout post type always use the builder
'et_pb_layout' === get_post_type( $page_id ) ||
// Extra Category post type always use the builder
'layout' === get_post_type( $page_id )
if ( ! function_exists( 'et_fb_is_enabled' ) ) :
* @internal NOTE: Don't use this from outside builder code! {@see et_core_is_fb_enabled()}.
function et_fb_is_enabled( $post_id = false ) {
// Cache results since the function could end up being called thousands of times.
$post_id = isset( $post->ID ) ? $post->ID : false;
$check = apply_filters( 'et_fb_is_enabled', null, $post_id );
if ( isset( $cache[ $post_id ] ) ) {
return $cache[ $post_id ];
$cache[ $post_id ] = false;
if ( is_customize_preview() ) {
if ( empty( $_GET['et_fb'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
if ( ! current_user_can( 'edit_posts' ) ) {
if ( ! et_pb_is_pagebuilder_used( $post_id ) ) {
if ( ! et_pb_is_allowed( 'use_visual_builder' ) ) {
$cache[ $post_id ] = true;
if ( ! function_exists( 'et_fb_is_builder_ajax' ) ) :
* Returns whether current request is a builder AJAX call.
function et_fb_is_builder_ajax() {
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
if ( ! wp_doing_ajax() || empty( $_REQUEST['action'] ) ) {
'et_fb_update_builder_assets',
'et_fb_retrieve_builder_data',
if ( ! function_exists( 'et_fb_is_computed_callback_ajax' ) ) :
* Returns whether current request is computed callback AJAX call
function et_fb_is_computed_callback_ajax() {
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
if ( ! wp_doing_ajax() || empty( $_REQUEST['action'] ) ) {
return 'et_pb_process_computed_property' === $_REQUEST['action'];
if ( ! function_exists( 'et_fb_is_resolve_post_content_callback_ajax' ) ) :
* Returns whether current request is resolve post content callback AJAX call
function et_fb_is_resolve_post_content_callback_ajax() {
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
if ( ! wp_doing_ajax() || empty( $_REQUEST['action'] ) ) {
return 'et_builder_resolve_post_content' === $_REQUEST['action'];
if ( ! function_exists( 'et_fb_auto_activate_builder' ) ) :
function et_fb_auto_activate_builder() {
current_user_can( 'edit_post', $post_id ) &&
isset( $_GET['et_fb_activation_nonce'] ) &&
wp_verify_nonce( $_GET['et_fb_activation_nonce' ], 'et_fb_activation_nonce_' . get_the_ID() )
$set_content = et_builder_set_content_activation( $post_id );
$post_url = get_permalink( $post_id );
$redirect_url = $set_content ? et_fb_get_vb_url( $post_url ) : $post_url;
wp_redirect( $redirect_url );
add_action( 'template_redirect', 'et_fb_auto_activate_builder' );
* Enable the VB for a post.
* @param integer $post_id
* @param bool $show_page_creation
function et_builder_enable_for_post( $post_id, $show_page_creation = true ) {
$_post = get_post( $post_id );
if ( ! $post_id || ! $_post || ! is_object( $_post ) ) {
$activate_builder = update_post_meta( $post_id, '_et_pb_use_builder', 'on' );
if ( false === $activate_builder ) {
update_post_meta( $post_id, '_et_pb_show_page_creation', $show_page_creation ? 'on' : 'off' );
function et_builder_set_content_activation( $post_id = false ) {
$_post = get_post( $post_id );
if ( ! $post_id || ! $_post || ! is_object( $_post ) ) {
$activate_builder = et_builder_enable_for_post( $post_id );
if ( false === $activate_builder ) {
// If content already has a section (not as divi/layout block attribute), it means builder is
// active and activation has to be skipped to avoid nested and unwanted builder structure
if ( ! has_block( 'divi/layout', $post_id ) && has_shortcode( $_post->post_content, 'et_pb_section' ) ) {
// `update_post_meta()`'s saved value is run through `stripslashes()` which makes encoded
// shortcode on layout block's `layoutContent` attributes looses its slashes when being saved.
// To fix this, If saved content has layout block, add one more slash using `wp_slash()`.
// NOTE:`$new_old_content` parameter is meant to be used as `update_post_meta()` parameter only
// {@see https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping}
$content_has_layout_block = has_block( 'divi/layout', $_post->post_content );
$new_old_content = $_post->post_content;
$saved_old_content = get_post_meta( $post_id, '_et_pb_old_content', true );
$save_old_content = update_post_meta( $post_id, '_et_pb_old_content', $new_old_content );
* Filters the flag that sets default Content during Builder activation.
* @param bool $is_skip_content_activation TRUE skips the content activation.
* @param WP_Post $_post The Post.
* @used-by et_builder_wc_init()
if ( apply_filters( 'et_builder_skip_content_activation', false, $_post ) ) {
if ( false === $save_old_content && $saved_old_content !== $_post->post_content && '' !== $_post->post_content ) {
$text_module = '' !== $_post->post_content ? '[et_pb_text admin_label="Text"]'. $_post->post_content .'[/et_pb_text]' : '';
if ( has_block( 'divi/layout', $post_id ) ) {
$updated_content = et_builder_convert_block_to_shortcode( $_post->post_content );
$updated_content = '[et_pb_section admin_label="section"]
[et_pb_row admin_label="row"]
[et_pb_column type="4_4"]'. $text_module .'[/et_pb_column]
$_post->post_content = $updated_content;
$update_post = wp_update_post( $_post );
if ( 0 < $update_post ) {
setup_postdata( $_post );
if ( ! function_exists( 'et_builder_get_font_family' ) ) :
function et_builder_get_font_family( $font_name, $use_important = false ) {
$user_fonts = et_builder_get_custom_fonts();
$fonts = isset( $user_fonts[ $font_name ] ) ? $user_fonts : et_builder_get_fonts();
$removed_fonts_mapping = et_builder_old_fonts_mapping();
$font_style = $font_weight = '';
$font_name_ms = isset( $fonts[ $font_name ] ) && isset( $fonts[ $font_name ]['add_ms_version'] ) ? "'{$font_name} MS', " : "";
if ( isset( $removed_fonts_mapping[ $font_name ] ) && isset( $removed_fonts_mapping[ $font_name ]['parent_font'] ) ) {
$font_style = $removed_fonts_mapping[ $font_name ]['styles'];
$font_name = $removed_fonts_mapping[ $font_name ]['parent_font'];
if ( '' !== $font_style ) {
$font_weight = sprintf( ' font-weight: %1$s;', esc_html( $font_style ) );
$style = sprintf( 'font-family: \'%1$s\', %5$s%2$s%3$s;%4$s',
isset( $fonts[ $font_name ] ) ? et_builder_get_websafe_font_stack( $fonts[ $font_name ]['type'] ) : 'sans-serif',
( $use_important ? ' !important' : '' ),
if ( ! function_exists( 'et_builder_get_fonts' ) ) :
function et_builder_get_fonts( $settings = array() ) {
// Only return websafe fonts if google fonts disabled
if ( ! et_core_use_google_fonts() ) {
return et_builder_get_websafe_fonts();
'prepend_standard_fonts' => true,
$settings = wp_parse_args( $settings, $defaults );
$fonts = $settings['prepend_standard_fonts']
? array_merge( et_builder_get_websafe_fonts(), et_builder_get_google_fonts() )
: array_merge( et_builder_get_google_fonts(), et_builder_get_websafe_fonts() );
if ( ! function_exists( 'et_builder_get_websafe_font_stack' ) ) :
function et_builder_get_websafe_font_stack( $type = 'sans-serif' ) {
$font_stack = 'Helvetica, Arial, Lucida, sans-serif';
$font_stack = 'Georgia, "Times New Roman", serif';
if ( ! function_exists( 'et_builder_get_websafe_fonts' ) ) :
function et_builder_get_websafe_fonts() {
return et_core_get_websafe_fonts();
if ( ! function_exists( 'et_builder_get_font_weight_list' ) ) :
function et_builder_get_font_weight_list() {
$default_font_weights_list = array(
'100' => esc_html__( 'Thin', 'et_builder' ),
'200' => esc_html__( 'Ultra Light', 'et_builder' ),
'300' => et_builder_i18n( 'Light' ),
'400' => esc_html__( 'Regular', 'et_builder' ),
'500' => esc_html__( 'Medium', 'et_builder' ),
'600' => esc_html__( 'Semi Bold', 'et_builder' ),
'700' => esc_html__( 'Bold', 'et_builder' ),
'800' => esc_html__( 'Ultra Bold', 'et_builder' ),
'900' => esc_html__( 'Heavy', 'et_builder' ),
return apply_filters( 'et_builder_all_font_weights', $default_font_weights_list );
* Retrieve list of uploaded user fonts stored in `et_uploaded_fonts` option.
* @return array fonts list
if ( ! function_exists( 'et_builder_get_custom_fonts' ) ) :
function et_builder_get_custom_fonts() {
$all_custom_fonts = get_option( 'et_uploaded_fonts', array() );
// Convert any falsey value to empty array to avoid PHP errors.
if ( ! is_array( $all_custom_fonts ) ) {
$all_custom_fonts = array();
return ( array ) apply_filters( 'et_builder_custom_fonts', $all_custom_fonts );
function et_builder_old_fonts_mapping() {
'Raleway Light' => array(
'parent_font' => 'Raleway',
'parent_font' => 'Roboto',
'Source Sans Pro Light' => array(
'parent_font' => 'Source Sans Pro',
'Open Sans Light' => array(
'parent_font' => 'Open Sans',
if ( ! function_exists( 'et_builder_google_fonts_sync' ) ) :
function et_builder_google_fonts_sync() {
$google_api_key = et_pb_get_google_api_key();
if ( '' === $google_api_key || ! et_core_use_google_fonts() ) {
$google_fonts_api_url = sprintf( 'https://www.googleapis.com/webfonts/v1/webfonts?key=%1$s', $google_api_key );
$google_fonts_response = wp_remote_get( esc_url_raw( $google_fonts_api_url ) );
$google_fonts = is_array( $google_fonts_response ) ? et_core_parse_google_fonts_json( wp_remote_retrieve_body( $google_fonts_response ) ) : array();
if ( ! empty( $google_fonts ) ) {
update_option( 'et_google_fonts_cache', $google_fonts );
// save google fonts cache status
set_transient( 'fonts_cache_status', 'valid', 12 * HOUR_IN_SECONDS );
if ( ! function_exists( 'et_builder_get_google_fonts' ) ) :
function et_builder_get_google_fonts() {
if ( ! et_core_use_google_fonts() ) {
// Update fonts cache daily.
if ( 'valid' !== get_transient( 'fonts_cache_status' ) ) {