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-shortcodes.php

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

55 lines 1.5 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 shortcodes (generic adapter).
4 *
5 * One adapter that loops the section manifest and registers a
6 * [mlsimport_property_<slug>] shortcode for every entry. Each shortcode resolves
7 * the property (optional id att; otherwise the loop post) and hands off to the
8 * one dispatcher — so the shortcode, block and Elementor widget all emit the
9 * same markup. Adding a section needs no change here. See docs/adr/0005.
10 *
11 * @package Mlsimport
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 require_once __DIR__ . '/property-section-registry.php';
19
20 /**
21 * Registers a shortcode per registered property section.
22 */
23 class Mlsimport_Property_Section_Shortcodes {
24
25 /**
26 * Register one shortcode for every manifest entry.
27 *
28 * @return void
29 */
30 public static function register(): void {
31 mlsimport_register_builtin_property_sections();
32
33 foreach ( array_keys( mlsimport_get_property_sections() ) as $slug ) {
34 add_shortcode(
35 'mlsimport_property_' . $slug,
36 static function ( $atts ) use ( $slug ) {
37 return self::render( $slug, $atts );
38 }
39 );
40 }
41 }
42
43 /**
44 * Map shortcode atts to a section render.
45 *
46 * @param string $slug Section slug.
47 * @param array|string $atts Shortcode attributes.
48 * @return string
49 */
50 public static function render( string $slug, $atts ): string {
51 $atts = shortcode_atts( array( 'id' => 0 ), (array) $atts, 'mlsimport_property_' . $slug );
52 return mlsimport_render_property_section( $slug, (int) $atts['id'] );
53 }
54 }
55