Upgarded to 4.17.4
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1140,9 +1140,11 @@ class ET_Builder_Module_Helper_ResponsiveOptions {
|
||||
$enable_fields = array(
|
||||
"{$background_base}_color" => "{$background_base}_enable_color",
|
||||
'use_background_color_gradient' => 'use_background_color_gradient',
|
||||
"{$background_base}_use_color_gradient" => "{$background_base}_enable_use_color_gradient",
|
||||
"{$background_base}_use_color_gradient" => "{$background_base}_use_color_gradient",
|
||||
"{$background_base}_image" => "{$background_base}_enable_image",
|
||||
"video_{$background_base}_values" => "video_{$background_base}_values",
|
||||
"{$background_base}_pattern_style" => "{$background_base}_enable_pattern_style",
|
||||
"{$background_base}_mask_style" => "{$background_base}_enable_mask_style",
|
||||
);
|
||||
|
||||
// Empty string is slug for desktop.
|
||||
@ -1171,25 +1173,35 @@ class ET_Builder_Module_Helper_ResponsiveOptions {
|
||||
|
||||
foreach ( $map_slugs[ $preview_mode ] as $slug ) {
|
||||
|
||||
// BG Color.
|
||||
if ( in_array( $base_setting, array( "{$background_base}_color", "{$background_base}_image" ) ) ) {
|
||||
|
||||
// BG Color, BG Image, BG Pattern, BG Mask.
|
||||
if (
|
||||
in_array(
|
||||
$base_setting,
|
||||
array(
|
||||
"{$background_base}_color",
|
||||
"{$background_base}_image",
|
||||
"{$background_base}_pattern_style",
|
||||
"{$background_base}_mask_style",
|
||||
),
|
||||
true
|
||||
)
|
||||
) {
|
||||
$base_type = str_replace( "{$background_base}_", '', $base_setting );
|
||||
$enable_default = ! empty( $fields[ "{$background_base}_enable_{$base_type}{$slug}" ] ) && ! empty( $fields[ "{$background_base}_enable_{$base_type}{$slug}" ]['default'] ) ? $fields[ "{$background_base}_enable_{$base_type}{$slug}" ]['default'] : '';
|
||||
$enable_value = ! empty( $attrs[ "{$background_base}_enable_{$base_type}{$slug}" ] ) ? $attrs[ "{$background_base}_enable_{$base_type}{$slug}" ] : $enable_default;
|
||||
$bg_value = ! empty( $attrs[ "{$background_base}_{$base_type}{$slug}" ] ) ? $attrs[ "{$background_base}_{$base_type}{$slug}" ] : '';
|
||||
$is_bg_enabled = 'off' !== $enable_value;
|
||||
$setting_value = ! empty( $attrs[ "{$background_base}_{$base_type}{$slug}" ] ) ? $attrs[ "{$background_base}_{$base_type}{$slug}" ] : '';
|
||||
$is_tab_enabled = 'off' !== $enable_value;
|
||||
|
||||
if ( '' !== $bg_value && $is_bg_enabled ) {
|
||||
$new_value = $bg_value;
|
||||
if ( '' !== $setting_value && $is_tab_enabled ) {
|
||||
$new_value = $setting_value;
|
||||
break;
|
||||
} elseif ( ! $is_bg_enabled ) {
|
||||
} elseif ( ! $is_tab_enabled ) {
|
||||
$new_value = '';
|
||||
break;
|
||||
}
|
||||
|
||||
// BG Gradient.
|
||||
} elseif ( in_array( $base_setting, array( 'use_background_color_gradient', "{$background_base}_use_color_gradient" ) ) ) {
|
||||
} elseif ( in_array( $base_setting, array( 'use_background_color_gradient', "{$background_base}_use_color_gradient" ), true ) ) {
|
||||
|
||||
$new_value = 'off';
|
||||
|
||||
@ -1198,31 +1210,47 @@ class ET_Builder_Module_Helper_ResponsiveOptions {
|
||||
'value' => "use_background_color_gradient{$slug}",
|
||||
'start' => "{$background_base}_color_gradient_start{$slug}",
|
||||
'end' => "{$background_base}_color_gradient_end{$slug}",
|
||||
'stops' => "{$background_base}_color_gradient_stops{$slug}",
|
||||
'unit' => "{$background_base}_color_gradient_unit{$slug}",
|
||||
),
|
||||
"{$background_base}_use_color_gradient" => array(
|
||||
'value' => "{$background_base}_use_color_gradient{$slug}",
|
||||
'start' => "{$background_base}_color_gradient_start{$slug}",
|
||||
'end' => "{$background_base}_color_gradient_end{$slug}",
|
||||
'stops' => "{$background_base}_color_gradient_stops{$slug}",
|
||||
'unit' => "{$background_base}_color_gradient_unit{$slug}",
|
||||
),
|
||||
);
|
||||
|
||||
$field_value = '';
|
||||
$field_start = '';
|
||||
$field_end = '';
|
||||
$field_stops = '';
|
||||
|
||||
if ( ! empty( $field_map[ $base_setting ] ) ) {
|
||||
$field_value = ! empty( $field_map[ $base_setting ]['value'] ) ? $field_map[ $base_setting ]['value'] : '';
|
||||
$field_start = ! empty( $field_map[ $base_setting ]['start'] ) ? $field_map[ $base_setting ]['start'] : '';
|
||||
$field_end = ! empty( $field_map[ $base_setting ]['end'] ) ? $field_map[ $base_setting ]['end'] : '';
|
||||
$field_stops = ! empty( $field_map[ $base_setting ]['stops'] ) ? $field_map[ $base_setting ]['stops'] : '';
|
||||
}
|
||||
|
||||
$use_gradient_default = ! empty( $fields[ $field_value ] ) ? $fields[ $field_value ] : '';
|
||||
$use_gradient_value = ! empty( $attrs[ $field_value ] ) ? $attrs[ $field_value ] : $use_gradient_default;
|
||||
$gradient_start_value = ! empty( $attrs[ $field_start ] ) ? $attrs[ $field_start ] : '';
|
||||
$gradient_end_value = ! empty( $attrs[ $field_end ] ) ? $attrs[ $field_end ] : '';
|
||||
$is_gradient_enabled = 'off' !== $use_gradient_value;
|
||||
// Set value from attrs, otherwise, assign default value, for desktop/tablet/phone.
|
||||
$use_gradient_value = $this->get_any_value( $attrs, $field_value, 'off', true );
|
||||
$gradient_start_value = $this->get_any_value( $attrs, $field_start, '', true );
|
||||
$gradient_end_value = $this->get_any_value( $attrs, $field_end, '', true );
|
||||
$gradient_stops_value = $this->get_any_value( $attrs, $field_stops, '', true );
|
||||
|
||||
if ( ( '' !== $gradient_start_value || '' !== $gradient_end_value ) && $is_gradient_enabled ) {
|
||||
// Set value from attrs, otherwise, assign value from desktop.
|
||||
if ( in_array( $slug, array( '__hover', '__sticky' ), true ) ) {
|
||||
$use_gradient_value = ! empty( $attrs[ $field_value ] ) ? $attrs[ $field_value ] : $use_gradient_value;
|
||||
$gradient_start_value = ! empty( $attrs[ $field_start ] ) ? $attrs[ $field_start ] : $gradient_start_value;
|
||||
$gradient_end_value = ! empty( $attrs[ $field_end ] ) ? $attrs[ $field_end ] : $gradient_end_value;
|
||||
$gradient_stops_value = ! empty( $attrs[ $field_stops ] ) ? $attrs[ $field_stops ] : $gradient_stops_value;
|
||||
}
|
||||
|
||||
$is_gradient_enabled = 'off' !== $use_gradient_value;
|
||||
|
||||
if ( ( '' !== $gradient_stops_value || ( '' !== $gradient_start_value || '' !== $gradient_end_value ) ) && $is_gradient_enabled ) {
|
||||
$new_value = 'on';
|
||||
break;
|
||||
} elseif ( ! $is_gradient_enabled ) {
|
||||
|
@ -288,15 +288,20 @@ class ET_Builder_Module_Helper_Sticky_Options {
|
||||
*/
|
||||
public function add_sticky_to_order_class( $selector, $is_sticky = true ) {
|
||||
$selectors = explode( ',', $selector );
|
||||
$selectors = array_map( 'trim', $selectors );
|
||||
$selectors = array_map(
|
||||
function( $selector ) use ( $is_sticky ) {
|
||||
$selector = trim( $selector );
|
||||
|
||||
// If current selector is sticky module, sticky selector is directly attached; if it isn't
|
||||
// it is safe to assume that the sticky selector is one of its parent DOM, hence the space.
|
||||
if ( $is_sticky ) {
|
||||
$selectors = preg_replace( '/(%%order_class%%)/i', '.et_pb_sticky$1', $selectors, 1 );
|
||||
} else {
|
||||
$selectors = preg_replace( '/(%%order_class%%)/i', '.et_pb_sticky $1', $selectors, 1 );
|
||||
}
|
||||
// If current selector is sticky module, sticky selector is directly attached; if it isn't
|
||||
// it is safe to assume that the sticky selector is one of its parent DOM, hence the space.
|
||||
if ( ! $is_sticky ) {
|
||||
$selector = ' ' . $selector;
|
||||
}
|
||||
|
||||
return '.et_pb_sticky' . $selector;
|
||||
},
|
||||
$selectors
|
||||
);
|
||||
|
||||
return implode( ', ', $selectors );
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ if ( et_is_woocommerce_plugin_active() ) {
|
||||
*
|
||||
* Valid values are Product Ids, `current` and `latest`.
|
||||
*
|
||||
* @param string $maybe_product_id
|
||||
* @param string $maybe_product_id Product ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -261,6 +261,144 @@ if ( et_is_woocommerce_plugin_active() ) {
|
||||
'toggle_slug' => 'main_content',
|
||||
);
|
||||
break;
|
||||
case 'offset_number':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Product Offset Number', 'et_builder' ),
|
||||
'type' => 'text',
|
||||
'option_category' => 'configuration',
|
||||
'description' => esc_html__( 'Choose how many products you would like to skip. These products will not be shown in the feed.', 'et_builder' ),
|
||||
'toggle_slug' => 'main_content',
|
||||
'default' => 0,
|
||||
);
|
||||
break;
|
||||
case 'fields_width':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Fields Width', 'et_builder' ),
|
||||
'description' => esc_html__( 'Set the width of the fields.', 'et_builder' ),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'default' => __( 'Default', 'et_builder' ),
|
||||
'fullwidth' => __( 'Fullwidth', 'et_builder' ),
|
||||
'2_column' => __( '2 Column', 'et_builder' ),
|
||||
),
|
||||
'default' => 'default',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'layout',
|
||||
'mobile_options' => true,
|
||||
);
|
||||
break;
|
||||
case 'collapse_table_gutters_borders':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Collapse Table Gutters and Borders', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => et_builder_i18n( 'Yes' ),
|
||||
'off' => et_builder_i18n( 'No' ),
|
||||
),
|
||||
'description' => esc_html__( 'Collapse Table Gutters and Borders.', 'et_builder' ),
|
||||
'toggle_slug' => 'table',
|
||||
'tab_slug' => 'advanced',
|
||||
'default' => 'off',
|
||||
'mobile_options' => true,
|
||||
);
|
||||
break;
|
||||
case 'vertical_gutter_width':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Vertical Gutters', 'et_builder' ),
|
||||
'type' => 'range',
|
||||
'default_unit' => 'px',
|
||||
'allowed_units' => array(
|
||||
'em',
|
||||
'rem',
|
||||
'px',
|
||||
'cm',
|
||||
'mm',
|
||||
'in',
|
||||
'pt',
|
||||
'pc',
|
||||
'ex',
|
||||
'vh',
|
||||
'vw',
|
||||
),
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 50,
|
||||
'step' => 1,
|
||||
'min_limit' => 0,
|
||||
),
|
||||
'default' => '0px',
|
||||
'mobile_options' => true,
|
||||
'sticky' => false,
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'table',
|
||||
'show_if' => array(
|
||||
'collapse_table_gutters_borders' => 'off',
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'horizontal_gutter_width':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Horizontal Gutters', 'et_builder' ),
|
||||
'type' => 'range',
|
||||
'default_unit' => 'px',
|
||||
'allowed_units' => array(
|
||||
'em',
|
||||
'rem',
|
||||
'px',
|
||||
'cm',
|
||||
'mm',
|
||||
'in',
|
||||
'pt',
|
||||
'pc',
|
||||
'ex',
|
||||
'vh',
|
||||
'vw',
|
||||
),
|
||||
'range_settings' => array(
|
||||
'min' => 0,
|
||||
'max' => 50,
|
||||
'step' => 1,
|
||||
'min_limit' => 0,
|
||||
),
|
||||
'default' => '0px',
|
||||
'mobile_options' => true,
|
||||
'sticky' => false,
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'table',
|
||||
'show_if' => array(
|
||||
'collapse_table_gutters_borders' => 'off',
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'placeholder_color':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Placeholder Color', 'et_builder' ),
|
||||
'description' => esc_html__( 'Pick a color to be used for the placeholder written inside input fields.', 'et_builder' ),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'form_field',
|
||||
'hover' => 'tabs',
|
||||
'mobile_options' => true,
|
||||
'sticky' => false,
|
||||
);
|
||||
break;
|
||||
case 'table_cell_alternating_background_color':
|
||||
$field = array(
|
||||
'label' => esc_html__( 'Table Cell Alternating Background Color', 'et_builder' ),
|
||||
'description' => esc_html__( 'Pick a color to be used for the alternating table cells.', 'et_builder' ),
|
||||
'type' => 'color-alpha',
|
||||
'custom_color' => true,
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'table_cell',
|
||||
'hover' => 'tabs',
|
||||
'mobile_options' => true,
|
||||
'sticky' => false,
|
||||
'priority' => 9,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$field = array();
|
||||
break;
|
||||
@ -958,6 +1096,418 @@ if ( et_is_woocommerce_plugin_active() ) {
|
||||
public static function reset_display_type( $option_name, $display_type ) {
|
||||
update_option( $option_name, $display_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops Checkout Coupon form from rendering.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public static function detach_wc_before_checkout_form() {
|
||||
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops Checkout Coupon form from rendering.
|
||||
*/
|
||||
public static function detach_wc_checkout_coupon_form() {
|
||||
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops Login Coupon form from rendering.
|
||||
*/
|
||||
public static function detach_wc_checkout_login_form() {
|
||||
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_before_checkout_form` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_before_checkout_form() {
|
||||
add_action(
|
||||
'woocommerce_before_checkout_form',
|
||||
'woocommerce_checkout_coupon_form',
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_before_checkout_form` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_checkout_coupon_form() {
|
||||
add_action(
|
||||
'woocommerce_before_checkout_form',
|
||||
'woocommerce_checkout_coupon_form',
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_before_checkout_form` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_checkout_login_form() {
|
||||
add_action(
|
||||
'woocommerce_before_checkout_form',
|
||||
'woocommerce_checkout_login_form',
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove `woocommerce_checkout_billing` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function detach_wc_checkout_billing() {
|
||||
if ( ! function_exists( 'WC' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = get_class( WC() );
|
||||
if ( ! method_exists( $class, 'checkout' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkout = WC()->checkout();
|
||||
remove_action(
|
||||
'woocommerce_checkout_billing',
|
||||
array( $checkout, 'checkout_form_billing' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_checkout_billing` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_checkout_billing() {
|
||||
if ( ! function_exists( 'WC' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = get_class( WC() );
|
||||
if ( ! method_exists( $class, 'checkout' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkout = WC()->checkout();
|
||||
add_action( 'woocommerce_checkout_billing', array( $checkout, 'checkout_form_billing' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove `woocommerce_checkout_shipping` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function detach_wc_checkout_shipping() {
|
||||
if ( ! function_exists( 'WC' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = get_class( WC() );
|
||||
if ( ! method_exists( $class, 'checkout' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkout = WC()->checkout();
|
||||
remove_action(
|
||||
'woocommerce_checkout_shipping',
|
||||
array( $checkout, 'checkout_form_shipping' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_checkout_shipping` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_checkout_shipping() {
|
||||
if ( ! function_exists( 'WC' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = get_class( WC() );
|
||||
if ( ! method_exists( $class, 'checkout' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkout = WC()->checkout();
|
||||
add_action(
|
||||
'woocommerce_checkout_shipping',
|
||||
array( $checkout, 'checkout_form_shipping' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove `woocommerce_checkout_order_review` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function detach_wc_checkout_payment() {
|
||||
remove_action(
|
||||
'woocommerce_checkout_order_review',
|
||||
'woocommerce_checkout_payment',
|
||||
20
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_checkout_order_review` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_checkout_payment() {
|
||||
add_action(
|
||||
'woocommerce_checkout_order_review',
|
||||
'woocommerce_checkout_payment',
|
||||
20
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops Order review (Mini cart) and Checkout Payment from rendering.
|
||||
*
|
||||
* @used-by ET_Builder_Module_Woocommerce_Checkout_Billing::get_checkout_billing()
|
||||
* @used-by ET_Builder_Module_Woocommerce_Checkout_Additional_Info::get_additional_info()
|
||||
*/
|
||||
public static function detach_wc_checkout_order_review() {
|
||||
remove_action(
|
||||
'woocommerce_checkout_order_review',
|
||||
'woocommerce_order_review',
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_checkout_order_review` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_checkout_order_review() {
|
||||
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove `woocommerce_cart_collaterals` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function detach_wc_cart_totals() {
|
||||
remove_action(
|
||||
'woocommerce_cart_collaterals',
|
||||
'woocommerce_cart_totals',
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable `woocommerce_cart_collaterals` hook.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function attach_wc_cart_totals() {
|
||||
add_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the required HTML data attributes based on the button name and slug.
|
||||
*
|
||||
* @param array $module_props Module attributes.
|
||||
* @param string $btn_slug Shortcode attribute name (i.e button_{device}).
|
||||
* @param string $btn_class Class name of the button to target in JS.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_button_icon_attrs( $module_props, $btn_slug = 'button', $btn_class = 'button' ) {
|
||||
$attrs = array();
|
||||
|
||||
// Get Icon values based on Device.
|
||||
$custom_icon_values = et_pb_responsive_options()->get_property_values( $module_props, "{$btn_slug}_icon", '', true );
|
||||
$custom_icon = et_()->array_get( $custom_icon_values, 'desktop' );
|
||||
$custom_icon_tablet = et_()->array_get( $custom_icon_values, 'tablet' );
|
||||
$custom_icon_phone = et_()->array_get( $custom_icon_values, 'phone' );
|
||||
|
||||
if ( empty( $btn_name ) ) {
|
||||
$btn_name = 'button';
|
||||
}
|
||||
|
||||
$icon_values = array(
|
||||
"data-{$btn_name}-icon" => $custom_icon,
|
||||
"data-{$btn_name}-icon-tablet" => $custom_icon_tablet,
|
||||
"data-{$btn_name}-icon-phone" => $custom_icon_phone,
|
||||
);
|
||||
|
||||
// Verify if Custom icon value exists at least in one of Desktop / Tablet / Phone.
|
||||
$has_custom_icon = count( array_filter( $icon_values ) ) > 0;
|
||||
|
||||
if ( ! $has_custom_icon ) {
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
$attrs['data-button-class'] = et_core_intentionally_unescaped( $btn_class, 'fixed_string' );
|
||||
|
||||
// Get the icon data-* attributes based on values set in DB.
|
||||
foreach ( $icon_values as $attr_name => $attr_value ) {
|
||||
if ( empty( $attr_value ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attrs[ $attr_name ] = esc_attr( et_pb_process_font_icon( $attr_value ) );
|
||||
}
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Button's data-* attrs for the Icons to render.
|
||||
*
|
||||
* These attributes are set on the outer wrapper & will be set on the Button elements using JS.
|
||||
*
|
||||
* @param array $module_props Module attributes/properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function add_custom_icon_attrs( $module_props ) {
|
||||
if ( ! is_array( $module_props ) || empty( $module_props ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$btn_attrs = self::get_button_icon_attrs( $module_props );
|
||||
|
||||
return $btn_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mock Products to Cart.
|
||||
*
|
||||
* Otherwise Checkout modules won't output content. The output is made visible only to VB.
|
||||
*
|
||||
* @param array $cart_contents Cart contents.
|
||||
*
|
||||
* @return array
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public static function set_dummy_cart_contents( $cart_contents ) {
|
||||
if ( ! is_array( $cart_contents ) ) {
|
||||
return $cart_contents;
|
||||
}
|
||||
|
||||
$cart_contents = array();
|
||||
$fake_products = array(
|
||||
999 => array(
|
||||
'name' => esc_html__( 'Product 1', 'et_builder' ),
|
||||
'price' => '12.00',
|
||||
'quantity' => 3,
|
||||
),
|
||||
1000 => array(
|
||||
'name' => esc_html__( 'Product 2', 'et_builder' ),
|
||||
'price' => '75.00',
|
||||
'quantity' => 1,
|
||||
),
|
||||
1001 => array(
|
||||
'name' => esc_html__( 'Product 3', 'et_builder' ),
|
||||
'price' => '38.00',
|
||||
'quantity' => 2,
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $fake_products as $id => $details ) {
|
||||
$product = new ET_Builder_Woocommerce_Product_Simple_Placeholder();
|
||||
$product->set_name( $details['name'] );
|
||||
$product->set_id( $id );
|
||||
$product->set_price( $details['price'] );
|
||||
|
||||
$cart_item_key = WC()->cart->generate_cart_id( $product->get_id() );
|
||||
|
||||
$cart_contents[ $cart_item_key ] = array(
|
||||
'key' => $cart_item_key,
|
||||
'product_id' => $product->get_id(),
|
||||
'variation_id' => 0,
|
||||
'variation' => array(),
|
||||
'quantity' => $details['quantity'],
|
||||
'data' => $product,
|
||||
'data_hash' => wc_get_cart_item_data_hash( $product ),
|
||||
);
|
||||
}
|
||||
|
||||
return $cart_contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product default.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_page_type_default() {
|
||||
return array(
|
||||
'filter',
|
||||
'et_builder_get_woo_default_page_type',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Page Type default based on the Cart & Checkout pages.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_page_type_default_value() {
|
||||
$is_cart_page = function_exists( 'is_cart' ) && is_cart();
|
||||
$is_checkout_page = function_exists( 'is_checkout' ) && is_checkout();
|
||||
|
||||
if ( $is_cart_page ) {
|
||||
return 'cart';
|
||||
} elseif ( $is_checkout_page ) {
|
||||
return 'checkout';
|
||||
} else {
|
||||
return 'product';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the TB Post ID That Uses Body Template.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
*
|
||||
* @return mixed Template Post ID.
|
||||
*/
|
||||
public static function get_tb_template_id_by_current_page_id( $post_id ) {
|
||||
if ( ! $post_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'et_template',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_et_body_layout_id',
|
||||
'value' => $post_id,
|
||||
),
|
||||
),
|
||||
);
|
||||
$query = new WP_Query( $args );
|
||||
$template_id = 0;
|
||||
|
||||
while ( $query->have_posts() ) {
|
||||
the_post();
|
||||
|
||||
$template_id = get_the_ID();
|
||||
if ( 0 !== $template_id ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return $template_id;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter(
|
||||
@ -983,4 +1533,12 @@ if ( et_is_woocommerce_plugin_active() ) {
|
||||
'get_woo_default_tabs_options',
|
||||
)
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'et_builder_get_woo_default_page_type',
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
'get_page_type_default_value',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user