upgraded to 4.14
This commit is contained in:
@ -998,9 +998,11 @@ class ET_Builder_Module_Blog extends ET_Builder_Module_Type_PostBased {
|
||||
? ' | '
|
||||
: '';
|
||||
|
||||
// phpcs:disable WordPress.WP.I18n.NoEmptyStrings -- intentionally used.
|
||||
$date = 'on' === $args['show_date']
|
||||
? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '<span class="published">' . esc_html( get_the_date( $args['meta_date'] ) ) . '</span>' ) )
|
||||
? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '<span class="published">' . esc_html( get_the_date( str_replace( '\\\\', '\\', $args['meta_date'] ) ) ) . '</span>' ) )
|
||||
: '';
|
||||
// phpcs:enable
|
||||
|
||||
$date_separator = ( ( 'on' === $args['show_author'] || 'on' === $args['show_date'] ) && 'on' === $args['show_categories'] )
|
||||
? ' | '
|
||||
|
@ -420,6 +420,10 @@ class ET_Builder_Module_Blurb extends ET_Builder_Module {
|
||||
'background-color' => '%%order_class%% .et_pb_only_image_mode_wrap, %%order_class%% .et-pb-icon',
|
||||
);
|
||||
|
||||
$fields['background_layout'] = array(
|
||||
'color' => '%%order_class%% .et_pb_module_header, %%order_class%% .et_pb_blurb_description',
|
||||
);
|
||||
|
||||
$fields['body_text_color'] = array(
|
||||
'color' => '%%order_class%% .et_pb_blurb_description',
|
||||
);
|
||||
|
@ -340,6 +340,20 @@ class ET_Builder_Module_Comments extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_meta' => array(
|
||||
'label' => esc_html__( 'Show Meta', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn meta on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
@ -466,6 +480,8 @@ class ET_Builder_Module_Comments extends ET_Builder_Module {
|
||||
$show_avatar = $this->props['show_avatar'];
|
||||
$show_reply = $this->props['show_reply'];
|
||||
$show_count = $this->props['show_count'];
|
||||
$show_meta = $this->props['show_meta'];
|
||||
$show_rating = et_()->array_get( $this->props, 'show_rating', '' );
|
||||
$header_level = $this->props['header_level'];
|
||||
$video_background = $this->video_background();
|
||||
$parallax_image_background = $this->get_parallax_image_background();
|
||||
@ -528,21 +544,36 @@ class ET_Builder_Module_Comments extends ET_Builder_Module {
|
||||
$this->add_classname( 'et_pb_no_comments_count' );
|
||||
}
|
||||
|
||||
if ( 'off' === $show_meta ) {
|
||||
$this->add_classname( 'et_pb_no_comments_meta' );
|
||||
}
|
||||
|
||||
if ( 'off' === $show_rating ) {
|
||||
$this->add_classname( 'et_pb_no_comments_rating' );
|
||||
}
|
||||
|
||||
// Removed automatically added classname
|
||||
$this->remove_classname( $render_slug );
|
||||
|
||||
$multi_view_data_attr = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_no_avatar' => array(
|
||||
'et_pb_no_avatar' => array(
|
||||
'show_avatar' => 'off',
|
||||
),
|
||||
'et_pb_no_reply_button' => array(
|
||||
'et_pb_no_reply_button' => array(
|
||||
'show_reply' => 'off',
|
||||
),
|
||||
'et_pb_no_comments_count' => array(
|
||||
'et_pb_no_comments_count' => array(
|
||||
'show_count' => 'off',
|
||||
),
|
||||
'et_pb_no_comments_meta' => array(
|
||||
'show_meta' => 'off',
|
||||
),
|
||||
/* WooCommerce Reviews Module uses the following class. */
|
||||
'et_pb_no_comments_rating' => array(
|
||||
'show_rating' => 'off',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
@ -11,6 +11,7 @@ class ET_Builder_Module_Contact_Form extends ET_Builder_Module_Type_WithSpamProt
|
||||
$this->vb_support = 'on';
|
||||
$this->child_slug = 'et_pb_contact_field';
|
||||
$this->child_item_text = esc_html__( 'Field', 'et_builder' );
|
||||
$this->_use_unique_id = true;
|
||||
|
||||
$this->main_css_element = '%%order_class%%.et_pb_contact_form_container';
|
||||
|
||||
@ -660,6 +661,36 @@ class ET_Builder_Module_Contact_Form extends ET_Builder_Module_Type_WithSpamProt
|
||||
$et_error_message = sprintf( '<p>%1$s</p>', et_core_esc_previously( $success_message ) );
|
||||
}
|
||||
|
||||
// Contact form should always have the ID. Use saved ID or generate automatically.
|
||||
$module_id = '' !== $this->module_id( false ) ? $this->module_id( false ) : 'et_pb_contact_form_' . $et_pb_contact_form_num;
|
||||
$unique_id = self::$_->array_get( $this->props, '_unique_id' );
|
||||
|
||||
if ( $nonce_result ) {
|
||||
// Additional info to be passed on the `et_pb_contact_form_submit` hook.
|
||||
$contact_form_info = array(
|
||||
'contact_form_id' => $module_id,
|
||||
'contact_form_number' => $et_pb_contact_form_num,
|
||||
'contact_form_unique_id' => $unique_id,
|
||||
'module_slug' => $render_slug,
|
||||
'post_id' => $this->get_the_ID(),
|
||||
);
|
||||
|
||||
/**
|
||||
* Fires after contact form is submitted.
|
||||
*
|
||||
* Use $et_contact_error variable to check whether there is an error on the form
|
||||
* entry submit process or not.
|
||||
*
|
||||
* @since 4.13.1
|
||||
*
|
||||
* @param array $processed_fields_values Processed fields values.
|
||||
* @param array $et_contact_error Whether there is an error on the form
|
||||
* entry submit process or not.
|
||||
* @param array $contact_form_info Additional contact form info.
|
||||
*/
|
||||
do_action( 'et_pb_contact_form_submit', $processed_fields_values, $et_contact_error, $contact_form_info );
|
||||
}
|
||||
|
||||
$form = '';
|
||||
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
|
||||
@ -728,12 +759,9 @@ class ET_Builder_Module_Contact_Form extends ET_Builder_Module_Type_WithSpamProt
|
||||
// Remove automatically added classname
|
||||
$this->remove_classname( $render_slug );
|
||||
|
||||
// Contact form should always have the ID. Use saved ID or generate automatically
|
||||
$module_id = '' !== $this->module_id( false ) ? $this->module_id( false ) : 'et_pb_contact_form_' . $et_pb_contact_form_num;
|
||||
|
||||
$output = sprintf(
|
||||
'
|
||||
<div id="%4$s" class="%5$s" data-form_unique_num="%6$s"%7$s>
|
||||
<div id="%4$s" class="%5$s" data-form_unique_num="%6$s" data-form_unique_id="%10$s"%7$s>
|
||||
%9$s
|
||||
%8$s
|
||||
%1$s
|
||||
@ -745,11 +773,12 @@ class ET_Builder_Module_Contact_Form extends ET_Builder_Module_Type_WithSpamProt
|
||||
$et_error_message,
|
||||
$form,
|
||||
esc_attr( $module_id ),
|
||||
$this->module_classname( $render_slug ),
|
||||
$this->module_classname( $render_slug ), // #5
|
||||
esc_attr( $et_pb_contact_form_num ),
|
||||
'on' === $use_redirect && '' !== $redirect_url ? sprintf( ' data-redirect_url="%1$s"', esc_attr( $redirect_url ) ) : '',
|
||||
$video_background,
|
||||
$parallax_image_background
|
||||
$parallax_image_background,
|
||||
esc_attr( $unique_id ) // #10
|
||||
);
|
||||
|
||||
return $output;
|
||||
|
@ -58,10 +58,10 @@ class ET_Builder_Module_Icon extends ET_Builder_Module {
|
||||
$this->advanced_fields = array(
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .et_pb_icon_wrap',
|
||||
'hover' => '%%order_class%% .et_pb_icon_wrap:hover',
|
||||
'padding' => '%%order_class%% .et_pb_icon_wrap',
|
||||
'margin' => '%%order_class%% .et_pb_icon_wrap',
|
||||
'main' => '%%order_class%%',
|
||||
'padding' => '%%order_class%% .et_pb_icon_wrap',
|
||||
'margin' => '%%order_class%%',
|
||||
'important' => 'all',
|
||||
),
|
||||
),
|
||||
'borders' => array(
|
||||
@ -267,7 +267,7 @@ class ET_Builder_Module_Icon extends ET_Builder_Module {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( $attrs, $content = null, $render_slug ) {
|
||||
public function render( $attrs, $content, $render_slug ) {
|
||||
$multi_view = et_pb_multi_view_options( $this );
|
||||
$title_text = $this->props['title_text'];
|
||||
$url = $this->props['url'];
|
||||
|
@ -482,14 +482,23 @@ class ET_Builder_Module_Image extends ET_Builder_Module {
|
||||
|
||||
// Only if force fullwidth is not set.
|
||||
if ( 'on' !== $force_fullwidth ) {
|
||||
// Only height or max-height is set, no width set.
|
||||
if ( 'auto' === $width && 'auto' !== $height || 'none' !== $max_height ) {
|
||||
$el_style = array(
|
||||
'selector' => '%%order_class%% .et_pb_image_wrap img',
|
||||
'declaration' => 'width: auto;',
|
||||
);
|
||||
ET_Builder_Element::set_style( $render_slug, $el_style );
|
||||
$responsive_width = et_pb_responsive_options()->get_property_values( $this->props, 'width' );
|
||||
$responsive_height = et_pb_responsive_options()->get_property_values( $this->props, 'height' );
|
||||
$responsive_max_width = et_pb_responsive_options()->get_property_values( $this->props, 'max_height' );
|
||||
$image_style_width = [];
|
||||
$modes = [ 'desktop', 'tablet', 'phone' ];
|
||||
|
||||
foreach ( $modes as $mode ) {
|
||||
// Only height or max-height is set, no width set.
|
||||
if ( 'auto' === $responsive_width[ $mode ] && 'auto' !== $responsive_height[ $mode ] || 'none' !== $responsive_max_width[ $mode ] ) {
|
||||
$image_style_width[ $mode ] = [
|
||||
'width' => 'auto',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
et_pb_responsive_options()->generate_responsive_css( $image_style_width, '%%order_class%% .et_pb_image_wrap img', '', $render_slug, '', '' );
|
||||
|
||||
}
|
||||
|
||||
$image_attachment_class = et_pb_media_options()->get_image_attachment_class( $this->props, 'src' );
|
||||
|
@ -351,7 +351,7 @@ class ET_Builder_Module_Portfolio extends ET_Builder_Module_Type_PostBased {
|
||||
* @return mixed portfolio item data
|
||||
*/
|
||||
static function get_portfolio_item( $args = array(), $conditional_tags = array(), $current_page = array() ) {
|
||||
global $et_fb_processing_shortcode_object, $post;
|
||||
global $et_fb_processing_shortcode_object, $post, $paged, $__et_portfolio_module_paged;
|
||||
|
||||
$global_processing_original_value = $et_fb_processing_shortcode_object;
|
||||
|
||||
@ -382,8 +382,13 @@ class ET_Builder_Module_Portfolio extends ET_Builder_Module_Type_PostBased {
|
||||
$et_paged = $is_front_page ? get_query_var( 'page' ) : get_query_var( 'paged' );
|
||||
}
|
||||
|
||||
if ( $__et_portfolio_module_paged > 1 ) {
|
||||
$et_paged = $__et_portfolio_module_paged;
|
||||
$paged = $__et_portfolio_module_paged; //phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited -- Override with ajax pagination.
|
||||
$args['paged'] = $__et_portfolio_module_paged;
|
||||
}
|
||||
|
||||
if ( $is_front_page ) {
|
||||
global $paged;
|
||||
$paged = $et_paged; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
|
||||
}
|
||||
|
||||
@ -764,7 +769,7 @@ class ET_Builder_Module_Portfolio extends ET_Builder_Module_Type_PostBased {
|
||||
'<div class="alignleft">
|
||||
<a href="%1$s">%2$s</a>
|
||||
</div>',
|
||||
esc_url( $portfolio->posts_next['url'] ),
|
||||
add_query_arg( 'et_portfolio', '', esc_url( $portfolio->posts_next['url'] ) ),
|
||||
esc_html( $portfolio->posts_next['label'] )
|
||||
);
|
||||
}
|
||||
@ -774,7 +779,7 @@ class ET_Builder_Module_Portfolio extends ET_Builder_Module_Type_PostBased {
|
||||
'<div class="alignright">
|
||||
<a href="%1$s">%2$s</a>
|
||||
</div>',
|
||||
esc_url( $portfolio->posts_prev['url'] ),
|
||||
add_query_arg( 'et_portfolio', '', esc_url( $portfolio->posts_prev['url'] ) ),
|
||||
esc_html( $portfolio->posts_prev['label'] )
|
||||
);
|
||||
}
|
||||
|
@ -62,15 +62,17 @@ class ET_Builder_Module_Field_Border extends ET_Builder_Module_Field_Base {
|
||||
if ( $template->is_enabled() && ! $template->has( 'border' ) ) {
|
||||
$template_placeholders = $template->placeholders(
|
||||
array(
|
||||
'suffix' => null,
|
||||
'label_prefix' => null,
|
||||
'tab_slug' => null,
|
||||
'toggle_slug' => null,
|
||||
'color_type' => null,
|
||||
'depends_on' => null,
|
||||
'depends_show_if' => null,
|
||||
'sub_toggle' => null,
|
||||
'defaults' => array(
|
||||
'suffix' => null,
|
||||
'label_prefix' => null,
|
||||
'tab_slug' => null,
|
||||
'toggle_slug' => null,
|
||||
'color_type' => null,
|
||||
'depends_on' => null,
|
||||
'depends_show_if_not' => null,
|
||||
'depends_show_if' => null,
|
||||
'use_radius' => null,
|
||||
'sub_toggle' => null,
|
||||
'defaults' => array(
|
||||
'border_radii' => null,
|
||||
'border_styles' => array(
|
||||
'width' => null,
|
||||
@ -98,16 +100,17 @@ class ET_Builder_Module_Field_Border extends ET_Builder_Module_Field_Base {
|
||||
public function get_fields( array $args = array(), $return_template_id = false ) {
|
||||
$settings = shortcode_atts(
|
||||
array(
|
||||
'suffix' => '',
|
||||
'label_prefix' => '',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'border',
|
||||
'color_type' => 'color-alpha',
|
||||
'depends_on' => null,
|
||||
'depends_show_if' => null,
|
||||
'sub_toggle' => null,
|
||||
'use_radius' => true,
|
||||
'defaults' => array(
|
||||
'suffix' => '',
|
||||
'label_prefix' => '',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'border',
|
||||
'color_type' => 'color-alpha',
|
||||
'depends_on' => null,
|
||||
'depends_show_if_not' => null,
|
||||
'depends_show_if' => null,
|
||||
'sub_toggle' => null,
|
||||
'use_radius' => true,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on||||',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
@ -426,8 +429,9 @@ class ET_Builder_Module_Field_Border extends ET_Builder_Module_Field_Base {
|
||||
// Add options dependency
|
||||
if ( ! is_null( $settings['depends_on'] ) ) {
|
||||
foreach ( $additional_options as &$option ) {
|
||||
$option['depends_on'] = $settings['depends_on'];
|
||||
$option['depends_show_if'] = $settings['depends_show_if'];
|
||||
$option['depends_on'] = $settings['depends_on'];
|
||||
$option['depends_show_if'] = $settings['depends_show_if'];
|
||||
$option['depends_show_if_not'] = $settings['depends_show_if_not'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,9 @@ require_once __DIR__ . '/display-conditions/Cookie.php';
|
||||
require_once __DIR__ . '/display-conditions/CategoryPage.php';
|
||||
require_once __DIR__ . '/display-conditions/TagPage.php';
|
||||
require_once __DIR__ . '/display-conditions/NumberOfViews.php';
|
||||
require_once __DIR__ . '/display-conditions/CustomField.php';
|
||||
require_once __DIR__ . '/display-conditions/UrlParameter.php';
|
||||
require_once __DIR__ . '/display-conditions/ProductStock.php';
|
||||
|
||||
/**
|
||||
* Import class dependencies
|
||||
@ -72,6 +75,9 @@ class ET_Builder_Module_Field_DisplayConditions extends ET_Builder_Module_Field_
|
||||
use CategoryPageCondition;
|
||||
use TagPageCondition;
|
||||
use NumberOfViewsCondition;
|
||||
use CustomFieldCondition;
|
||||
use UrlParameterCondition;
|
||||
use ProductStockCondition;
|
||||
|
||||
/**
|
||||
* Custom current date.
|
||||
@ -157,11 +163,6 @@ class ET_Builder_Module_Field_DisplayConditions extends ET_Builder_Module_Field_
|
||||
* @return boolean Conditions final result.
|
||||
*/
|
||||
public function is_displayable( $display_conditions, $only_return_status = false ) {
|
||||
// Bail out and just display the module if below WordPress 5.3.
|
||||
if ( version_compare( get_bloginfo( 'version' ), '5.3', '<' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Bail out and just display the module if $display_conditions is not array.
|
||||
if ( ! is_array( $display_conditions ) ) {
|
||||
return true;
|
||||
@ -290,6 +291,15 @@ class ET_Builder_Module_Field_DisplayConditions extends ET_Builder_Module_Field_
|
||||
case 'numberOfViews':
|
||||
return $this->_process_number_of_views_condition( $condition_id, $condition_settings );
|
||||
|
||||
case 'customField':
|
||||
return $this->_process_custom_field_condition( $condition_settings );
|
||||
|
||||
case 'urlParameter':
|
||||
return $this->_process_url_parameter_condition( $condition_settings );
|
||||
|
||||
case 'productStock':
|
||||
return $this->_process_product_stock_condition( $condition_settings );
|
||||
|
||||
default:
|
||||
if ( isset( $condition_settings['dynamicPosts'] ) ) {
|
||||
return $this->_process_dynamic_posts_condition( $condition_settings );
|
||||
@ -341,6 +351,20 @@ class ET_Builder_Module_Field_DisplayConditions extends ET_Builder_Module_Field_
|
||||
break;
|
||||
}
|
||||
|
||||
// Exception! "Custom Field" Condition can have multiple conditions.
|
||||
$is_custom_field = 'customField' === $condition['condition'];
|
||||
if ( $is_custom_field ) {
|
||||
$is_conflicted = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Exception! "URL Parameter" Condition can have multiple conditions.
|
||||
$is_url_parameter = 'urlParameter' === $condition['condition'];
|
||||
if ( $is_url_parameter ) {
|
||||
$is_conflicted = false;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* When operator is set to "OR/ANY" and we have more than one condition, all other conditions
|
||||
* will be set as conflicted, giving the priority to the latest condition in the list.
|
||||
|
@ -241,6 +241,9 @@ class ET_Builder_Module_Field_MarginPadding extends ET_Builder_Module_Field_Base
|
||||
'sub_toggle' => $sub_toggle,
|
||||
'priority' => $config['priority'],
|
||||
);
|
||||
if ( isset( $config['depends_on'] ) && '' !== $config['depends_on'] ) {
|
||||
$fields[ $custom_padding ]['depends_on'] = $config['depends_on'];
|
||||
}
|
||||
$fields[ $custom_padding_tablet ] = array(
|
||||
'type' => 'skip',
|
||||
'tab_slug' => $tab_slug,
|
||||
|
@ -30,7 +30,8 @@ trait AuthorCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
$display_rule = isset( $condition_settings['authorDisplay'] ) ? $condition_settings['authorDisplay'] : '';
|
||||
$legacy_display_rule = isset( $condition_settings['authorDisplay'] ) ? $condition_settings['authorDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$authors_raw = isset( $condition_settings['authors'] ) ? $condition_settings['authors'] : [];
|
||||
$authors_ids = array_map(
|
||||
function( $item ) {
|
||||
|
@ -25,9 +25,11 @@ trait BrowserCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_browser_condition( $condition_settings ) {
|
||||
$display_rule = isset( $condition_settings['browserDisplay'] ) ? $condition_settings['browserDisplay'] : 'is';
|
||||
$browsers_raw = isset( $condition_settings['browsers'] ) ? $condition_settings['browsers'] : '';
|
||||
$browsers = explode( '|', $browsers_raw );
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['browserDisplay'] ) ? $condition_settings['browserDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$browsers_raw = isset( $condition_settings['browsers'] ) ? $condition_settings['browsers'] : '';
|
||||
$browsers = explode( '|', $browsers_raw );
|
||||
// phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- User Agent is not stored or displayed therefore XSS safe.
|
||||
$useragent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
||||
$is_old_edge = preg_match( '/edge\//i', $useragent );
|
||||
|
@ -28,15 +28,18 @@ trait CartContentsCondition {
|
||||
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||
return false;
|
||||
}
|
||||
$display_rule = isset( $condition_settings['cartContentsDisplay'] ) ? $condition_settings['cartContentsDisplay'] : 'hasProducts';
|
||||
$products_raw = isset( $condition_settings['products'] ) ? $condition_settings['products'] : [];
|
||||
$products_ids = array_map(
|
||||
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['cartContentsDisplay'] ) ? $condition_settings['cartContentsDisplay'] : 'hasProducts';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$products_raw = isset( $condition_settings['products'] ) ? $condition_settings['products'] : [];
|
||||
$products_ids = array_map(
|
||||
function( $item ) {
|
||||
return isset( $item['value'] ) ? $item['value'] : '';
|
||||
},
|
||||
$products_raw
|
||||
);
|
||||
$is_cart_empty = WC()->cart->is_empty();
|
||||
$is_cart_empty = WC()->cart->is_empty();
|
||||
|
||||
switch ( $display_rule ) {
|
||||
case 'hasProducts':
|
||||
|
@ -31,8 +31,9 @@ trait CategoriesCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get condition's settings.
|
||||
$display_rule = isset( $condition_settings['categoriesDisplay'] ) ? $condition_settings['categoriesDisplay'] : 'is';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['categoriesDisplay'] ) ? $condition_settings['categoriesDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$categories_raw = isset( $condition_settings['categories'] ) ? $condition_settings['categories'] : [];
|
||||
$categories = array_map(
|
||||
function( $item ) {
|
||||
|
@ -31,8 +31,9 @@ trait CategoryPageCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get condition's settings.
|
||||
$display_rule = isset( $condition_settings['categoryPageDisplay'] ) ? $condition_settings['categoryPageDisplay'] : 'is';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['categoryPageDisplay'] ) ? $condition_settings['categoryPageDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$categories_raw = isset( $condition_settings['categories'] ) ? $condition_settings['categories'] : [];
|
||||
$queried_object = get_queried_object();
|
||||
$is_queried_object_valid = $queried_object instanceof \WP_Term && property_exists( $queried_object, 'taxonomy' );
|
||||
|
@ -25,7 +25,9 @@ trait CookieCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_cookie_condition( $condition_settings ) {
|
||||
$display_rule = isset( $condition_settings['cookieDisplay'] ) ? $condition_settings['cookieDisplay'] : 'cookieExists';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['cookieDisplay'] ) ? $condition_settings['cookieDisplay'] : 'cookieExists';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$cookie_name = isset( $condition_settings['cookieName'] ) ? $condition_settings['cookieName'] : '';
|
||||
$cookie_value = isset( $condition_settings['cookieValue'] ) ? $condition_settings['cookieValue'] : '';
|
||||
$is_cookie_set = ( isset( $_COOKIE[ $cookie_name ] ) ) ? true : false;
|
||||
|
@ -22,17 +22,19 @@ trait DateArchiveCondition {
|
||||
*
|
||||
* @since 4.11.0
|
||||
*
|
||||
* @param array $all_settings Containing all settings of the condition.
|
||||
* @param array $condition_settings Containing all settings of the condition.
|
||||
*
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_date_archive_condition( $all_settings ) {
|
||||
protected function _process_date_archive_condition( $condition_settings ) {
|
||||
if ( ! is_date() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$display_rule = isset( $all_settings['dateArchiveDisplay'] ) ? $all_settings['dateArchiveDisplay'] : 'isAfter';
|
||||
$date = isset( $all_settings['dateArchive'] ) ? $all_settings['dateArchive'] : '';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['dateArchiveDisplay'] ) ? $condition_settings['dateArchiveDisplay'] : 'isAfter';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$date = isset( $condition_settings['dateArchive'] ) ? $condition_settings['dateArchive'] : '';
|
||||
|
||||
$year = get_query_var( 'year' );
|
||||
$monthnum = get_query_var( 'monthnum' ) === 0 ? 1 : get_query_var( 'monthnum' );
|
||||
|
@ -27,7 +27,9 @@ trait DateTimeCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_date_time_condition( $condition_settings ) {
|
||||
$display_rule = isset( $condition_settings['dateTimeDisplay'] ) ? $condition_settings['dateTimeDisplay'] : 'isAfter';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['dateTimeDisplay'] ) ? $condition_settings['dateTimeDisplay'] : 'isAfter';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$date = isset( $condition_settings['date'] ) ? $condition_settings['date'] : '';
|
||||
$time = isset( $condition_settings['time'] ) ? $condition_settings['time'] : '';
|
||||
$all_day = isset( $condition_settings['allDay'] ) ? $condition_settings['allDay'] : '';
|
||||
@ -132,6 +134,9 @@ trait DateTimeCondition {
|
||||
* @return boolean Condition repetition result.
|
||||
*/
|
||||
protected function _is_datetime_condition_repeated( $condition_settings, $is_on_specific_date, $current_datetime, $target_datetime ) {
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['dateTimeDisplay'] ) ? $condition_settings['dateTimeDisplay'] : 'isAfter';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$repeat = isset( $condition_settings['repeat'] ) ? $condition_settings['repeat'] : '';
|
||||
$repeat_frequency = isset( $condition_settings['repeatFrequency'] ) ? $condition_settings['repeatFrequency'] : '';
|
||||
$repeat_frequency_specific_days = isset( $condition_settings['repeatFrequencySpecificDays'] ) ? $condition_settings['repeatFrequencySpecificDays'] : '';
|
||||
@ -142,7 +147,7 @@ trait DateTimeCondition {
|
||||
$from_time = isset( $condition_settings['fromTime'] ) ? $condition_settings['fromTime'] : '';
|
||||
$until_time = isset( $condition_settings['untilTime'] ) ? $condition_settings['untilTime'] : '';
|
||||
$is_repeated = false;
|
||||
$is_on_specific_days = 'isOnSpecificDays' === $condition_settings['dateTimeDisplay'];
|
||||
$is_on_specific_days = 'isOnSpecificDays' === $display_rule;
|
||||
|
||||
if ( $is_on_specific_days || ( 'on' === $repeat && ! $is_on_specific_date ) ) {
|
||||
if ( $is_on_specific_days ) {
|
||||
|
@ -30,16 +30,18 @@ trait DynamicPostsCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
$display_rule = isset( $condition_settings['dynamicPostsDisplay'] ) ? $condition_settings['dynamicPostsDisplay'] : '';
|
||||
$dynamic_posts_raw = isset( $condition_settings['dynamicPosts'] ) ? $condition_settings['dynamicPosts'] : [];
|
||||
$dynamic_posts_ids = array_map(
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['dynamicPostsDisplay'] ) ? $condition_settings['dynamicPostsDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$dynamic_posts_raw = isset( $condition_settings['dynamicPosts'] ) ? $condition_settings['dynamicPosts'] : [];
|
||||
$dynamic_posts_ids = array_map(
|
||||
function( $item ) {
|
||||
return isset( $item['value'] ) ? $item['value'] : '';
|
||||
},
|
||||
$dynamic_posts_raw
|
||||
);
|
||||
$is_on_shop_page = class_exists( 'WooCommerce' ) && is_shop();
|
||||
$current_page_id = $is_on_shop_page ? wc_get_page_id( 'shop' ) : get_queried_object_id();
|
||||
$is_on_shop_page = class_exists( 'WooCommerce' ) && is_shop();
|
||||
$current_page_id = $is_on_shop_page ? wc_get_page_id( 'shop' ) : get_queried_object_id();
|
||||
|
||||
$should_display = array_intersect( $dynamic_posts_ids, (array) $current_page_id ) ? true : false;
|
||||
|
||||
|
@ -25,26 +25,12 @@ trait LoggedInStatusCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_logged_in_status_condition( $condition_settings ) {
|
||||
$logged_in_status = isset( $condition_settings['loggedInStatus'] ) ? $condition_settings['loggedInStatus'] : 'loggedIn';
|
||||
$should_display = ( is_user_logged_in() ) ? true : false;
|
||||
return ( 'loggedIn' === $logged_in_status ) ? $should_display : ! $should_display;
|
||||
}
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['loggedInStatus'] ) ? $condition_settings['loggedInStatus'] : 'loggedIn';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$should_display = ( is_user_logged_in() ) ? true : false;
|
||||
|
||||
/**
|
||||
* Checks logged in status for possible conflicts.
|
||||
*
|
||||
* @param string $current_value Curent setting value.
|
||||
* @param string $prev_value Previous setting value.
|
||||
* @param array $conflicting_value Defined conflicting value.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _is_logged_in_status_conflicted( $current_value, $prev_value, $conflicting_value ) {
|
||||
$is_current_value_conflicted = in_array( $current_value, $conflicting_value, true );
|
||||
$is_prev_value_conflicted = in_array( $prev_value, $conflicting_value, true );
|
||||
if ( $is_current_value_conflicted && $is_prev_value_conflicted ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ( 'loggedIn' === $display_rule ) ? $should_display : ! $should_display;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ trait OperatingSystemCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_operating_system_condition( $condition_settings ) {
|
||||
$display_rule = isset( $condition_settings['operatingSystemDisplay'] ) ? $condition_settings['operatingSystemDisplay'] : 'is';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['operatingSystemDisplay'] ) ? $condition_settings['operatingSystemDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$operating_systems_raw = isset( $condition_settings['operatingSystems'] ) ? $condition_settings['operatingSystems'] : '';
|
||||
$operating_systems = explode( '|', $operating_systems_raw );
|
||||
$current_os = $this->_get_os();
|
||||
|
@ -25,7 +25,9 @@ trait PageVisitCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_page_visit_condition( $condition_settings ) {
|
||||
$display_rule = isset( $condition_settings['pageVisitDisplay'] ) ? $condition_settings['pageVisitDisplay'] : 'hasVisitedSpecificPage';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['pageVisitDisplay'] ) ? $condition_settings['pageVisitDisplay'] : 'hasVisitedSpecificPage';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$pages_raw = isset( $condition_settings['pages'] ) ? $condition_settings['pages'] : [];
|
||||
$pages_ids = array_map(
|
||||
function( $item ) {
|
||||
@ -34,10 +36,13 @@ trait PageVisitCondition {
|
||||
$pages_raw
|
||||
);
|
||||
$has_visited_specific_page = false;
|
||||
$cookie = [];
|
||||
|
||||
if ( isset( $_COOKIE['divi_post_visit'] ) ) {
|
||||
// phpcs:ignore ET.Sniffs.ValidatedSanitizedInput, WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- Cookie is not stored or displayed therefore XSS safe, base64_decode returned data is an array and necessary validation checks are performed.
|
||||
$cookie = json_decode( base64_decode( $_COOKIE['divi_post_visit'] ), true );
|
||||
$cookie = json_decode( base64_decode( $_COOKIE['divi_post_visit'] ), true );
|
||||
}
|
||||
if ( $cookie && is_array( $cookie ) ) {
|
||||
$col = array_column( $cookie, 'id' );
|
||||
$has_visited_specific_page = array_intersect( $pages_ids, $col ) ? true : false;
|
||||
}
|
||||
|
@ -30,17 +30,19 @@ trait PostTypeCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
$display_rule = isset( $condition_settings['postTypeDisplay'] ) ? $condition_settings['postTypeDisplay'] : '';
|
||||
$post_types_raw = isset( $condition_settings['postTypes'] ) ? $condition_settings['postTypes'] : [];
|
||||
$post_types_values = array_map(
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['postTypeDisplay'] ) ? $condition_settings['postTypeDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$post_types_raw = isset( $condition_settings['postTypes'] ) ? $condition_settings['postTypes'] : [];
|
||||
$post_types_values = array_map(
|
||||
function( $item ) {
|
||||
return $item['value'];
|
||||
},
|
||||
$post_types_raw
|
||||
);
|
||||
$is_on_shop_page = class_exists( 'WooCommerce' ) && is_shop();
|
||||
$current_queried_id = $is_on_shop_page ? wc_get_page_id( 'shop' ) : get_queried_object_id();
|
||||
$post_type = get_post_type( $current_queried_id );
|
||||
$is_on_shop_page = class_exists( 'WooCommerce' ) && is_shop();
|
||||
$current_queried_id = $is_on_shop_page ? wc_get_page_id( 'shop' ) : get_queried_object_id();
|
||||
$post_type = get_post_type( $current_queried_id );
|
||||
|
||||
$should_display = array_intersect( $post_types_values, (array) $post_type ) ? true : false;
|
||||
|
||||
|
@ -29,10 +29,12 @@ trait ProductPurchaseCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
$display_rule = isset( $condition_settings['productPurchaseDisplay'] ) ? $condition_settings['productPurchaseDisplay'] : 'hasBoughtProduct';
|
||||
$products_raw = isset( $condition_settings['products'] ) ? $condition_settings['products'] : [];
|
||||
$current_user = wp_get_current_user();
|
||||
$products_ids = array_map(
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['productPurchaseDisplay'] ) ? $condition_settings['productPurchaseDisplay'] : 'hasBoughtProduct';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$products_raw = isset( $condition_settings['products'] ) ? $condition_settings['products'] : [];
|
||||
$current_user = wp_get_current_user();
|
||||
$products_ids = array_map(
|
||||
function( $item ) {
|
||||
return isset( $item['value'] ) ? $item['value'] : '';
|
||||
},
|
||||
|
@ -30,7 +30,9 @@ trait SearchResultsCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
$display_rule = isset( $condition_settings['searchResultsDisplay'] ) ? $condition_settings['searchResultsDisplay'] : 'is';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['searchResultsDisplay'] ) ? $condition_settings['searchResultsDisplay'] : 'specificSearchQueries';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$specific_search_queries_raw = isset( $condition_settings['specificSearchQueries'] ) ? $condition_settings['specificSearchQueries'] : '';
|
||||
$excluded_search_queries_raw = isset( $condition_settings['excludedSearchQueries'] ) ? $condition_settings['excludedSearchQueries'] : '';
|
||||
$specific_search_queries = explode( ',', $specific_search_queries_raw );
|
||||
|
@ -31,8 +31,9 @@ trait TagPageCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get condition's settings.
|
||||
$display_rule = isset( $condition_settings['tagPageDisplay'] ) ? $condition_settings['tagPageDisplay'] : 'is';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['tagPageDisplay'] ) ? $condition_settings['tagPageDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$tags_raw = isset( $condition_settings['tags'] ) ? $condition_settings['tags'] : [];
|
||||
$queried_object = get_queried_object();
|
||||
$is_queried_object_valid = $queried_object instanceof \WP_Term && property_exists( $queried_object, 'taxonomy' );
|
||||
|
@ -31,8 +31,9 @@ trait TagsCondition {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get condition's settings.
|
||||
$display_rule = isset( $condition_settings['tagsDisplay'] ) ? $condition_settings['tagsDisplay'] : 'is';
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['tagsDisplay'] ) ? $condition_settings['tagsDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$tags_raw = isset( $condition_settings['tags'] ) ? $condition_settings['tags'] : [];
|
||||
$tags = array_map(
|
||||
function( $item ) {
|
||||
|
@ -25,17 +25,19 @@ trait UserRoleCondition {
|
||||
* @return boolean Condition output.
|
||||
*/
|
||||
protected function _process_user_role_condition( $condition_settings ) {
|
||||
$display_rule = isset( $condition_settings['userRoleDisplay'] ) ? $condition_settings['userRoleDisplay'] : 'is';
|
||||
$roles_raw = isset( $condition_settings['userRoles'] ) ? $condition_settings['userRoles'] : [];
|
||||
$ids_raw = isset( $condition_settings['userIds'] ) ? $condition_settings['userIds'] : '';
|
||||
$roles = array_map(
|
||||
// Checks for additional display rule for compatibility with Conditional Display older versions which didn't use `displayRule` key.
|
||||
$legacy_display_rule = isset( $condition_settings['userRoleDisplay'] ) ? $condition_settings['userRoleDisplay'] : 'is';
|
||||
$display_rule = isset( $condition_settings['displayRule'] ) ? $condition_settings['displayRule'] : $legacy_display_rule;
|
||||
$roles_raw = isset( $condition_settings['userRoles'] ) ? $condition_settings['userRoles'] : [];
|
||||
$ids_raw = isset( $condition_settings['userIds'] ) ? $condition_settings['userIds'] : '';
|
||||
$roles = array_map(
|
||||
function( $item ) {
|
||||
return $item['value'];
|
||||
},
|
||||
$roles_raw
|
||||
);
|
||||
$ids = isset( $ids_raw ) ? array_map( 'trim', array_filter( explode( ',', $ids_raw ) ) ) : array();
|
||||
$user = wp_get_current_user();
|
||||
$ids = isset( $ids_raw ) ? array_map( 'trim', array_filter( explode( ',', $ids_raw ) ) ) : array();
|
||||
$user = wp_get_current_user();
|
||||
|
||||
$should_display_based_on_roles = array_intersect( $roles, (array) $user->roles ) ? true : false;
|
||||
$should_display_based_on_ids = array_intersect( $ids, (array) $user->ID ) ? true : false;
|
||||
|
@ -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',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ abstract class ET_Builder_Module_Settings_Migration {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $max_version = '4.13.0';
|
||||
public static $max_version = '4.14.0';
|
||||
|
||||
/**
|
||||
* Array of already migrated data.
|
||||
@ -107,6 +107,8 @@ abstract class ET_Builder_Module_Settings_Migration {
|
||||
'3.25.3' => 'ShopOrderByDefault',
|
||||
'3.27.4' => 'TextAlignment',
|
||||
'4.13.0' => 'IconManager',
|
||||
'4.13.1' => 'ContactFormUniqueID',
|
||||
'4.14.0' => 'WooTextOG',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -526,7 +526,7 @@ class ET_Builder_Module_Settings_Migration_IconManager extends ET_Builder_Module
|
||||
return '';
|
||||
}
|
||||
|
||||
return et_pb_process_font_icon( $this->_current_value ) . '||divi||' . et_pb_get_normal_font_weight_value();
|
||||
return et_pb_build_extended_font_icon_value( $this->_current_value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Add to cart component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Add To Cart', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Add To Cart', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_add_to_cart';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Add To Cart', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Add To Cart', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_add_to_cart';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -32,11 +35,10 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'text' => array(
|
||||
'title' => et_builder_i18n( 'Text' ),
|
||||
'priority' => 45,
|
||||
'field_label' => array(
|
||||
'title' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
),
|
||||
'header' => array(
|
||||
'header' => array(
|
||||
'title' => esc_html__( 'Heading Text', 'et_builder' ),
|
||||
'priority' => 49,
|
||||
'tabbed_subtoggles' => true,
|
||||
@ -67,7 +69,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
),
|
||||
'width' => array(
|
||||
'width' => array(
|
||||
'title' => et_builder_i18n( 'Sizing' ),
|
||||
'priority' => 80,
|
||||
),
|
||||
@ -77,23 +79,23 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'fonts' => array(
|
||||
'body' => array(
|
||||
'label' => et_builder_i18n( 'Text' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%%, %%order_class%% a, %%order_class%% label, %%order_class%%.et_pb_module .et_pb_module_inner .stock',
|
||||
'important' => 'all',
|
||||
'field_label' => array(
|
||||
'label' => esc_html__( 'Field Labels', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% label',
|
||||
)
|
||||
),
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'line_height' => array(
|
||||
'default' => '1.3em',
|
||||
),
|
||||
'hide_text_align' => true,
|
||||
'toggle_slug' => 'text',
|
||||
'font' => array(
|
||||
'font' => array(
|
||||
'default' => '|700|||||||',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => '14px',
|
||||
),
|
||||
'toggle_slug' => 'field_label',
|
||||
),
|
||||
),
|
||||
'background' => array(
|
||||
@ -107,21 +109,17 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'text' => array(
|
||||
'use_background_layout' => true,
|
||||
'use_background_layout' => false,
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% td.label',
|
||||
'text_shadow' => '%%order_class%% td.label',
|
||||
),
|
||||
'options' => array(
|
||||
'text_orientation' => array(
|
||||
'text_orientation' => array(
|
||||
'default' => 'left',
|
||||
),
|
||||
'background_layout' => array(
|
||||
'default' => 'light',
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
),
|
||||
),
|
||||
'text_shadow' => array(
|
||||
// Don't add text-shadow fields since they already are via font-options.
|
||||
'default' => false,
|
||||
),
|
||||
'button' => array(
|
||||
'button' => array(
|
||||
'label' => et_builder_i18n( 'Button' ),
|
||||
@ -343,7 +341,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
*/
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'product' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product',
|
||||
array(
|
||||
'default' => ET_Builder_Module_Helper_Woocommerce_Modules::get_product_default(),
|
||||
@ -352,7 +350,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
)
|
||||
),
|
||||
'product_filter' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product_filter' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'product_filter',
|
||||
array(
|
||||
'computed_affects' => array(
|
||||
@ -360,7 +358,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
),
|
||||
)
|
||||
),
|
||||
'show_quantity' => array(
|
||||
'show_quantity' => array(
|
||||
'label' => esc_html__( 'Show Quantity Field', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
@ -374,7 +372,7 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_stock' => array(
|
||||
'show_stock' => array(
|
||||
'label' => esc_html__( 'Show Stock', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
@ -388,7 +386,22 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'__add_to_cart' => array(
|
||||
'field_label_position' => array(
|
||||
'label' => esc_html__( 'Fields Label Position', 'et_builder' ),
|
||||
'description' => esc_html__( 'Set the position of the field labels.', 'et_builder' ),
|
||||
'type' => 'select',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'inline' => __( 'Inline', 'et_builder' ),
|
||||
'stacked' => __( 'Stacked', 'et_builder' ),
|
||||
),
|
||||
'default' => 'default',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'field_label',
|
||||
'mobile_options' => true,
|
||||
'priority' => 15,
|
||||
),
|
||||
'__add_to_cart' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
'ET_Builder_Module_Woocommerce_Add_To_Cart',
|
||||
@ -407,22 +420,75 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the Add to Cart form's action.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param string $permalink Permalink.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function replace_add_to_cart_form_action( $permalink ) {
|
||||
$the_id = et_core_page_resource_get_the_ID();
|
||||
if ( 0 === absint( et_core_page_resource_get_the_ID() ) ) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
$link = get_permalink( $the_id );
|
||||
|
||||
// Validate if Post exists.
|
||||
return $link ? $link : $permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get add to cart markup as string
|
||||
*
|
||||
* @since 4.14.0 Update Add to Cart Form action {@see https://github.com/elegantthemes/Divi/issues/16682}
|
||||
*
|
||||
* @since 4.4.0 Fixed compatibility w/ WooCommerce Product Add-ons
|
||||
* @see https://github.com/elegantthemes/Divi/issues/19116
|
||||
*
|
||||
* @param array $args Additional arguments.
|
||||
* @param array $args Arguments from Computed Prop AJAX call.
|
||||
* @param array $conditional_tags Conditional Tags.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_add_to_cart( $args = array() ) {
|
||||
return et_builder_wc_render_module_template(
|
||||
public static function get_add_to_cart( $args = array(), $conditional_tags = array() ) {
|
||||
$is_tb = 'true' === et_()->array_get( $conditional_tags, 'is_tb', 'false' );
|
||||
$is_bfb = 'true' === et_()->array_get( $conditional_tags, 'is_bfb', 'false' );
|
||||
$is_bfb_activated = 'true' === et_()->array_get( $conditional_tags, 'is_bfb_activated', 'false' );
|
||||
$is_builder = $is_tb || $is_bfb || $is_bfb_activated;
|
||||
|
||||
if ( ! $is_builder ) {
|
||||
add_filter(
|
||||
'woocommerce_add_to_cart_form_action',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Add_To_Cart',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
'replace_add_to_cart_form_action'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$output = et_builder_wc_render_module_template(
|
||||
'woocommerce_template_single_add_to_cart',
|
||||
$args,
|
||||
array( 'product', 'post' )
|
||||
);
|
||||
|
||||
if ( ! $is_builder ) {
|
||||
remove_filter(
|
||||
'woocommerce_add_to_cart_form_action',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Add_To_Cart',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- This is a function call.
|
||||
'replace_add_to_cart_form_action'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -452,12 +518,18 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_hide_input_quantity' => array(
|
||||
'et_pb_hide_input_quantity' => array(
|
||||
'show_quantity' => 'off',
|
||||
),
|
||||
'et_pb_hide_stock' => array(
|
||||
'et_pb_hide_stock' => array(
|
||||
'show_stock' => 'off',
|
||||
),
|
||||
'et_pb_fields_label_position_inline' => array(
|
||||
'field_label_position' => 'inline',
|
||||
),
|
||||
'et_pb_fields_label_position_stacked' => array(
|
||||
'field_label_position' => 'stacked',
|
||||
),
|
||||
),
|
||||
),
|
||||
false,
|
||||
@ -562,6 +634,9 @@ class ET_Builder_Module_Woocommerce_Add_To_Cart extends ET_Builder_Module {
|
||||
$this->add_classname( 'et_pb_with_focus_border' );
|
||||
}
|
||||
|
||||
$fields_label_position = et_()->array_get( $this->props, 'field_label_position', 'inline' );
|
||||
$this->add_classname( "et_pb_fields_label_position_{$fields_label_position}" );
|
||||
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::process_background_layout_data( $render_slug, $this );
|
||||
ET_Builder_Module_Helper_Woocommerce_Modules::process_custom_button_icons( $render_slug, $this );
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Additional Info component.
|
||||
*/
|
||||
@ -20,10 +22,11 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
* @since 4.0.6 Implemented Attribute Row, Title and Body Custom CSS fields.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Additional Info', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Additional Info', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_additional_info';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Information', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Information', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_additional_info';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -34,7 +37,7 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'text' => array(
|
||||
'text' => array(
|
||||
'title' => et_builder_i18n( 'Text' ),
|
||||
'priority' => 45,
|
||||
'tabbed_subtoggles' => true,
|
||||
@ -50,9 +53,21 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
),
|
||||
'header' => array(
|
||||
'header' => array(
|
||||
'title' => esc_html__( 'Title Text', 'et_builder' ),
|
||||
),
|
||||
'table' => array(
|
||||
'title' => esc_html__( 'Table', 'et_builder' ),
|
||||
'priority' => 70,
|
||||
),
|
||||
'table_row' => array(
|
||||
'title' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'priority' => 75,
|
||||
),
|
||||
'table_cell' => array(
|
||||
'title' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'priority' => 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -155,6 +170,211 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
'default' => false,
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'table' => array(
|
||||
'label' => esc_html__( 'Table', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
'use_padding' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table' => array(
|
||||
'label_prefix' => 'Table',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% table.shop_attributes',
|
||||
'border_radii' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '0px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
'composite' => array(
|
||||
'border_top' => array(
|
||||
'border_width_top' => '1px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_row' => array(
|
||||
'label' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_row' => array(
|
||||
'label_prefix' => 'Table Row',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'border_radii' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
'border_styles' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_row' => array(
|
||||
'label' => esc_html__( 'Table Row', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_row' => array(
|
||||
'label_prefix' => 'Table Row',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
// Accepts only string and not array. Hence using `implode`.
|
||||
'border_radii' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
'border_styles' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes th',
|
||||
'%%order_class%% table.shop_attributes td',
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr',
|
||||
),
|
||||
),
|
||||
),
|
||||
'table_cell' => array(
|
||||
'label' => esc_html__( 'Table Cell', 'et_builder' ),
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => implode(
|
||||
', ',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes tr th',
|
||||
'%%order_class%% table.shop_attributes tr td',
|
||||
)
|
||||
),
|
||||
),
|
||||
'use_margin' => false,
|
||||
),
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'border_styles' => array(
|
||||
'table_cell' => array(
|
||||
'label_prefix' => 'Table Cell',
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_styles' => '%%order_class%% table.shop_attributes tr th,%%order_class%% table.shop_attributes tr td',
|
||||
'border_radii' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes tr td',
|
||||
),
|
||||
),
|
||||
'use_focus_borders' => false,
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|0px|0px|0px|0px',
|
||||
'border_styles' => array(
|
||||
'width' => '1px',
|
||||
'style' => 'dotted',
|
||||
),
|
||||
'composite' => array(
|
||||
'border_top' => array(
|
||||
'border_width_top' => '1px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% table.shop_attributes tr th, %%order_class%% table.shop_attributes td',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
@ -332,6 +552,24 @@ class ET_Builder_Module_Woocommerce_Additional_Info extends ET_Builder_Module {
|
||||
|
||||
add_filter( "et_builder_module_{$render_slug}_outer_wrapper_attrs", array( $this, 'add_multi_view_attrs' ), 10, 2 );
|
||||
|
||||
$table_row_bg_color = et_()->array_get( $this->props, 'table_row_background_color', '' );
|
||||
|
||||
if ( ! empty( $table_row_bg_color ) ) {
|
||||
ET_Builder_Element::set_style(
|
||||
$render_slug,
|
||||
array(
|
||||
'selector' => implode(
|
||||
',',
|
||||
array(
|
||||
'%%order_class%% table.shop_attributes tr:nth-child(even) th',
|
||||
'%%order_class%% table.shop_attributes tr:nth-child(even) td',
|
||||
)
|
||||
),
|
||||
'declaration' => 'background: inherit',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$output = self::get_additional_info( $this->props );
|
||||
|
||||
// Render empty string if no output is generated to avoid unwanted vertical space.
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Breadcrumb component.
|
||||
*/
|
||||
@ -25,10 +27,11 @@ class ET_Builder_Module_Woocommerce_Breadcrumb extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Breadcrumb', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Breadcrumbs', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Breadcrumbs', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_breadcrumb';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
$this->main_css_element = '%%order_class%% .woocommerce-breadcrumb';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Description component.
|
||||
*/
|
||||
@ -20,10 +22,11 @@ class ET_Builder_Module_Woocommerce_Description extends ET_Builder_Module {
|
||||
* @since 4.0.6 Updated `toggle_slug` to avoid empty Tabs in Text OG.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Description', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Descriptions', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_description';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Description', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Description', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_description';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Module_Gallery' ) ) {
|
||||
require_once ET_BUILDER_DIR_RESOLVED_PATH . '/module/Gallery.php';
|
||||
}
|
||||
@ -26,9 +28,10 @@ class ET_Builder_Module_Woocommerce_Gallery extends ET_Builder_Module_Gallery {
|
||||
public function init() {
|
||||
parent::init();
|
||||
|
||||
$this->name = esc_html__( 'Woo Gallery', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Galleries', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Product Gallery', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Gallery', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_gallery';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
$this->main_css_element = '%%order_class%%';
|
||||
|
||||
// Intentionally removing inherited options group.
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Images component.
|
||||
*/
|
||||
@ -18,9 +20,11 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Images', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_images';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Images', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Images', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_images';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
@ -32,14 +36,15 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
'sale_badge' => esc_html__( 'Sale Badge Text', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->advanced_fields = array(
|
||||
'borders' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% div.images ol.flex-control-thumbs.flex-control-nav li, %%order_class%% .flex-viewport, %%order_class%% .woocommerce-product-gallery--without-images .woocommerce-product-gallery__wrapper, %%order_class%% .woocommerce-product-gallery > div:not(.flex-viewport) .woocommerce-product-gallery__image, %%order_class%% .woocommerce-product-gallery > .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image, %%order_class%% .woocommerce-product-gallery .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image',
|
||||
@ -50,10 +55,25 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'image',
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% span.onsale',
|
||||
'border_styles' => '%%order_class%% span.onsale',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|3px|3px|3px|3px',
|
||||
),
|
||||
'label_prefix' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'default' => array(),
|
||||
'image' => array(
|
||||
'label' => esc_html__( 'Image Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
@ -64,6 +84,17 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% span.onsale',
|
||||
'overlay' => 'inset',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'background' => array(),
|
||||
'margin_padding' => array(
|
||||
@ -93,6 +124,31 @@ class ET_Builder_Module_Woocommerce_Images extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'background_color' => false,
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% ul.products li.product span.onsale',
|
||||
'important' => array( 'custom_margin', 'custom_padding' ),
|
||||
),
|
||||
'custom_margin' => array(
|
||||
'default' => '0px|0px|0px|0px|false|false',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '6px|18px|6px|18px|false|false',
|
||||
),
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
'border_styles' => false,
|
||||
'box_shadow' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->help_videos = array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Meta component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Meta extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Meta', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Metas', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_meta';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Meta', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Meta', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_meta';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Price component.
|
||||
*/
|
||||
@ -18,12 +20,13 @@ class ET_Builder_Module_Woocommerce_Price extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Price', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Prices', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Product Price', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Price', 'et_builder' );
|
||||
|
||||
// Use `et_pb_wc_{module}` for all WooCommerce modules.
|
||||
$this->slug = 'et_pb_wc_price';
|
||||
$this->vb_support = 'on';
|
||||
$this->slug = 'et_pb_wc_price';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Rating component.
|
||||
*/
|
||||
@ -20,10 +22,11 @@ class ET_Builder_Module_Woocommerce_Rating extends ET_Builder_Module {
|
||||
* @since 3.29.2 Added custom margin default.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Rating', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Ratings', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_rating';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Rating', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Rating', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_rating';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Related Products component.
|
||||
*
|
||||
@ -26,6 +28,13 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
*/
|
||||
public static $static_props;
|
||||
|
||||
/**
|
||||
* Number of products to be offset.
|
||||
*
|
||||
* @var int Default 0.
|
||||
*/
|
||||
public static $offset = 0;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
@ -33,12 +42,13 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
* @see {https://github.com/elegantthemes/Divi/issues/17436}
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Related Product', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Related Products', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Related Products', 'et_builder' );
|
||||
|
||||
// Use `et_pb_wc_{module}` for all WooCommerce modules.
|
||||
$this->slug = 'et_pb_wc_related_products';
|
||||
$this->vb_support = 'on';
|
||||
$this->slug = 'et_pb_wc_related_products';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->main_css_element = '%%order_class%%';
|
||||
|
||||
@ -46,14 +56,16 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'general' => array(
|
||||
'toggles' => array(
|
||||
'main_content' => et_builder_i18n( 'Content' ),
|
||||
'elements' => et_builder_i18n( 'Elements' ),
|
||||
),
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
// Avoid Text suffix by manually defining the `star` toggle slug.
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'sale_badge' => esc_html__( 'Sale Badge Text', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -168,7 +180,7 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'borders' => array(
|
||||
'default' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%%.et_pb_wc_related_products .product',
|
||||
@ -176,7 +188,7 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'image' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%%.et_pb_module .et_shop_image',
|
||||
@ -188,14 +200,29 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'image',
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% span.onsale',
|
||||
'border_styles' => '%%order_class%% span.onsale',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|3px|3px|3px|3px',
|
||||
),
|
||||
'label_prefix' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'default' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .product',
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'image' => array(
|
||||
'label' => esc_html__( 'Image Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
@ -209,6 +236,17 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'position' => '',
|
||||
),
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% span.onsale',
|
||||
'overlay' => 'inset',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
@ -250,6 +288,31 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'background_color' => false,
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% ul.products li.product span.onsale',
|
||||
'important' => array( 'custom_margin', 'custom_padding' ),
|
||||
),
|
||||
'custom_margin' => array(
|
||||
'default' => '0px|0px|0px|0px|false|false',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '6px|18px|6px|18px|false|false',
|
||||
),
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
'border_styles' => false,
|
||||
'box_shadow' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
@ -352,6 +415,24 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
),
|
||||
)
|
||||
),
|
||||
'include_categories' => array(
|
||||
'label' => esc_html__( 'Included Categories', 'et_builder' ),
|
||||
'type' => 'categories',
|
||||
'meta_categories' => array(
|
||||
'all' => esc_html__( 'All Categories', 'et_builder' ),
|
||||
'current' => esc_html__( 'Current Category', 'et_builder' ),
|
||||
),
|
||||
'renderer_options' => array(
|
||||
'use_terms' => true,
|
||||
'term_name' => 'product_cat',
|
||||
),
|
||||
'description' => esc_html__( 'Choose which categories you would like to include.', 'et_builder' ),
|
||||
'taxonomy_name' => 'product_cat',
|
||||
'toggle_slug' => 'main_content',
|
||||
'computed_affects' => array(
|
||||
'__related_products',
|
||||
),
|
||||
),
|
||||
'sale_badge_color' => array(
|
||||
'label' => esc_html__( 'Sale Badge Color', 'et_builder' ),
|
||||
'description' => esc_html__( 'Pick a color to use for the sales bade that appears on products that are on sale.', 'et_builder' ),
|
||||
@ -394,6 +475,84 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'sticky' => true,
|
||||
),
|
||||
'show_name' => array(
|
||||
'label' => esc_html__( 'Show Name', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn name on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_image' => array(
|
||||
'label' => esc_html__( 'Show Image', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn image on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_price' => array(
|
||||
'label' => esc_html__( 'Show Price', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn price on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_rating' => array(
|
||||
'label' => esc_html__( 'Show Rating', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn rating on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_sale_badge' => array(
|
||||
'label' => esc_html__( 'Show Sale Badge', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn sale badge on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'offset_number' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'offset_number',
|
||||
array(
|
||||
'computed_affects' => array(
|
||||
'__related_products',
|
||||
),
|
||||
)
|
||||
),
|
||||
'__related_products' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
@ -406,6 +565,8 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'posts_number',
|
||||
'columns_number',
|
||||
'orderby',
|
||||
'offset_number',
|
||||
'include_categories',
|
||||
),
|
||||
'computed_minimum' => array(
|
||||
'product',
|
||||
@ -416,6 +577,50 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the related product category Ids.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $term_ids Term IDs.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function set_related_products_categories( $term_ids ) {
|
||||
$include_cats = et_()->array_get( self::$static_props, 'include_categories', '' );
|
||||
$meta_cats = array( 'all', 'current' );
|
||||
|
||||
// WooCommerce by default handles All & Current based on the global $product.
|
||||
// So return the filtered $term_ids to let WooCommerce take control.
|
||||
if ( in_array( $include_cats, $meta_cats, true ) || empty( $include_cats ) ) {
|
||||
return $term_ids;
|
||||
}
|
||||
|
||||
// Return user selected categories if they exist.
|
||||
$include_cats = explode( ',', $include_cats );
|
||||
|
||||
return $include_cats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends offset to the WP_Query that retrieves Products.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $query_args Query args.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function append_offset( $query_args ) {
|
||||
if ( ! is_array( $query_args ) ) {
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
$query_args['offset'] = self::$offset;
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -450,6 +655,10 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
* we pass them via a static variable.
|
||||
*/
|
||||
self::$static_props = $args;
|
||||
$offset_number = et_()->array_get( $args, 'offset_number', 0 );
|
||||
$include_cats = et_()->array_get( $args, 'include_categories', '' );
|
||||
$include_cats = ! empty( $include_cats ) ? explode( ',', $include_cats ) : array();
|
||||
$is_include_cats = is_array( $include_cats ) && count( $include_cats ) > 0;
|
||||
|
||||
// Force set product's class to ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder
|
||||
// in TB so related product can outputs visible content based on pre-filled value in TB
|
||||
@ -457,11 +666,45 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
add_filter( 'woocommerce_product_class', 'et_theme_builder_wc_product_class' );
|
||||
}
|
||||
|
||||
$is_offset_valid = absint( $offset_number ) > 0;
|
||||
if ( $is_offset_valid ) {
|
||||
self::$offset = $offset_number;
|
||||
|
||||
add_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
'append_offset',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( $is_include_cats ) {
|
||||
$product_id = et_builder_wc_get_product_id( $args );
|
||||
// To include only selected categories the cached transient should be flushed,
|
||||
// so WooCommerce can compute the categories and cache it again.
|
||||
delete_transient( 'wc_related_' . $product_id );
|
||||
|
||||
add_filter(
|
||||
'woocommerce_get_related_product_cat_terms',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_categories'
|
||||
)
|
||||
);
|
||||
|
||||
// Also disable related Products by tag
|
||||
// so Products from other categories are not included.
|
||||
add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
|
||||
}
|
||||
|
||||
add_filter(
|
||||
'woocommerce_output_related_products_args',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
'set_related_products_args',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_args'
|
||||
)
|
||||
);
|
||||
|
||||
@ -471,10 +714,37 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
'woocommerce_output_related_products_args',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
'set_related_products_args',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_args'
|
||||
)
|
||||
);
|
||||
|
||||
if ( $is_include_cats ) {
|
||||
remove_filter(
|
||||
'woocommerce_get_related_product_cat_terms',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'set_related_products_categories'
|
||||
)
|
||||
);
|
||||
|
||||
remove_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
|
||||
}
|
||||
|
||||
if ( $is_offset_valid ) {
|
||||
remove_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Related_Products',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'append_offset'
|
||||
)
|
||||
);
|
||||
|
||||
self::$offset = 0;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -553,6 +823,54 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
return $selected_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Multi view attributes to the Outer wrapper.
|
||||
*
|
||||
* Since we do not have control over the WooCommerce Related Products markup, we inject Multi
|
||||
* view attributes on to the Outer wrapper.
|
||||
*
|
||||
* @param array $outer_wrapper_attrs Outer wrapper attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_multi_view_attrs( $outer_wrapper_attrs ) {
|
||||
$multi_view = et_pb_multi_view_options( $this );
|
||||
|
||||
// phpcs:disable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned -- Invalid warning.
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_wc_related_products_no_name' => array(
|
||||
'show_name' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_image' => array(
|
||||
'show_image' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_price' => array(
|
||||
'show_price' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_rating' => array(
|
||||
'show_rating' => 'off',
|
||||
),
|
||||
'et_pb_wc_related_products_no_sale_badge' => array(
|
||||
'show_sale_badge' => 'off',
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
false,
|
||||
null,
|
||||
true
|
||||
);
|
||||
// phpcs:enable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned
|
||||
|
||||
if ( $multi_view_attrs && is_array( $multi_view_attrs ) ) {
|
||||
$outer_wrapper_attrs = array_merge( $outer_wrapper_attrs, $multi_view_attrs );
|
||||
}
|
||||
|
||||
return $outer_wrapper_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
@ -680,19 +998,30 @@ class ET_Builder_Module_Woocommerce_Related_Products extends ET_Builder_Module {
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
'output_data_icon_attrs',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'output_data_icon_attrs'
|
||||
),
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
add_filter(
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
$this,
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'add_multi_view_attrs',
|
||||
)
|
||||
);
|
||||
|
||||
$output = $this->_render_module_wrapper( $output, $render_slug );
|
||||
|
||||
remove_filter(
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
'output_data_icon_attrs',
|
||||
// phpcs:ignore WordPress.Arrays.CommaAfterArrayItem.NoComma -- Call to a function.
|
||||
'output_data_icon_attrs'
|
||||
),
|
||||
10
|
||||
);
|
||||
|
@ -13,6 +13,8 @@ if ( ! class_exists( 'ET_Builder_Module_Gallery' ) ) {
|
||||
require_once ET_BUILDER_DIR_RESOLVED_PATH . '/module/Comments.php';
|
||||
}
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Reviews component.
|
||||
*/
|
||||
@ -26,9 +28,10 @@ class ET_Builder_Module_Woocommerce_Reviews extends ET_Builder_Module_Comments {
|
||||
parent::init();
|
||||
|
||||
// Define basic module information.
|
||||
$this->name = esc_html__( 'Woo Reviews', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Reviews', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_reviews';
|
||||
$this->name = esc_html__( 'Woo Product Reviews', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Reviews', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_reviews';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
// Modify toggle settings.
|
||||
$this->settings_modal_toggles['general']['toggles']['main_content'] = array(
|
||||
@ -189,6 +192,20 @@ class ET_Builder_Module_Woocommerce_Reviews extends ET_Builder_Module_Comments {
|
||||
),
|
||||
)
|
||||
);
|
||||
$fields['show_rating'] = array(
|
||||
'label' => esc_html__( 'Show Rating', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn rating on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
);
|
||||
$fields['__reviews'] = array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Stock component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Stock extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Stock', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Stock', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_stock';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Stock', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Stock', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_stock';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Module_Tabs' ) ) {
|
||||
require_once ET_BUILDER_DIR_RESOLVED_PATH . '/module/Tabs.php';
|
||||
}
|
||||
@ -28,9 +30,10 @@ class ET_Builder_Module_Woocommerce_Tabs extends ET_Builder_Module_Tabs {
|
||||
parent::init();
|
||||
|
||||
// Define WooCommerce Tabs module property; overwriting inherited property.
|
||||
$this->name = esc_html__( 'Woo Tabs', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Tabs', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_tabs';
|
||||
$this->name = esc_html__( 'Woo Product Tabs', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Tabs', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_tabs';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
/*
|
||||
* Set property for holding rendering data so the data rendering via
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Title component.
|
||||
*/
|
||||
@ -18,10 +20,11 @@ class ET_Builder_Module_Woocommerce_Title extends ET_Builder_Module {
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Title', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Titles', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_title';
|
||||
$this->vb_support = 'on';
|
||||
$this->name = esc_html__( 'Woo Product Title', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Title', 'et_builder' );
|
||||
$this->slug = 'et_pb_wc_title';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->settings_modal_toggles = array(
|
||||
'general' => array(
|
||||
|
@ -10,6 +10,8 @@
|
||||
* @since 3.29
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class representing WooCommerce Upsells component.
|
||||
*/
|
||||
@ -21,16 +23,24 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
*/
|
||||
public static $static_props;
|
||||
|
||||
/**
|
||||
* Number of products to be offset.
|
||||
*
|
||||
* @var int Default 0.
|
||||
*/
|
||||
public static $offset = 0;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
public function init() {
|
||||
$this->name = esc_html__( 'Woo Upsell', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Upsells', 'et_builder' );
|
||||
$this->name = esc_html__( 'Woo Product Upsell', 'et_builder' );
|
||||
$this->plural = esc_html__( 'Woo Product Upsell', 'et_builder' );
|
||||
|
||||
// Use `et_pb_wc_{module}` for all WooCommerce modules.
|
||||
$this->slug = 'et_pb_wc_upsells';
|
||||
$this->vb_support = 'on';
|
||||
$this->slug = 'et_pb_wc_upsells';
|
||||
$this->vb_support = 'on';
|
||||
$this->folder_name = 'et_pb_woo_modules';
|
||||
|
||||
$this->main_css_element = '%%order_class%%';
|
||||
|
||||
@ -38,14 +48,16 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'general' => array(
|
||||
'toggles' => array(
|
||||
'main_content' => et_builder_i18n( 'Content' ),
|
||||
'elements' => et_builder_i18n( 'Elements' ),
|
||||
),
|
||||
),
|
||||
'advanced' => array(
|
||||
'toggles' => array(
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
'overlay' => et_builder_i18n( 'Overlay' ),
|
||||
'image' => et_builder_i18n( 'Image' ),
|
||||
// Avoid Text suffix by manually defining the `star` toggle slug.
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'star' => esc_html__( 'Star Rating', 'et_builder' ),
|
||||
'sale_badge' => esc_html__( 'Sale Badge Text', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -73,7 +85,8 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'letter_spacing_hover' => '%%order_class%% ul.products li.product:hover .star-rating',
|
||||
),
|
||||
'font_size' => array(
|
||||
'default' => 14,
|
||||
'default' => '14px',
|
||||
'label' => esc_html__( 'Star Rating Size', 'et_builder' ),
|
||||
),
|
||||
'hide_font' => true,
|
||||
'hide_line_height' => true,
|
||||
@ -81,9 +94,6 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'text_align' => array(
|
||||
'label' => esc_html__( 'Star Rating Alignment', 'et_builder' ),
|
||||
),
|
||||
'font_size' => array(
|
||||
'label' => esc_html__( 'Star Rating Size', 'et_builder' ),
|
||||
),
|
||||
'text_color' => array(
|
||||
'label' => esc_html__( 'Star Rating Color', 'et_builder' ),
|
||||
),
|
||||
@ -179,14 +189,29 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'image',
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'css' => array(
|
||||
'main' => array(
|
||||
'border_radii' => '%%order_class%% span.onsale',
|
||||
'border_styles' => '%%order_class%% span.onsale',
|
||||
),
|
||||
'important' => true,
|
||||
),
|
||||
'defaults' => array(
|
||||
'border_radii' => 'on|3px|3px|3px|3px',
|
||||
),
|
||||
'label_prefix' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
),
|
||||
'box_shadow' => array(
|
||||
'default' => array(
|
||||
'default' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% .product',
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'image' => array(
|
||||
'label' => esc_html__( 'Image Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
@ -200,6 +225,17 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'position' => '',
|
||||
),
|
||||
),
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge Box Shadow', 'et_builder' ),
|
||||
'option_category' => 'layout',
|
||||
'tab_slug' => 'advanced',
|
||||
'toggle_slug' => 'sale_badge',
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% span.onsale',
|
||||
'overlay' => 'inset',
|
||||
'important' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
@ -240,6 +276,31 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
),
|
||||
),
|
||||
'button' => false,
|
||||
'form_field' => array(
|
||||
'sale_badge' => array(
|
||||
'label' => esc_html__( 'Sale Badge', 'et_builder' ),
|
||||
'background_color' => false,
|
||||
'text_color' => false,
|
||||
'focus_background_color' => false,
|
||||
'focus_text_color' => false,
|
||||
'font_field' => false,
|
||||
'margin_padding' => array(
|
||||
'css' => array(
|
||||
'main' => '%%order_class%% ul.products li.product span.onsale',
|
||||
'important' => array( 'custom_margin', 'custom_padding' ),
|
||||
),
|
||||
'custom_margin' => array(
|
||||
'default' => '0px|0px|0px|0px|false|false',
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'default' => '6px|18px|6px|18px|false|false',
|
||||
),
|
||||
'toggle_slug' => 'sale_badge',
|
||||
),
|
||||
'border_styles' => false,
|
||||
'box_shadow' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->custom_css_fields = array(
|
||||
@ -384,6 +445,84 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'mobile_options' => true,
|
||||
'sticky' => true,
|
||||
),
|
||||
'show_name' => array(
|
||||
'label' => esc_html__( 'Show Name', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn name on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_image' => array(
|
||||
'label' => esc_html__( 'Show Image', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn image on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_price' => array(
|
||||
'label' => esc_html__( 'Show Price', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn price on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_rating' => array(
|
||||
'label' => esc_html__( 'Show Rating', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn rating on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'show_sale_badge' => array(
|
||||
'label' => esc_html__( 'Show Sale Badge', 'et_builder' ),
|
||||
'type' => 'yes_no_button',
|
||||
'option_category' => 'configuration',
|
||||
'options' => array(
|
||||
'on' => esc_html__( 'Yes', 'et_builder' ),
|
||||
'off' => esc_html__( 'No', 'et_builder' ),
|
||||
),
|
||||
'default_on_front' => 'on',
|
||||
'toggle_slug' => 'elements',
|
||||
'description' => esc_html__( 'Turn sale badge on or off.', 'et_builder' ),
|
||||
'mobile_options' => true,
|
||||
'hover' => 'tabs',
|
||||
),
|
||||
'offset_number' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
|
||||
'offset_number',
|
||||
array(
|
||||
'computed_affects' => array(
|
||||
'__upsells',
|
||||
),
|
||||
)
|
||||
),
|
||||
'__upsells' => array(
|
||||
'type' => 'computed',
|
||||
'computed_callback' => array(
|
||||
@ -396,6 +535,7 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
'posts_number',
|
||||
'columns_number',
|
||||
'orderby',
|
||||
'offset_number',
|
||||
),
|
||||
'computed_minimum' => array(
|
||||
'product',
|
||||
@ -406,6 +546,25 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends offset to the WP_Query that retrieves Products.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param array $query_args Query args.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function append_offset( $query_args ) {
|
||||
if ( ! is_array( $query_args ) ) {
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
$query_args['offset'] = self::$offset;
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -433,6 +592,7 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
*/
|
||||
public static function get_upsells( $args = array(), $conditional_tags = array(), $current_page = array() ) {
|
||||
self::$static_props = $args;
|
||||
$offset_number = et_()->array_get( $args, 'offset_number', 0 );
|
||||
|
||||
// Force set product's class to ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder
|
||||
// in TB so related product can outputs visible content based on pre-filled value in TB
|
||||
@ -449,6 +609,16 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
add_filter( 'woocommerce_product_class', 'et_theme_builder_wc_product_class' );
|
||||
}
|
||||
|
||||
$is_offset_valid = absint( $offset_number ) > 0;
|
||||
if ( $is_offset_valid ) {
|
||||
self::$offset = $offset_number;
|
||||
|
||||
add_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array( 'ET_Builder_Module_Woocommerce_Upsells', 'append_offset' )
|
||||
);
|
||||
}
|
||||
|
||||
add_filter(
|
||||
'woocommerce_upsell_display_args',
|
||||
array(
|
||||
@ -474,12 +644,18 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
|
||||
remove_filter(
|
||||
'woocommerce_upsell_display_args',
|
||||
array(
|
||||
'ET_Builder_Module_Woocommerce_Upsells',
|
||||
'set_upsell_display_args',
|
||||
)
|
||||
array( 'ET_Builder_Module_Woocommerce_Upsells', 'set_upsell_display_args' )
|
||||
);
|
||||
|
||||
if ( $is_offset_valid ) {
|
||||
remove_filter(
|
||||
'woocommerce_shortcode_products_query',
|
||||
array( 'ET_Builder_Module_Woocommerce_Upsells', 'append_offset' )
|
||||
);
|
||||
|
||||
self::$offset = 0;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -538,6 +714,51 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
return $selected_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Multi view attributes to the Outer wrapper.
|
||||
*
|
||||
* Since we do not have control over the WooCommerce Related Products markup, we inject Multi
|
||||
* view attributes on to the Outer wrapper.
|
||||
*
|
||||
* @param array $outer_wrapper_attrs Outer wrapper attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_multi_view_attrs( $outer_wrapper_attrs ) {
|
||||
$multi_view = et_pb_multi_view_options( $this );
|
||||
|
||||
$multi_view_attrs = $multi_view->render_attrs(
|
||||
array(
|
||||
'classes' => array(
|
||||
'et_pb_wc_upsells_no_name' => array(
|
||||
'show_name' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_image' => array(
|
||||
'show_image' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_price' => array(
|
||||
'show_price' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_rating' => array(
|
||||
'show_rating' => 'off',
|
||||
),
|
||||
'et_pb_wc_upsells_no_sale_badge' => array(
|
||||
'show_sale_badge' => 'off',
|
||||
),
|
||||
),
|
||||
),
|
||||
false,
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
if ( $multi_view_attrs && is_array( $multi_view_attrs ) ) {
|
||||
$outer_wrapper_attrs = array_merge( $outer_wrapper_attrs, $multi_view_attrs );
|
||||
}
|
||||
|
||||
return $outer_wrapper_attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the module output.
|
||||
*
|
||||
@ -668,6 +889,14 @@ class ET_Builder_Module_Woocommerce_Upsells extends ET_Builder_Module {
|
||||
2
|
||||
);
|
||||
|
||||
add_filter(
|
||||
"et_builder_module_{$render_slug}_outer_wrapper_attrs",
|
||||
array(
|
||||
$this,
|
||||
'add_multi_view_attrs',
|
||||
)
|
||||
);
|
||||
|
||||
$output = $this->_render_module_wrapper( $output, $render_slug );
|
||||
|
||||
remove_filter(
|
||||
|
Reference in New Issue
Block a user