| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Copy Icon Block |
| 4 |
* |
| 5 |
* @package Copy the Code |
| 6 |
* @since 3.1.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace CopyTheCode\Elementor\Block; |
| 10 |
|
| 11 |
use CopyTheCode\Helpers; |
| 12 |
use Elementor\Widget_Base; |
| 13 |
use Elementor\Controls_Manager; |
| 14 |
|
| 15 |
/** |
| 16 |
* Copy Icon Block |
| 17 |
* |
| 18 |
* @since 3.1.0 |
| 19 |
*/ |
| 20 |
class CopyIcon extends Widget_Base { |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor |
| 24 |
*/ |
| 25 |
public function __construct( $data = [], $args = null ) { |
| 26 |
parent::__construct( $data, $args ); |
| 27 |
|
| 28 |
// Core. |
| 29 |
wp_enqueue_script( 'ctc-clipboard', COPY_THE_CODE_URI . 'assets/js/clipboard.js', [ 'jquery' ], COPY_THE_CODE_VER, true ); |
| 30 |
|
| 31 |
// Block. |
| 32 |
wp_enqueue_style( 'ctc-el-copy-icon', COPY_THE_CODE_URI . 'classes/elementor/widgets/copy-icon/style.css', [], COPY_THE_CODE_VER ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Get script dependencies |
| 37 |
*/ |
| 38 |
public function get_script_depends() { |
| 39 |
return [ 'ctc-clipboard' ]; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Get style dependencies |
| 44 |
*/ |
| 45 |
public function get_style_depends() { |
| 46 |
return [ 'ctc-el-copy-icon' ]; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Get name |
| 51 |
*/ |
| 52 |
public function get_name() { |
| 53 |
return 'ctc_copy_icon'; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Get title |
| 58 |
*/ |
| 59 |
public function get_title() { |
| 60 |
return esc_html__( 'Copy to Clipboard Icon', 'copy-the-code' ); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Get icon |
| 65 |
*/ |
| 66 |
public function get_icon() { |
| 67 |
return 'eicon-favorite'; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Get categories |
| 72 |
*/ |
| 73 |
public function get_categories() { |
| 74 |
return Helpers::get_categories(); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Get keywords |
| 79 |
*/ |
| 80 |
public function get_keywords() { |
| 81 |
return Helpers::get_keywords( [ 'icon' ] ); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Render block |
| 86 |
*/ |
| 87 |
public function render() { |
| 88 |
?> |
| 89 |
<span class="ctc-block ctc-copy-icon"> |
| 90 |
<span copy-as-raw="yes" class="ctc-block-copy ctc-block-copy-icon" role="button" aria-label="Copied"> |
| 91 |
<?php echo Helpers::get_svg_copy_icon(); ?> |
| 92 |
<?php echo Helpers::get_svg_checked_icon(); ?> |
| 93 |
</span> |
| 94 |
<?php Helpers::render_copy_content( $this ); ?> |
| 95 |
</span> |
| 96 |
<?php |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Register block controls |
| 101 |
*/ |
| 102 |
protected function _register_controls() { |
| 103 |
Helpers::register_copy_content_section( $this ); |
| 104 |
|
| 105 |
Helpers::register_style_section( |
| 106 |
$this, |
| 107 |
'Icon', |
| 108 |
'.ctc-copy-icon svg', |
| 109 |
[ |
| 110 |
'padding' => false, |
| 111 |
'border_radius' => false, |
| 112 |
'typography' => false, |
| 113 |
'text_align' => false, |
| 114 |
'normal_background' => false, |
| 115 |
'normal_box_shadow' => false, |
| 116 |
'normal_border' => false, |
| 117 |
'normal_text_color' => [ |
| 118 |
'label' => esc_html__( 'Fill Color', 'copy-the-code' ), |
| 119 |
'selectors' => [ |
| 120 |
'{{WRAPPER}} .ctc-copy-icon svg' => 'fill: {{VALUE}};', |
| 121 |
], |
| 122 |
], |
| 123 |
'hover_text_color' => [ |
| 124 |
'label' => esc_html__( 'Fill Color', 'copy-the-code' ), |
| 125 |
'selectors' => [ |
| 126 |
'{{WRAPPER}} .ctc-copy-icon svg:hover' => 'fill: {{VALUE}};', |
| 127 |
], |
| 128 |
], |
| 129 |
'size' => [ |
| 130 |
'label' => esc_html__( 'Icon Size', 'copy-the-code' ), |
| 131 |
'selectors' => [ |
| 132 |
'{{WRAPPER}} .ctc-copy-icon svg' => 'font-size: {{SIZE}}{{UNIT}};', |
| 133 |
], |
| 134 |
], |
| 135 |
] |
| 136 |
); |
| 137 |
} |
| 138 |
|
| 139 |
} |
| 140 |
|