| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Copy Button 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 Button Block |
| 17 |
* |
| 18 |
* @since 3.1.0 |
| 19 |
*/ |
| 20 |
class CopyButton 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 = [], $args = null ) { |
| 31 |
parent::__construct( $data, $args ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get name |
| 36 |
*/ |
| 37 |
public function get_name() { |
| 38 |
return 'ctc_copy_button'; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Get title |
| 43 |
*/ |
| 44 |
public function get_title() { |
| 45 |
return esc_html__( 'Copy to Clipboard Button', 'copy-the-code' ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Get icon |
| 50 |
*/ |
| 51 |
public function get_icon() { |
| 52 |
return 'eicon-button'; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get categories |
| 57 |
*/ |
| 58 |
public function get_categories() { |
| 59 |
return Helpers::get_categories(); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Get keywords |
| 64 |
*/ |
| 65 |
public function get_keywords() { |
| 66 |
return Helpers::get_keywords( [ 'copy', 'button', 'clipboard', 'copy button', 'clipboard button' ] ); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Render |
| 71 |
*/ |
| 72 |
public function render() { |
| 73 |
?> |
| 74 |
<div class="ctc-block ctc-copy-button"> |
| 75 |
<div class="ctc-block-actions"> |
| 76 |
<?php |
| 77 |
Helpers::render_copy_button( $this ); |
| 78 |
?> |
| 79 |
</div> |
| 80 |
<?php Helpers::render_copy_content( $this ); ?> |
| 81 |
</div> |
| 82 |
<?php |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Register controls |
| 87 |
*/ |
| 88 |
protected function _register_controls() { |
| 89 |
Helpers::register_copy_content_section( $this ); |
| 90 |
|
| 91 |
Helpers::register_copy_button_section( $this ); |
| 92 |
|
| 93 |
Helpers::register_copy_button_style_section( $this ); |
| 94 |
} |
| 95 |
|
| 96 |
} |
| 97 |
|