Loading a plugin pattern with block binding in a shortcode

2 Bedrooms

2 Bedrooms

2 Bathrooms

2 Bathrooms

2 Receptions

2 Receptions

2 Cloakrooms

2 Cloakrooms

Attached Garage

Attached Garage

Gardens Front and Rear

Gardens Front and Rear

EV Charging

EV Charging

Solar Panels

Solar Panels

Sustainable New Build

Sustainable New Build

House Battery

House Battery

Heat Pump

Heat Pump

Owl

Owl

Bat

Bat

Paw

Paw

Flower

Flower

property hive is active and this is the block!

Price:
Warning: Undefined property: stdClass::$price_formatted in /nas/content/live/gomo/wp-content/plugins/gomo-acf-plugin/blocks/gomo-property-hive-features/template.php on line 30

Bedrooms:
Warning: Undefined property: stdClass::$bedrooms in /nas/content/live/gomo/wp-content/plugins/gomo-acf-plugin/blocks/gomo-property-hive-features/template.php on line 31

Bathrooms:
Warning: Undefined property: stdClass::$bathrooms in /nas/content/live/gomo/wp-content/plugins/gomo-acf-plugin/blocks/gomo-property-hive-features/template.php on line 32

Property Type:
Warning: Undefined property: stdClass::$property_type in /nas/content/live/gomo/wp-content/plugins/gomo-acf-plugin/blocks/gomo-property-hive-features/template.php on line 33

Bedrooms: field_66fa78028aa36

Bathrooms: field_66fa78028a9ef

Was having trouple loading a pattern in an ACF Block it was unable to get the block bindings before loading the block that was calling the pattern.

Using a shortcode to call the pattern seem to fix this and brings the pattern in with the block bindings working:

Shortcode function:

function gomo_get_plugin_part($atts) {
	ob_start();
	if ( $atts['file']) {
		$filename = 'parts/' . $atts['file'] .'.php';
	} else {
		$filename = 'parts/testimonial-pattern.php';
	}
	require $filename;
	return ob_get_clean();
  }
  add_shortcode('display-part', 'gomo_get_plugin_part');

Files are saved in the plugin and the pattern code can not be changed without copying the code in the theme editor making the changes and then putting back in the plugin file.

This could also be resolved by having a synced pattern on the site but this is hard to break for a user. Keeps the patterns library cleaner.

I imagine the block binding how to add them and work with them will get better soon but this is an option for now.

Example block binding pattern (built in the site editor and then saved out):

<!-- wp:paragraph { "metadata":{"bindings":{"content":{"source":"acf/field","args":{"key":"organisation"}}},"name":"Organisation"},"style":{"elements":{"link":{"color":{"text":"var:preset|color|secondary"}}}},"textColor":"secondary","fontSize":"small"} -->
<p class="has-secondary-color has-text-color has-link-color has-small-font-size">Organisation</p>
<!-- /wp:paragraph -->