| @@ -20,27 +20,11 @@ | ||
| 20 | 20 | /** |
| 21 | 21 | * BuilderFns class |
| 22 | 22 | */ |
| 23 | 23 | class RenderHelpers { |
| 24 | - /** | |
| 25 | - * Get data. | |
| 26 | - * | |
| 27 | - * @param array|string $haystack The array or string to search for the value. | |
| 28 | - * @param string $needle The key to look for in the array or the string itself. | |
| 29 | - * @param mixed $default The default value to return if the key is not. | |
| 30 | - * | |
| 31 | - * @return mixed | |
| 32 | - */ | |
| 33 | - public static function get_data( $haystack, $needle, $default = null ) { | |
| 34 | - if ( is_array( $haystack ) && ! empty( $haystack[ $needle ] ) ) { | |
| 35 | - return $haystack[ $needle ]; | |
| 36 | - } elseif ( is_string( $haystack ) && ! empty( $haystack ) ) { | |
| 37 | - return $haystack; | |
| 38 | - } else { | |
| 39 | - return $default; | |
| 40 | - } | |
| 41 | - } | |
| 42 | 24 | |
| 25 | + | |
| 26 | + | |
| 43 | 27 | /** |
| 44 | 28 | * Builds an array with field values. |
| 45 | 29 | * |
| 46 | 30 | * @param array $meta Field values. |
| @@ -49,15 +33,15 @@ | ||
| 49 | 33 | * |
| 50 | 34 | * @return array |
| 51 | 35 | */ |
| 52 | 36 | public static function meta_dataset( array $meta, $template = '', $raw_settings = [] ) { |
| 53 | - $c_image_size = self::get_data( $meta, 'image_custom_dimension', [] ); | |
| 54 | - $c_image_size['crop'] = self::get_data( $meta, 'image_crop', [] ); | |
| 37 | + $c_image_size = ! empty( $meta['image_custom_dimension'] ) ? $meta['image_custom_dimension'] : []; | |
| 38 | + $c_image_size['crop'] = ! empty( $meta['image_crop'] ) ? $meta['image_crop'] : ''; | |
| 55 | 39 | |
| 56 | - if ( ( ! empty( $_GET['displayview'] ) && 'list' === $_GET['displayview'] ) || ( empty( $_GET['displayview'] ) && ( ! empty( $meta['view_mode'] ) && 'list' === $meta['view_mode'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 57 | - $meta['cols'] = self::get_data( $meta, 'list_cols', 1 ); | |
| 58 | - $meta['cols_tablet'] = self::get_data( $meta, 'list_cols_tablet', $meta['cols'] ); | |
| 59 | - $meta['cols_mobile'] = self::get_data( $meta, 'list_cols_mobile', $meta['cols'] ); | |
| 40 | + if ( ( ! empty( $_GET['displayview'] ) && 'list' === $_GET['displayview'] ) || ( empty( $_GET['displayview'] ) && ( ! empty( $meta['view_mode'] ) && 'list' === $meta['view_mode'] ) ) ) { | |
| 41 | + $meta['cols'] = ! empty( $meta['list_cols'] ) ? $meta['list_cols'] : 1; | |
| 42 | + $meta['cols_tablet'] = ! empty( $meta['list_cols_tablet'] ) ? $meta['list_cols_tablet'] : $meta['cols']; | |
| 43 | + $meta['cols_mobile'] = ! empty( $meta['list_cols_mobile'] ) ? $meta['list_cols_mobile'] : $meta['cols']; | |
| 60 | 44 | } |
| 61 | 45 | |
| 62 | 46 | $data = apply_filters( |
| 63 | 47 | 'rtsb/elementor/render/meta_dataset', |
| @@ -63,53 +47,53 @@ | ||
| 63 | 47 | 'rtsb/elementor/render/meta_dataset', |
| 64 | 48 | [ |
| 65 | 49 | // Layout. |
| 66 | 50 | 'widget' => 'custom', |
| 67 | - 'template' => self::get_data( $template, '', '' ), | |
| 68 | - 'raw_settings' => $raw_settings, | |
| 69 | - 'layout' => self::get_data( $meta, 'layout', 'layout1' ), | |
| 70 | - 'grid_layout' => self::get_data( $raw_settings, 'layout', 'grid-layout1' ), | |
| 71 | - 'list_layout' => self::get_data( $raw_settings, 'list_layout', 'list-layout1' ), | |
| 72 | - 'd_cols' => self::get_data( $meta, 'cols', 0 ), | |
| 73 | - 't_cols' => self::get_data( $meta, 'cols_tablet', 2 ), | |
| 74 | - 'm_cols' => self::get_data( $meta, 'cols_mobile', 1 ), | |
| 75 | - 'grid_type' => self::get_data( $meta, 'grid_style', 'even' ), | |
| 51 | + 'template' => ! empty( $template ) ? $template : '', | |
| 52 | + 'raw_settings' => ! empty( $raw_settings ) ? $raw_settings : [], | |
| 53 | + 'layout' => ! empty( $meta['layout'] ) ? $meta['layout'] : 'layout1', | |
| 54 | + 'grid_layout' => ! empty( $raw_settings['layout'] ) ? $raw_settings['layout'] : 'grid-layout1', | |
| 55 | + 'list_layout' => ! empty( $raw_settings['list_layout'] ) ? $raw_settings['list_layout'] : 'list-layout1', | |
| 56 | + 'd_cols' => ! empty( $meta['cols'] ) ? $meta['cols'] : 0, | |
| 57 | + 't_cols' => ! empty( $meta['cols_tablet'] ) ? $meta['cols_tablet'] : 2, | |
| 58 | + 'm_cols' => ! empty( $meta['cols_mobile'] ) ? $meta['cols_mobile'] : 1, | |
| 59 | + 'grid_type' => ! empty( $meta['grid_style'] ) ? $meta['grid_style'] : 'even', | |
| 76 | 60 | |
| 77 | 61 | // Query. |
| 78 | - 'post_in' => self::get_data( $meta, 'include_posts', [] ), | |
| 79 | - 'post_not_in' => self::get_data( $meta, 'exclude_posts', [] ), | |
| 62 | + 'post_in' => ! empty( $meta['include_posts'] ) && is_array( $meta['include_posts'] ) ? $meta['include_posts'] : [], | |
| 63 | + 'post_not_in' => ! empty( $meta['exclude_posts'] ) && is_array( $meta['exclude_posts'] ) ? $meta['exclude_posts'] : [], | |
| 80 | 64 | 'limit' => ( empty( $meta['posts_limit'] ) || '-1' === $meta['posts_limit'] ) ? 10000000 : $meta['posts_limit'], |
| 81 | - 'offset' => self::get_data( $meta, 'posts_offset', 0 ), | |
| 82 | - 'order_by' => self::get_data( $meta, 'posts_order_by', 'date' ), | |
| 83 | - 'order' => self::get_data( $meta, 'posts_order', 'DESC' ), | |
| 84 | - 'author_in' => self::get_data( $meta, 'filter_author', [] ), | |
| 85 | - 'display_by' => self::get_data( $meta, 'products_filter', 'date' ), | |
| 86 | - 'categories' => self::get_data( $meta, 'filter_categories', [] ), | |
| 87 | - 'tags' => self::get_data( $meta, 'filter_tags', [] ), | |
| 88 | - 'attributes' => self::get_data( $meta, 'filter_attributes', [] ), | |
| 89 | - 'relation' => self::get_data( $meta, 'tax_relation', 'OR' ), | |
| 90 | - 'category_source' => self::get_data( $meta, 'select_source', 'product_cat' ), | |
| 91 | - 'category_term' => self::get_data( $meta, 'select_cat' ), | |
| 92 | - 'display_cat_by' => self::get_data( $meta, 'display_cat_by' ), | |
| 93 | - 'include_cats' => self::get_data( $meta, 'include_cats', [] ), | |
| 94 | - 'exclude_cats' => self::get_data( $meta, 'exclude_cats', [] ), | |
| 95 | - 'select_parent_cat' => self::get_data( $meta, 'select_parent_cat' ), | |
| 96 | - 'select_cats' => self::get_data( $meta, 'select_cats', [] ), | |
| 97 | - 'select_cat_ids' => self::get_data( $meta, 'include_cat_ids', '' ), | |
| 65 | + 'offset' => ! empty( $meta['posts_offset'] ) ? $meta['posts_offset'] : 0, | |
| 66 | + 'order_by' => ! empty( $meta['posts_order_by'] ) ? $meta['posts_order_by'] : 'date', | |
| 67 | + 'order' => ! empty( $meta['posts_order'] ) ? $meta['posts_order'] : 'DESC', | |
| 68 | + 'author_in' => ! empty( $meta['filter_author'] ) && is_array( $meta['filter_author'] ) ? $meta['filter_author'] : [], | |
| 69 | + 'display_by' => ! empty( $meta['products_filter'] ) ? $meta['products_filter'] : 'date', | |
| 70 | + 'categories' => ! empty( $meta['filter_categories'] ) && is_array( $meta['filter_categories'] ) ? $meta['filter_categories'] : [], | |
| 71 | + 'tags' => ! empty( $meta['filter_tags'] ) && is_array( $meta['filter_tags'] ) ? $meta['filter_tags'] : [], | |
| 72 | + 'attributes' => ! empty( $meta['filter_attributes'] ) && is_array( $meta['filter_attributes'] ) ? $meta['filter_attributes'] : [], | |
| 73 | + 'relation' => ! empty( $meta['tax_relation'] ) ? $meta['tax_relation'] : 'OR', | |
| 74 | + 'category_source' => ! empty( $meta['select_source'] ) ? $meta['select_source'] : 'product_cat', | |
| 75 | + 'category_term' => ! empty( $meta['select_cat'] ) ? $meta['select_cat'] : null, | |
| 76 | + 'display_cat_by' => ! empty( $meta['display_cat_by'] ) ? $meta['display_cat_by'] : null, | |
| 77 | + 'include_cats' => ! empty( $meta['include_cats'] ) && is_array( $meta['include_cats'] ) ? $meta['include_cats'] : [], | |
| 78 | + 'exclude_cats' => ! empty( $meta['exclude_cats'] ) && is_array( $meta['exclude_cats'] ) ? $meta['exclude_cats'] : [], | |
| 79 | + 'select_parent_cat' => ! empty( $meta['select_parent_cat'] ) ? $meta['select_parent_cat'] : null, | |
| 80 | + 'select_cats' => ! empty( $meta['select_cats'] ) && is_array( $meta['select_cats'] ) ? $meta['select_cats'] : [], | |
| 81 | + 'select_cat_ids' => ! empty( $meta['include_cat_ids'] ) ? $meta['include_cat_ids'] : '', | |
| 98 | 82 | 'cats_limit' => ( empty( $meta['cats_limit'] ) || '-1' === $meta['cats_limit'] ) ? 10000000 : $meta['cats_limit'], |
| 99 | 83 | 'show_empty' => ! empty( $meta['show_empty'] ), |
| 100 | 84 | 'show_uncategorized' => ! empty( $meta['show_uncategorized'] ), |
| 101 | 85 | 'show_subcats' => ! empty( $meta['show_subcats'] ), |
| 102 | 86 | 'show_top_level_cats' => ! empty( $meta['show_top_level_cats'] ), |
| 103 | - 'cats_order_by' => self::get_data( $meta, 'cats_order_by', 'name' ), | |
| 104 | - 'cats_order' => self::get_data( $meta, 'cats_order', 'DESC' ), | |
| 105 | - 'rtsb_order' => self::get_data( $meta, 'rtsb_order', 'ASC' ), | |
| 106 | - 'rtsb_orderby' => self::get_data( $meta, 'rtsb_orderby', 'menu_order' ), | |
| 87 | + 'cats_order_by' => ! empty( $meta['cats_order_by'] ) ? $meta['cats_order_by'] : 'name', | |
| 88 | + 'cats_order' => ! empty( $meta['cats_order'] ) ? $meta['cats_order'] : 'DESC', | |
| 89 | + 'rtsb_order' => ! empty( $meta['rtsb_order'] ) ? $meta['rtsb_order'] : 'ASC', | |
| 90 | + 'rtsb_orderby' => ! empty( $meta['rtsb_orderby'] ) ? $meta['rtsb_orderby'] : 'menu_order', | |
| 107 | 91 | |
| 108 | 92 | // Pagination. |
| 109 | 93 | 'pagination' => ! empty( $meta['show_pagination'] ), |
| 110 | - 'posts_loading_type' => self::get_data( $meta, 'pagination_type', 'pagination' ), | |
| 111 | - 'posts_per_page' => self::get_data( $meta, 'pagination_per_page', '' ), | |
| 94 | + 'posts_loading_type' => ! empty( $meta['pagination_type'] ) ? $meta['pagination_type'] : 'pagination', | |
| 95 | + 'posts_per_page' => ! empty( $meta['pagination_per_page'] ) ? $meta['pagination_per_page'] : '', | |
| 112 | 96 | |
| 113 | 97 | // Image. |
| 114 | 98 | 'f_img' => ! empty( $meta['show_featured_image'] ), |
| 115 | 99 | 'gallery_img' => ! empty( $meta['show_product_gallery'] ), |
| @@ -114,13 +98,13 @@ | ||
| 114 | 98 | 'f_img' => ! empty( $meta['show_featured_image'] ), |
| 115 | 99 | 'gallery_img' => ! empty( $meta['show_product_gallery'] ), |
| 116 | 100 | 'c_img' => ! empty( $meta['show_cat_image'] ), |
| 117 | 101 | 'hover_img' => ! empty( $meta['show_hover_image'] ), |
| 118 | - 'f_img_size' => self::get_data( $meta, 'image', 'medium' ), | |
| 102 | + 'f_img_size' => ! empty( $meta['image'] ) ? $meta['image'] : 'medium', | |
| 119 | 103 | 'custom_img_size' => ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [], |
| 120 | 104 | 'default_img_id' => ! empty( $meta['default_preview_image']['id'] ) ? $meta['default_preview_image']['id'] : null, |
| 121 | 105 | 'show_overlay' => ! empty( $meta['show_overlay'] ), |
| 122 | - 'hover_animation' => self::get_data( $meta, 'image_hover_animation', 'none' ), | |
| 106 | + 'hover_animation' => ! empty( $meta['image_hover_animation'] ) ? $meta['image_hover_animation'] : 'none', | |
| 123 | 107 | 'show_custom_image' => ! empty( $meta['show_custom_image'] ), |
| 124 | 108 | 'custom_image' => ! empty( $meta['custom_image']['id'] ) ? $meta['custom_image']['id'] : null, |
| 125 | 109 | |
| 126 | 110 | // Visibility. |
| @@ -126,73 +110,73 @@ | ||
| 126 | 110 | // Visibility. |
| 127 | 111 | 'visibility' => ! empty( self::content_visibility( $meta ) ) ? self::content_visibility( $meta ) : [], |
| 128 | 112 | |
| 129 | 113 | // Action Buttons. |
| 130 | - 'btn_preset' => self::get_data( $meta, 'action_btn_preset', 'preset1' ), | |
| 131 | - 'btn_position' => self::get_data( $meta, 'action_btn_position', 'above' ), | |
| 132 | - 'tooltip_position' => self::get_data( $meta, 'action_btn_tooltip_position', 'top' ), | |
| 114 | + 'btn_preset' => ! empty( $meta['action_btn_preset'] ) ? $meta['action_btn_preset'] : 'preset1', | |
| 115 | + 'btn_position' => ! empty( $meta['action_btn_position'] ) ? $meta['action_btn_position'] : 'above', | |
| 116 | + 'tooltip_position' => ! empty( $meta['action_btn_tooltip_position'] ) ? $meta['action_btn_tooltip_position'] : 'top', | |
| 133 | 117 | |
| 134 | 118 | // Product Title. |
| 135 | - 'title_tag' => self::get_data( $meta, 'title_tag', 'h3' ), | |
| 119 | + 'title_tag' => ! empty( $meta['title_tag'] ) ? $meta['title_tag'] : 'h3', | |
| 136 | 120 | 'title_hover' => ! empty( $meta['title_hover'] ), |
| 137 | - 'title_limit' => self::get_data( $meta, 'title_limit', 'default' ), | |
| 138 | - 'title_limit_custom' => self::get_data( $meta, 'title_limit_custom' ), | |
| 121 | + 'title_limit' => ! empty( $meta['title_limit'] ) ? $meta['title_limit'] : 'default', | |
| 122 | + 'title_limit_custom' => ! empty( $meta['title_limit_custom'] ) ? $meta['title_limit_custom'] : null, | |
| 139 | 123 | 'show_custom_title' => ! empty( $meta['show_custom_title'] ), |
| 140 | - 'cat_custom_title' => self::get_data( $meta, 'custom_title', '' ), | |
| 124 | + 'cat_custom_title' => ! empty( $meta['custom_title'] ) ? $meta['custom_title'] : '', | |
| 141 | 125 | |
| 142 | 126 | // Variation Swatches. |
| 143 | - 'swatch_position' => self::get_data( $meta, 'swatch_position', 'top' ), | |
| 144 | - 'swatch_type' => self::get_data( $meta, 'swatch_type', 'circle' ), | |
| 127 | + 'swatch_position' => ! empty( $meta['swatch_position'] ) ? $meta['swatch_position'] : 'top', | |
| 128 | + 'swatch_type' => ! empty( $meta['swatch_type'] ) ? $meta['swatch_type'] : 'circle', | |
| 145 | 129 | |
| 146 | 130 | // Short Description. |
| 147 | 131 | 'show_custom_excerpt' => ! empty( $meta['show_custom_description'] ), |
| 148 | - 'cat_custom_excerpt' => self::get_data( $meta, 'custom_description', '' ), | |
| 149 | - 'cat_excerpt_position' => self::get_data( $meta, 'excerpt_position', 'below' ), | |
| 150 | - 'excerpt_limit' => self::get_data( $meta, 'excerpt_limit', 'default' ), | |
| 151 | - 'excerpt_limit_custom' => self::get_data( $meta, 'excerpt_limit_custom', 200 ), | |
| 132 | + 'cat_custom_excerpt' => ! empty( $meta['custom_description'] ) ? $meta['custom_description'] : '', | |
| 133 | + 'cat_excerpt_position' => ! empty( $meta['excerpt_position'] ) ? $meta['excerpt_position'] : 'below', | |
| 134 | + 'excerpt_limit' => ! empty( $meta['excerpt_limit'] ) ? $meta['excerpt_limit'] : 'default', | |
| 135 | + 'excerpt_limit_custom' => ! empty( $meta['excerpt_limit_custom'] ) ? $meta['excerpt_limit_custom'] : 200, | |
| 152 | 136 | |
| 153 | 137 | // Count. |
| 154 | - 'count_position' => self::get_data( $meta, 'count_display_type', 'flex' ), | |
| 155 | - 'before_count' => self::get_data( $meta, 'before_count', '' ), | |
| 156 | - 'after_count' => self::get_data( $meta, 'after_count', '' ), | |
| 138 | + 'count_position' => ! empty( $meta['count_display_type'] ) ? $meta['count_display_type'] : 'flex', | |
| 139 | + 'before_count' => ! empty( $meta['before_count'] ) ? $meta['before_count'] : '', | |
| 140 | + 'after_count' => ! empty( $meta['after_count'] ) ? $meta['after_count'] : '', | |
| 157 | 141 | |
| 158 | 142 | // Add to cart. |
| 159 | 143 | 'show_cart_icon' => ! empty( $meta['show_cart_icon'] ), |
| 160 | 144 | 'show_cart_text' => ! empty( $meta['show_cart_text'] ), |
| 161 | - 'add_to_cart_icon' => self::get_data( $meta, 'add_to_cart_icon', [] ), | |
| 162 | - 'add_to_cart_success_icon' => self::get_data( $meta, 'add_to_cart_success_icon', [] ), | |
| 163 | - 'add_to_cart_text' => self::get_data( $meta, 'add_to_cart_text', esc_html__( 'Add to Cart', 'shopbuilder' ) ), | |
| 164 | - 'add_to_cart_success_text' => self::get_data( $meta, 'add_to_cart_success_text', '' ), | |
| 165 | - 'add_to_cart_alignment' => self::get_data( $meta, 'cart_icon_alignment', 'left' ), | |
| 145 | + 'add_to_cart_icon' => ! empty( $meta['add_to_cart_icon'] ) ? $meta['add_to_cart_icon'] : [], | |
| 146 | + 'add_to_cart_success_icon' => ! empty( $meta['add_to_cart_success_icon'] ) ? $meta['add_to_cart_success_icon'] : [], | |
| 147 | + 'add_to_cart_text' => ! empty( $meta['add_to_cart_text'] ) ? $meta['add_to_cart_text'] : esc_html__( 'Add to Cart', 'shopbuilder' ), | |
| 148 | + 'add_to_cart_success_text' => ! empty( $meta['add_to_cart_success_text'] ) ? $meta['add_to_cart_success_text'] : '', | |
| 149 | + 'add_to_cart_alignment' => ! empty( $meta['cart_icon_alignment'] ) ? $meta['cart_icon_alignment'] : 'left', | |
| 166 | 150 | |
| 167 | 151 | // Action Button Icons. |
| 168 | - 'quick_view_icon' => self::get_data( $meta, 'quick_view_icon', [] ), | |
| 169 | - 'comparison_icon' => self::get_data( $meta, 'comparison_icon', [] ), | |
| 170 | - 'comparison_icon_added' => self::get_data( $meta, 'comparison_icon_added', [] ), | |
| 171 | - 'wishlist_icon' => self::get_data( $meta, 'wishlist_icon', [] ), | |
| 172 | - 'wishlist_icon_added' => self::get_data( $meta, 'wishlist_icon_added', [] ), | |
| 152 | + 'quick_view_icon' => ! empty( $meta['quick_view_icon'] ) ? $meta['quick_view_icon'] : [], | |
| 153 | + 'comparison_icon' => ! empty( $meta['comparison_icon'] ) ? $meta['comparison_icon'] : [], | |
| 154 | + 'comparison_icon_added' => ! empty( $meta['comparison_icon_added'] ) ? $meta['comparison_icon_added'] : [], | |
| 155 | + 'wishlist_icon' => ! empty( $meta['wishlist_icon'] ) ? $meta['wishlist_icon'] : [], | |
| 156 | + 'wishlist_icon_added' => ! empty( $meta['wishlist_icon_added'] ) ? $meta['wishlist_icon_added'] : [], | |
| 173 | 157 | |
| 174 | 158 | // Badges. |
| 175 | - 'sale_badge_type' => self::get_data( $meta, 'sale_badges_type', 'percentage' ), | |
| 176 | - 'sale_badge_text' => self::get_data( $meta, 'sale_badges_text', esc_html__( 'Sale', 'shopbuilder' ) ), | |
| 177 | - 'custom_badge_text' => self::get_data( $meta, 'custom_badge_text', esc_html__( 'Sale', 'shopbuilder' ) ), | |
| 178 | - 'out_of_stock_badge_text' => self::get_data( $meta, 'stock_badges_text', esc_html__( 'Out of Stock', 'shopbuilder' ) ), | |
| 179 | - 'badge_position' => self::get_data( $meta, 'badges_position', 'top' ), | |
| 180 | - 'badge_alignment' => self::get_data( $meta, 'badges_alignment', 'left' ), | |
| 181 | - 'badge_preset' => self::get_data( $meta, 'custom_badge_preset', 'preset-1' ), | |
| 159 | + 'sale_badge_type' => ! empty( $meta['sale_badges_type'] ) ? $meta['sale_badges_type'] : 'percentage', | |
| 160 | + 'sale_badge_text' => ! empty( $meta['sale_badges_text'] ) ? $meta['sale_badges_text'] : esc_html__( 'Sale', 'shopbuilder' ), | |
| 161 | + 'custom_badge_text' => ! empty( $meta['custom_badge_text'] ) ? $meta['custom_badge_text'] : esc_html__( 'Sale', 'shopbuilder' ), | |
| 162 | + 'out_of_stock_badge_text' => ! empty( $meta['stock_badges_text'] ) ? $meta['stock_badges_text'] : esc_html__( 'Out of Stock', 'shopbuilder' ), | |
| 163 | + 'badge_position' => ! empty( $meta['badges_position'] ) ? $meta['badges_position'] : 'top', | |
| 164 | + 'badge_alignment' => ! empty( $meta['badges_alignment'] ) ? $meta['badges_alignment'] : 'left', | |
| 165 | + 'badge_preset' => ! empty( $meta['custom_badge_preset'] ) ? $meta['custom_badge_preset'] : 'preset-1', | |
| 182 | 166 | |
| 183 | 167 | // Link. |
| 184 | 168 | 'image_link' => ! empty( $meta['image_link'] ), |
| 185 | 169 | 'title_link' => ! empty( $meta['title_link'] ), |
| 186 | - 'hover_btn_text' => self::get_data( $meta, 'hover_btn_text', esc_html__( 'See Details', 'shopbuilder' ) ), | |
| 170 | + 'hover_btn_text' => ! empty( $meta['hover_btn_text'] ) ? $meta['hover_btn_text'] : esc_html__( 'See Details', 'shopbuilder' ), | |
| 187 | 171 | 'show_hover_btn_icon' => ! empty( $meta['show_hover_btn_icon'] ), |
| 188 | - 'hover_btn_icon' => self::get_data( $meta, 'hover_btn_icon', [] ), | |
| 189 | - 'custom_link' => self::get_data( $meta, 'custom_link' ), | |
| 172 | + 'hover_btn_icon' => ! empty( $meta['hover_btn_icon'] ) ? $meta['hover_btn_icon'] : [], | |
| 173 | + 'custom_link' => ! empty( $meta['custom_link'] ) ? $meta['custom_link'] : null, | |
| 190 | 174 | |
| 191 | 175 | // Slider. |
| 192 | - 'd_group' => self::get_data( $meta, 'cols_group', 1 ), | |
| 193 | - 't_group' => self::get_data( $meta, 'cols_group_tablet', 1 ), | |
| 194 | - 'm_group' => self::get_data( $meta, 'cols_group_mobile', 1 ), | |
| 176 | + 'd_group' => ! empty( $meta['cols_group'] ) ? $meta['cols_group'] : 1, | |
| 177 | + 't_group' => ! empty( $meta['cols_group_tablet'] ) ? $meta['cols_group_tablet'] : 1, | |
| 178 | + 'm_group' => ! empty( $meta['cols_group_mobile'] ) ? $meta['cols_group_mobile'] : 1, | |
| 195 | 179 | 'auto_play' => ! empty( $meta['slide_autoplay'] ), |
| 196 | 180 | 'stop_on_hover' => ! empty( $meta['pause_hover'] ), |
| 197 | 181 | 'slider_nav' => ! empty( $meta['slider_nav'] ), |
| 198 | 182 | 'slider_dot' => ! empty( $meta['slider_pagi'] ), |
| @@ -198,14 +182,14 @@ | ||
| 198 | 182 | 'slider_dot' => ! empty( $meta['slider_pagi'] ), |
| 199 | 183 | 'loop' => ! empty( $meta['slider_loop'] ), |
| 200 | 184 | 'lazy_load' => ! empty( $meta['slider_lazy_load'] ), |
| 201 | 185 | 'auto_height' => ! empty( $meta['slider_auto_height'] ), |
| 202 | - 'speed' => self::get_data( $meta, 'slide_speed', 2000 ), | |
| 186 | + 'speed' => ! empty( $meta['slide_speed'] ) ? $meta['slide_speed'] : 2000, | |
| 203 | 187 | 'space_between' => isset( $meta['grid_gap']['size'] ) && strlen( $meta['grid_gap']['size'] ) ? $meta['grid_gap']['size'] : 30, |
| 204 | - 'auto_play_timeout' => self::get_data( $meta, 'autoplay_timeout', 5000 ), | |
| 205 | - 'nav_position' => self::get_data( $meta, 'slider_nav_position', 'top' ), | |
| 206 | - 'left_arrow_icon' => self::get_data( $meta, 'slider_left_arrow_icon', [] ), | |
| 207 | - 'right_arrow_icon' => self::get_data( $meta, 'slider_right_arrow_icon', [] ), | |
| 188 | + 'auto_play_timeout' => ! empty( $meta['autoplay_timeout'] ) ? $meta['autoplay_timeout'] : 5000, | |
| 189 | + 'nav_position' => ! empty( $meta['slider_nav_position'] ) ? $meta['slider_nav_position'] : 'top', | |
| 190 | + 'left_arrow_icon' => ! empty( $meta['slider_left_arrow_icon'] ) ? $meta['slider_left_arrow_icon'] : [], | |
| 191 | + 'right_arrow_icon' => ! empty( $meta['slider_right_arrow_icon'] ) ? $meta['slider_right_arrow_icon'] : [], | |
| 208 | 192 | ], |
| 209 | 193 | $meta |
| 210 | 194 | ); |
| 211 | 195 | |
| @@ -227,11 +211,11 @@ | ||
| 227 | 211 | |
| 228 | 212 | $queried_obj = get_queried_object(); |
| 229 | 213 | |
| 230 | 214 | if ( is_shop() || is_product_taxonomy() ) { |
| 231 | - $data['posts_per_page'] = self::get_products_per_page(); | |
| 232 | - $data['order_by'] = self::get_data( $data, 'rtsb_orderby', $data['order_by'] ); | |
| 233 | - $data['order'] = self::get_data( $data, 'rtsb_order', $data['order'] ); | |
| 215 | + $data['posts_per_page'] = wc_get_default_products_per_row() * wc_get_default_product_rows_per_page(); | |
| 216 | + $data['order_by'] = ! empty( $data['rtsb_orderby'] ) ? esc_html( $data['rtsb_orderby'] ) : $data['orderby']; | |
| 217 | + $data['order'] = ! empty( $data['rtsb_order'] ) ? esc_html( $data['rtsb_order'] ) : $data['order']; | |
| 234 | 218 | } |
| 235 | 219 | |
| 236 | 220 | if ( ! is_shop() && is_product_taxonomy() ) { |
| 237 | 221 | if ( ! empty( $queried_obj->taxonomy ) ) { |
| @@ -254,15 +238,19 @@ | ||
| 254 | 238 | * |
| 255 | 239 | * @return array |
| 256 | 240 | */ |
| 257 | 241 | public static function archive_meta_dataset( array $meta, $template = '' ) { |
| 242 | + $products_row = absint( get_option( 'woocommerce_catalog_rows', 4 ) ); | |
| 243 | + $products_col = absint( get_option( 'woocommerce_catalog_columns', 4 ) ); | |
| 244 | + $products_per_page = apply_filters( 'rtsb/elementor/archive/products_per_page', $products_row * $products_col ); | |
| 245 | + | |
| 258 | 246 | $data = apply_filters( |
| 259 | 247 | 'rtsb/elementor/render/archive_meta_dataset', |
| 260 | 248 | [ |
| 261 | 249 | // Layout. |
| 262 | 250 | 'widget' => 'default', |
| 263 | - 'template' => self::get_data( $template, '', '' ), | |
| 264 | - 'view_mode' => self::get_data( $meta, 'view_mode', 'grid' ), | |
| 251 | + 'template' => ! empty( $template ) ? $template : '', | |
| 252 | + 'view_mode' => ! empty( $meta['view_mode'] ) ? $meta['view_mode'] : 'grid', | |
| 265 | 253 | 'show_flash_sale' => ! empty( $meta['show_flash_sale'] ), |
| 266 | 254 | 'wishlist_button' => ! empty( $meta['wishlist_button'] ), |
| 267 | 255 | 'comparison_button' => ! empty( $meta['comparison_button'] ), |
| 268 | 256 | 'quick_view_button' => ! empty( $meta['quick_view_button'] ), |
| @@ -267,20 +255,20 @@ | ||
| 267 | 255 | 'comparison_button' => ! empty( $meta['comparison_button'] ), |
| 268 | 256 | 'quick_view_button' => ! empty( $meta['quick_view_button'] ), |
| 269 | 257 | 'show_rating' => ! empty( $meta['show_rating'] ), |
| 270 | 258 | 'show_pagination' => ! empty( $meta['show_pagination'] ), |
| 271 | - 'cart_icon' => self::get_data( $meta, 'cart_icon', [] ), | |
| 272 | - 'wishlist_icon' => self::get_data( $meta, 'wishlist_icon', [] ), | |
| 273 | - 'wishlist_icon_added' => self::get_data( $meta, 'wishlist_icon_added', [] ), | |
| 274 | - 'comparison_icon' => self::get_data( $meta, 'comparison_icon', [] ), | |
| 275 | - 'comparison_icon_added' => self::get_data( $meta, 'comparison_icon_added', [] ), | |
| 276 | - 'quick_view_icon' => self::get_data( $meta, 'quick_view_icon', [] ), | |
| 277 | - 'prev_icon' => self::get_data( $meta, 'prev_icon', [] ), | |
| 278 | - 'next_icon' => self::get_data( $meta, 'next_icon', [] ), | |
| 279 | - 'posts_per_page' => self::get_products_per_page(), | |
| 280 | - 'rtsb_order' => self::get_data( $meta, 'rtsb_order', 'ASC' ), | |
| 281 | - 'rtsb_orderby' => self::get_data( $meta, 'rtsb_orderby', 'menu_order' ), | |
| 282 | - 'tooltip_position' => self::get_data( $meta, 'action_btn_tooltip_position', 'top' ), | |
| 259 | + 'cart_icon' => ! empty( $meta['cart_icon'] ) ? $meta['cart_icon'] : [], | |
| 260 | + 'wishlist_icon' => ! empty( $meta['wishlist_icon'] ) ? $meta['wishlist_icon'] : [], | |
| 261 | + 'wishlist_icon_added' => ! empty( $meta['wishlist_icon_added'] ) ? $meta['wishlist_icon_added'] : [], | |
| 262 | + 'comparison_icon' => ! empty( $meta['comparison_icon'] ) ? $meta['comparison_icon'] : [], | |
| 263 | + 'comparison_icon_added' => ! empty( $meta['comparison_icon_added'] ) ? $meta['comparison_icon_added'] : [], | |
| 264 | + 'quick_view_icon' => ! empty( $meta['quick_view_icon'] ) ? $meta['quick_view_icon'] : [], | |
| 265 | + 'prev_icon' => ! empty( $meta['prev_icon'] ) ? $meta['prev_icon'] : [], | |
| 266 | + 'next_icon' => ! empty( $meta['next_icon'] ) ? $meta['next_icon'] : [], | |
| 267 | + 'posts_per_page' => ! empty( $products_per_page ) ? $products_per_page : 12, | |
| 268 | + 'rtsb_order' => ! empty( $meta['rtsb_order'] ) ? $meta['rtsb_order'] : 'ASC', | |
| 269 | + 'rtsb_orderby' => ! empty( $meta['rtsb_orderby'] ) ? $meta['rtsb_orderby'] : 'menu_order', | |
| 270 | + 'tooltip_position' => ! empty( $meta['action_btn_tooltip_position'] ) ? $meta['action_btn_tooltip_position'] : 'top', | |
| 283 | 271 | ], |
| 284 | 272 | $meta |
| 285 | 273 | ); |
| 286 | 274 | |
| @@ -411,23 +399,11 @@ | ||
| 411 | 399 | |
| 412 | 400 | case 'list-layout1': |
| 413 | 401 | case 'list-layout2': |
| 414 | 402 | case 'list-layout3': |
| 415 | - case 'list-layout5': | |
| 416 | 403 | $columns = 1; |
| 417 | 404 | break; |
| 418 | 405 | |
| 419 | - case 'list-layout4': | |
| 420 | - case 'list-layout6': | |
| 421 | - case 'slider-layout5': | |
| 422 | - case 'slider-layout8': | |
| 423 | - $columns = 2; | |
| 424 | - break; | |
| 425 | - | |
| 426 | - case 'grid-layout6': | |
| 427 | - $columns = 5; | |
| 428 | - break; | |
| 429 | - | |
| 430 | 406 | case 'category-layout1': |
| 431 | 407 | $columns = 6; |
| 432 | 408 | break; |
| 433 | 409 | |
| @@ -435,9 +411,9 @@ | ||
| 435 | 411 | $columns = 4; |
| 436 | 412 | break; |
| 437 | 413 | } |
| 438 | 414 | |
| 439 | - return apply_filters( 'rtsb/element/general/default_columns', $columns, $layout ); | |
| 415 | + return $columns; | |
| 440 | 416 | } |
| 441 | 417 | |
| 442 | 418 | /** |
| 443 | 419 | * Pagination JSON data. |
| @@ -449,142 +425,12 @@ | ||
| 449 | 425 | */ |
| 450 | 426 | public static function pagination_data( $metas, $template ) { |
| 451 | 427 | $el_data = self::meta_dataset( $metas, $template ); |
| 452 | 428 | |
| 453 | - return esc_js( wp_json_encode( $el_data ) ); | |
| 429 | + return ' data-rtsb-ajax=\'' . esc_js( wp_json_encode( $el_data ) ) . '\''; | |
| 454 | 430 | } |
| 455 | 431 | |
| 456 | 432 | /** |
| 457 | - * Container classes | |
| 458 | - * | |
| 459 | - * @param array $metas Meta data. | |
| 460 | - * @param array $settings Settings array. | |
| 461 | - * @param string $custom_class Custom class. | |
| 462 | - * | |
| 463 | - * @return mixed|null | |
| 464 | - */ | |
| 465 | - public static function prepare_container_classes( $metas = [], $settings = [], $custom_class = '' ) { | |
| 466 | - $classes = 'rtsb-elementor-container products rtsb-pos-r '; | |
| 467 | - $classes .= $custom_class; | |
| 468 | - | |
| 469 | - $layout = $metas['layout']; | |
| 470 | - $is_cat = preg_match( '/category/', $layout ); | |
| 471 | - $cart_txt_class = ''; | |
| 472 | - | |
| 473 | - $animation = $metas['hover_animation']; | |
| 474 | - | |
| 475 | - if ( ! $is_cat ) { | |
| 476 | - $cart_txt_class = $metas['show_cart_text'] ? ' has-cart-text' : ' no-cart-text'; | |
| 477 | - $animation .= ' gallery-hover-' . ( ! empty( $settings['gallery_hover_animation'] ) ? $settings['gallery_hover_animation'] : 'fade' ); | |
| 478 | - } | |
| 479 | - | |
| 480 | - $badge_class = [ | |
| 481 | - 'position' => $metas['badge_position'], | |
| 482 | - 'alignment' => $metas['badge_alignment'], | |
| 483 | - ]; | |
| 484 | - | |
| 485 | - if ( ! in_array( 'clear-btn', $metas['visibility'], true ) ) { | |
| 486 | - $classes .= ' no-clear-btn'; | |
| 487 | - } | |
| 488 | - | |
| 489 | - $classes .= ! empty( $metas['pagination'] ) ? ' rtsb-has-pagination' : ' rtsb-no-pagination'; | |
| 490 | - $classes .= ' badge-' . esc_attr( $badge_class['position'] ) . ' badge-' . esc_attr( $badge_class['alignment'] ) . esc_attr( $cart_txt_class ) . ' img-hover-' . esc_attr( $animation ) . ' excerpt-' . esc_attr( $metas['cat_excerpt_position'] ); | |
| 491 | - | |
| 492 | - if ( $metas['show_overlay'] ) { | |
| 493 | - $classes .= ' has-overlay'; | |
| 494 | - } | |
| 495 | - | |
| 496 | - if ( in_array( 'single-cat', $metas['visibility'], true ) ) { | |
| 497 | - $classes .= ' show-single-cat'; | |
| 498 | - } | |
| 499 | - | |
| 500 | - if ( ! $is_cat ) { | |
| 501 | - $action_btn_classes = [ | |
| 502 | - 'show_compare_text' => 'has-compare-text', | |
| 503 | - 'show_quick_view_text' => 'has-quick-view-text', | |
| 504 | - 'show_wishlist_text' => 'has-wishlist-text', | |
| 505 | - 'show_compare_icon' => 'no-compare-icon', | |
| 506 | - 'show_quick_view_icon' => 'no-quick-view-icon', | |
| 507 | - 'show_wishlist_icon' => 'no-wishlist-icon', | |
| 508 | - 'show_quick_checkout_icon' => 'no-quick_checkout-icon', | |
| 509 | - ]; | |
| 510 | - | |
| 511 | - foreach ( $action_btn_classes as $setting_key => $class ) { | |
| 512 | - if ( strpos( $setting_key, 'icon' ) !== false ) { | |
| 513 | - $classes .= empty( $settings[ $setting_key ] ) ? ' ' . $class : ''; | |
| 514 | - } else { | |
| 515 | - $classes .= ! empty( $settings[ $setting_key ] ) ? ' ' . $class : ''; | |
| 516 | - } | |
| 517 | - } | |
| 518 | - | |
| 519 | - if ( rtsb()->has_pro() && ! empty( $settings['custom_ordering'] ) ) { | |
| 520 | - $classes .= ' has-custom-ordering'; | |
| 521 | - } | |
| 522 | - } | |
| 523 | - | |
| 524 | - return apply_filters( 'rtsb/product/container/class', $classes, $settings ); | |
| 525 | - } | |
| 526 | - | |
| 527 | - /** | |
| 528 | - * Row classes | |
| 529 | - * | |
| 530 | - * @param array $settings Settings array. | |
| 531 | - * | |
| 532 | - * @return mixed|null | |
| 533 | - */ | |
| 534 | - public static function prepare_row_classes( $settings = [] ) { | |
| 535 | - $masonry_class = null; | |
| 536 | - $classes = 'rtsb-row rtsb-content-loader element-loading'; | |
| 537 | - $loader_class = ' rtsb-pre-loader'; | |
| 538 | - | |
| 539 | - $layout = $settings['layout']; | |
| 540 | - $grid_type = $settings['grid_type']; | |
| 541 | - $is_carousel = preg_match( '/slider/', $layout ); | |
| 542 | - | |
| 543 | - if ( 'even' === $grid_type ) { | |
| 544 | - $masonry_class = ' rtsb-even'; | |
| 545 | - } elseif ( 'masonry' === $grid_type ) { | |
| 546 | - $masonry_class = ' rtsb-masonry'; | |
| 547 | - } | |
| 548 | - | |
| 549 | - if ( ! rtsb()->has_pro() || $is_carousel ) { | |
| 550 | - $masonry_class = ' rtsb-even'; | |
| 551 | - } | |
| 552 | - | |
| 553 | - $classes .= ' rtsb-' . $layout . $masonry_class . $loader_class; | |
| 554 | - | |
| 555 | - return apply_filters( 'rtsb/elementor/row/classes', $classes, $settings ); | |
| 556 | - } | |
| 557 | - | |
| 558 | - /** | |
| 559 | - * Prepare pagination attributes. | |
| 560 | - * | |
| 561 | - * @param string $layout The layout type. | |
| 562 | - * @param bool $has_filters Whether the widget has filters. | |
| 563 | - * @param string $template The template name. | |
| 564 | - * @param array $settings The widget settings. | |
| 565 | - * @param bool $ajax Whether to enable AJAX pagination. | |
| 566 | - * | |
| 567 | - * @return string | |
| 568 | - */ | |
| 569 | - public static function prepare_pagination_attr( $layout, $has_filters, $template, $settings, $ajax ) { | |
| 570 | - $is_cat = preg_match( '/category/', $layout ); | |
| 571 | - $is_carousel = preg_match( '/slider/', $layout ); | |
| 572 | - | |
| 573 | - if ( $is_carousel ) { | |
| 574 | - return $has_filters ? self::pagination_data( $settings, $template ) : ''; | |
| 575 | - } elseif ( $is_cat ) { | |
| 576 | - return ''; | |
| 577 | - } else { | |
| 578 | - $ajax_pagination = ! empty( $settings['show_pagination'] ) && 'pagination' !== $settings['pagination_type']; | |
| 579 | - $page = Fns::product_filters_has_ajax( 'shop' ) || Fns::product_filters_has_ajax( 'archive' ); | |
| 580 | - $condition = rtsb()->has_pro() && $ajax && ( $ajax_pagination || $has_filters || $page ); | |
| 581 | - | |
| 582 | - return $condition ? self::pagination_data( $settings, $template ) : ''; | |
| 583 | - } | |
| 584 | - } | |
| 585 | - | |
| 586 | - /** | |
| 587 | 433 | * Archive JSON data. |
| 588 | 434 | * |
| 589 | 435 | * @param array $metas Data set. |
| 590 | 436 | * @param string $template Template name. |
| @@ -613,26 +459,26 @@ | ||
| 613 | 459 | $m_col = 0 === $meta['m_cols'] ? 1 : $meta['m_cols']; |
| 614 | 460 | |
| 615 | 461 | if ( \Elementor\Plugin::$instance->breakpoints->has_custom_breakpoints() ) { |
| 616 | 462 | // Widescreen. |
| 617 | - $w_col = self::get_data( $settings, 'cols_widescreen' ); | |
| 463 | + $w_col = ! empty( $settings['cols_widescreen'] ) ? $settings['cols_widescreen'] : null; | |
| 618 | 464 | $w_col = 0 === $w_col ? self::default_columns( $meta['layout'] ) : $w_col; |
| 619 | - $w_group = self::get_data( $settings, 'cols_group_widescreen', 1 ); | |
| 465 | + $w_group = ! empty( $settings['cols_group_widescreen'] ) ? $settings['cols_group_widescreen'] : 1; | |
| 620 | 466 | |
| 621 | 467 | // Laptop. |
| 622 | - $l_col = self::get_data( $settings, 'cols_laptop' ); | |
| 468 | + $l_col = ! empty( $settings['cols_laptop'] ) ? $settings['cols_laptop'] : null; | |
| 623 | 469 | $l_col = 0 === $l_col ? self::default_columns( $meta['layout'] ) : $l_col; |
| 624 | - $l_group = self::get_data( $settings, 'cols_group_laptop', 1 ); | |
| 470 | + $l_group = ! empty( $settings['cols_group_laptop'] ) ? $settings['cols_group_laptop'] : 1; | |
| 625 | 471 | |
| 626 | 472 | // Tablet Landscape. |
| 627 | - $te_col = self::get_data( $settings, 'cols_tablet_extra' ); | |
| 473 | + $te_col = ! empty( $settings['cols_tablet_extra'] ) ? $settings['cols_tablet_extra'] : null; | |
| 628 | 474 | $te_col = 0 === $te_col ? 3 : $te_col; |
| 629 | - $te_group = self::get_data( $settings, 'cols_group_tablet_extra', 1 ); | |
| 475 | + $te_group = ! empty( $settings['cols_group_tablet_extra'] ) ? $settings['cols_group_tablet_extra'] : 1; | |
| 630 | 476 | |
| 631 | 477 | // Mobile Landscape. |
| 632 | - $me_col = self::get_data( $settings, 'cols_mobile_extra' ); | |
| 478 | + $me_col = ! empty( $settings['cols_mobile_extra'] ) ? $settings['cols_mobile_extra'] : null; | |
| 633 | 479 | $me_col = 0 === $me_col ? 2 : $me_col; |
| 634 | - $me_group = self::get_data( $settings, 'cols_group_mobile_extra', 1 ); | |
| 480 | + $me_group = ! empty( $settings['cols_group_mobile_extra'] ) ? $settings['cols_group_mobile_extra'] : 1; | |
| 635 | 481 | |
| 636 | 482 | $el_breakpoints = Fns::get_elementor_breakpoints(); |
| 637 | 483 | |
| 638 | 484 | foreach ( $el_breakpoints as $key => $value ) { |
| @@ -794,18 +640,72 @@ | ||
| 794 | 640 | 'disableOnInteraction' => false, |
| 795 | 641 | ]; |
| 796 | 642 | } |
| 797 | 643 | |
| 798 | - $slider_options = apply_filters( 'rtsb/elementor/render/slider_dataset', $slider_options, $meta ); | |
| 799 | - $carouselClass = 'rtsb-carousel-slider slider-loading rtsb-pos-s ' . $meta['nav_position'] . '-nav' . $has_dots; | |
| 644 | + $carouselClass = 'rtsb-carousel-slider slider-loading rtsb-pos-s ' . $meta['nav_position'] . '-nav' . $has_dots; | |
| 800 | 645 | |
| 801 | 646 | return [ |
| 802 | - 'data' => esc_js( wp_json_encode( $slider_options ) ), | |
| 647 | + 'data' => ' data-options=\'' . esc_js( wp_json_encode( $slider_options ) ) . '\'', | |
| 803 | 648 | 'class' => $carouselClass, |
| 804 | 649 | ]; |
| 805 | 650 | } |
| 806 | 651 | |
| 807 | 652 | /** |
| 653 | + * Renders pagination | |
| 654 | + * | |
| 655 | + * @param object $wp_query WP_Query object. | |
| 656 | + * @param array $meta Meta values. | |
| 657 | + * @param int $limit Post limit. | |
| 658 | + * @param int $per_page Posts per page. | |
| 659 | + * | |
| 660 | + * @return string | |
| 661 | + */ | |
| 662 | + public static function render_pagination( $wp_query, $meta, $limit, $per_page ) { | |
| 663 | + $html_utility = null; | |
| 664 | + $html = null; | |
| 665 | + $ajax = false; | |
| 666 | + $is_grid = preg_match( '/grid-layout/', $meta['layout'] ) || preg_match( '/list-layout/', $meta['layout'] ); | |
| 667 | + $posts_per_page = $wp_query->query_vars['posts_per_page']; | |
| 668 | + $total_page = $wp_query->max_num_pages; | |
| 669 | + | |
| 670 | + if ( $limit && ( empty( $wp_query->query['tax_query'] ) ) ) { | |
| 671 | + $found_post = $wp_query->found_posts; | |
| 672 | + | |
| 673 | + if ( $per_page && $found_post > $per_page ) { | |
| 674 | + $found_post = $limit; | |
| 675 | + $total_page = ceil( $found_post / $per_page ); | |
| 676 | + } | |
| 677 | + } | |
| 678 | + | |
| 679 | + $total_page = absint( $total_page ); | |
| 680 | + | |
| 681 | + $args = [ | |
| 682 | + 'total_page' => $total_page, | |
| 683 | + 'posts_per_page' => $posts_per_page, | |
| 684 | + 'ajax' => $ajax, | |
| 685 | + ]; | |
| 686 | + | |
| 687 | + if ( 'pagination' === $meta['posts_loading_type'] ) { | |
| 688 | + if ( $is_grid ) { | |
| 689 | + $html_utility .= Fns::custom_pagination( | |
| 690 | + $total_page, | |
| 691 | + $posts_per_page | |
| 692 | + ); | |
| 693 | + } | |
| 694 | + } else { | |
| 695 | + ob_start(); | |
| 696 | + do_action( 'rtsb/elementor/render/pagination', $meta, $wp_query, $args ); | |
| 697 | + $html_utility .= ob_get_clean(); | |
| 698 | + } | |
| 699 | + | |
| 700 | + if ( $html_utility ) { | |
| 701 | + $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>'; | |
| 702 | + } | |
| 703 | + | |
| 704 | + return $html; | |
| 705 | + } | |
| 706 | + | |
| 707 | + /** | |
| 808 | 708 | * Preloader. |
| 809 | 709 | * |
| 810 | 710 | * @param string $layout Layout. |
| 811 | 711 | * |
| @@ -885,11 +785,9 @@ | ||
| 885 | 785 | |
| 886 | 786 | $script[] = 'rtsb-imagesloaded'; |
| 887 | 787 | $script[] = 'rtsb-public'; |
| 888 | 788 | |
| 889 | - foreach ( $script as $sc ) { | |
| 890 | - wp_enqueue_script( $sc ); | |
| 891 | - } | |
| 789 | + wp_enqueue_script( $script ); | |
| 892 | 790 | } |
| 893 | 791 | } |
| 894 | 792 | |
| 895 | 793 | /** |
| @@ -915,19 +813,6 @@ | ||
| 915 | 813 | return true; |
| 916 | 814 | } |
| 917 | 815 | |
| 918 | 816 | return false; |
| 919 | - } | |
| 920 | - | |
| 921 | - /** | |
| 922 | - * Get the number of products per page based on WooCommerce settings. | |
| 923 | - * | |
| 924 | - * @return int | |
| 925 | - */ | |
| 926 | - public static function get_products_per_page() { | |
| 927 | - $products_row = absint( get_option( 'woocommerce_catalog_rows', 4 ) ); | |
| 928 | - $products_col = absint( get_option( 'woocommerce_catalog_columns', 4 ) ); | |
| 929 | - $products_per_page = apply_filters( 'rtsb/elementor/archive/products_per_page', $products_row * $products_col ); | |
| 930 | - | |
| 931 | - return ! empty( $products_per_page ) ? $products_per_page : 12; | |
| 932 | 817 | } |
| 933 | 818 | } |