Tribe__Events__Pro__Editor::migrate_additional_fields_params_to_blocks( $params,  $slug,  $post )

Generate the attributes from additional fields that are doing the migration into the new blocks UI, it sets the attributes of the additional fields that are marked as “Include this field on all new events in the Gutenberg block editor” it sets 4 attributes based on the meta value associated with the additional field


Parameters

$params

(Required)

$slug

(Required)

$post

(Required)


Top ↑

Return

(array)


Top ↑

Source

File: src/Tribe/Editor.php

	public function migrate_additional_fields_params_to_blocks( $params, $slug, $post ) {
		/** @var Tribe__Events__Pro__Editor__Additional_Fields $editor */
		$editor                      = tribe( 'events-pro.editor.fields' );
		$additional_fields_templates = $editor->get_block_names( true, true );
		$block_names                 = array_keys( $additional_fields_templates );

		if (
			empty( $block_names )
			|| empty( $additional_fields_templates )
			|| empty( $additional_fields_templates[ $slug ] )
			|| ! ( $post instanceof WP_Post )
			|| $slug !== $params // if $slug !== $params it means params has been set already as s
		) {
			return $params;
		}

		$field = $additional_fields_templates[ $slug ];
		$value = strval( get_post_meta( $post->ID, $field['name'], true ) );
		$output = $value;

		if ( 'checkbox' === $field['type'] ) {
			$output = $this->format_checkbox_field( $value );
		}

		return array(
			'isPristine' => empty( $value ),
			'output'     => $output,
			'value'      => $value,
			'label'      => $field['label'],
		);
	}

Top ↑

Changelog

Changelog
Version Description
4.5 Introduced.