upgraded to 4.14

This commit is contained in:
2021-12-20 18:06:11 +00:00
parent 80f1e87db9
commit 3166bdf932
153 changed files with 5204 additions and 1003 deletions

View File

@ -8,7 +8,7 @@
if ( ! defined( 'ET_BUILDER_PRODUCT_VERSION' ) ) {
// Note, this will be updated automatically during grunt release task.
define( 'ET_BUILDER_PRODUCT_VERSION', '4.13.0' );
define( 'ET_BUILDER_PRODUCT_VERSION', '4.14.4' );
}
if ( ! defined( 'ET_BUILDER_VERSION' ) ) {
@ -1372,10 +1372,12 @@ function et_fb_current_page_woocommerce_components() {
*/
function et_fb_woocommerce_tabs() {
global $product, $post;
$old_product = $product;
$old_post = $post;
$is_product = isset( $product ) && is_a( $product, 'WC_Product' );
if ( ! isset( $product ) && et_is_woocommerce_plugin_active() ) {
if ( ! $is_product && et_is_woocommerce_plugin_active() ) {
$product = ET_Builder_Module_Helper_Woocommerce_Modules::get_product( 'latest' );
if ( $product ) {
@ -1899,6 +1901,17 @@ function et_fb_process_to_shortcode( $object, $options = array(), $library_item_
$value = str_replace( '\\', '%92', $value );
}
// Encode backslash for custom date format attributes.
$modules_and_attr_with_custom_date = array(
'et_pb_blog' => 'meta_date',
'et_pb_fullwidth_post_title' => 'date_format',
'et_pb_post_title' => 'date_format',
);
if ( ! empty( $modules_and_attr_with_custom_date[ $type ] ) && $modules_and_attr_with_custom_date[ $type ] === $attribute ) {
$value = str_replace( '\\', '%92', $value );
}
$attributes .= ' ' . esc_attr( $attribute ) . '="' . et_core_esc_previously( $value ) . '"';
}
}
@ -2114,6 +2127,7 @@ add_action( 'wp_ajax_et_fb_ajax_drop_autosave', 'et_fb_ajax_drop_autosave' );
* Ajax Callback :: Save layout.
*/
function et_fb_ajax_save() {
if ( ! isset( $_POST['et_fb_save_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['et_fb_save_nonce'] ), 'et_fb_save_nonce' ) ) {
wp_send_json_error();
}
@ -2166,7 +2180,9 @@ function et_fb_ajax_save() {
// Get old content and if we should return to the Default Editor.
$post_content = get_post_meta( $post_id, '_et_pb_old_content', true );
} else {
update_post_meta( $post_id, '_et_pb_use_builder', 'on' );
if ( ! $is_layout_block_preview ) {
update_post_meta( $post_id, '_et_pb_use_builder', 'on' );
}
$post_content = et_fb_process_to_shortcode( $shortcode_data, $options, $layout_type, true, true );
}
@ -2725,51 +2741,55 @@ endif;
*/
function et_builder_get_acceptable_css_string_values( $property = 'all' ) {
$css_string_values = array(
'width' => array(
'width' => array(
'auto',
'inherit',
'initial',
'unset',
'',
),
'max-width' => array(
'max-width' => array(
'none',
'inherit',
'initial',
'unset',
),
'margin' => array(
'margin' => array(
'auto',
'inherit',
'initial',
'unset',
),
'padding' => array(
'padding' => array(
'inherit',
'initial',
'unset',
),
'height' => array(
'height' => array(
'auto',
'inherit',
'initial',
'unset',
),
'min-height' => array(
'min-height' => array(
'auto',
'inherit',
'initial',
'unset',
),
'max-height' => array(
'max-height' => array(
'none',
'inherit',
'initial',
'unset',
),
'z-index' => array(
'z-index' => array(
'auto',
),
'font-size' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
'line-height' => array(
'',
),
'font-size' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ),
);
$acceptable_strings = apply_filters( 'et_builder_acceptable_css_string_values', $css_string_values );
@ -5441,8 +5461,9 @@ if ( ! function_exists( 'et_pb_postinfo_meta' ) ) :
$postinfo_meta[] = ' ' . esc_html__( 'by', 'et_builder' ) . ' <span class="author vcard">' . et_pb_get_the_author_posts_link() . '</span>';
}
if ( in_array( 'date', $postinfo, true ) ) {
$postinfo_meta[] = '<span class="published">' . esc_html( get_the_time( wp_unslash( $date_format ) ) ) . '</span>';
$postinfo_meta[] = '<span class="published">' . esc_html( get_the_time( $date_format ) ) . '</span>';
}
if ( in_array( 'categories', $postinfo, true ) ) {
@ -10618,7 +10639,9 @@ function et_fb_get_builder_shortcode_object( $post_type, $post_id, $layout_type
function et_fb_generate_post_content_module_selector( array $array, $element_type ) {
global $current_section;
global $current_row;
global $current_row_inner;
global $current_column;
global $current_column_inner;
global $current_module;
global $post_content_module_selector;
@ -10648,13 +10671,36 @@ function et_fb_generate_post_content_module_selector( array $array, $element_typ
et_fb_generate_post_content_module_selector( $array[ $key ]['content'], $array[ $key ]['type'] );
}
}
} elseif ( 'et_pb_column' === $element_type ) {
} elseif ( 'et_pb_row_inner' === $element_type ) {
// Loop through columns.
foreach ( $array as $key => $value ) {
if ( isset( $array[ $key ]['content'] ) && is_array( $array[ $key ]['content'] ) ) {
$current_column_inner = $key;
et_fb_generate_post_content_module_selector( $array[ $key ]['content'], $array[ $key ]['type'] );
}
}
} elseif ( 'et_pb_column' === $element_type || 'et_pb_column_inner' === $element_type ) {
// Loop through modules.
foreach ( $array as $key => $value ) {
if ( 'et_pb_post_content' === $array[ $key ]['type'] ) {
if ( 'et_pb_row_inner' === $array[ $key ]['type'] ) {
foreach ( $array as $key => $value ) {
if ( isset( $array[ $key ]['content'] ) && is_array( $array[ $key ]['content'] ) ) {
$current_row_inner = $key;
et_fb_generate_post_content_module_selector( $array[ $key ]['content'], $array[ $key ]['type'] );
}
}
} elseif ( 'et_pb_post_content' === $array[ $key ]['type'] ) {
// If Post Content Module is Found build the selector from current Section, Row, and Column.
$current_module = $key;
$post_content_module_selector = array(
$current_module = $key;
$is_column_inner = 'et_pb_column_inner' === $array[ $key ]['parent_slug'];
$post_content_module_selector = $is_column_inner ? array(
'section' => $current_section,
'row_inner' => $current_row_inner,
'column' => $current_row,
'column_inner' => $current_column_inner,
'module' => $current_module,
) : array(
'section' => $current_section,
'row' => $current_row,
'column' => $current_column,
@ -10664,8 +10710,8 @@ function et_fb_generate_post_content_module_selector( array $array, $element_typ
// If Post Content Module is FullWidth create selector with section and module id.
$current_module = $key;
$post_content_module_selector = array(
'section' => $current_section,
'fullwidth_module' => $current_module,
'section' => $current_section,
'module' => $current_module,
);
}
}
@ -10687,14 +10733,21 @@ function et_fb_generate_post_content_module_selector( array $array, $element_typ
* @return array
*/
function et_fb_generate_tb_body_area_with_post_content( $theme_builder_body_fields, $selector, $post_content_fields ) {
$is_full_width = isset( $selector['fullwidth_module'] );
if ( ! isset( $selector['row'] ) && ! isset( $selector['column'] ) ) {
$original_post_content_module = $theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['module'] ];
if ( $is_full_width ) {
$original_post_content_module = $theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['fullwidth_module'] ];
$theme_builder_body_fields[ $selector['section'] ]['attrs']['post_content_module_attrs'] = $original_post_content_module['attrs'];
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['module'] ]['content'] = $post_content_fields;
} elseif ( null === $selector['column'] ) {
$original_post_content_module = $theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['row'] ]['content'][ $selector['module'] ];
$theme_builder_body_fields[ $selector['section'] ]['attrs']['post_content_module_attrs'] = $original_post_content_module['attrs'];
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['fullwidth_module'] ]['content'] = $post_content_fields;
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['fullwidth_module'] ]['content'] = $post_content_fields;
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['row'] ]['attrs']['post_content_module_attrs'] = $original_post_content_module['attrs'];
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['row'] ]['content'][ $selector['module'] ]['content'] = $post_content_fields;
} elseif ( isset( $selector['row_inner'] ) ) {
$original_post_content_module = $theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['column'] ]['content'][ $selector['row_inner'] ]['content'][ $selector['column_inner'] ]['content'][ $selector['module'] ];
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['column'] ]['content'][ $selector['row_inner'] ]['content'][ $selector['column_inner'] ]['attrs']['post_content_module_attrs'] = $original_post_content_module['attrs'];
$theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['column'] ]['content'][ $selector['row_inner'] ]['content'][ $selector['column_inner'] ]['content'][ $selector['module'] ]['content'] = $post_content_fields;
} else {
$original_post_content_module = $theme_builder_body_fields[ $selector['section'] ]['content'][ $selector['row'] ]['content'][ $selector['column'] ]['content'][ $selector['module'] ];
@ -11122,6 +11175,11 @@ function et_fb_add_additional_attrs( $processed_attrs, $output ) {
$allowlisted_attrs[ $attr ] = $value;
}
// Extra conversion for the case with the `font_icon__hover` option.
if ( ! empty( $allowlisted_attrs['font_icon__hover'] ) && et_pb_maybe_old_divi_font_icon( $allowlisted_attrs['font_icon__hover'] ) ) {
$allowlisted_attrs['font_icon__hover'] = et_pb_build_extended_font_icon_value( $allowlisted_attrs['font_icon__hover'], null, null, true );
}
if ( $allowlisted_attrs ) {
$output['attrs'] = array_merge( $output['attrs'], $allowlisted_attrs );
}
@ -12450,6 +12508,11 @@ if ( ! function_exists( 'et_filter_wp_calculate_image_srcset' ) ) :
continue;
}
// In some SVG images, the value of `$max_width` is 0, in those cases we can set `$max_width` from `$size_array`.
if ( ! $max_width ) {
$max_width = $size_array[0];
}
$responsive_sources[ $max_width ] = array(
'url' => str_replace( basename( $image_src ), $size_data['file'], $image_src ),
'descriptor' => 'w',