acf_export_enter_title_here()ACF 6.2.1

Exports the "Enter Title Here" text for the provided ACF post types.

Хуков нет.

Возвращает

Строку.

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

acf_export_enter_title_here( $post_types );
$post_types(массив) (обязательный)
The post types being exported.

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

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

Код acf_export_enter_title_here() ACF 6.4.2

function acf_export_enter_title_here( array $post_types ) {
	$to_export = array();
	$export    = '';

	foreach ( $post_types as $post_type ) {
		if ( ! empty( $post_type['enter_title_here'] ) ) {
			$to_export[ $post_type['post_type'] ] = $post_type['enter_title_here'];
		}
	}

	if ( ! empty( $to_export ) ) {
		$export .= "\r\nadd_filter( 'enter_title_here', function( \$default, \$post ) {\r\n";
		$export .= "\tswitch ( \$post->post_type ) {\r\n";

		foreach ( $to_export as $post_type => $enter_title_here ) {
			$export .= "\t\tcase '$post_type':\r\n\t\t\treturn '$enter_title_here';\r\n";
		}

		$export .= "\t}\r\n\r\n\treturn \$default;\r\n}, 10, 2 );\r\n\r\n";
	}

	return esc_textarea( $export );
}