: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* WooCommerce Modules: ET_Builder_Module_Woocommerce_Description class
* The ET_Builder_Module_Woocommerce_Description Class is responsible for rendering the
* Description markup using the WooCommerce template.
* Class representing WooCommerce Gallery component.
class ET_Builder_Module_Woocommerce_Gallery extends ET_Builder_Module_Gallery {
* Modify properties defined on base module's (gallery) init()
$this->name = esc_html__( 'Woo Gallery', 'et_builder' );
$this->plural = esc_html__( 'Woo Galleries', 'et_builder' );
$this->slug = 'et_pb_wc_gallery';
$this->main_css_element = '%%order_class%%';
// Intentionally removing inherited options group.
unset( $this->settings_modal_toggles['general']['toggles']['main_content'] );
// Rename Elements Option group to Content.
$this->settings_modal_toggles['general']['toggles']['elements'] = et_builder_i18n( 'Content' );
// Intentionally removing inherited advanced options group.
$this->advanced_fields['link_options'] = false;
$this->advanced_fields['fonts']['title']['font_size'] = array(
$this->advanced_fields['fonts']['title']['line_height'] = array(
$this->advanced_fields['fonts']['pagination']['font_size'] = array(
$this->advanced_fields['fonts']['pagination']['line_height'] = array(
$this->advanced_fields['fonts']['caption']['font_size'] = array(
$this->advanced_fields['fonts']['caption']['line_height'] = array(
$this->advanced_fields['position_fields'] = array(
$this->custom_css_fields = array(
'label' => esc_html__( 'Gallery Item', 'et_builder' ),
'selector' => '.et_pb_gallery_item',
'gallery_pagination' => array(
'label' => esc_html__( 'Gallery Pagination', 'et_builder' ),
'selector' => '.et-pb-controllers a',
'gallery_pagination_active' => array(
'label' => esc_html__( 'Pagination Active Page', 'et_builder' ),
'selector' => '.et-pb-controllers a.et-pb-active-control',
$this->help_videos = array(
'name' => esc_html__( 'Divi WooCommerce Modules', 'et_builder' ),
// Insert classname to module wrapper.
'et_builder_wc_gallery_classes',
'add_wc_gallery_classname',
* Insert Woo Galleries specific fields and modify fields inherited from base module (gallery)
public function get_fields() {
* Woo Galleries fields that need to be prepended before fields inherited from gallery
$product_default = ET_Builder_Module_Helper_Woocommerce_Modules::get_product_default();
$wc_gallery_fields = array(
'product' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
'default' => $product_default,
'toggle_slug' => 'elements',
'computed_affects' => array(
'product_filter' => ET_Builder_Module_Helper_Woocommerce_Modules::get_field(
'toggle_slug' => 'elements',
'computed_affects' => array(
// Base module (gallery) fields.
$fields = parent::get_fields();
// Set the default Layout as Slider.
if ( array_key_exists( 'fullwidth', $fields ) ) {
$fields['fullwidth']['default_on_front'] = 'on';
// Prepending WC images field to fields inherited from gallery module (base module).
$fields = array_merge( $wc_gallery_fields, $fields );
// Hide gallery upload image field because module images are set from "Product" field.
$fields['gallery_ids']['type'] = 'hidden';
* Modify `__gallery`'s `computed_callback` attribute so Woo Gallery can insert additional
* arguments to computed callback result.
$fields['__gallery'] = array(
'computed_callback' => array(
'ET_Builder_Module_Woocommerce_Gallery',
'computed_depends_on' => array(
// Field is hidden because its control is take over by `product` field.
* Fields exist but not being rendered because their options group is hidden
// Exising and visible fields.
* Computed callback's callback method which adjusted arguments passed to original computed
* callback's callback so the result is suitable for Woo Gallery module
* @param array $args Arguments from Computed Prop AJAX call.
* @param array $conditional_tags Conditional Tags.
* @param array $current_page Current page args.
public static function get_wc_gallery( $args = array(), $conditional_tags = array(), $current_page = array() ) {
if ( 'current' === $args['product'] && 'true' === et_()->array_get( $conditional_tags, 'is_tb', false ) ) {
et_theme_builder_wc_set_global_objects( $conditional_tags );
// Generate valid `gallery_ids` value based `product` attribute.
$product = ET_Builder_Module_Helper_Woocommerce_Modules::get_product( $args['product'] );
$attachment_ids = array();
$featured_image_id = intval( $product->get_image_id() );
$attachment_ids = $product->get_gallery_image_ids();
// Modify `gallery_ids` value.
$args['gallery_ids'] = $attachment_ids;
// Don't display Placeholder when no Gallery image is available.
// @see https://github.com/elegantthemes/submodule-builder/pull/6706#issuecomment-542275647
if ( 0 === count( $attachment_ids ) ) {
$args['attachment_id'] = -1;
return ET_Builder_Module_Gallery::get_gallery( $args, $conditional_tags, $current_page );
* Modify module wrapper's classname
* @param array $classname List of class names.
* @param int $render_count Count of times the module is rendered.
public function add_wc_gallery_classname( $classname, $render_count ) {
// For gallery to be properly rendered, it needs `et_pb_gallery` classname.
$classname[] = 'et_pb_gallery';
* Use ET_Builder_Module_Woocommerce_Gallery::get_wc_gallery() instead of base module's
* ET_Builder_Module_Gallery::get_gallery() method for defining attachment value in
* frontend's `render()` and visual builder's computed callback result
* @param array $args Additional arguments.
public function get_attachments( $args = array() ) {
$args['product'] = $this->props['product'];
return self::get_wc_gallery( $args );
new ET_Builder_Module_Woocommerce_Gallery();