| 1 |
<?php |
| 2 |
|
| 3 |
namespace HelloPlus\Modules\TemplateParts\Components; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
use Elementor\Core\Documents_Manager; |
| 10 |
use HelloPlus\Includes\Utils; |
| 11 |
|
| 12 |
/** |
| 13 |
* class Document |
| 14 |
**/ |
| 15 |
class Document { |
| 16 |
|
| 17 |
public function get_documents_list(): array { |
| 18 |
return [ |
| 19 |
'Ehp_Header', |
| 20 |
'Ehp_Footer', |
| 21 |
]; |
| 22 |
} |
| 23 |
|
| 24 |
public function get_documents_namespace(): string { |
| 25 |
return 'HelloPlus\Modules\TemplateParts\Documents\\'; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Add Hello+ documents |
| 30 |
* |
| 31 |
* @param Documents_Manager $documents_manager |
| 32 |
* |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
public function register( Documents_Manager $documents_manager ) { |
| 36 |
$documents = $this->get_documents_list(); |
| 37 |
$namespace = $this->get_documents_namespace(); |
| 38 |
|
| 39 |
foreach ( $documents as $document ) { |
| 40 |
/** @var \HelloPlus\Modules\TemplateParts\Documents\Ehp_Document_Base $doc_class */ |
| 41 |
$doc_class = $namespace . $document; |
| 42 |
|
| 43 |
// add the doc type to Elementor documents: |
| 44 |
$documents_manager->register_document_type( $doc_class::get_type(), $doc_class ); |
| 45 |
|
| 46 |
$doc_class::register_hooks(); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
public function register_remote_source() { |
| 52 |
Utils::elementor()->templates_manager->register_source( |
| 53 |
'HelloPlus\Modules\TemplateParts\Classes\Sources\Source_Remote_Ehp' |
| 54 |
); |
| 55 |
} |
| 56 |
|
| 57 |
public function __construct() { |
| 58 |
add_action( 'elementor/documents/register', [ $this, 'register' ] ); |
| 59 |
add_action( 'elementor/init', [ $this, 'register_remote_source' ] ); |
| 60 |
} |
| 61 |
} |
| 62 |
|