PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.8.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.8.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.8.0, at classes/elementor/widgets/deal/widget.php

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