PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.4.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.4.0
5.5.3 3.1.0 3.2.0 3.2.1 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.6.0 3.7.0 3.8.0 3.8.1 3.8.2 3.8.3 4.0.0 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 All 78 releases
copy-the-code / classes / elementor / widgets / deal / widget.php

widget.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 3.4.0, at classes/elementor/widgets/deal/widget.php

280 lines 8.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Elementor Deal Block
5 *
6 * @package Copy the Code
7 * @since 3.1.0
8 */
9 namespace CopyTheCode\Elementor\Block;
10
11 use CopyTheCode\Helpers ;
12 use Elementor\Widget_Base ;
13 use Elementor\Controls_Manager ;
14 /**
15 * Deal Block
16 *
17 * @since 3.1.0
18 */
19 class Deal extends Widget_Base
20 {
21 /**
22 * Constructor
23 *
24 * @param array $data
25 * @param array $args
26 *
27 * @since 3.1.0
28 */
29 public function __construct( $data = array(), $args = null )
30 {
31 parent::__construct( $data, $args );
32 // Block.
33 wp_enqueue_style(
34 'ctc-el-deal',
35 COPY_THE_CODE_URI . 'classes/elementor/widgets/deal/style.css',
36 [],
37 COPY_THE_CODE_VER,
38 'all'
39 );
40 wp_enqueue_script(
41 'ctc-el-deal',
42 COPY_THE_CODE_URI . 'classes/elementor/widgets/deal/script.js',
43 [],
44 COPY_THE_CODE_VER,
45 true
46 );
47 }
48
49 /**
50 * Get style dependencies
51 */
52 public function get_style_depends()
53 {
54 return [ 'ctc-el-deal' ];
55 }
56
57 /**
58 * Get script dependencies
59 */
60 public function get_script_depends()
61 {
62 return [ 'ctc-el-deal' ];
63 }
64
65 /**
66 * Get name
67 */
68 public function get_name()
69 {
70 return 'ctc_deal';
71 }
72
73 /**
74 * Get title
75 */
76 public function get_title()
77 {
78 return esc_html__( 'Deal', 'copy-the-code' );
79 }
80
81 /**
82 * Get icon
83 */
84 public function get_icon()
85 {
86 return 'eicon-basket-solid';
87 }
88
89 /**
90 * Get categories
91 */
92 public function get_categories()
93 {
94 return Helpers::get_categories();
95 }
96
97 /**
98 * Get keywords
99 */
100 public function get_keywords()
101 {
102 return Helpers::get_keywords( [
103 'deal',
104 'offer',
105 'coupon',
106 'sale'
107 ] );
108 }
109
110 /**
111 * Render
112 */
113 public function render()
114 {
115 $image = $this->get_settings_for_display( 'image' );
116 $heading = $this->get_settings_for_display( 'heading' );
117 $description = $this->get_settings_for_display( 'description' );
118 $button_text = $this->get_settings_for_display( 'button_text' );
119 $button_link = $this->get_settings_for_display( 'button_link' );
120 $link_target = $this->get_settings_for_display( 'link_target' );
121 $details = $this->get_settings_for_display( 'details' );
122 $toggle_details = $this->get_settings_for_display( 'toggle_details' );
123 ?>
124 <div class="ctc-block ctc-deal">
125 <div class="ctc-deal-header">
126 <?php
127
128 if ( $image['url'] ) {
129 ?>
130 <div class="ctc-deal-image">
131 <img src="<?php
132 echo esc_url( $image['url'] ) ;
133 ?>" alt="<?php
134 echo esc_attr( $heading ) ;
135 ?>">
136 </div>
137 <?php
138 }
139
140 ?>
141 <div class="ctc-deal-headings">
142 <h3 class="ctc-deal-heading"><?php
143 echo esc_html( $heading ) ;
144 ?></h3>
145
146 <?php
147
148 if ( $description ) {
149 ?>
150 <div class="ctc-deal-description"><?php
151 echo wp_kses_post( wpautop( $description ) ) ;
152 ?></div>
153 <?php
154 }
155
156 ?>
157
158 </div>
159 <div class="ctc-deal-cta">
160 <a href="<?php
161 echo esc_url( $button_link['url'] ) ;
162 ?>" target="<?php
163 echo esc_attr( $link_target ) ;
164 ?>" class="ctc-deal-link"><?php
165 echo esc_html( $button_text ) ;
166 ?></a>
167 </div>
168 </div>
169 <?php
170
171 if ( $details ) {
172 ?>
173 <div class="ctc-deal-details">
174 <?php
175 $toggle_details_class = ( 'yes' === $toggle_details ? 'ctc-toggle-details' : '' );
176 if ( 'yes' === $toggle_details ) {
177 echo '<a href="#" class="ctc-deal-toggle-link">Show Details</a>' ;
178 }
179 echo '<div class="ctc-details-content ' . $toggle_details_class . '">' . wp_kses_post( wpautop( $details ) ) . '</div>' ;
180 ?>
181 </div>
182 <?php
183 }
184
185 ?>
186 </div>
187 <?php
188 }
189
190 /**
191 * Register controls
192 */
193 protected function _register_controls()
194 {
195 $this->start_controls_section( 'image_section', [
196 'label' => esc_html__( 'Deal Image', 'copy-the-code' ),
197 ] );
198 $this->add_control( 'image', [
199 'label' => esc_html__( 'Deal Image', 'copy-the-code' ),
200 'type' => Controls_Manager::MEDIA,
201 'default' => [
202 'url' => \Elementor\Utils::get_placeholder_image_src(),
203 ],
204 ] );
205 $this->end_controls_section();
206 $this->start_controls_section( 'heading_section', [
207 'label' => esc_html__( 'Heading', 'copy-the-code' ),
208 ] );
209 $this->add_control( 'heading', [
210 'label' => esc_html__( 'Heading', 'copy-the-code' ),
211 'type' => Controls_Manager::TEXT,
212 'default' => esc_html__( 'Get up to 10% off on all products', 'copy-the-code' ),
213 ] );
214 $this->end_controls_section();
215 $this->start_controls_section( 'description_section', [
216 'label' => esc_html__( 'Short Description', 'copy-the-code' ),
217 ] );
218 $this->add_control( 'description', [
219 'label' => esc_html__( 'Short Description', 'copy-the-code' ),
220 'type' => Controls_Manager::WYSIWYG,
221 'default' => 'Get up to 50% off on all products. Offer valid till <b>31st December 2020</b>.',
222 ] );
223 $this->end_controls_section();
224 $this->start_controls_section( 'button_section', [
225 'label' => esc_html__( 'Button', 'copy-the-code' ),
226 ] );
227 // Button Text.
228 $this->add_control( 'button_text', [
229 'label' => esc_html__( 'Button Text', 'copy-the-code' ),
230 'type' => Controls_Manager::TEXT,
231 'default' => esc_html__( 'Get Deal', 'copy-the-code' ),
232 ] );
233 // Button Link.
234 $this->add_control( 'button_link', [
235 'label' => esc_html__( 'Button Link', 'copy-the-code' ),
236 'type' => Controls_Manager::URL,
237 'default' => [
238 'url' => '#',
239 ],
240 ] );
241 // Link target.
242 $this->add_control( 'link_target', [
243 'label' => esc_html__( 'Link Target', 'copy-the-code' ),
244 'type' => Controls_Manager::SELECT,
245 'default' => '_blank',
246 'options' => [
247 '_self' => esc_html__( 'Self', 'copy-the-code' ),
248 '_blank' => esc_html__( 'Blank', 'copy-the-code' ),
249 ],
250 ] );
251 $this->end_controls_section();
252 $this->start_controls_section( 'details_section', [
253 'label' => esc_html__( 'Details', 'copy-the-code' ),
254 ] );
255 // Details.
256 $this->add_control( 'details', [
257 'label' => esc_html__( 'Details', 'copy-the-code' ),
258 'type' => Controls_Manager::WYSIWYG,
259 'default' => '<ul><li>Get upto 50% off on all products.</li><li>
260 Offer valid till <b>31st December 2020</b>.</li><li>No coupon code required.</li></ul>',
261 ] );
262 // Enable Toggle Details.
263 $this->add_control( 'toggle_details', [
264 'label' => esc_html__( 'Enable Toggle Details', 'copy-the-code' ),
265 'type' => Controls_Manager::SWITCHER,
266 'default' => 'yes',
267 ] );
268 $this->end_controls_section();
269 Helpers::register_pro_sections( $this, [
270 'Header',
271 'Heading',
272 'Description',
273 'Button',
274 'Details',
275 'Details > Link',
276 'Details > Content'
277 ] );
278 }
279
280 }