ACF_Taxonomy::export_post_as_phppublicACF 6.1

Returns a string that can be used to create a taxonomy in PHP.

Метод класса: ACF_Taxonomy{}

Хуков нет.

Возвращает

Строку.

Использование

$ACF_Taxonomy = new ACF_Taxonomy();
$ACF_Taxonomy->export_post_as_php( $post );
$post(массив)
The main taxonomy array.
По умолчанию: array()

Список изменений

С версии 6.1 Введена.

Код ACF_Taxonomy::export_post_as_php() ACF 6.4.2

public function export_post_as_php( $post = array() ) {
	$return = '';
	if ( empty( $post ) ) {
		return $return;
	}

	$post         = $this->validate_post( $post );
	$taxonomy_key = $post['taxonomy'];
	$objects      = (array) $post['object_type'];
	$objects      = var_export( $objects, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions -- Used for PHP export.
	$args         = $this->get_taxonomy_args( $post, false );

	// Restore original metabox callback.
	if ( ! empty( $args['meta_box_cb'] ) && ! empty( $post['meta_box_cb'] ) ) {
		$args['meta_box_cb'] = $post['meta_box_cb'];
	}

	$args = var_export( $args, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions -- Used for PHP export.

	if ( ! $args ) {
		return $return;
	}

	$args    = $this->format_code_for_export( $args );
	$objects = $this->format_code_for_export( $objects );

	$return .= "register_taxonomy( '{$taxonomy_key}', {$objects}, {$args} );\r\n";

	return esc_textarea( $return );
}