Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/module/helpers
File: WooCommerceModules.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WooCommerce Module Helper
[2] Fix | Delete
*
[3] Fix | Delete
* @package Divi
[4] Fix | Delete
* @sub-package Builder
[5] Fix | Delete
* @since 3.29
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[9] Fix | Delete
die( 'Direct access forbidden.' );
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
if ( et_is_woocommerce_plugin_active() ) {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Class ET_Builder_Module_Helper_Woocommerce_Modules
[16] Fix | Delete
*
[17] Fix | Delete
* Shared code between all Woo Modules.
[18] Fix | Delete
*/
[19] Fix | Delete
class ET_Builder_Module_Helper_Woocommerce_Modules {
[20] Fix | Delete
/**
[21] Fix | Delete
* Returns TRUE if the Product attribute value is valid.
[22] Fix | Delete
*
[23] Fix | Delete
* Valid values are Product Ids, `current` and `latest`.
[24] Fix | Delete
*
[25] Fix | Delete
* @param string $maybe_product_id
[26] Fix | Delete
*
[27] Fix | Delete
* @return bool
[28] Fix | Delete
*/
[29] Fix | Delete
public static function is_product_attr_valid( $maybe_product_id ) {
[30] Fix | Delete
if ( empty( $maybe_product_id ) ) {
[31] Fix | Delete
return false;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
if ( absint( $maybe_product_id ) === 0
[35] Fix | Delete
&& ! in_array( $maybe_product_id, array( 'current', 'latest' ) ) ) {
[36] Fix | Delete
return false;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
return true;
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Gets the Product Id by the given Product prop value.
[44] Fix | Delete
*
[45] Fix | Delete
* @param string $valid_product_attr
[46] Fix | Delete
*
[47] Fix | Delete
* @return int
[48] Fix | Delete
*/
[49] Fix | Delete
public static function get_product_id_by_prop( $valid_product_attr ) {
[50] Fix | Delete
if ( ! self::is_product_attr_valid( $valid_product_attr ) ) {
[51] Fix | Delete
return 0;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( 'current' === $valid_product_attr ) {
[55] Fix | Delete
$current_post_id = ET_Builder_Element::get_current_post_id();
[56] Fix | Delete
[57] Fix | Delete
if ( et_theme_builder_is_layout_post_type( get_post_type( $current_post_id ) ) ) {
[58] Fix | Delete
// We want to use the latest product when we are editing a TB layout.
[59] Fix | Delete
$valid_product_attr = 'latest';
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
if ( ! in_array( $valid_product_attr, array(
[64] Fix | Delete
'current',
[65] Fix | Delete
'latest',
[66] Fix | Delete
) ) && false === get_post_status( $valid_product_attr ) ) {
[67] Fix | Delete
$valid_product_attr = 'latest';
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
if ( 'current' === $valid_product_attr ) {
[71] Fix | Delete
$product_id = ET_Builder_Element::get_current_post_id();
[72] Fix | Delete
} else if ( 'latest' === $valid_product_attr ) {
[73] Fix | Delete
$args = array(
[74] Fix | Delete
'limit' => 1,
[75] Fix | Delete
'post_status' => array( 'publish', 'private' ),
[76] Fix | Delete
'perm' => 'readable',
[77] Fix | Delete
);
[78] Fix | Delete
[79] Fix | Delete
$products = wc_get_products( $args );
[80] Fix | Delete
if ( ! empty( $products ) ) {
[81] Fix | Delete
$product_id = $products[0]->get_id();
[82] Fix | Delete
} else {
[83] Fix | Delete
return 0;
[84] Fix | Delete
}
[85] Fix | Delete
} else if ( is_numeric( $valid_product_attr ) && 'product' !== get_post_type( $valid_product_attr ) ) {
[86] Fix | Delete
// There is a condition that $valid_product_attr value passed here is not the product ID.
[87] Fix | Delete
// For example when you set product breadcrumb as Blurb Title when building layout in TB.
[88] Fix | Delete
// So we get the most recent product ID in date descending order.
[89] Fix | Delete
$query = new WC_Product_Query( array(
[90] Fix | Delete
'limit' => 1,
[91] Fix | Delete
'orderby' => 'date',
[92] Fix | Delete
'order' => 'DESC',
[93] Fix | Delete
'return' => 'ids',
[94] Fix | Delete
'status' => array( 'publish' ),
[95] Fix | Delete
) );
[96] Fix | Delete
[97] Fix | Delete
$products = $query->get_products();
[98] Fix | Delete
[99] Fix | Delete
if ( $products && ! empty( $products[0] ) ) {
[100] Fix | Delete
$product_id = absint( $products[0] );
[101] Fix | Delete
} else {
[102] Fix | Delete
$product_id = absint( $valid_product_attr );
[103] Fix | Delete
}
[104] Fix | Delete
} else {
[105] Fix | Delete
$product_id = absint( $valid_product_attr );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
return $product_id;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Gets the Product (WC_Product) by the value stored in the Product attribute.
[113] Fix | Delete
*
[114] Fix | Delete
* @see WC_Product
[115] Fix | Delete
*
[116] Fix | Delete
* @param string $maybe_product_id The Value stored in the Product attribute using VB.
[117] Fix | Delete
*
[118] Fix | Delete
* @return false|WC_Product
[119] Fix | Delete
*/
[120] Fix | Delete
public static function get_product( $maybe_product_id ) {
[121] Fix | Delete
$product_id = self::get_product_id_by_prop( $maybe_product_id );
[122] Fix | Delete
[123] Fix | Delete
/*
[124] Fix | Delete
* No need to check `wc_get_product()` exists since this Class is defined only when
[125] Fix | Delete
* WooCommerce is active.
[126] Fix | Delete
*/
[127] Fix | Delete
$product = wc_get_product( $product_id );
[128] Fix | Delete
if ( empty( $product ) ) {
[129] Fix | Delete
return false;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
return $product;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* Gets the Product ID.
[137] Fix | Delete
*
[138] Fix | Delete
* @see WC_Product
[139] Fix | Delete
*
[140] Fix | Delete
* @param string $maybe_product_id The Value stored in the Product attribute using VB.
[141] Fix | Delete
*
[142] Fix | Delete
* @return int WP_Product ID.
[143] Fix | Delete
*/
[144] Fix | Delete
public static function get_product_id( $maybe_product_id ) {
[145] Fix | Delete
$product = self::get_product( $maybe_product_id );
[146] Fix | Delete
if ( ! $product ) {
[147] Fix | Delete
return 0;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
return $product->get_id();
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
/**
[154] Fix | Delete
* Get reusable WooCommerce field definition
[155] Fix | Delete
*
[156] Fix | Delete
* @since 3.29
[157] Fix | Delete
*
[158] Fix | Delete
* @param string $name Field template name.
[159] Fix | Delete
* @param array $attrs Attribute that need to be inserted into field definition.
[160] Fix | Delete
* @param array $unset Attribute that need to be removed from field definition.
[161] Fix | Delete
*
[162] Fix | Delete
* @return array
[163] Fix | Delete
*/
[164] Fix | Delete
public static function get_field( $name, $attrs = array(), $unset = array() ) {
[165] Fix | Delete
switch ( $name ) {
[166] Fix | Delete
case 'product':
[167] Fix | Delete
$field = array(
[168] Fix | Delete
'label' => esc_html__( 'Product', 'et_builder' ),
[169] Fix | Delete
'type' => 'select_product',
[170] Fix | Delete
'option_category' => 'basic_option',
[171] Fix | Delete
'description' => esc_html__( 'Here you can select the Product.', 'et_builder' ),
[172] Fix | Delete
'toggle_slug' => 'main_content',
[173] Fix | Delete
'searchable' => true,
[174] Fix | Delete
'displayRecent' => false,
[175] Fix | Delete
'default' => 'current',
[176] Fix | Delete
'post_type' => 'product',
[177] Fix | Delete
'computed_affects' => array(
[178] Fix | Delete
'__product',
[179] Fix | Delete
),
[180] Fix | Delete
);
[181] Fix | Delete
break;
[182] Fix | Delete
case 'product_filter':
[183] Fix | Delete
$field = array(
[184] Fix | Delete
'label' => esc_html__( 'Filter By', 'et_builder' ),
[185] Fix | Delete
'type' => 'select',
[186] Fix | Delete
'option_category' => 'configuration',
[187] Fix | Delete
'options' => array(
[188] Fix | Delete
'newest' => esc_html__( 'Newest', 'et_builder' ),
[189] Fix | Delete
),
[190] Fix | Delete
'toggle_slug' => 'main_content',
[191] Fix | Delete
'description' => esc_html__( 'Here you can filter the Products.', 'et_builder' ),
[192] Fix | Delete
'default' => 'newest',
[193] Fix | Delete
'show_if' => array(
[194] Fix | Delete
'product' => '-1',
[195] Fix | Delete
),
[196] Fix | Delete
'computed_affects' => array(
[197] Fix | Delete
'__product',
[198] Fix | Delete
),
[199] Fix | Delete
);
[200] Fix | Delete
break;
[201] Fix | Delete
case 'posts_number':
[202] Fix | Delete
$field = array(
[203] Fix | Delete
'default' => '12',
[204] Fix | Delete
'label' => esc_html__( 'Product Count', 'et_builder' ),
[205] Fix | Delete
'type' => 'text',
[206] Fix | Delete
'option_category' => 'configuration',
[207] Fix | Delete
'description' => esc_html__( 'Define the number of products that should be displayed per page.', 'et_builder' ),
[208] Fix | Delete
'computed_affects' => array(
[209] Fix | Delete
'__product',
[210] Fix | Delete
),
[211] Fix | Delete
'toggle_slug' => 'main_content',
[212] Fix | Delete
);
[213] Fix | Delete
break;
[214] Fix | Delete
case 'columns_number':
[215] Fix | Delete
$field = array(
[216] Fix | Delete
'label' => esc_html__( 'Column Layout', 'et_builder' ),
[217] Fix | Delete
'type' => 'select',
[218] Fix | Delete
'option_category' => 'layout',
[219] Fix | Delete
'options' => array(
[220] Fix | Delete
'6' => sprintf( esc_html__( '%1$s Columns', 'et_builder' ), esc_html( '6' ) ),
[221] Fix | Delete
'5' => sprintf( esc_html__( '%1$s Columns', 'et_builder' ), esc_html( '5' ) ),
[222] Fix | Delete
'4' => sprintf( esc_html__( '%1$s Columns', 'et_builder' ), esc_html( '4' ) ),
[223] Fix | Delete
'3' => sprintf( esc_html__( '%1$s Columns', 'et_builder' ), esc_html( '3' ) ),
[224] Fix | Delete
'2' => sprintf( esc_html__( '%1$s Columns', 'et_builder' ), esc_html( '2' ) ),
[225] Fix | Delete
'1' => esc_html__( '1 Column', 'et_builder' ),
[226] Fix | Delete
),
[227] Fix | Delete
'default' => '0',
[228] Fix | Delete
'description' => esc_html__( 'Choose how many columns to display.', 'et_builder' ),
[229] Fix | Delete
'computed_affects' => array(
[230] Fix | Delete
'__product',
[231] Fix | Delete
),
[232] Fix | Delete
'toggle_slug' => 'main_content',
[233] Fix | Delete
);
[234] Fix | Delete
break;
[235] Fix | Delete
case 'orderby':
[236] Fix | Delete
$field = array(
[237] Fix | Delete
'label' => esc_html__( 'Order', 'et_builder' ),
[238] Fix | Delete
'type' => 'select',
[239] Fix | Delete
'option_category' => 'configuration',
[240] Fix | Delete
'options' => array(
[241] Fix | Delete
'default' => esc_html__( 'Default Sorting', 'et_builder' ),
[242] Fix | Delete
'menu_order' => esc_html__( 'Sort by Menu Order', 'et_builder' ),
[243] Fix | Delete
'popularity' => esc_html__( 'Sort By Popularity', 'et_builder' ),
[244] Fix | Delete
'date' => esc_html__( 'Sort By Date: Oldest To Newest', 'et_builder' ),
[245] Fix | Delete
'date-desc' => esc_html__( 'Sort By Date: Newest To Oldest', 'et_builder' ),
[246] Fix | Delete
'price' => esc_html__( 'Sort By Price: Low To High', 'et_builder' ),
[247] Fix | Delete
'price-desc' => esc_html__( 'Sort By Price: High To Low', 'et_builder' ),
[248] Fix | Delete
),
[249] Fix | Delete
'default_on_front' => 'default',
[250] Fix | Delete
'description' => esc_html__( 'Choose how your products should be ordered.', 'et_builder' ),
[251] Fix | Delete
'computed_affects' => array(
[252] Fix | Delete
'__shop',
[253] Fix | Delete
),
[254] Fix | Delete
'toggle_slug' => 'main_content',
[255] Fix | Delete
);
[256] Fix | Delete
break;
[257] Fix | Delete
default:
[258] Fix | Delete
$field = array();
[259] Fix | Delete
break;
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
// Added custom attribute(s).
[263] Fix | Delete
if ( ! empty( $attrs ) ) {
[264] Fix | Delete
$field = wp_parse_args( $attrs, $field );
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
// Remove default attribute(s).
[268] Fix | Delete
if ( ! empty( $unset ) ) {
[269] Fix | Delete
foreach ( $unset as $unset_attr ) {
[270] Fix | Delete
unset( $field[ $unset_attr ] );
[271] Fix | Delete
}
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
return $field;
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
/**
[278] Fix | Delete
* Gets the Reviews title.
[279] Fix | Delete
*
[280] Fix | Delete
* @since 3.29
[281] Fix | Delete
*
[282] Fix | Delete
* @param WC_Product $product The Product Post.
[283] Fix | Delete
*
[284] Fix | Delete
* @return string
[285] Fix | Delete
*/
[286] Fix | Delete
public static function get_reviews_title( $product ) {
[287] Fix | Delete
$reviews_title = '';
[288] Fix | Delete
[289] Fix | Delete
if ( ! ( $product instanceof WC_Product ) ) {
[290] Fix | Delete
return $reviews_title;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
$count = $product->get_review_count();
[294] Fix | Delete
if ( $count ) {
[295] Fix | Delete
$reviews_title = sprintf(
[296] Fix | Delete
esc_html( _n( '%1$s review for %2$s', '%1$s reviews for %2$s', $count, 'et_builder' ) ),
[297] Fix | Delete
esc_html( $count ),
[298] Fix | Delete
'<span>' . $product->get_title() . '</span>'
[299] Fix | Delete
);
[300] Fix | Delete
} else {
[301] Fix | Delete
$reviews_title = esc_html__( 'Reviews', 'et_builder' );
[302] Fix | Delete
}
[303] Fix | Delete
[304] Fix | Delete
return $reviews_title;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
/**
[308] Fix | Delete
* Gets the Reviews comment form.
[309] Fix | Delete
*
[310] Fix | Delete
* @since 3.29
[311] Fix | Delete
*
[312] Fix | Delete
* @param WC_Product $product The Product Post.
[313] Fix | Delete
* @param WP_Comment[] $comments Array of Comment objects.
[314] Fix | Delete
*
[315] Fix | Delete
* @return string
[316] Fix | Delete
*/
[317] Fix | Delete
public static function get_reviews_comment_form( $product, $comments ) {
[318] Fix | Delete
$has_reviews = empty( $comments ) ? false : true;
[319] Fix | Delete
ob_start();
[320] Fix | Delete
?>
[321] Fix | Delete
<?php if ( get_option( 'woocommerce_review_rating_verification_required' ) === 'no' ||
[322] Fix | Delete
wc_customer_bought_product( '', get_current_user_id(), $product->get_id() ) ) : ?>
[323] Fix | Delete
[324] Fix | Delete
<div id="review_form_wrapper">
[325] Fix | Delete
<div id="review_form">
[326] Fix | Delete
<?php
[327] Fix | Delete
$commenter = wp_get_current_commenter();
[328] Fix | Delete
[329] Fix | Delete
$comment_form = array(
[330] Fix | Delete
'title_reply' => $has_reviews ? esc_html__( 'Add a review', 'et_builder' ) : sprintf( esc_html__( 'Be the first to review &ldquo;%s&rdquo;', 'woocommerce' ), get_the_title( $product->get_id() ) ),
[331] Fix | Delete
'title_reply_to' => esc_html__( 'Leave a Reply to %s', 'et_builder' ),
[332] Fix | Delete
'title_reply_before' => '<span id="reply-title" class="comment-reply-title">',
[333] Fix | Delete
'title_reply_after' => '</span>',
[334] Fix | Delete
'comment_notes_after' => '',
[335] Fix | Delete
'fields' => array(
[336] Fix | Delete
'author' => '<p class="comment-form-author">' . '<label for="author">' . esc_html__( 'Name', 'woocommerce' ) . '&nbsp;<span class="required">*</span></label> ' .
[337] Fix | Delete
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" required /></p>',
[338] Fix | Delete
'email' => '<p class="comment-form-email"><label for="email">' . esc_html__( 'Email', 'woocommerce' ) . '&nbsp;<span class="required">*</span></label> ' .
[339] Fix | Delete
'<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" required /></p>',
[340] Fix | Delete
),
[341] Fix | Delete
'label_submit' => esc_html__( 'Submit', 'et_builder' ),
[342] Fix | Delete
'submit_button' => '<button name="%1$s" type="submit" id="%2$s" class="et_pb_button %3$s" />%4$s</button>',
[343] Fix | Delete
'logged_in_as' => '',
[344] Fix | Delete
'comment_field' => '',
[345] Fix | Delete
);
[346] Fix | Delete
[347] Fix | Delete
if ( $account_page_url = wc_get_page_permalink( 'myaccount' ) ) {
[348] Fix | Delete
/* translators: %s opening and closing link tags respectively */
[349] Fix | Delete
$comment_form['must_log_in'] = '<p class="must-log-in">' . sprintf( esc_html__( 'You must be %1$slogged in%2$s to post a review.', 'woocommerce' ), '<a href="' . esc_url( $account_page_url ) . '">', '</a>' ) . '</p>';
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
[353] Fix | Delete
$comment_form['comment_field'] = '<div class="comment-form-rating"><label for="rating">' . esc_html__( 'Your rating', 'et_builder' ) . '</label><select name="rating" id="rating" required>
[354] Fix | Delete
<option value="">' . esc_html__( 'Rate&hellip;', 'et_builder' ) . '</option>
[355] Fix | Delete
<option value="5">' . esc_html__( 'Perfect', 'et_builder' ) . '</option>
[356] Fix | Delete
<option value="4">' . esc_html__( 'Good', 'et_builder' ) . '</option>
[357] Fix | Delete
<option value="3">' . esc_html__( 'Average', 'et_builder' ) . '</option>
[358] Fix | Delete
<option value="2">' . esc_html__( 'Not that bad', 'et_builder' ) . '</option>
[359] Fix | Delete
<option value="1">' . esc_html__( 'Very poor', 'et_builder' ) . '</option>
[360] Fix | Delete
</select></div>';
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
$comment_form['comment_field'] .= '<p class="comment-form-comment"><label for="comment">' . esc_html__( 'Your review', 'et_builder' ) . '&nbsp;<span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" required></textarea></p>';
[364] Fix | Delete
[365] Fix | Delete
comment_form(
[366] Fix | Delete
apply_filters( 'woocommerce_product_review_comment_form_args', $comment_form ),
[367] Fix | Delete
$product->get_id()
[368] Fix | Delete
);
[369] Fix | Delete
?>
[370] Fix | Delete
</div>
[371] Fix | Delete
</div>
[372] Fix | Delete
[373] Fix | Delete
<?php else : ?>
[374] Fix | Delete
[375] Fix | Delete
<p class="woocommerce-verification-required"><?php esc_html_e( 'Only logged in customers who have purchased this product may leave a review.', 'woocommerce' ); ?></p>
[376] Fix | Delete
[377] Fix | Delete
<?php endif; ?>
[378] Fix | Delete
<?php
[379] Fix | Delete
return ob_get_clean();
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
/**
[383] Fix | Delete
* Gets the formatted weight markup for the given Product Id.
[384] Fix | Delete
*
[385] Fix | Delete
* @param int $product_id Product Id.
[386] Fix | Delete
*
[387] Fix | Delete
* @return string
[388] Fix | Delete
*/
[389] Fix | Delete
public static function get_weight_formatted( $product_id ) {
[390] Fix | Delete
$product = self::get_product( $product_id );
[391] Fix | Delete
$markup = '';
[392] Fix | Delete
[393] Fix | Delete
if ( ! $product ) {
[394] Fix | Delete
return $markup;
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
return ( $product->has_weight() ) ? wc_format_weight( $product->get_weight() ) : $markup;
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
/**
[401] Fix | Delete
* Gets the formatted dimension markup for the given Product Id.
[402] Fix | Delete
*
[403] Fix | Delete
* @param int $product_id Product Id.
[404] Fix | Delete
*
[405] Fix | Delete
* @return string
[406] Fix | Delete
*/
[407] Fix | Delete
public static function get_dimensions_formatted( $product_id ) {
[408] Fix | Delete
$product = self::get_product( $product_id );
[409] Fix | Delete
$markup = '';
[410] Fix | Delete
[411] Fix | Delete
if ( ! $product ) {
[412] Fix | Delete
return $markup;
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
return ( $product->has_dimensions() ) ? wc_format_dimensions( $product->get_dimensions( false ) ) : $markup;
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
/**
[419] Fix | Delete
* Filters the $outer_wrapper_attrs.
[420] Fix | Delete
* Adds 'data-background-layout' and 'data-background-layout-hover' attributes if needed.
[421] Fix | Delete
*
[422] Fix | Delete
* @since 3.29
[423] Fix | Delete
*
[424] Fix | Delete
* @param array $outer_wrapper_attrs Key value pairs of outer wrapper attributes.
[425] Fix | Delete
* @param ET_Builder_Element $this_class Module's class.
[426] Fix | Delete
*
[427] Fix | Delete
* @return array filtered $outer_wrapper_attrs.
[428] Fix | Delete
*/
[429] Fix | Delete
public static function maybe_add_background_layout_data( $outer_wrapper_attrs, $this_class ) {
[430] Fix | Delete
$background_layout = et_()->array_get( $this_class->props, 'background_layout', '' );
[431] Fix | Delete
$background_layout_hover = et_pb_hover_options()->get_value( 'background_layout', $this_class->props, 'light' );
[432] Fix | Delete
$background_layout_hover_enabled = et_pb_hover_options()->is_enabled( 'background_layout', $this_class->props );
[433] Fix | Delete
[434] Fix | Delete
if ( $background_layout_hover_enabled ) {
[435] Fix | Delete
$outer_wrapper_attrs['data-background-layout'] = esc_attr( $background_layout );
[436] Fix | Delete
$outer_wrapper_attrs['data-background-layout-hover'] = esc_attr( $background_layout_hover );
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
return $outer_wrapper_attrs;
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
/**
[443] Fix | Delete
* Processes the Background Layout options for Woocommerce Modules.
[444] Fix | Delete
* Adds Background Layout related classes.
[445] Fix | Delete
* Adds Filter for $outer_wrapper_attrs, so required data attributes can be added for specific modules.
[446] Fix | Delete
*
[447] Fix | Delete
* @since 3.29
[448] Fix | Delete
*
[449] Fix | Delete
* @param string $render_slug Module's render slug.
[450] Fix | Delete
* @param ET_Builder_Element $this_class Module's class.
[451] Fix | Delete
*
[452] Fix | Delete
* @return void.
[453] Fix | Delete
*/
[454] Fix | Delete
public static function process_background_layout_data( $render_slug, $this_class ) {
[455] Fix | Delete
$background_layout = et_()->array_get( $this_class->props, 'background_layout', '' );
[456] Fix | Delete
$background_layout_values = et_pb_responsive_options()->get_property_values( $this_class->props, 'background_layout' );
[457] Fix | Delete
$background_layout_tablet = et_()->array_get( $background_layout_values, 'tablet', '' );
[458] Fix | Delete
$background_layout_phone = et_()->array_get( $background_layout_values, 'phone', '' );
[459] Fix | Delete
[460] Fix | Delete
$this_class->add_classname( "et_pb_bg_layout_{$background_layout}" );
[461] Fix | Delete
[462] Fix | Delete
if ( ! empty( $background_layout_tablet ) ) {
[463] Fix | Delete
$this_class->add_classname( "et_pb_bg_layout_{$background_layout_tablet}_tablet" );
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
if ( ! empty( $background_layout_phone ) ) {
[467] Fix | Delete
$this_class->add_classname( "et_pb_bg_layout_{$background_layout_phone}_phone" );
[468] Fix | Delete
}
[469] Fix | Delete
[470] Fix | Delete
add_filter( "et_builder_module_{$render_slug}_outer_wrapper_attrs", array( 'ET_Builder_Module_Helper_Woocommerce_Modules', 'maybe_add_background_layout_data' ), 10, 2 );
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
/**
[474] Fix | Delete
* Processes the Button Icon options for Woocommerce Modules.
[475] Fix | Delete
* Adds et_pb_woo_custom_button_icon class if needed.
[476] Fix | Delete
* Adds Filter for $outer_wrapper_attrs, so required button icon attributes can be added for specific modules.
[477] Fix | Delete
*
[478] Fix | Delete
* @since 3.29
[479] Fix | Delete
*
[480] Fix | Delete
* @param string $render_slug Module's render slug.
[481] Fix | Delete
* @param ET_Builder_Element $this_class Module's class.
[482] Fix | Delete
*
[483] Fix | Delete
* @return void.
[484] Fix | Delete
*/
[485] Fix | Delete
public static function process_custom_button_icons( $render_slug, $this_class ) {
[486] Fix | Delete
$button_custom = $this_class->props['custom_button'];
[487] Fix | Delete
$custom_icon_values = et_()->array_get( $this_class->props, 'button_icon', '' );
[488] Fix | Delete
[489] Fix | Delete
// Exit if no custom styles or icons defined for button.
[490] Fix | Delete
if ( 'on' !== $button_custom || '' === $custom_icon_values ) {
[491] Fix | Delete
return;
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
$this_class->add_classname( 'et_pb_woo_custom_button_icon' );
[495] Fix | Delete
add_filter( "et_builder_module_{$render_slug}_outer_wrapper_attrs", array( 'ET_Builder_Module_Helper_Woocommerce_Modules', 'add_custom_button_icons' ), 10, 2 );
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
/**
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function