| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Elementor Email Address 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 Address Block |
| 16 |
* |
| 17 |
* @since 3.1.0 |
| 18 |
*/ |
| 19 |
class Address extends Widget_Base |
| 20 |
{ |
| 21 |
public function __construct( $data = array(), $args = null ) |
| 22 |
{ |
| 23 |
parent::__construct( $data, $args ); |
| 24 |
// Core. |
| 25 |
wp_enqueue_style( |
| 26 |
'ctc-blocks', |
| 27 |
COPY_THE_CODE_URI . 'classes/blocks/assets/css/style.css', |
| 28 |
[], |
| 29 |
COPY_THE_CODE_VER, |
| 30 |
'all' |
| 31 |
); |
| 32 |
wp_enqueue_script( |
| 33 |
'ctc-clipboard', |
| 34 |
COPY_THE_CODE_URI . 'assets/js/clipboard.js', |
| 35 |
[ 'jquery' ], |
| 36 |
COPY_THE_CODE_VER, |
| 37 |
true |
| 38 |
); |
| 39 |
// Block. |
| 40 |
wp_enqueue_style( |
| 41 |
'ctc-el-email-address', |
| 42 |
COPY_THE_CODE_URI . 'classes/elementor/widgets/email-address/style.css', |
| 43 |
[ 'ctc-blocks' ], |
| 44 |
COPY_THE_CODE_VER, |
| 45 |
'all' |
| 46 |
); |
| 47 |
} |
| 48 |
|
| 49 |
public function get_script_depends() |
| 50 |
{ |
| 51 |
return [ 'ctc-el-email-address' ]; |
| 52 |
} |
| 53 |
|
| 54 |
public function get_style_depends() |
| 55 |
{ |
| 56 |
return [ 'ctc-el-email-address' ]; |
| 57 |
} |
| 58 |
|
| 59 |
public function get_name() |
| 60 |
{ |
| 61 |
return 'ctc_copy_email_address'; |
| 62 |
} |
| 63 |
|
| 64 |
public function get_title() |
| 65 |
{ |
| 66 |
return esc_html__( 'Email Address', 'copy-the-code' ); |
| 67 |
} |
| 68 |
|
| 69 |
public function get_icon() |
| 70 |
{ |
| 71 |
return 'eicon-email-field'; |
| 72 |
} |
| 73 |
|
| 74 |
public function get_categories() |
| 75 |
{ |
| 76 |
return Helpers::get_categories(); |
| 77 |
} |
| 78 |
|
| 79 |
public function get_keywords() |
| 80 |
{ |
| 81 |
return Helpers::get_keywords( [ |
| 82 |
'email', |
| 83 |
'copy', |
| 84 |
'content', |
| 85 |
'address' |
| 86 |
] ); |
| 87 |
} |
| 88 |
|
| 89 |
public function render() |
| 90 |
{ |
| 91 |
$email = $this->get_settings( 'email' ); |
| 92 |
if ( empty($email) ) { |
| 93 |
return; |
| 94 |
} |
| 95 |
?> |
| 96 |
<span class="ctc-block ctc-email-address"> |
| 97 |
<a href="mailto:<?php |
| 98 |
echo esc_attr( $email ) ; |
| 99 |
?>" class="ctc-block-content"> |
| 100 |
<?php |
| 101 |
echo esc_html( $email ) ; |
| 102 |
?> |
| 103 |
</a> |
| 104 |
<span class="ctc-block-copy ctc-block-copy-icon" role="button" aria-label="Copied"> |
| 105 |
<?php |
| 106 |
echo Helpers::get_svg_copy_icon() ; |
| 107 |
?> |
| 108 |
<?php |
| 109 |
echo Helpers::get_svg_checked_icon() ; |
| 110 |
?> |
| 111 |
</span> |
| 112 |
<?php |
| 113 |
Helpers::render_copy_content( $this, [ |
| 114 |
'content' => $email, |
| 115 |
] ); |
| 116 |
?> |
| 117 |
</span> |
| 118 |
<?php |
| 119 |
} |
| 120 |
|
| 121 |
protected function _register_controls() |
| 122 |
{ |
| 123 |
$this->start_controls_section( 'email_address_section', [ |
| 124 |
'label' => esc_html__( 'Email', 'copy-the-code' ), |
| 125 |
] ); |
| 126 |
$this->add_control( 'email', [ |
| 127 |
'label' => esc_html__( 'Email Address', 'copy-the-code' ), |
| 128 |
'type' => Controls_Manager::TEXT, |
| 129 |
'default' => '[email protected]', |
| 130 |
] ); |
| 131 |
$this->end_controls_section(); |
| 132 |
Helpers::register_pro_sections( $this, [ 'Email Address', 'Icon' ] ); |
| 133 |
} |
| 134 |
|
| 135 |
} |