PluginProbe
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code / 3.1.0
Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code v3.1.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 / email-sample / widget.php

widget.php in Copy Anything to Clipboard for WordPress – Copy Button, Copy Text & Copy Code 3.1.0, at classes/elementor/widgets/email-sample/widget.php

255 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Elementor Email Sample Block
5 *
6 * @package Copy the Code
7 * @since 3.1.0
8 */
9 namespace CopyTheCode\Elementor\Block\Email;
10
11 use CopyTheCode\Helpers ;
12 use Elementor\Widget_Base ;
13 use Elementor\Controls_Manager ;
14 /**
15 * Email Sample Block
16 *
17 * @since 3.1.0
18 */
19 class Sample 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 // Core.
33 wp_enqueue_style(
34 'ctc-blocks-core',
35 COPY_THE_CODE_URI . 'classes/blocks/assets/css/style.css',
36 [],
37 COPY_THE_CODE_VER,
38 'all'
39 );
40 wp_enqueue_script(
41 'ctc-clipboard',
42 COPY_THE_CODE_URI . 'assets/js/clipboard.js',
43 [ 'jquery' ],
44 COPY_THE_CODE_VER,
45 true
46 );
47 wp_enqueue_script(
48 'ctc-blocks-core',
49 COPY_THE_CODE_URI . 'classes/blocks/assets/js/core.js',
50 [ 'ctc-clipboard' ],
51 COPY_THE_CODE_VER,
52 true
53 );
54 // Block.
55 wp_enqueue_style(
56 'ctc-el-email-sample',
57 COPY_THE_CODE_URI . 'classes/elementor/widgets/email-sample/style.css',
58 [ 'ctc-blocks-core' ],
59 COPY_THE_CODE_VER,
60 'all'
61 );
62 }
63
64 /**
65 * Get script dependencies
66 */
67 public function get_script_depends()
68 {
69 return [ 'ctc-el-email-sample' ];
70 }
71
72 /**
73 * Get style dependencies
74 */
75 public function get_style_depends()
76 {
77 return [ 'ctc-blocks-core' ];
78 }
79
80 /**
81 * Get name
82 */
83 public function get_name()
84 {
85 return 'ctc_copy_email_sample';
86 }
87
88 /**
89 * Get title
90 */
91 public function get_title()
92 {
93 return esc_html__( 'Email Sample', 'copy-the-code' );
94 }
95
96 /**
97 * Get icon
98 */
99 public function get_icon()
100 {
101 return 'eicon-email-field';
102 }
103
104 /**
105 * Get categories
106 */
107 public function get_categories()
108 {
109 return [ 'basic' ];
110 }
111
112 /**
113 * Get keywords
114 */
115 public function get_keywords()
116 {
117 return [
118 'email',
119 'copy',
120 'content',
121 'template'
122 ];
123 }
124
125 /**
126 * Render
127 */
128 public function render()
129 {
130 $sample_email = $this->get_settings_for_display( 'sample_email' );
131 $copy_button_text = $this->get_settings_for_display( 'copy_button_text' );
132 $copy_button_text_copied = $this->get_settings_for_display( 'copy_button_text_copied' );
133 $show_icon = $this->get_settings_for_display( 'show_icon' );
134 $icon_direction = $this->get_settings_for_display( 'icon_direction' );
135 if ( empty($sample_email) ) {
136 return;
137 }
138 $display_content = preg_replace( '/\\[([^\\]]*)\\]/', '<span class="ctc-email-highlight">[$1]</span>', $sample_email );
139 $display_content = wpautop( $display_content );
140 $with_icon = ( 'yes' === $this->get_settings_for_display( 'show_icon' ) ? 'with-icon' : '' );
141 ?>
142 <div class="ctc-block ctc-email-sample">
143 <div class="ctc-block-content">
144 <?php
145 echo wp_kses_post( $display_content ) ;
146 ?>
147 </div>
148 <div class="ctc-block-actions">
149 <?php
150 echo Helpers::get_copy_button( [
151 'as_raw' => 'yes',
152 'copy_button_text' => $copy_button_text,
153 'copy_button_text_copied' => $copy_button_text_copied,
154 'icon_direction' => $icon_direction,
155 'show_icon' => $show_icon,
156 ] ) ;
157 ?>
158 </div>
159 <textarea class="ctc-copy-content" style="display: none;"><?php
160 echo esc_html( $sample_email ) ;
161 ?></textarea>
162 </div>
163 <?php
164 }
165
166 /**
167 * Register controls
168 */
169 protected function _register_controls()
170 {
171 /**
172 * Group: Email Section
173 */
174 $this->start_controls_section( 'email_section', [
175 'label' => esc_html__( 'Email Sample', 'copy-the-code' ),
176 ] );
177 $this->add_control( 'sample_email', [
178 'label' => esc_html__( 'Email Sample', 'copy-the-code' ),
179 'type' => Controls_Manager::TEXTAREA,
180 'default' => "Subject: Application for [Job Title] - [Your Name]\r\n\r\nDear [Hiring Manager's Name],\r\n\r\nI hope this email finds you well. I am writing to express my strong interest in the [Job Title] position at [Company Name], as advertised on your website. With my background in [Relevant Skill/Experience] and a passion for [Company's Mission or Industry], I believe I am a strong fit for your team.\r\n\r\nSincerely,\r\n[Your Name]\r\n[Your Contact Information]",
181 'rows' => 10,
182 'description' => esc_html__( 'Use [ ] to highlight the text.', 'copy-the-code' ),
183 ] );
184 $this->end_controls_section();
185 $this->button();
186 }
187
188 /**
189 * Button
190 */
191 protected function button()
192 {
193 /**
194 * Group - Button
195 */
196 $this->start_controls_section( 'copy_button_section', [
197 'label' => esc_html__( 'Button', 'copy-the-code' ),
198 ] );
199 $this->add_control( 'copy_button_text', [
200 'label' => esc_html__( 'Button Text', 'copy-the-code' ),
201 'type' => Controls_Manager::TEXT,
202 'default' => esc_html__( 'Copy to Clipboard', 'copy-the-code' ),
203 ] );
204 $this->add_control( 'copy_button_text_copied', [
205 'label' => esc_html__( 'Button Text (After Copied)', 'copy-the-code' ),
206 'type' => Controls_Manager::TEXT,
207 'default' => esc_html__( 'Copied to Clipboard', 'copy-the-code' ),
208 ] );
209 // Show Icon.
210 $this->add_control( 'show_icon', [
211 'label' => esc_html__( 'Show Icon', 'copy-the-code' ),
212 'type' => Controls_Manager::SWITCHER,
213 'label_on' => esc_html__( 'Show', 'copy-the-code' ),
214 'label_off' => esc_html__( 'Hide', 'copy-the-code' ),
215 'return_value' => 'yes',
216 'default' => 'yes',
217 ] );
218 $this->add_control( 'icon_direction', [
219 'label' => esc_html__( 'Icon Direction', 'copy-the-code' ),
220 'type' => Controls_Manager::SELECT,
221 'default' => 'before',
222 'options' => [
223 'before' => esc_html__( 'Before', 'copy-the-code' ),
224 'after' => esc_html__( 'After', 'copy-the-code' ),
225 ],
226 'condition' => [
227 'show_icon' => 'yes',
228 ],
229 ] );
230 $this->add_responsive_control( 'icon_text_gap', [
231 'label' => esc_html__( 'Icon and Text Gap', 'copy-the-code' ),
232 'type' => Controls_Manager::SLIDER,
233 'size_units' => [ 'px', 'em' ],
234 'range' => [
235 'px' => [
236 'min' => 0,
237 'max' => 100,
238 ],
239 'em' => [
240 'min' => 0,
241 'max' => 10,
242 ],
243 ],
244 'selectors' => [
245 '{{WRAPPER}} .ctc-with-icon' => 'gap: {{SIZE}}{{UNIT}};',
246 ],
247 'condition' => [
248 'show_icon' => 'yes',
249 ],
250 ] );
251 $this->end_controls_section();
252 // Group - Button End.
253 }
254
255 }