PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Elementor/Helper/RenderHelpers.php +105 -16 3.2.53.2.6 View file →
@@ -278,8 +278,16 @@
278 278 $data['queried_term'] = esc_html( $queried_obj->term_id );
279 279 }
280 280 }
281 281
282 + if ( is_search() ) {
283 + $search_query = get_search_query();
284 +
285 + if ( $search_query ) {
286 + $data['search_query'] = sanitize_text_field( $search_query );
287 + }
288 + }
289 +
282 290 return apply_filters( 'rtsb/elementor/render/meta_dataset_final', $data, $meta, $raw_settings );
283 291 }
284 292
285 293 /**
@@ -331,8 +339,16 @@
331 339 $data['queried_term'] = esc_html( $queried_obj->term_id );
332 340 }
333 341 }
334 342
343 + if ( is_search() ) {
344 + $search_query = get_search_query();
345 +
346 + if ( $search_query ) {
347 + $data['search_query'] = sanitize_text_field( $search_query );
348 + }
349 + }
350 +
335 351 return apply_filters( 'rtsb/elementor/render/archive_meta_dataset_final', $data, $meta );
336 352 }
337 353
338 354 /**
@@ -1373,12 +1389,20 @@
1373 1389 * @return string The generated HTML for the product filter list.
1374 1390 */
1375 1391 public static function get_product_default_filter_list_html( $data, $input = 'checkbox', $additional_data = [], $parent = 0 ) {
1376 1392
1377 - $html = '';
1378 - $default_tax = [];
1379 - $is_attribute = ! empty( $data['is_attribute'] );
1380 - $active_option = isset( $_GET[ $additional_data['taxonomy'] ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $additional_data['taxonomy'] ] ) ) ) : []; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1393 + $html = '';
1394 + $default_tax = [];
1395 + $is_attribute = ! empty( $data['is_attribute'] );
1396 +
1397 + $param_key = isset( $additional_data['taxonomy'] ) ? $additional_data['taxonomy'] : '';
1398 + if ( $param_key && 0 === strpos( $param_key, 'pa_' ) ) {
1399 + $param_key = 'filter_' . substr( $param_key, 3 );
1400 + }
1401 +
1402 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1403 + $raw_values = ( $param_key && isset( $_GET[ $param_key ] ) ) ? wc_clean( wp_unslash( $_GET[ $param_key ] ) ) : '';
1404 + $active_option = $raw_values ? array_map( 'urldecode', explode( ',', $raw_values ) ) : [];
1381 1405 $counter = 0;
1382 1406
1383 1407 if ( $is_attribute ) {
1384 1408 list(
@@ -1394,11 +1418,10 @@
1394 1418 continue;
1395 1419 }
1396 1420
1397 1421 if ( $is_attribute ) {
1398 - $tax_link = remove_query_arg( $filter_name, $base_link );
1399 - $tax_link = add_query_arg( $filter_name, $tax->slug, $tax_link );
1400 - $active_option = isset( $_GET[ $filter_name ] ) ? explode( ',', sanitize_text_field( wp_unslash( $_GET[ $filter_name ] ) ) ) : []; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1422 + $tax_link = remove_query_arg( $filter_name, $base_link );
1423 + $tax_link = add_query_arg( $filter_name, $tax->slug, $tax_link );
1401 1424 } else {
1402 1425 $tax_link = get_term_link( $tax );
1403 1426 }
1404 1427
@@ -1403,17 +1426,19 @@
1403 1426 }
1404 1427
1405 1428 $unique_id = substr( uniqid(), -4 );
1406 1429
1407 - $active_tax = in_array( $tax->slug, $active_option, true ) ? ' checked' : '';
1408 - $active_tax_parent = in_array( $tax->slug, $active_option, true ) ? ' active' : '';
1430 + $decoded_slug = urldecode( $tax->slug );
1431 + $is_active = in_array( $decoded_slug, $active_option, true ) || in_array( $tax->slug, $active_option, true );
1432 + $active_tax = $is_active ? ' checked' : '';
1433 + $active_tax_parent = $is_active ? ' active' : '';
1409 1434 $term_children = in_array( $tax->taxonomy, [ 'product_cat', 'product_brand' ], true ) ? get_term_children( $tax->term_id, $tax->taxonomy ) : [];
1410 1435 $taxonomy = $tax->taxonomy;
1411 - $product_count = $tax->count;
1436 + $product_count = self::get_visible_term_count( $tax->taxonomy, $tax->term_id );
1412 1437
1413 1438 // Show count.
1414 1439 if ( 'archive' === apply_filters( 'rtsb/builder/set/current/page/type', '' ) && ! empty( $data['count_display'] ) && 'block' === $data['count_display'] ) {
1415 - $product_count = self::count_tax_data( $tax, $tax->count );
1440 + $product_count = self::count_tax_data( $tax, $product_count );
1416 1441 }
1417 1442
1418 1443 // Show Empty Categories.
1419 1444 if ( empty( $data['show_empty_terms'] ) && 0 === $product_count ) {
@@ -1529,8 +1554,14 @@
1529 1554 'field' => 'term_id',
1530 1555 'terms' => $tax->term_id,
1531 1556 'operator' => 'IN',
1532 1557 ],
1558 + [
1559 + 'taxonomy' => 'product_visibility',
1560 + 'terms' => [ 'exclude-from-catalog' ],
1561 + 'field' => 'name',
1562 + 'operator' => 'NOT IN',
1563 + ],
1533 1564 ];
1534 1565
1535 1566 $query = new WC_Product_Query( $args );
1536 1567 $products = $query->get_products();
@@ -1543,13 +1574,20 @@
1543 1574 'limit' => -1,
1544 1575 'return' => 'ids',
1545 1576 'status' => 'publish',
1546 1577 'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
1578 + 'relation' => 'AND',
1547 1579 [
1548 1580 'taxonomy' => $taxonomy,
1549 1581 'field' => 'term_id',
1550 1582 'terms' => $term_id,
1551 1583 ],
1584 + [
1585 + 'taxonomy' => 'product_visibility',
1586 + 'terms' => [ 'exclude-from-catalog' ],
1587 + 'field' => 'name',
1588 + 'operator' => 'NOT IN',
1589 + ],
1552 1590 ],
1553 1591 ];
1554 1592
1555 1593 if ( 'product_cat' === $page->taxonomy ) {
@@ -1567,9 +1605,58 @@
1567 1605 }
1568 1606
1569 1607 return $count;
1570 1608 }
1609 +
1571 1610 /**
1611 + * Get the count of visible (non-hidden) products for a given taxonomy term.
1612 + *
1613 + * Excludes products with WooCommerce visibility set to 'Hidden'
1614 + * (products assigned the 'exclude-from-catalog' term).
1615 + *
1616 + * @param string $taxonomy The taxonomy name.
1617 + * @param int $term_id The term ID.
1618 + *
1619 + * @return int Visible product count.
1620 + */
1621 + public static function get_visible_term_count( $taxonomy, $term_id ) {
1622 + static $cache = [];
1623 +
1624 + $cache_key = $taxonomy . '_' . $term_id;
1625 +
1626 + if ( isset( $cache[ $cache_key ] ) ) {
1627 + return $cache[ $cache_key ];
1628 + }
1629 +
1630 + $args = [
1631 + 'limit' => -1,
1632 + 'return' => 'ids',
1633 + 'status' => 'publish',
1634 + 'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
1635 + 'relation' => 'AND',
1636 + [
1637 + 'taxonomy' => $taxonomy,
1638 + 'field' => 'term_id',
1639 + 'terms' => $term_id,
1640 + ],
1641 + [
1642 + 'taxonomy' => 'product_visibility',
1643 + 'terms' => [ 'exclude-from-catalog' ],
1644 + 'field' => 'name',
1645 + 'operator' => 'NOT IN',
1646 + ],
1647 + ],
1648 + ];
1649 +
1650 + $query = new WC_Product_Query( $args );
1651 + $count = count( $query->get_products() );
1652 +
1653 + $cache[ $cache_key ] = $count;
1654 +
1655 + return $count;
1656 + }
1657 +
1658 + /**
1572 1659 * Get filter HTML.
1573 1660 *
1574 1661 * @param string $filter_type Filter type.
1575 1662 * @param array $options Options.
@@ -1652,16 +1739,18 @@
1652 1739
1653 1740 $html = '<ul class="product-default-filters rtsb-terms-wrapper ' . esc_attr( $term_info['type'] ) . '-variable-wrapper' . esc_attr( $data['show_label'] ) . '">';
1654 1741
1655 1742 foreach ( $terms as $attr_term ) {
1656 - $count = $attr_term->count;
1743 + $count = self::get_visible_term_count( $attr_term->taxonomy, $attr_term->term_id );
1657 1744 $term_link = remove_query_arg( $term_info['filter_name'], $term_info['base_link'] );
1658 1745 $term_link = add_query_arg( $term_info['filter_name'], $attr_term->slug, $term_link );
1659 1746 $unique_id = substr( uniqid(), -6 );
1660 1747 $name = 'term-' . wc_variation_attribute_name( $term_info['attribute'] ) . '-' . $unique_id;
1661 - $selected_class = in_array( $attr_term->slug, $term_info['current_filter'], true ) ? ' selected' : '';
1662 - $selected_item = in_array( $attr_term->slug, $term_info['current_filter'], true ) ? ' checked' : '';
1663 - $active_class = in_array( $attr_term->slug, $term_info['current_filter'], true ) ? ' active' : '';
1748 + $decoded_slug = urldecode( $attr_term->slug );
1749 + $is_selected = in_array( $decoded_slug, $term_info['current_filter'], true ) || in_array( $attr_term->slug, $term_info['current_filter'], true );
1750 + $selected_class = $is_selected ? ' selected' : '';
1751 + $selected_item = $is_selected ? ' checked' : '';
1752 + $active_class = $is_selected ? ' active' : '';
1664 1753
1665 1754 $args = [
1666 1755 'id' => $name,
1667 1756 'name' => $attr_term->name,
@@ -1675,9 +1764,9 @@
1675 1764 'selected_item' => $selected_item,
1676 1765 ];
1677 1766
1678 1767 if ( 'archive' === apply_filters( 'rtsb/builder/set/current/page/type', '' ) && ! empty( $data['count_display'] ) && 'block' === $data['count_display'] ) {
1679 - $count = self::count_tax_data( $args, $attr_term->count );
1768 + $count = self::count_tax_data( $args, $count );
1680 1769 }
1681 1770
1682 1771 $args['count'] = $count;
1683 1772