ACF_Admin_Field_Groups::setup_sync()publicACF 5.9.0

Sets up the field groups ready for sync.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$ACF_Admin_Field_Groups = new ACF_Admin_Field_Groups();
$ACF_Admin_Field_Groups->setup_sync();

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

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

Код ACF_Admin_Field_Groups::setup_sync() ACF 6.0.4

public function setup_sync() {

	// Review local json field groups.
	if ( acf_get_local_json_files() ) {

		// Get all groups in a single cached query to check if sync is available.
		$all_field_groups = acf_get_field_groups();
		foreach ( $all_field_groups as $field_group ) {

			// Extract vars.
			$local    = acf_maybe_get( $field_group, 'local' );
			$modified = acf_maybe_get( $field_group, 'modified' );
			$private  = acf_maybe_get( $field_group, 'private' );

			// Ignore if is private.
			if ( $private ) {
				continue;

				// Ignore not local "json".
			} elseif ( $local !== 'json' ) {
				continue;

				// Append to sync if not yet in database.
			} elseif ( ! $field_group['ID'] ) {
				$this->sync[ $field_group['key'] ] = $field_group;

				// Append to sync if "json" modified time is newer than database.
			} elseif ( $modified && $modified > get_post_modified_time( 'U', true, $field_group['ID'] ) ) {
				$this->sync[ $field_group['key'] ] = $field_group;
			}
		}
	}
}