| 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 |
* Constructor |
| 22 |
* |
| 23 |
* @param array $data |
| 24 |
* @param array $args |
| 25 |
* |
| 26 |
* @since 3.1.0 |
| 27 |
*/ |
| 28 |
public function __construct( $data = [], $args = null ) { |
| 29 |
parent::__construct( $data, $args ); |
| 30 |
// Core. |
| 31 |
wp_enqueue_style( |
| 32 |
'ctc-blocks-core', |
| 33 |
COPY_THE_CODE_URI . 'classes/blocks/assets/css/style.css', |
| 34 |
[], |
| 35 |
COPY_THE_CODE_VER, |
| 36 |
'all' |
| 37 |
); |
| 38 |
wp_enqueue_script( |
| 39 |
'ctc-clipboard', |
| 40 |
COPY_THE_CODE_URI . 'assets/js/clipboard.js', |
| 41 |
['jquery'], |
| 42 |
COPY_THE_CODE_VER, |
| 43 |
true |
| 44 |
); |
| 45 |
wp_enqueue_script( |
| 46 |
'ctc-blocks-core', |
| 47 |
COPY_THE_CODE_URI . 'classes/blocks/assets/js/core.js', |
| 48 |
['ctc-clipboard'], |
| 49 |
COPY_THE_CODE_VER, |
| 50 |
true |
| 51 |
); |
| 52 |
// Block. |
| 53 |
wp_enqueue_style( |
| 54 |
'ctc-el-email-sample', |
| 55 |
COPY_THE_CODE_URI . 'classes/elementor/widgets/email-sample/style.css', |
| 56 |
['ctc-blocks-core'], |
| 57 |
COPY_THE_CODE_VER, |
| 58 |
'all' |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Get script dependencies |
| 64 |
*/ |
| 65 |
public function get_script_depends() { |
| 66 |
return ['ctc-el-email-sample']; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Get style dependencies |
| 71 |
*/ |
| 72 |
public function get_style_depends() { |
| 73 |
return ['ctc-blocks-core']; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Get name |
| 78 |
*/ |
| 79 |
public function get_name() { |
| 80 |
return 'ctc_copy_email_sample'; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Get title |
| 85 |
*/ |
| 86 |
public function get_title() { |
| 87 |
return esc_html__( 'Email Sample', 'copy-the-code' ); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Get icon |
| 92 |
*/ |
| 93 |
public function get_icon() { |
| 94 |
return 'eicon-facebook-comments'; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Get categories |
| 99 |
*/ |
| 100 |
public function get_categories() { |
| 101 |
return Helpers::get_categories(); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Get keywords |
| 106 |
*/ |
| 107 |
public function get_keywords() { |
| 108 |
return Helpers::get_keywords( [ |
| 109 |
'email', |
| 110 |
'copy', |
| 111 |
'content', |
| 112 |
'template' |
| 113 |
] ); |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Render |
| 118 |
*/ |
| 119 |
public function render() { |
| 120 |
$sample_email = $this->get_settings_for_display( 'sample_email' ); |
| 121 |
if ( empty( $sample_email ) ) { |
| 122 |
return; |
| 123 |
} |
| 124 |
$display_content = preg_replace( '/\\[([^\\]]*)\\]/', '<span class="ctc-email-highlight">[$1]</span>', $sample_email ); |
| 125 |
$display_content = wpautop( $display_content ); |
| 126 |
?> |
| 127 |
<div class="ctc-block ctc-email-sample"> |
| 128 |
<div class="ctc-block-content"> |
| 129 |
<?php |
| 130 |
echo wp_kses_post( $display_content ); |
| 131 |
?> |
| 132 |
</div> |
| 133 |
<div class="ctc-block-actions"> |
| 134 |
<?php |
| 135 |
Helpers::render_copy_button( $this ); |
| 136 |
?> |
| 137 |
</div> |
| 138 |
<?php |
| 139 |
Helpers::render_copy_content( $this, [ |
| 140 |
'content' => wp_kses_post( $sample_email ), |
| 141 |
] ); |
| 142 |
?> |
| 143 |
</div> |
| 144 |
<?php |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Register controls |
| 149 |
*/ |
| 150 |
protected function _register_controls() { |
| 151 |
/** |
| 152 |
* Group: Email Section |
| 153 |
*/ |
| 154 |
$this->start_controls_section( 'email_section', [ |
| 155 |
'label' => esc_html__( 'Email Sample', 'copy-the-code' ), |
| 156 |
] ); |
| 157 |
$this->add_control( 'sample_email', [ |
| 158 |
'label' => esc_html__( 'Email Sample', 'copy-the-code' ), |
| 159 |
'type' => Controls_Manager::TEXTAREA, |
| 160 |
'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]", |
| 161 |
'rows' => 10, |
| 162 |
'description' => esc_html__( 'Use [ ] to highlight the text.', 'copy-the-code' ), |
| 163 |
] ); |
| 164 |
$this->end_controls_section(); |
| 165 |
Helpers::register_copy_button_section( $this ); |
| 166 |
Helpers::register_pro_sections( $this, ['Email Sample', 'Highlight Text'] ); |
| 167 |
Helpers::register_copy_button_style_section( $this ); |
| 168 |
} |
| 169 |
|
| 170 |
} |
| 171 |
|