PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / general / brands / config.php
shop-press / Elementor / widgets / general / brands Last commit date
config.php 1 year ago
config.php
184 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets;
3
4 defined( 'ABSPATH' ) || exit;
5
6 use ShopPress\Elementor\ShopPressWidgets;
7 use Elementor\Controls_Manager;
8 use ShopPress\Modules\VariationSwatches\Frontend;
9
10 class BrandsAttribute extends ShopPressWidgets {
11
12 public function get_name() {
13 return 'sp-brands-attribute';
14 }
15
16 public function get_title() {
17 return __( 'Brand Attributes', 'shop-press' );
18 }
19
20 public function get_icon() {
21 return 'sp-widget sp-eicon-product-brands';
22 }
23
24 public function get_style_depends() {
25 if ( is_rtl() ) {
26 return array( 'sp-brands', 'sp-brands-rtl' );
27 } else {
28 return array( 'sp-brands' );
29 }
30 }
31
32 public function get_categories() {
33 return array( 'sp_general' );
34 }
35
36 public function setup_styling_options() {
37 $this->register_group_styler(
38 'att_brand_wrapper',
39 __( 'Wrapper', 'shop-press' ),
40 array(
41 'wrapper' => array(
42 'label' => esc_html__( 'Wrapper', 'shop-press' ),
43 'type' => 'styler',
44 'selector' => '.sp-brands.sp-brands-attrs.sp-brands-grid',
45 'wrapper' => '{{WRAPPER}}',
46 ),
47 )
48 );
49 $this->register_group_styler(
50 'att_brand',
51 __( 'Brand', 'shop-press' ),
52 array(
53 'att_brand_items_wrapper' => array(
54 'label' => esc_html__( 'Items Wrapper', 'shop-press' ),
55 'type' => 'styler',
56 'selector' => '.sp-brands-items',
57 'wrapper' => '{{WRAPPER}} .sp-brands.sp-brands-attrs.sp-brands-grid',
58 ),
59 'att_brand_item' => array(
60 'label' => esc_html__( 'Item', 'shop-press' ),
61 'type' => 'styler',
62 'selector' => '.sp-brand-item',
63 'wrapper' => '{{WRAPPER}} .sp-brands.sp-brands-attrs.sp-brands-grid .sp-brands-items',
64 ),
65 'att_brand_link' => array(
66 'label' => esc_html__( 'Link', 'shop-press' ),
67 'type' => 'styler',
68 'selector' => 'a',
69 'wrapper' => '{{WRAPPER}} .sp-brands.sp-brands-attrs.sp-brands-grid .sp-brands-items .sp-brand-item',
70 ),
71 'att_brand_image_wrapper' => array(
72 'label' => esc_html__( 'Image Wrapper', 'shop-press' ),
73 'type' => 'styler',
74 'selector' => '.sp-brand-img-wrapper',
75 'wrapper' => '{{WRAPPER}} .sp-brands.sp-brands-attrs.sp-brands-grid .sp-brands-items .sp-brand-item a',
76 ),
77 'att_brand_image' => array(
78 'label' => esc_html__( 'Image', 'shop-press' ),
79 'type' => 'styler',
80 'selector' => 'img',
81 'wrapper' => '{{WRAPPER}} .sp-brands.sp-brands-attrs.sp-brands-grid .sp-brands-items .sp-brand-item a .sp-brand-img-wrapper',
82 ),
83 'att_brand_title' => array(
84 'label' => esc_html__( 'Brand Name', 'shop-press' ),
85 'type' => 'styler',
86 'selector' => '.brand-name',
87 'wrapper' => '{{WRAPPER}} .sp-brands.sp-brands-attrs.sp-brands-grid .sp-brands-items .sp-brand-item a',
88 ),
89 )
90 );
91 }
92
93 protected function register_controls() {
94 $brands = array();
95 $attributes = Frontend::get_brand_attributes( false );
96 $terms = $attributes['terms'] ?? array();
97
98 foreach ( $terms as $key => $term ) {
99 $brands[ $term->term_id ] = $term->name;
100 }
101
102 $this->start_controls_section(
103 'section_content',
104 array(
105 'label' => __( 'General', 'shop-press' ),
106 )
107 );
108
109 $this->add_control(
110 'display_name',
111 array(
112 'label' => __( 'Brand Name', 'shop-press' ),
113 'type' => Controls_Manager::SWITCHER,
114 'default' => 'false',
115 'return_value' => 'true',
116 )
117 );
118
119 $this->add_control(
120 'display_logo',
121 array(
122 'label' => __( 'Brand Logo', 'shop-press' ),
123 'type' => Controls_Manager::SWITCHER,
124 'default' => 'true',
125 'return_value' => 'true',
126 )
127 );
128
129 $this->add_control(
130 'hide_empty',
131 array(
132 'label' => __( 'Hide Empty', 'shop-press' ),
133 'type' => Controls_Manager::SWITCHER,
134 'default' => 'true',
135 'return_value' => 'true',
136 )
137 );
138
139 $this->add_control(
140 'brands',
141 array(
142 'label' => __( 'Brands', 'shop-press' ),
143 'type' => Controls_Manager::SELECT2,
144 'default' => '',
145 'multiple' => true,
146 'options' => $brands,
147 )
148 );
149
150 $this->end_controls_section();
151 $this->carousel_options();
152 $this->setup_styling_options();
153
154 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
155 }
156
157 protected function render() {
158 $settings = $this->get_settings_for_display();
159
160 do_action( 'shoppress/widget/before_render', $settings );
161
162 if ( $this->is_editor() ) {
163 echo '<script>jQuery(document).ready(function($){if (typeof sp_slider_init === "function") {sp_slider_init();}});</script>';
164 }
165
166 $args = array(
167 'display_name' => $settings['display_name'],
168 'display_logo' => $settings['display_logo'],
169 'hide_empty' => $settings['hide_empty'],
170 'brands' => $settings['brands'],
171 'carousel' => $settings['carousel'],
172 'carousel_columns' => $settings['carousel_columns'],
173 'slide_speed' => $settings['slide_speed'],
174 'show_controls' => $settings['show_controls'],
175 'autoplay' => $settings['autoplay'],
176 'autoplay_speed' => $settings['autoplay_speed'],
177 'carousel_loop' => $settings['carousel_loop'],
178 'slider_rows' => $settings['slider_rows'],
179 );
180
181 sp_load_builder_template( 'general/brands', $args );
182 }
183 }
184