# shopbuilder/2.0.0/app/Elementor/Helper/RenderHelpers.php

ShopBuilder – WooCommerce Builder For Elementor, version 2.0.0. 672 lines.

- Page: https://pluginprobe.com/plugins/shopbuilder/2.0.0/code/app/Elementor/Helper/RenderHelpers.php
- Raw: https://pluginprobe.com/plugins/shopbuilder/2.0.0/raw/app/Elementor/Helper/RenderHelpers.php
- Modified: 2023-11-03T12:09:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shopbuilder/2.0.0/code/app/Elementor/Helper/RenderHelpers.php#L10-L20`.

```php
<?php
/**
 * Elementor Render Helper Class.
 *
 * This class contains render helper logics.
 *
 * @package RadiusTheme\SB
 */

namespace RadiusTheme\SB\Elementor\Helper;

use RadiusTheme\SB\Helpers\BuilderFns;
use RadiusTheme\SB\Helpers\Fns;

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
	exit( 'This script cannot be accessed directly.' );
}

/**
 * BuilderFns class
 */
class RenderHelpers {



	/**
	 * Builds an array with field values.
	 *
	 * @param array  $meta Field values.
	 * @param string $template Template name.
	 * @param array  $raw_settings Raw settings.
	 *
	 * @return array
	 */
	public static function meta_dataset( array $meta, $template = '', $raw_settings = [] ) {
		$c_image_size         = ! empty( $meta['image_custom_dimension'] ) ? $meta['image_custom_dimension'] : [];
		$c_image_size['crop'] = ! empty( $meta['image_crop'] ) ? $meta['image_crop'] : '';

		if ( ( ! empty( $_GET['displayview'] ) && 'list' === $_GET['displayview'] ) || ( empty( $_GET['displayview'] ) && ( ! empty( $meta['view_mode'] ) && 'list' === $meta['view_mode'] ) ) ) {
			$meta['cols']        = ! empty( $meta['list_cols'] ) ? $meta['list_cols'] : 1;
			$meta['cols_tablet'] = ! empty( $meta['list_cols_tablet'] ) ? $meta['list_cols_tablet'] : $meta['cols'];
			$meta['cols_mobile'] = ! empty( $meta['list_cols_mobile'] ) ? $meta['list_cols_mobile'] : $meta['cols'];
		}

		$data = apply_filters(
			'rtsb/elementor/render/meta_dataset',
			[
				// Layout.
				'widget'                   => 'custom',
				'template'                 => ! empty( $template ) ? $template : '',
				'raw_settings'             => ! empty( $raw_settings ) ? $raw_settings : [],
				'layout'                   => ! empty( $meta['layout'] ) ? $meta['layout'] : 'layout1',
				'd_cols'                   => ! empty( $meta['cols'] ) ? $meta['cols'] : 0,
				't_cols'                   => ! empty( $meta['cols_tablet'] ) ? $meta['cols_tablet'] : 2,
				'm_cols'                   => ! empty( $meta['cols_mobile'] ) ? $meta['cols_mobile'] : 1,
				'grid_type'                => ! empty( $meta['grid_style'] ) ? $meta['grid_style'] : 'even',

				// Query.
				'post_in'                  => ! empty( $meta['include_posts'] ) && is_array( $meta['include_posts'] ) ? $meta['include_posts'] : [],
				'post_not_in'              => ! empty( $meta['exclude_posts'] ) && is_array( $meta['exclude_posts'] ) ? $meta['exclude_posts'] : [],
				'limit'                    => ( empty( $meta['posts_limit'] ) || '-1' === $meta['posts_limit'] ) ? 10000000 : $meta['posts_limit'],
				'offset'                   => ! empty( $meta['posts_offset'] ) ? $meta['posts_offset'] : 0,
				'order_by'                 => ! empty( $meta['posts_order_by'] ) ? $meta['posts_order_by'] : 'date',
				'order'                    => ! empty( $meta['posts_order'] ) ? $meta['posts_order'] : 'DESC',
				'author_in'                => ! empty( $meta['filter_author'] ) && is_array( $meta['filter_author'] ) ? $meta['filter_author'] : [],
				'display_by'               => ! empty( $meta['products_filter'] ) ? $meta['products_filter'] : 'date',
				'categories'               => ! empty( $meta['filter_categories'] ) && is_array( $meta['filter_categories'] ) ? $meta['filter_categories'] : [],
				'tags'                     => ! empty( $meta['filter_tags'] ) && is_array( $meta['filter_tags'] ) ? $meta['filter_tags'] : [],
				'attributes'               => ! empty( $meta['filter_attributes'] ) && is_array( $meta['filter_attributes'] ) ? $meta['filter_attributes'] : [],
				'relation'                 => ! empty( $meta['tax_relation'] ) ? $meta['tax_relation'] : 'OR',
				'category_source'          => ! empty( $meta['select_source'] ) ? $meta['select_source'] : 'product_cat',
				'category_term'            => ! empty( $meta['select_cat'] ) ? $meta['select_cat'] : null,
				'display_cat_by'           => ! empty( $meta['display_cat_by'] ) ? $meta['display_cat_by'] : null,
				'include_cats'             => ! empty( $meta['include_cats'] ) && is_array( $meta['include_cats'] ) ? $meta['include_cats'] : [],
				'exclude_cats'             => ! empty( $meta['exclude_cats'] ) && is_array( $meta['exclude_cats'] ) ? $meta['exclude_cats'] : [],
				'select_parent_cat'        => ! empty( $meta['select_parent_cat'] ) ? $meta['select_parent_cat'] : null,
				'select_cats'              => ! empty( $meta['select_cats'] ) && is_array( $meta['select_cats'] ) ? $meta['select_cats'] : [],
				'select_cat_ids'           => ! empty( $meta['include_cat_ids'] ) ? $meta['include_cat_ids'] : '',
				'cats_limit'               => ( empty( $meta['cats_limit'] ) || '-1' === $meta['cats_limit'] ) ? 10000000 : $meta['cats_limit'],
				'show_empty'               => ! empty( $meta['show_empty'] ),
				'show_uncategorized'       => ! empty( $meta['show_uncategorized'] ),
				'show_subcats'             => ! empty( $meta['show_subcats'] ),
				'show_top_level_cats'      => ! empty( $meta['show_top_level_cats'] ),
				'cats_order_by'            => ! empty( $meta['cats_order_by'] ) ? $meta['cats_order_by'] : 'name',
				'cats_order'               => ! empty( $meta['cats_order'] ) ? $meta['cats_order'] : 'DESC',
				'rtsb_order'               => ! empty( $meta['rtsb_order'] ) ? $meta['rtsb_order'] : 'ASC',
				'rtsb_orderby'             => ! empty( $meta['rtsb_orderby'] ) ? $meta['rtsb_orderby'] : 'menu_order',

				// Pagination.
				'pagination'               => ! empty( $meta['show_pagination'] ),
				'posts_loading_type'       => ! empty( $meta['pagination_type'] ) ? $meta['pagination_type'] : 'pagination',
				'posts_per_page'           => ! empty( $meta['pagination_per_page'] ) ? $meta['pagination_per_page'] : '',

				// Image.
				'f_img'                    => ! empty( $meta['show_featured_image'] ),
				'gallery_img'              => ! empty( $meta['show_product_gallery'] ),
				'c_img'                    => ! empty( $meta['show_cat_image'] ),
				'hover_img'                => ! empty( $meta['show_hover_image'] ),
				'f_img_size'               => ! empty( $meta['image'] ) ? $meta['image'] : 'medium',
				'custom_img_size'          => ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [],
				'default_img_id'           => ! empty( $meta['default_preview_image']['id'] ) ? $meta['default_preview_image']['id'] : null,
				'show_overlay'             => ! empty( $meta['show_overlay'] ),
				'hover_animation'          => ! empty( $meta['image_hover_animation'] ) ? $meta['image_hover_animation'] : 'none',
				'show_custom_image'        => ! empty( $meta['show_custom_image'] ),
				'custom_image'             => ! empty( $meta['custom_image']['id'] ) ? $meta['custom_image']['id'] : null,

				// Visibility.
				'visibility'               => ! empty( self::content_visibility( $meta ) ) ? self::content_visibility( $meta ) : [],

				// Action Buttons.
				'btn_preset'               => ! empty( $meta['action_btn_preset'] ) ? $meta['action_btn_preset'] : 'preset1',
				'btn_position'             => ! empty( $meta['action_btn_position'] ) ? $meta['action_btn_position'] : 'above',
				'tooltip_position'         => ! empty( $meta['action_btn_tooltip_position'] ) ? $meta['action_btn_tooltip_position'] : 'top',

				// Product Title.
				'title_tag'                => ! empty( $meta['title_tag'] ) ? $meta['title_tag'] : 'h3',
				'title_hover'              => ! empty( $meta['title_hover'] ),
				'title_limit'              => ! empty( $meta['title_limit'] ) ? $meta['title_limit'] : 'default',
				'title_limit_custom'       => ! empty( $meta['title_limit_custom'] ) ? $meta['title_limit_custom'] : null,
				'show_custom_title'        => ! empty( $meta['show_custom_title'] ),
				'cat_custom_title'         => ! empty( $meta['custom_title'] ) ? $meta['custom_title'] : '',

				// Variation Swatches.
				'swatch_position'          => ! empty( $meta['swatch_position'] ) ? $meta['swatch_position'] : 'top',
				'swatch_type'              => ! empty( $meta['swatch_type'] ) ? $meta['swatch_type'] : 'circle',

				// Short Description.
				'show_custom_excerpt'      => ! empty( $meta['show_custom_description'] ),
				'cat_custom_excerpt'       => ! empty( $meta['custom_description'] ) ? $meta['custom_description'] : '',
				'cat_excerpt_position'     => ! empty( $meta['excerpt_position'] ) ? $meta['excerpt_position'] : 'below',
				'excerpt_limit'            => ! empty( $meta['excerpt_limit'] ) ? $meta['excerpt_limit'] : 'default',
				'excerpt_limit_custom'     => ! empty( $meta['excerpt_limit_custom'] ) ? $meta['excerpt_limit_custom'] : 200,

				// Count.
				'count_position'           => ! empty( $meta['count_display_type'] ) ? $meta['count_display_type'] : 'flex',
				'before_count'             => ! empty( $meta['before_count'] ) ? $meta['before_count'] : '',
				'after_count'              => ! empty( $meta['after_count'] ) ? $meta['after_count'] : '',

				// Add to cart.
				'show_cart_icon'           => ! empty( $meta['show_cart_icon'] ),
				'show_cart_text'           => ! empty( $meta['show_cart_text'] ),
				'add_to_cart_icon'         => ! empty( $meta['add_to_cart_icon'] ) ? $meta['add_to_cart_icon'] : [],
				'add_to_cart_success_icon' => ! empty( $meta['add_to_cart_success_icon'] ) ? $meta['add_to_cart_success_icon'] : [],
				'add_to_cart_text'         => ! empty( $meta['add_to_cart_text'] ) ? $meta['add_to_cart_text'] : esc_html__( 'Add to Cart', 'shopbuilder' ),
				'add_to_cart_success_text' => ! empty( $meta['add_to_cart_success_text'] ) ? $meta['add_to_cart_success_text'] : '',
				'add_to_cart_alignment'    => ! empty( $meta['cart_icon_alignment'] ) ? $meta['cart_icon_alignment'] : 'left',

				// Action Button Icons.
				'quick_view_icon'          => ! empty( $meta['quick_view_icon'] ) ? $meta['quick_view_icon'] : [],
				'comparison_icon'          => ! empty( $meta['comparison_icon'] ) ? $meta['comparison_icon'] : [],
				'comparison_icon_added'    => ! empty( $meta['comparison_icon_added'] ) ? $meta['comparison_icon_added'] : [],
				'wishlist_icon'            => ! empty( $meta['wishlist_icon'] ) ? $meta['wishlist_icon'] : [],
				'wishlist_icon_added'      => ! empty( $meta['wishlist_icon_added'] ) ? $meta['wishlist_icon_added'] : [],

				// Badges.
				'sale_badge_type'          => ! empty( $meta['sale_badges_type'] ) ? $meta['sale_badges_type'] : 'percentage',
				'sale_badge_text'          => ! empty( $meta['sale_badges_text'] ) ? $meta['sale_badges_text'] : esc_html__( 'Sale', 'shopbuilder' ),
				'custom_badge_text'        => ! empty( $meta['custom_badge_text'] ) ? $meta['custom_badge_text'] : esc_html__( 'Sale', 'shopbuilder' ),
				'out_of_stock_badge_text'  => ! empty( $meta['stock_badges_text'] ) ? $meta['stock_badges_text'] : esc_html__( 'Out of Stock', 'shopbuilder' ),
				'badge_position'           => ! empty( $meta['badges_position'] ) ? $meta['badges_position'] : 'top',
				'badge_alignment'          => ! empty( $meta['badges_alignment'] ) ? $meta['badges_alignment'] : 'left',
				'badge_preset'             => ! empty( $meta['custom_badge_preset'] ) ? $meta['custom_badge_preset'] : 'preset-1',

				// Link.
				'image_link'               => ! empty( $meta['image_link'] ),
				'title_link'               => ! empty( $meta['title_link'] ),
				'hover_btn_text'           => ! empty( $meta['hover_btn_text'] ) ? $meta['hover_btn_text'] : esc_html__( 'See Details', 'shopbuilder' ),
				'show_hover_btn_icon'      => ! empty( $meta['show_hover_btn_icon'] ),
				'hover_btn_icon'           => ! empty( $meta['hover_btn_icon'] ) ? $meta['hover_btn_icon'] : [],
				'custom_link'              => ! empty( $meta['custom_link'] ) ? $meta['custom_link'] : null,

				// Slider.
				'd_group'                  => ! empty( $meta['cols_group'] ) ? $meta['cols_group'] : 1,
				't_group'                  => ! empty( $meta['cols_group_mobile'] ) ? $meta['cols_group_mobile'] : 1,
				'm_group'                  => ! empty( $meta['cols_group_mobile'] ) ? $meta['cols_group_mobile'] : 1,
				'auto_play'                => ! empty( $meta['slide_autoplay'] ),
				'stop_on_hover'            => ! empty( $meta['pause_hover'] ),
				'slider_nav'               => ! empty( $meta['slider_nav'] ),
				'slider_dot'               => ! empty( $meta['slider_pagi'] ),
				'loop'                     => ! empty( $meta['slider_loop'] ),
				'lazy_load'                => ! empty( $meta['slider_lazy_load'] ),
				'auto_height'              => ! empty( $meta['slider_auto_height'] ),
				'speed'                    => ! empty( $meta['slide_speed'] ) ? $meta['slide_speed'] : 2000,
				'space_between'            => isset( $meta['grid_gap']['size'] ) && strlen( $meta['grid_gap']['size'] ) ? $meta['grid_gap']['size'] : 30,
				'auto_play_timeout'        => ! empty( $meta['autoplay_timeout'] ) ? $meta['autoplay_timeout'] : 5000,
				'nav_position'             => ! empty( $meta['slider_nav_position'] ) ? $meta['slider_nav_position'] : 'top',
				'left_arrow_icon'          => ! empty( $meta['slider_left_arrow_icon'] ) ? $meta['slider_left_arrow_icon'] : [],
				'right_arrow_icon'         => ! empty( $meta['slider_right_arrow_icon'] ) ? $meta['slider_right_arrow_icon'] : [],
			],
			$meta
		);

		if ( ! empty( $meta['cols_widescreen'] ) ) {
			$data['w_cols'] = $meta['cols_widescreen'];
		}

		if ( ! empty( $meta['cols_laptop'] ) ) {
			$data['l_cols'] = $meta['cols_laptop'];
		}

		if ( ! empty( $meta['cols_tablet_extra'] ) ) {
			$data['te_cols'] = $meta['cols_tablet_extra'];
		}

		if ( ! empty( $meta['cols_mobile_extra'] ) ) {
			$data['me_cols'] = $meta['cols_mobile_extra'];
		}

		$queried_obj = get_queried_object();

		if ( is_shop() || is_product_taxonomy() ) {
			$data['posts_per_page'] = wc_get_default_products_per_row() * wc_get_default_product_rows_per_page();
			$data['order_by']       = ! empty( $data['rtsb_orderby'] ) ? esc_html( $data['rtsb_orderby'] ) : $data['orderby'];
			$data['order']          = ! empty( $data['rtsb_order'] ) ? esc_html( $data['rtsb_order'] ) : $data['order'];
		}

		if ( ! is_shop() && is_product_taxonomy() ) {
			if ( ! empty( $queried_obj->taxonomy ) ) {
				$data['queried_tax'] = esc_html( $queried_obj->taxonomy );
			}

			if ( ! empty( $queried_obj->term_id ) ) {
				$data['queried_term'] = esc_html( $queried_obj->term_id );
			}
		}

		return apply_filters( 'rtsb/elementor/render/meta_dataset_final', $data, $meta );
	}

	/**
	 * Builds an array with field values.
	 *
	 * @param array  $meta Field values.
	 * @param string $template Template name.
	 *
	 * @return array
	 */
	public static function archive_meta_dataset( array $meta, $template = '' ) {
		$products_row      = absint( get_option( 'woocommerce_catalog_rows', 4 ) );
		$products_col      = absint( get_option( 'woocommerce_catalog_columns', 4 ) );
		$products_per_page = apply_filters( 'rtsb/elementor/archive/products_per_page', $products_row * $products_col );

		$data = apply_filters(
			'rtsb/elementor/render/archive_meta_dataset',
			[
				// Layout.
				'widget'                => 'default',
				'template'              => ! empty( $template ) ? $template : '',
				'view_mode'             => ! empty( $meta['view_mode'] ) ? $meta['view_mode'] : 'grid',
				'show_flash_sale'       => ! empty( $meta['show_flash_sale'] ),
				'wishlist_button'       => ! empty( $meta['wishlist_button'] ),
				'comparison_button'     => ! empty( $meta['comparison_button'] ),
				'quick_view_button'     => ! empty( $meta['quick_view_button'] ),
				'show_rating'           => ! empty( $meta['show_rating'] ),
				'show_pagination'       => ! empty( $meta['show_pagination'] ),
				'cart_icon'             => ! empty( $meta['cart_icon'] ) ? $meta['cart_icon'] : [],
				'wishlist_icon'         => ! empty( $meta['wishlist_icon'] ) ? $meta['wishlist_icon'] : [],
				'wishlist_icon_added'   => ! empty( $meta['wishlist_icon_added'] ) ? $meta['wishlist_icon_added'] : [],
				'comparison_icon'       => ! empty( $meta['comparison_icon'] ) ? $meta['comparison_icon'] : [],
				'comparison_icon_added' => ! empty( $meta['comparison_icon_added'] ) ? $meta['comparison_icon_added'] : [],
				'quick_view_icon'       => ! empty( $meta['quick_view_icon'] ) ? $meta['quick_view_icon'] : [],
				'prev_icon'             => ! empty( $meta['prev_icon'] ) ? $meta['prev_icon'] : [],
				'next_icon'             => ! empty( $meta['next_icon'] ) ? $meta['next_icon'] : [],
				'posts_per_page'        => ! empty( $products_per_page ) ? $products_per_page : 12,
				'rtsb_order'            => ! empty( $meta['rtsb_order'] ) ? $meta['rtsb_order'] : 'ASC',
				'rtsb_orderby'          => ! empty( $meta['rtsb_orderby'] ) ? $meta['rtsb_orderby'] : 'menu_order',
				'tooltip_position'      => ! empty( $meta['action_btn_tooltip_position'] ) ? $meta['action_btn_tooltip_position'] : 'top',
			],
			$meta
		);

		$queried_obj = get_queried_object();

		if ( ! is_shop() && BuilderFns::is_archive() ) {
			if ( ! empty( $queried_obj->taxonomy ) ) {
				$data['queried_tax'] = esc_html( $queried_obj->taxonomy );
			}

			if ( ! empty( $queried_obj->term_id ) ) {
				$data['queried_term'] = esc_html( $queried_obj->term_id );
			}
		}

		return apply_filters( 'rtsb/elementor/render/archive_meta_dataset_final', $data, $meta );
	}

	/**
	 * Setting up content visibility
	 *
	 * @param array $settings Elementor settings.
	 *
	 * @return array
	 */
	public static function content_visibility( $settings ) {
		$visibility = [];

		if ( ! empty( $settings['show_title'] ) ) {
			$visibility[] = 'title';
		}

		if ( ! empty( $settings['show_short_desc'] ) ) {
			$visibility[] = 'excerpt';
		}

		if ( ! empty( $settings['show_price'] ) ) {
			$visibility[] = 'price';
		}

		if ( ! empty( $settings['show_rating'] ) ) {
			$visibility[] = 'rating';
		}

		if ( ! empty( $settings['show_badges'] ) ) {
			$visibility[] = 'badges';
		}

		if ( ! empty( $settings['show_categories'] ) ) {
			$visibility[] = 'categories';
		}

		if ( ! empty( $settings['single_category'] ) ) {
			$visibility[] = 'single-cat';
		}

		if ( ! empty( $settings['show_swatches'] ) ) {
			$visibility[] = 'swatches';
		}

		if ( ! empty( $settings['show_vs_clear_btn'] ) ) {
			$visibility[] = 'clear-btn';
		}

		if ( ! empty( $settings['show_count'] ) ) {
			$visibility[] = 'count';
		}

		if ( ! empty( $settings['show_wishlist'] ) ) {
			$visibility[] = 'wishlist';
		}

		if ( ! empty( $settings['show_compare'] ) ) {
			$visibility[] = 'compare';
		}

		if ( ! empty( $settings['show_quick_view'] ) ) {
			$visibility[] = 'quick_view';
		}

		if ( ! empty( $settings['show_add_to_cart'] ) ) {
			$visibility[] = 'add_to_cart';
		}

		return $visibility;
	}

	/**
	 * Set Default Layout.
	 *
	 * @param string $layout Layout.
	 *
	 * @return string
	 */
	public static function set_default_layout( $layout ) {
		$is_list       = preg_match( '/list/', $layout );
		$is_cat_single = preg_match( '/category-single/', $layout );
		$is_cat        = preg_match( '/category/', $layout );
		$is_carousel   = preg_match( '/slider/', $layout );
		$default       = 'grid-layout1';

		if ( $is_list ) {
			$default = 'list-layout1';
		} elseif ( $is_cat_single ) {
			$default = 'category-single-layout1';
		} elseif ( $is_cat ) {
			$default = 'category-layout1';
		} elseif ( $is_carousel ) {
			$default = 'slider-layout1';
		}

		return $default;
	}

	/**
	 * Default layout columns.
	 *
	 * @param int $layout Layout.
	 *
	 * @return int
	 */
	public static function default_columns( $layout ) {
		switch ( $layout ) {
			case 'grid-layout2':
			case 'slider-layout2':
				$columns = 3;
				break;

			case 'list-layout1':
			case 'list-layout2':
			case 'list-layout3':
				$columns = 1;
				break;

			case 'category-layout1':
				$columns = 6;
				break;

			default:
				$columns = 4;
				break;
		}

		return $columns;
	}

	/**
	 * Pagination JSON data.
	 *
	 * @param array  $metas Data set.
	 * @param string $template Template name.
	 *
	 * @return string
	 */
	public static function pagination_data( $metas, $template ) {
		$el_data = self::meta_dataset( $metas, $template );

		return ' data-rtsb-ajax=\'' . esc_js( wp_json_encode( $el_data ) ) . '\'';
	}

	/**
	 * Archive JSON data.
	 *
	 * @param array  $metas Data set.
	 * @param string $template Template name.
	 *
	 * @return string
	 */
	public static function archive_data( $metas, $template ) {
		$el_data = self::archive_meta_dataset( $metas, $template );

		return ' data-rtsb-ajax=\'' . esc_js( wp_json_encode( $el_data ) ) . '\'';
	}

	/**
	 * Slider options.
	 *
	 * @param array $meta Meta values.
	 *
	 * @return array
	 */
	public static function slider_data( array $meta ) {
		$has_dots  = $meta['slider_dot'] ? ' has-dot' : ' no-dot';
		$has_dots .= $meta['slider_nav'] ? ' has-nav' : ' no-nav';

		$d_col = 0 === $meta['d_cols'] ? self::default_columns( $meta['layout'] ) : $meta['d_cols'];
		$t_col = 0 === $meta['t_cols'] ? 2 : $meta['t_cols'];
		$m_col = 0 === $meta['m_cols'] ? 1 : $meta['m_cols'];

		$slider_options = [
			'slidesPerView'  => absint( $d_col ),
			'slidesPerGroup' => absint( $meta['d_group'] ),
			'speed'          => absint( $meta['speed'] ),
			'loop'           => $meta['loop'],
			'autoHeight'     => $meta['auto_height'],
			'preloadImages'  => ! $meta['lazy_load'],
			'lazy'           => $meta['lazy_load'],
			'breakpoints'    => [
				0   => [
					'slidesPerView'  => absint( $m_col ),
					'slidesPerGroup' => absint( $meta['m_group'] ),
					'pagination'     => [
						'dynamicBullets' => true,
					],
				],
				767 => [
					'slidesPerView'  => absint( $t_col ),
					'slidesPerGroup' => absint( $meta['t_group'] ),
					'pagination'     => [
						'dynamicBullets' => false,
					],
				],
				991 => [
					'slidesPerView'  => absint( $d_col ),
					'slidesPerGroup' => absint( $meta['d_group'] ),
				],
			],
		];

		if ( $meta['auto_play'] ) {
			$slider_options['autoplay'] = [
				'delay'                => absint( $meta['auto_play_timeout'] ),
				'pauseOnMouseEnter'    => $meta['stop_on_hover'],
				'disableOnInteraction' => false,
			];
		}

		$carouselClass = 'rtsb-carousel-slider slider-loading rtsb-pos-s ' . $meta['nav_position'] . '-nav' . $has_dots;

		return [
			'data'  => ' data-options=\'' . esc_js( wp_json_encode( $slider_options ) ) . '\'',
			'class' => $carouselClass,
		];
	}

	/**
	 * Renders pagination
	 *
	 * @param object $wp_query WP_Query object.
	 * @param array  $meta Meta values.
	 * @param int    $limit Post limit.
	 * @param int    $per_page Posts per page.
	 *
	 * @return string
	 */
	public static function render_pagination( $wp_query, $meta, $limit, $per_page ) {
		$html_utility   = null;
		$html           = null;
		$ajax           = false;
		$is_grid        = preg_match( '/grid-layout/', $meta['layout'] ) || preg_match( '/list-layout/', $meta['layout'] );
		$posts_per_page = $wp_query->query_vars['posts_per_page'];
		$total_page     = $wp_query->max_num_pages;

		if ( $limit && ( empty( $wp_query->query['tax_query'] ) ) ) {
			$found_post = $wp_query->found_posts;

			if ( $per_page && $found_post > $per_page ) {
				$found_post = $limit;
				$total_page = ceil( $found_post / $per_page );
			}
		}

		$total_page = absint( $total_page );

		$args = [
			'total_page'     => $total_page,
			'posts_per_page' => $posts_per_page,
			'ajax'           => $ajax,
		];

		if ( 'pagination' === $meta['posts_loading_type'] ) {
			if ( $is_grid ) {
				$html_utility .= Fns::custom_pagination(
					$total_page,
					$posts_per_page
				);
			}
		} else {
			ob_start();
			do_action( 'rtsb/elementor/render/pagination', $meta, $wp_query, $args );
			$html_utility .= ob_get_clean();
		}

		if ( $html_utility ) {
			$html .= '<div class="rtsb-pagination-wrap element-loading" data-total-pages="' . absint( $total_page ) . '" data-posts-per-page="' . absint( $posts_per_page ) . '" data-type="' . esc_attr( $meta['posts_loading_type'] ) . '">' . $html_utility . '</div>';
		}

		return $html;
	}

	/**
	 * Preloader.
	 *
	 * @param string $layout Layout.
	 *
	 * @return string
	 */
	public static function pre_loader( $layout ) {
		$loader_class = '';

		$is_carousel = preg_match( '/slider/', $layout );

		if ( $is_carousel ) {
			$loader_class = ' full-op';
		}

		return '<div class="rtsb-elements-loading rtsb-ball-clip-rotate"><div></div></div>';
	}

	/**
	 * Badge class.
	 *
	 * @param string $preset Badge preset.
	 *
	 * @return string|null
	 */
	public static function badge_class( $preset ) {
		switch ( $preset ) {
			case 'preset-default':
				$class = 'default-badge';
				break;
			case 'preset2':
				$class = 'fill angle-right';
				break;
			case 'preset3':
				$class = 'outline';
				break;

			case 'preset4':
				$class = 'outline angle-right';
				break;

			default:
				$class = 'fill';
				break;
		}

		return $class;
	}

	/**
	 * Registers required scripts.
	 *
	 * @param array $scripts Scripts to register.
	 *
	 * @return void
	 */
	public static function register_scripts( $scripts ) {
		$caro   = false;
		$script = [];

		$script[] = 'jquery';

		foreach ( $scripts as $sc => $value ) {
			if ( ! empty( $sc ) ) {
				if ( 'isCarousel' === $sc ) {
					$caro = $value;
				}
			}
		}

		if ( count( $scripts ) ) {
			/**
			 * Scripts.
			 */
			if ( $caro ) {
				$script[] = 'swiper';
			}

			$script[] = 'rtsb-imagesloaded';
			$script[] = 'rtsb-public';

			wp_enqueue_script( $script );
		}
	}

	/**
	 * Check if a wrapper is needed based on the current theme.
	 *
	 * @return bool
	 */
	public static function is_wrapper_needed() {
		$theme_list = apply_filters(
			'rtsb/products/inner/wrapper/basedon/themes',
			[
				'twentytwentyone',
				'twentytwentytwo',
				'twentytwentythree',
				'storefront',
				'hello-elementor',
				'astra',
			],
			rtsb()->current_theme
		);

		if ( in_array( rtsb()->current_theme, $theme_list, true ) ) {
			return true;
		}

		return false;
	}
}

```
