PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / single-product / sharing / config.php
shop-press / Elementor / widgets / single-product / sharing Last commit date
config.php 2 years ago
config.php
206 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets;
3
4 defined( 'ABSPATH' ) || exit;
5
6 use Elementor\Controls_Manager;
7 use Elementor\Repeater;
8 use ShopPress\Elementor\ShopPressWidgets;
9
10 class Sharing extends ShopPressWidgets {
11
12 public function get_name() {
13 return 'sp-sharing';
14 }
15
16 public function get_title() {
17 return __( 'Product Sharing', 'shop-press' );
18 }
19
20 public function get_icon() {
21 return 'sp-widget sp-eicon-product-sharing';
22 }
23
24 public function get_categories() {
25 return array( 'sp_woo_single' );
26 }
27
28 // public function get_style_depends() {
29 // return array( 'sp-sharing' );
30 // }
31
32 // public function get_script_depends() {
33 // return array( 'sp-sharing' );
34 // }
35
36 public function setup_styling_options() {
37
38 $this->register_group_styler(
39 'wrapper',
40 __( 'Wrapper', 'shop-press' ),
41 array(
42 'wrapper' => array(
43 'label' => esc_html__( 'Wrapper', 'shop-press' ),
44 'type' => 'styler',
45 'selector' => '.sp-sharing',
46 'wrapper' => '{{WRAPPER}}',
47 ),
48 )
49 );
50
51 $this->register_group_styler(
52 'socials',
53 __( 'Socials', 'shop-press' ),
54 array(
55 'link_container' => array(
56 'label' => esc_html__( 'Social Container', 'shop-press' ),
57 'type' => 'styler',
58 'selector' => '.sp-sharing-button',
59 'wrapper' => '{{WRAPPER}} .sp-sharing',
60 ),
61 'link' => array(
62 'label' => esc_html__( 'Share Icon Label', 'shop-press' ),
63 'type' => 'styler',
64 'selector' => 'span.sp-sharing-label',
65 'wrapper' => '{{WRAPPER}} .sp-sharing .sp-sharing-button',
66 ),
67 'link_icon' => array(
68 'label' => esc_html__( 'Share Icon', 'shop-press' ),
69 'type' => 'styler',
70 'selector' => 'path',
71 'wrapper' => '{{WRAPPER}} .sp-sharing .sp-sharing-button .sp-sharing-icon',
72 ),
73 'items_wrapper' => array(
74 'label' => esc_html__( 'Sharing Items Wrapper', 'shop-press' ),
75 'type' => 'styler',
76 'selector' => 'ul',
77 'wrapper' => '{{WRAPPER}} .sp-sharing',
78 ),
79 'sharing_items' => array(
80 'label' => esc_html__( 'Sharing Item', 'shop-press' ),
81 'type' => 'styler',
82 'selector' => 'li.sp-sharing-item ',
83 'wrapper' => '{{WRAPPER}} ul',
84 ),
85 'item_text' => array(
86 'label' => esc_html__( 'Item Title', 'shop-press' ),
87 'type' => 'styler',
88 'selector' => 'a',
89 'wrapper' => '{{WRAPPER}} li.sp-sharing-item',
90 ),
91 'item_icon' => array(
92 'label' => esc_html__( 'Item Icon', 'shop-press' ),
93 'type' => 'styler',
94 'selector' => 'i',
95 'wrapper' => '{{WRAPPER}} li.sp-sharing-item a',
96 ),
97 )
98 );
99 }
100
101 protected function register_controls() {
102 $this->start_controls_section(
103 'section_content',
104 array(
105 'label' => __( 'General', 'shop-press' ),
106 )
107 );
108
109 $this->add_control(
110 'type',
111 array(
112 'label' => __( 'Type', 'shop-press' ),
113 'type' => Controls_Manager::SELECT,
114 'options' => array(
115 'icon' => __( 'Icon', 'shop-press' ),
116 'label' => __( 'Label', 'shop-press' ),
117 'icon-label' => __( 'Icon + Label', 'shop-press' ),
118 ),
119 'default' => 'icon-label',
120 )
121 );
122
123 $this->add_control(
124 'label',
125 array(
126 'label' => __( 'Label', 'shop-press' ),
127 'type' => Controls_Manager::TEXT,
128 'default' => 'Share',
129 )
130 );
131
132 $share_url_patterns = sp_get_social_share_links();
133 $social_share_options = array_column( $share_url_patterns, 'title', 'social' );
134
135 $repeater = new Repeater();
136 $repeater->add_control(
137 'social_item',
138 array(
139 'label' => __( 'Social', 'shop-press' ),
140 'type' => Controls_Manager::SELECT,
141 'options' => $social_share_options,
142 )
143 );
144
145 $repeater->add_control(
146 'title',
147 array(
148 'label' => __( 'Title', 'shop-press' ),
149 'type' => Controls_Manager::TEXT,
150 )
151 );
152
153 $repeater->add_control(
154 'social_class',
155 array(
156 'label' => __( 'Custom Class', 'shop-press' ),
157 'type' => Controls_Manager::TEXT,
158 )
159 );
160
161 $repeater->add_control(
162 'icon',
163 array(
164 'label' => __( 'Icon', 'shop-press' ),
165 'type' => Controls_Manager::ICONS,
166 )
167 );
168
169 $this->add_control(
170 'links',
171 array(
172 'label' => __( 'List', 'shop-press' ),
173 'type' => Controls_Manager::REPEATER,
174 'fields' => $repeater->get_controls(),
175 'title_field' => '{{{ title }}}',
176 'default' => array(
177 array(
178 'social_item' => 'x',
179 'title' => 'X',
180 ),
181 ),
182 )
183 );
184
185 $this->end_controls_section();
186
187 $this->setup_styling_options();
188
189 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
190 }
191
192 protected function render() {
193 $settings = $this->get_settings_for_display();
194
195 do_action( 'shoppress/widget/before_render', $settings );
196
197 $args = array(
198 'type' => $settings['type'],
199 'label' => $settings['label'],
200 'links' => $settings['links'],
201 );
202
203 sp_load_builder_template( 'single-product/product-sharing', $args );
204 }
205 }
206