: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
add_action( 'wp_ajax_et_fb_ajax_save', 'et_fb_ajax_save' );
function et_fb_get_shortcode_from_fb_object() {
if ( ! et_core_security_check( 'edit_posts', 'et_fb_convert_to_shortcode_nonce', 'et_fb_convert_to_shortcode_nonce', '_POST', false ) ) {
$shortcode_data = json_decode( stripslashes( $_POST['modules'] ), true );
$post_content = et_fb_process_to_shortcode( $shortcode_data, array(), $layout_type );
// Get rendered post content only if it's needed.
$utils = ET_Core_Data_Utils::instance();
$return_rendered_content = sanitize_text_field( $utils->array_get( $_POST, 'options.return_rendered_content', 'false' ) );
$rendered_post_content = 'true' === $return_rendered_content ? do_shortcode( $post_content ) : '';
wp_send_json_success( array(
'processed_content' => $post_content,
'rendered_content' => $rendered_post_content,
add_action( 'wp_ajax_et_fb_get_shortcode_from_fb_object', 'et_fb_get_shortcode_from_fb_object' );
function et_fb_save_layout() {
if ( ! wp_verify_nonce( $_POST['et_fb_save_library_modules_nonce'], 'et_fb_save_library_modules_nonce' ) ){
if ( ! current_user_can( 'edit_posts' ) ) {
if ( empty( $_POST['et_layout_name'] ) ) {
$post_type = sanitize_text_field( et_()->array_get( $_POST, 'et_post_type', 'page' ) );
if ( et_theme_builder_is_layout_post_type( $post_type ) ) {
// Treat TB layouts as normal posts when storing layouts from the library.
'layout_type' => isset( $_POST['et_layout_type'] ) ? sanitize_text_field( $_POST['et_layout_type'] ) : 'layout',
'layout_selected_cats' => isset( $_POST['et_layout_cats'] ) ? sanitize_text_field( $_POST['et_layout_cats'] ) : '',
'built_for_post_type' => $post_type,
'layout_new_cat' => isset( $_POST['et_layout_new_cat'] ) ? sanitize_text_field( $_POST['et_layout_new_cat'] ) : '',
'columns_layout' => isset( $_POST['et_columns_layout'] ) ? sanitize_text_field( $_POST['et_columns_layout'] ) : '0',
'module_type' => isset( $_POST['et_module_type'] ) ? sanitize_text_field( $_POST['et_module_type'] ) : 'et_pb_unknown',
'layout_scope' => isset( $_POST['et_layout_scope'] ) ? sanitize_text_field( $_POST['et_layout_scope'] ) : 'not_global',
'module_width' => isset( $_POST['et_module_width'] ) ? sanitize_text_field( $_POST['et_module_width'] ) : 'regular',
'layout_content' => isset( $_POST['et_layout_content'] ) ? et_fb_process_to_shortcode( json_decode( stripslashes( $_POST['et_layout_content'] ), true ) ) : '',
'layout_name' => isset( $_POST['et_layout_name'] ) ? sanitize_text_field( $_POST['et_layout_name'] ) : '',
$new_layout_meta = et_pb_submit_layout( $args );
die( et_core_esc_previously( $new_layout_meta ) );
add_action( 'wp_ajax_et_fb_save_layout', 'et_fb_save_layout' );
function et_fb_prepare_shortcode() {
if ( !isset( $_POST['et_fb_prepare_shortcode_nonce'] ) || !wp_verify_nonce( $_POST['et_fb_prepare_shortcode_nonce'], 'et_fb_prepare_shortcode_nonce' ) ) {
if ( ! current_user_can( 'edit_posts' ) ) {
$content = isset( $_POST['et_page_content'] ) ? json_decode( stripslashes( $_POST['et_page_content'] ), true ) : '';
$apply_global_presets = isset( $_POST['apply_global_presets'] ) ? wp_validate_boolean( $_POST['apply_global_presets'] ) : false;
'apply_global_presets' => $apply_global_presets,
$result = $content ? et_fb_process_to_shortcode( $content, $options, '', false ) : '';
die( json_encode( array( 'shortcode' => $result ) ) );
add_action( 'wp_ajax_et_fb_prepare_shortcode', 'et_fb_prepare_shortcode' );
function et_fb_update_layout() {
if ( ! wp_verify_nonce( $_POST['et_fb_save_library_modules_nonce'], 'et_fb_save_library_modules_nonce' ) ) {
if ( ! current_user_can( 'edit_posts' ) ) {
$post_id = isset( $_POST['et_template_post_id'] ) ? absint( $_POST['et_template_post_id'] ) : '';
if ( ! current_user_can( 'edit_post', $post_id ) ) {
$post_content = json_decode( stripslashes( $_POST['et_layout_content'] ), true );
$new_content = isset( $_POST['et_layout_content'] ) ? et_fb_process_to_shortcode( $post_content ) : '';
$excluded_global_options = isset( $_POST['et_excluded_global_options'] ) ? stripslashes( $_POST['et_excluded_global_options'] ) : array();
$is_saving_global_module = isset( $_POST['et_saving_global_module'] ) ? sanitize_text_field( $_POST['et_saving_global_module'] ) : '';
'post_content' => $new_content,
$result = wp_update_post( $update );
if ( ! $result || is_wp_error( $result ) ) {
ET_Core_PageResource::remove_static_resources( 'all', 'all' );
// update list of unsynced options for global module
if ( 'true' === $is_saving_global_module ) {
update_post_meta( $post_id, '_et_pb_excluded_global_options', sanitize_text_field( $excluded_global_options ) );
add_action( 'wp_ajax_et_fb_update_layout', 'et_fb_update_layout' );
function et_fb_fetch_attachments() {
et_core_security_check( 'edit_posts', 'et_fb_fetch_attachments', 'et_fb_fetch_attachments' );
$ids = ET_Core_Data_Utils::instance()->array_get( $_POST, 'ids' );
$attachments = get_posts( array(
'post_type' => 'attachment',
foreach ( $attachments as $index => $attachment ) {
foreach ( get_intermediate_image_sizes() as $size ) {
$metadata[ $size ] = wp_get_attachment_image_src( $attachment->ID, $size );
$attachments[ $index ] = array_merge( get_object_vars( $attachment ), array(
wp_send_json( $attachments );
add_action( 'wp_ajax_et_fb_fetch_attachments', 'et_fb_fetch_attachments' );
if ( ! function_exists( 'et_fb_disable_product_tour' ) ) :
function et_fb_disable_product_tour() {
do_action( 'et_fb_disable_product_tour' );
if ( ! et_core_security_check_passed( 'edit_posts' ) ) {
ET_Core_Logger::debug( 'Unable to disable product tour. Security check failed!' );
$user_id = (int) get_current_user_id();
$all_product_settings = et_get_option( 'product_tour_status', array() );
$all_product_settings[ $user_id ] = 'off';
et_update_option( 'product_tour_status', $all_product_settings );
* Generate output string for `include_categories` option used in backbone template.
if ( ! function_exists( 'et_builder_include_categories_option' ) ) :
function et_builder_include_categories_option( $args = array(), $default_category = '' ) {
if ( !empty( $args['custom_items'] ) ) {
$custom_items = $args['custom_items'];
unset($args['custom_items']);
$defaults = apply_filters( 'et_builder_include_categories_defaults', array (
'term_name' => 'project_category',
'field_name' => 'et_pb_include_categories',
$args = wp_parse_args( $args, $defaults );
$args['field_name'] = esc_attr( $args['field_name'] );
$term_args = apply_filters( 'et_builder_include_categories_option_args', array( 'hide_empty' => false, ) );
$output = "\t" . "<% var {$args['field_name']}_temp = typeof data !== 'undefined' && typeof data.{$args['field_name']} !== 'undefined' ? data.{$args['field_name']}.split( ',' ) : ['" . esc_html( $default_category ) . "']; {$args['field_name']}_temp = typeof data === 'undefined' && typeof {$args['field_name']} !== 'undefined' ? {$args['field_name']}.split( ',' ) : {$args['field_name']}_temp; %>" . "\n";
if ( $args['use_terms'] ) {
$cats_array = get_terms( $args['term_name'], $term_args );
$cats_array = get_categories( apply_filters( 'et_builder_get_categories_args', 'hide_empty=0' ) );
$cats_array = array_merge( $custom_items, $cats_array );
if ( empty( $cats_array ) ) {
$taxonomy_type = $args['use_terms'] ? $args['term_name'] : 'category';
$taxonomy = get_taxonomy( $taxonomy_type );
$labels = get_taxonomy_labels( $taxonomy );
$output = sprintf( '<p>%1$s</p>', esc_html( $labels->not_found ) );
foreach ( $cats_array as $category ) {
"<%%= _.contains( {$args['field_name']}_temp, '%1\$s' ) ? checked='checked' : '' %%>",
is_array( $category ) ? esc_html( $category['term_id'] ) : esc_html( $category->term_id )
'%4$s<label><input type="checkbox" name="%5$s" value="%1$s"%3$s> %2$s</label><br/>',
is_array( $category ) ? esc_html( $category['term_id'] ) : esc_html( $category->term_id ),
is_array( $category ) ? esc_html( $category['name'] ) : esc_html( $category->name ),
$output = "<div id='{$args['field_name']}'>" . $output . '</div>';
return apply_filters( 'et_builder_include_categories_option_html', $output );
* Generate output string for `include_shop_categories` option used in backbone template.
if ( ! function_exists( 'et_builder_include_categories_shop_option' ) ) :
function et_builder_include_categories_shop_option( $args = array() ) {
if ( ! class_exists( 'WooCommerce' ) ) {
$output = "\t" . "<% var et_pb_include_categories_shop_temp = typeof data !== 'undefined' && typeof data.et_pb_include_categories !== 'undefined' ? data.et_pb_include_categories.split( ',' ) : []; et_pb_include_categories_shop_temp = typeof data === 'undefined' && typeof et_pb_include_categories !== 'undefined' ? et_pb_include_categories.split( ',' ) : et_pb_include_categories_shop_temp; %>" . "\n";
$product_categories = et_builder_get_shop_categories( $args );
$output .= '<div id="et_pb_include_categories">';
if ( is_array( $product_categories ) && ! empty( $product_categories ) ) {
foreach ( $product_categories as $category ) {
if ( is_object( $category ) && is_a($category, 'WP_Term') ) {
'<%%= _.contains( et_pb_include_categories_shop_temp, "%1$s" ) ? checked="checked" : "" %%>',
esc_html( $category->term_id )
'%4$s<label><input type="checkbox" name="et_pb_include_categories" value="%1$s"%3$s> %2$s</label><br/>',
esc_attr( $category->term_id ),
esc_html( $category->name ),
return apply_filters( 'et_builder_include_categories_option_html', $output );
if ( ! function_exists( 'et_divi_get_projects' ) ) :
function et_divi_get_projects( $args = array() ) {
'post_type' => 'project',
$args = wp_parse_args( $args, $default_args );
return new WP_Query( $args );
if ( ! function_exists( 'et_pb_extract_items' ) ) :
function et_pb_extract_items( $content ) {
$output = $first_character = '';
$lines = array_filter( explode( "\n", str_replace( array( '<p>', '</p>', '<br />' ), "\n", $content ) ) );
foreach ( $lines as $line ) {
if ( '–' === substr( $line, 0, 7 ) ) {
$line = '-' . substr( $line, 7 );
$first_character = $line[0];
if ( in_array( $first_character, array( '-', '+' ) ) ) {
$line = trim( substr( $line, 1 ) );
$output .= sprintf( '[et_pb_pricing_item available="%2$s"]%1$s[/et_pb_pricing_item]',
( '-' === $first_character ? 'off' : 'on' )
return do_shortcode( $output );
* Get all acceptable string value for given CSS property
* @param string property name
* @return array of acceptable CSS string values of given property name
function et_builder_get_acceptable_css_string_values( $property = 'all' ) {
$acceptable_strings = apply_filters( 'et_builder_acceptable_css_string_values', array(
'font-size' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
if ( 'all' === $property ) {
return $acceptable_strings;
return isset( $acceptable_strings[ $property ] ) ? $acceptable_strings[ $property ] : array();
if ( ! function_exists( 'et_builder_process_range_value' ) ) :
function et_builder_process_range_value( $range, $option_type = '' ) {
if ( $range !== 'none' ) {
$range_digit = floatval( $range );
$range_string = str_replace( et_()->to_css_decimal( $range_digit ), '', (string) $range );
if ( '' !== $option_type && in_array( $range, et_builder_get_acceptable_css_string_values( $option_type ) ) ) {
if ( '' === $range_string ) {
$range_string = 'line_height' === $option_type && 3 >= $range_digit ? 'em' : 'px';
$result = et_()->to_css_decimal( $range_digit ) . $range_string;
return apply_filters( 'et_builder_processed_range_value', $result, $range, $range_string );
if ( ! function_exists( 'et_builder_get_border_styles' ) ) :
function et_builder_get_border_styles() {
'solid' => esc_html__( 'Solid', 'et_builder' ),
'dashed' => esc_html__( 'Dashed', 'et_builder' ),
'dotted' => esc_html__( 'Dotted', 'et_builder' ),
'double' => esc_html__( 'Double', 'et_builder' ),
'groove' => esc_html__( 'Groove', 'et_builder' ),
'ridge' => esc_html__( 'Ridge', 'et_builder' ),
'inset' => esc_html__( 'Inset', 'et_builder' ),
'outset' => esc_html__( 'Outset', 'et_builder' ),
'none' => et_builder_i18n( 'None' ),
return apply_filters( 'et_builder_border_styles', $styles );
if ( ! function_exists( 'et_builder_font_options' ) ) :
function et_builder_font_options() {
$default_options = array( 'default' => array(
'name' => et_builder_i18n( 'Default' ),
$fonts = array_merge( $default_options, et_builder_get_fonts() );
foreach ( $fonts as $font_name => $font_settings ) {
$options[ $font_name ] = 'default' !== $font_name ? $font_name : $font_settings['name'];
if ( ! function_exists( 'et_builder_get_google_font_items' ) ) :
function et_builder_get_google_font_items() {
$font_options = et_builder_font_options();
foreach ( $font_options as $key => $value ) {
'<li class="select-option-item select-option-item-%3$s" data-value="%1$s">%2$s</li>',
str_replace( ' ', '_', esc_attr( $key ) )
if ( ! function_exists( 'et_builder_set_element_font' ) ) :
function et_builder_set_element_font( $font, $use_important = false, $default = false ) {
$font_values = explode( '|', $font );
$default = ! $default ? "||||||||" : $default;
$font_values_default = explode( '|', $default );
if ( ! empty( $font_values ) ) {
// backward compatibility with old version of theme
if ( isset( $font_values[1] ) ) {
$font_values[1] = 'on' === $font_values[1] ? '700' : $font_values[1];
$font_values = array_map( 'trim', $font_values );
$font_name = $font_values[0];
$font_weight = isset( $font_values[1] ) && '' !== $font_values[1] ? $font_values[1] : '';
$is_font_italic = isset( $font_values[2] ) && 'on' === $font_values[2] ? true : false;
$is_font_uppercase = isset( $font_values[3] ) && 'on' === $font_values[3] ? true : false;
$is_font_underline = isset( $font_values[4] ) && 'on' === $font_values[4] ? true : false;
$is_font_small_caps = isset( $font_values[5] ) && 'on' === $font_values[5] ? true : false;
$is_font_line_through = isset( $font_values[6] ) && 'on' === $font_values[6] ? true : false;
$font_line_color = isset( $font_values[7] ) ? $font_values[7] : '';
$font_line_style = isset( $font_values[8] ) ? $font_values[8] : '';
$font_name_default = $font_values_default[0];
$font_weight_default = isset( $font_values_default[1] ) && '' !== $font_values_default[1] ? $font_values_default[1] : '';
$is_font_italic_default = isset( $font_values_default[2] ) && 'on' === $font_values_default[2] ? true : false;
$is_font_uppercase_default = isset( $font_values_default[3] ) && 'on' === $font_values_default[3] ? true : false;
$is_font_underline_default = isset( $font_values_default[4] ) && 'on' === $font_values_default[4] ? true : false;
$is_font_small_caps_default = isset( $font_values_default[5] ) && 'on' === $font_values_default[5] ? true : false;
$is_font_line_through_default = isset( $font_values_default[6] ) && 'on' === $font_values_default[6] ? true : false;
$font_line_color_default = isset( $font_values_default[7] ) ? $font_values_default[7] : '';
$font_line_style_default = isset( $font_values_default[8] ) ? $font_values_default[8] : '';