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.2 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 All 37 releases
mlsimport / includes / standalone / class-mlsimport-page-block-shortcodes.php

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

54 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) page-block shortcodes (generic adapter).
4 *
5 * One adapter that loops the page-block manifest and registers a
6 * [mlsimport_<slug>] shortcode for every entry. Each shortcode maps its atts
7 * (defaulted from the block's arg schema) and hands off to the one dispatcher — so
8 * shortcode, Gutenberg block and Elementor widget all emit identical markup.
9 * Adding a block needs no change here. See docs/adr/0007.
10 *
11 * @package Mlsimport
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 require_once __DIR__ . '/page-block-registry.php';
19
20 /**
21 * Registers a shortcode per registered page block.
22 */
23 class Mlsimport_Page_Block_Shortcodes {
24
25 /**
26 * Register one shortcode for every manifest entry.
27 *
28 * @return void
29 */
30 public static function register(): void {
31 // One [mlsimport_<slug>] shortcode per manifest entry.
32 foreach ( mlsimport_get_page_blocks() as $slug => $def ) {
33 add_shortcode(
34 'mlsimport_' . $slug,
35 static function ( $atts ) use ( $slug ) {
36 return self::render( $slug, $atts );
37 }
38 );
39 }
40 }
41
42 /**
43 * Map shortcode atts (defaulted from the schema) to a page-block render.
44 *
45 * @param string $slug Block slug.
46 * @param array|string $atts Shortcode attributes.
47 * @return string
48 */
49 public static function render( string $slug, $atts ): string {
50 $atts = shortcode_atts( mlsimport_page_block_defaults( $slug ), (array) $atts, 'mlsimport_' . $slug );
51 return mlsimport_render_page_block( $slug, $atts );
52 }
53 }
54