1: <?php
2: /**
3: * Elementor EPL Listing Document base class.
4: *
5: * @package EPL
6: * @subpackage PageBuilders/Elementor
7: * @since 3.6.0
8: */
9:
10: // Exit if accessed directly.
11: if ( ! defined( 'ABSPATH' ) ) {
12: exit;
13: }
14:
15: /**
16: * Shared behaviour for the EPL Single Listing and EPL Listing Card documents.
17: *
18: * Both document types are designed with the regular EPL Elementor widgets and
19: * are rendered by EPL itself rather than through Elementor Pro's Theme Builder
20: * conditions, so they opt out of the conditions UI and instead expose a
21: * lightweight editor-canvas preview listing control.
22: */
23: abstract class EPL_Elementor_Listing_Document extends \Elementor\Modules\Library\Documents\Container {
24:
25: /**
26: * Document properties.
27: *
28: * @return array
29: * @since 3.6.0 New: Elementor templates for free Elementor (beta).
30: */
31: public static function get_properties() {
32: $properties = parent::get_properties();
33: $properties['support_conditions'] = false;
34: return $properties;
35: }
36:
37: /**
38: * Register document controls.
39: * @since 3.6.0 New: Elementor templates for free Elementor (beta).
40: */
41: protected function register_controls() {
42: parent::register_controls();
43:
44: $this->start_controls_section(
45: 'epl_template_settings',
46: array(
47: 'label' => esc_html__( 'EPL Template Settings', 'easy-property-listings' ),
48: 'tab' => \Elementor\Controls_Manager::TAB_SETTINGS,
49: )
50: );
51:
52: $this->add_control(
53: 'epl_preview_listing',
54: array(
55: 'label' => esc_html__( 'Preview Listing ID', 'easy-property-listings' ),
56: 'type' => \Elementor\Controls_Manager::NUMBER,
57: 'default' => '',
58: 'description' => esc_html__( 'Optional. Show a specific listing on the editor canvas instead of an automatically selected one.', 'easy-property-listings' ),
59: 'render_type' => 'template',
60: )
61: );
62:
63: $this->end_controls_section();
64: }
65:
66: /**
67: * Save the document, flagging it in plain post meta as an EPL listing
68: * template so EPL's front-end router can query for it without
69: * unserializing the full Elementor page-settings meta on every request.
70: *
71: * @param array $data Document data.
72: * @return bool|array
73: * @since 3.6.0 New: Elementor templates for free Elementor (beta).
74: */
75: public function save( $data ) {
76: $result = parent::save( $data );
77:
78: if ( $result ) {
79: update_post_meta( $this->post->ID, '_epl_elementor_template_context', 'listing' );
80: }
81:
82: return $result;
83: }
84: }
85: