PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.1.1
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.1.1
7.2.1 7.2 7.1.2 7.1.1 7.1 7.0.4 7.0.6 7.0.7 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 6.3.1 trunk 5.7.3 5.7.5 5.8.1 5.8.2 5.8.3 5.8.4 5.8.6 6.0.4 6.0.5 All 36 releases
mlsimport / includes / standalone / class-mlsimport-property-section-elementor.php

class-mlsimport-property-section-elementor.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 7.1.1, at includes/standalone/class-mlsimport-property-section-elementor.php

87 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Standalone (theme_id 990) single-property section Elementor widget (adapter).
4 *
5 * One generic Elementor widget, "MLSImport Property Section", with a Section
6 * picker control (options from the manifest) + a property-id control. Its render
7 * delegates to the one dispatcher, so Elementor emits the same markup as the
8 * shortcode and the block.
9 *
10 * Why a picker rather than one widget per manifest entry: Elementor rebuilds a
11 * widget from its registered prototype's CLASS with empty constructor args, so a
12 * slug baked in via the constructor is lost at render time. A single widget with
13 * a Section control is the robust, no-eval equivalent. The render logic lives in
14 * render_settings() so it is testable without Elementor loaded. See docs/adr/0005
15 * (controls are behavioral-only; styling is our own CSS).
16 *
17 * @package Mlsimport
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 require_once __DIR__ . '/property-section-registry.php';
25
26 /**
27 * Registers and backs the generic Elementor property-section widget.
28 */
29 class Mlsimport_Property_Section_Elementor {
30
31 /**
32 * Hook the Elementor widget registration. Inert when Elementor is absent.
33 *
34 * @return void
35 */
36 public static function register(): void {
37 add_action( 'elementor/widgets/register', array( __CLASS__, 'register_widget' ) );
38 }
39
40 /**
41 * Register the generic widget with Elementor's widget manager.
42 *
43 * @param mixed $widgets_manager Elementor\Widgets_Manager.
44 * @return void
45 */
46 public static function register_widget( $widgets_manager ): void {
47 if ( ! class_exists( '\Elementor\Widget_Base' ) ) {
48 return;
49 }
50 mlsimport_register_builtin_property_sections();
51 require_once __DIR__ . '/elementor/class-mlsimport-elementor-property-section-widget.php';
52 if ( is_object( $widgets_manager ) && method_exists( $widgets_manager, 'register' ) ) {
53 $widgets_manager->register( new Mlsimport_Elementor_Property_Section_Widget() );
54 }
55 }
56
57 /**
58 * Section picker options for the widget control: slug => label.
59 *
60 * @return array
61 */
62 public static function section_options(): array {
63 mlsimport_register_builtin_property_sections();
64 $options = array();
65 foreach ( mlsimport_get_property_sections() as $slug => $def ) {
66 $options[ $slug ] = $def['label'];
67 }
68 return $options;
69 }
70
71 /**
72 * Render from a settings array (the widget's get_settings_for_display()).
73 * Pure delegation to the dispatcher — the testable core of the widget.
74 *
75 * @param array $settings Elementor control values.
76 * @return string
77 */
78 public static function render_settings( array $settings ): string {
79 $slug = isset( $settings['section'] ) ? (string) $settings['section'] : '';
80 if ( '' === $slug ) {
81 return '';
82 }
83 $id = isset( $settings['property_id'] ) ? (int) $settings['property_id'] : 0;
84 return mlsimport_render_property_section( $slug, $id );
85 }
86 }
87