| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Blocks |
| 4 |
* |
| 5 |
* @package Copy the Code |
| 6 |
* @since 3.1.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace CopyTheCode\Elementor; |
| 10 |
|
| 11 |
use CopyTheCode\Elementor\Block\Email\Sample as EmailSample; |
| 12 |
use CopyTheCode\Elementor\Block\Email\Address as EmailAddress; |
| 13 |
use CopyTheCode\Elementor\Block\PhoneNumber; |
| 14 |
use CopyTheCode\Elementor\Block\CopyButton; |
| 15 |
use CopyTheCode\Elementor\Block\CopyIcon; |
| 16 |
use CopyTheCode\Elementor\Block\Blockquote; |
| 17 |
use CopyTheCode\Elementor\Block\CodeSnippet; |
| 18 |
use CopyTheCode\Elementor\Block\Message; |
| 19 |
use CopyTheCode\Elementor\Block\Deal; |
| 20 |
use CopyTheCode\Elementor\Block\Coupon; |
| 21 |
use CopyTheCode\Elementor\Block\AI\Prompt\Generator as AIPromptGenerator; |
| 22 |
use CopyTheCode\Elementor\Block\Wish; |
| 23 |
use CopyTheCode\Elementor\Block\Shayari; |
| 24 |
use CopyTheCode\Elementor\Block\SMS; |
| 25 |
use CopyTheCode\Elementor\Block\Table; |
| 26 |
|
| 27 |
/** |
| 28 |
* Blocks |
| 29 |
* |
| 30 |
* @since 3.1.0 |
| 31 |
*/ |
| 32 |
class Blocks { |
| 33 |
|
| 34 |
/** |
| 35 |
* Constructor |
| 36 |
*/ |
| 37 |
public function __construct() { |
| 38 |
if ( ! is_plugin_active('elementor/elementor.php') ) { |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] ); |
| 43 |
add_action( 'elementor/elements/categories_registered', [ $this, 'register_category' ] ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Register category |
| 48 |
* |
| 49 |
* @param object $elements_manager |
| 50 |
* |
| 51 |
* @since 3.1.0 |
| 52 |
*/ |
| 53 |
public function register_category( $elements_manager ) { |
| 54 |
$elements_manager->add_category( |
| 55 |
'copy-the-code', |
| 56 |
[ |
| 57 |
'title' => esc_html__( 'Copy Anything to Clipboard', 'copy-the-code' ), |
| 58 |
'icon' => 'fa fa-code', |
| 59 |
] |
| 60 |
); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Register widgets |
| 65 |
* |
| 66 |
* @param object $widgets_manager |
| 67 |
* |
| 68 |
* @since 3.1.0 |
| 69 |
*/ |
| 70 |
public function register_widgets( $widgets_manager ) { |
| 71 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/email-sample/widget.php'; |
| 72 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/email-address/widget.php'; |
| 73 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/phone-number/widget.php'; |
| 74 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/copy-button/widget.php'; |
| 75 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/copy-icon/widget.php'; |
| 76 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/blockquote/widget.php'; |
| 77 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/code-snippet/widget.php'; |
| 78 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/message/widget.php'; |
| 79 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/wish/widget.php'; |
| 80 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/shayari/widget.php'; |
| 81 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/sms/widget.php'; |
| 82 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/deal/widget.php'; |
| 83 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/coupon/widget.php'; |
| 84 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/ai-prompt-generator/widget.php'; |
| 85 |
require_once COPY_THE_CODE_DIR . 'classes/elementor/widgets/table/widget.php'; |
| 86 |
|
| 87 |
$widgets_manager->register( new EmailSample() ); |
| 88 |
$widgets_manager->register( new EmailAddress() ); |
| 89 |
$widgets_manager->register( new PhoneNumber() ); |
| 90 |
$widgets_manager->register( new CopyButton() ); |
| 91 |
$widgets_manager->register( new CopyIcon() ); |
| 92 |
$widgets_manager->register( new Blockquote() ); |
| 93 |
$widgets_manager->register( new CodeSnippet() ); |
| 94 |
$widgets_manager->register( new Message() ); |
| 95 |
$widgets_manager->register( new Wish() ); |
| 96 |
$widgets_manager->register( new Shayari() ); |
| 97 |
$widgets_manager->register( new SMS() ); |
| 98 |
$widgets_manager->register( new Deal() ); |
| 99 |
$widgets_manager->register( new Coupon() ); |
| 100 |
$widgets_manager->register( new AIPromptGenerator() ); |
| 101 |
$widgets_manager->register( new Table() ); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Get blocks |
| 106 |
* |
| 107 |
* @return array |
| 108 |
* |
| 109 |
* @since 3.1.0 |
| 110 |
*/ |
| 111 |
public static function get_blocks() { |
| 112 |
return [ |
| 113 |
[ |
| 114 |
'id' => 'email-sample', |
| 115 |
'name' => 'Email Sample', |
| 116 |
'description' => 'Create the email sample and allow users to copy it.', |
| 117 |
], |
| 118 |
[ |
| 119 |
'id' => 'email-address', |
| 120 |
'name' => 'Email Address', |
| 121 |
'description' => 'Add the email address and allow users to copy it.', |
| 122 |
], |
| 123 |
[ |
| 124 |
'id' => 'phone-number', |
| 125 |
'name' => 'Phone Number', |
| 126 |
'description' => 'Add the phone number and allow users to copy it.', |
| 127 |
], |
| 128 |
[ |
| 129 |
'id' => 'copy-button', |
| 130 |
'name' => 'Copy Button', |
| 131 |
'description' => 'Add the copy button and add the hidden content which you want to copy.', |
| 132 |
], |
| 133 |
[ |
| 134 |
'id' => 'copy-icon', |
| 135 |
'name' => 'Copy Icon', |
| 136 |
'description' => 'Add the copy icon and add the hidden content which you want to copy.', |
| 137 |
], |
| 138 |
[ |
| 139 |
'id' => 'blockquote', |
| 140 |
'name' => 'Blockquote', |
| 141 |
'description' => 'Create the blockquote and allow users to copy the text.', |
| 142 |
], |
| 143 |
[ |
| 144 |
'id' => 'code-snippet', |
| 145 |
'name' => 'Code Snippet', |
| 146 |
'description' => 'Create the code snippet and allow users to copy the text.', |
| 147 |
], |
| 148 |
]; |
| 149 |
} |
| 150 |
|
| 151 |
} |