PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / widgets / loop / sale-flash / config.php
shop-press / Elementor / widgets / loop / sale-flash Last commit date
config.php 2 years ago
config.php
150 lines
1 <?php
2 namespace ShopPress\Elementor\Widgets\LoopBuilder;
3
4 use ShopPress\Elementor\ShopPressWidgets;
5 use Elementor\Controls_Manager;
6
7 defined( 'ABSPATH' ) || exit;
8
9 class OnSale extends ShopPressWidgets {
10
11 public function get_name() {
12 return 'sp-onsale';
13 }
14
15 public function get_title() {
16 return __( 'Product Sale', 'shop-press' );
17 }
18
19 public function get_icon() {
20 return 'sp-widget sp-eicon-sale-badge';
21 }
22
23 public function get_categories() {
24 return array( 'sp_woo_loop' );
25 }
26
27 public function setup_styling_options() {
28 $this->register_group_styler(
29 'wrapper',
30 __( 'Wrapper', 'shop-press' ),
31 array(
32 'wrapper' => array(
33 'label' => esc_html__( 'Wrapper', 'shop-press' ),
34 'type' => 'styler',
35 'selector' => '.sp-onsale',
36 'wrapper' => '{{WRAPPER}}',
37 ),
38 )
39 );
40
41 $this->register_group_styler(
42 'label',
43 __( 'Label', 'shop-press' ),
44 array(
45 'label' => array(
46 'label' => esc_html__( 'Label', 'shop-press' ),
47 'type' => 'styler',
48 'selector' => 'span.onsale',
49 'wrapper' => '{{WRAPPER}} .sp-onsale',
50 ),
51 )
52 );
53
54 $this->register_group_styler(
55 'icon',
56 __( 'Icon', 'shop-press' ),
57 array(
58 'icon' => array(
59 'label' => esc_html__( 'Icon', 'shop-press' ),
60 'type' => 'styler',
61 'selector' => '.sp-icon',
62 'wrapper' => '{{WRAPPER}} .sp-onsale',
63 ),
64 )
65 );
66 }
67 protected function register_controls() {
68 $this->start_controls_section(
69 'section_content',
70 array(
71 'label' => __( 'General', 'shop-press' ),
72 )
73 );
74 $this->add_control(
75 'label',
76 array(
77 'label' => __( 'Label.', 'shop-press' ),
78 'type' => Controls_Manager::TEXT,
79 'default' => __( 'Sale!', 'shop-press' ),
80 'separator' => 'before',
81 )
82 );
83 $this->add_control(
84 'cart_icon',
85 array(
86 'label' => __( 'Icon', 'shop-press' ),
87 'type' => Controls_Manager::ICONS,
88 'fa4compatibility' => 'icon',
89 )
90 );
91
92 $this->add_control(
93 'cart_icon_pos',
94 array(
95 'label' => __( 'Icon Position', 'shop-press' ),
96 'type' => Controls_Manager::SELECT,
97 'default' => 'after',
98 'options' => array(
99 'before' => __( 'Before', 'shop-press' ),
100 'after' => __( 'After', 'shop-press' ),
101 ),
102 )
103 );
104 $this->end_controls_section();
105
106 $this->setup_styling_options();
107
108 do_action( 'shoppress/elementor/widget/register_controls_init', $this );
109 }
110
111 protected function render() {
112 $settings = $this->get_settings_for_display();
113
114 do_action( 'shoppress/widget/before_render', $settings );
115
116 $args = array(
117 'label' => $settings['label'],
118 'cart_icon' => $settings['cart_icon'],
119 'cart_icon_pos' => $settings['cart_icon_pos'],
120 );
121
122 if ( $this->editor_preview() ) {
123 sp_load_builder_template( 'loop/loop-sale-flash', $args );
124 }
125 }
126
127 protected function content_template() {
128 ?>
129 <#
130 var iconHTML = elementor.helpers.renderIcon( view, settings.cart_icon, { 'aria-hidden': true }, 'i' , 'object' );
131 var render_icon;
132 var icon_pos = settings.cart_icon_pos;
133 var label = settings.label;
134 var icon = iconHTML.value ?? '';
135
136 if ( 'before' === icon_pos ) {
137 render_icon = icon + label;
138 }
139
140 if ( 'after' === icon_pos ) {
141 render_icon = label + icon;
142 }
143 #>
144 <div class="sp-onsale">
145 <span class="onsale">{{{ render_icon }}}</span>
146 </div>
147 <?php
148 }
149 }
150