ACF_WPML_Compatibility::is_translatable()publicACF 5.2.3

is_translatable

Returns true if the acf-field-group post type is translatable. Also adds compatibility with ACF4 settings

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

Хуков нет.

Возвращает

true|false.

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

$ACF_WPML_Compatibility = new ACF_WPML_Compatibility();
$ACF_WPML_Compatibility->is_translatable();

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

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

Код ACF_WPML_Compatibility::is_translatable() ACF 6.0.4

function is_translatable() {

	// global
	global $sitepress;

	// vars
	$post_types = $sitepress->get_setting( 'custom_posts_sync_option' );

	// return false if no post types
	if ( ! acf_is_array( $post_types ) ) {
		return false;
	}

	// prevent 'acf-field' from being translated
	if ( ! empty( $post_types['acf-field'] ) ) {
		$post_types['acf-field'] = 0;
		$sitepress->set_setting( 'custom_posts_sync_option', $post_types );
	}

	// when upgrading to version 5, review 'acf' setting
	// update 'acf-field-group' if 'acf' is translatable, and 'acf-field-group' does not yet exist
	if ( ! empty( $post_types['acf'] ) && ! isset( $post_types['acf-field-group'] ) ) {
		$post_types['acf-field-group'] = 1;
		$sitepress->set_setting( 'custom_posts_sync_option', $post_types );
	}

	// return true if acf-field-group is translatable
	if ( ! empty( $post_types['acf-field-group'] ) ) {
		return true;
	}

	// return
	return false;
}