class-ele-builder-document-base.php
1 year ago
class-ele-builder-documents.php
1 year ago
class-ele-document-singular.php
1 year ago
class-ele-builder-document-base.php
101 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class: Ecafe_Ele_Document_Base |
| 4 | * Name: Document Base |
| 5 | * Slug: ec-template-builder-document |
| 6 | * |
| 7 | * @package Ecafe |
| 8 | * @since 3.0.24 |
| 9 | */ |
| 10 | if ( ! defined( 'WPINC' ) ) { |
| 11 | die; |
| 12 | } |
| 13 | |
| 14 | class Ecafe_Ele_Document_Base extends Elementor\Core\Base\Document { |
| 15 | |
| 16 | public function get_name() { |
| 17 | return 'ec-template-builder-document'; |
| 18 | } |
| 19 | |
| 20 | public static function get_type() { |
| 21 | return 'ec-template-builder-document'; |
| 22 | } |
| 23 | |
| 24 | public static function get_properties() { |
| 25 | $properties = parent::get_properties(); |
| 26 | |
| 27 | $properties['cpt'] = array( 'ec_theme_builder' ); |
| 28 | $properties['register_type'] = true; |
| 29 | $properties['support_kit'] = true; |
| 30 | |
| 31 | return $properties; |
| 32 | } |
| 33 | |
| 34 | public static function get_preview_as_default() { |
| 35 | return ''; |
| 36 | } |
| 37 | |
| 38 | public static function get_preview_as_options() { |
| 39 | return array(); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get elements data with new query |
| 44 | * |
| 45 | * @param null $data |
| 46 | * @param boolean $with_html_content |
| 47 | * |
| 48 | */ |
| 49 | public function get_elements_raw_data( $data = null, $with_html_content = false ) { |
| 50 | |
| 51 | ecafe_theme_builder_load()->documents->ec_preview_query_switch(); |
| 52 | |
| 53 | $editor_data = parent::get_elements_raw_data( $data, $with_html_content ); |
| 54 | |
| 55 | ecafe_theme_builder_load()->documents->ec_current_query_restore(); |
| 56 | |
| 57 | return $editor_data; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Render current element |
| 63 | * |
| 64 | * @param $data |
| 65 | * |
| 66 | */ |
| 67 | public function render_element( $data ) { |
| 68 | |
| 69 | ecafe_theme_builder_load()->documents->ec_preview_query_switch(); |
| 70 | |
| 71 | $render_html = parent::render_element( $data ); |
| 72 | |
| 73 | ecafe_theme_builder_load()->documents->ec_current_query_restore(); |
| 74 | |
| 75 | return $render_html; |
| 76 | |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Return elements data |
| 81 | * |
| 82 | * @param string $status |
| 83 | * |
| 84 | */ |
| 85 | public function get_elements_data( $status = 'publish' ) { |
| 86 | |
| 87 | if ( ! isset( $_GET[ ECAFE_POST ] ) || ! isset( $_GET['preview'] ) ) { |
| 88 | return parent::get_elements_data( $status ); |
| 89 | } |
| 90 | |
| 91 | ecafe_theme_builder_load()->documents->ec_preview_query_switch(); |
| 92 | |
| 93 | $elements = parent::get_elements_data( $status ); |
| 94 | |
| 95 | ecafe_theme_builder_load()->documents->ec_current_query_restore(); |
| 96 | |
| 97 | return $elements; |
| 98 | |
| 99 | } |
| 100 | |
| 101 | } |