ACF\Pro\AI\GEO\Outputs

Blocks::add_block_json_auto_jsonld_support │ public │ ACF 6.8.0

Add support for autoJsonLd property from block.json ACF namespace

Maps the 'autoJsonLd' property from block.json's acf namespace to 'auto_jsonld' setting. Also maps 'schemaType' to 'schema_type' for custom Schema.org @type values. This runs after ACF's own block.json handler.

Method of the class: Blocks{}

No Hooks.

Returns

array. Modified block settings.

Usage

$Blocks = new Blocks();
$Blocks->add_block_json_auto_jsonld_support( $settings, $metadata );
$settings(array) (required)
The compiled block settings.
$metadata(array) (required)
The raw json metadata.

Changelog

Since 6.8.0 Introduced.

Blocks::add_block_json_auto_jsonld_support() code ACF 6.8.8

public function add_block_json_auto_jsonld_support( $settings, $metadata ) {
	// Only process ACF blocks.
	if ( ! isset( $metadata['acf'] ) || ! is_array( $metadata['acf'] ) ) {
		return $settings;
	}

	// Map autoJsonLd from ACF namespace to auto_jsonld.
	if ( isset( $metadata['acf']['autoJsonLd'] ) ) {
		$settings['auto_jsonld'] = $metadata['acf']['autoJsonLd'];
	}

	// Map schemaType from ACF namespace to schema_type.
	if ( isset( $metadata['acf']['schemaType'] ) ) {
		$settings['schema_type'] = $metadata['acf']['schemaType'];
	}

	return $settings;
}