ACF_Local_JSON::save_file() public ACF 5.9.0
Saves a field group JSON file.
{} Это метод класса: ACF_Local_JSON{}
Хуков нет.
Возвращает
true/false.
Использование
$ACF_Local_JSON = new ACF_Local_JSON(); $ACF_Local_JSON->save_file( $key, $field_group );
- $key(строка) (обязательный)
- The field group key.
- $field_group(массив) (обязательный)
- The field group.
Список изменений
С версии 5.9.0 | Введена. |
Код ACF_Local_JSON::save_file() ACF Local JSON::save file ACF 5.9.1
public function save_file( $key, $field_group ) {
$path = acf_get_setting( 'save_json' );
$file = untrailingslashit( $path ) . '/' . $key . '.json';
if( !is_writable($path) ) {
return false;
}
// Append modified time.
if( $field_group['ID'] ) {
$field_group['modified'] = get_post_modified_time( 'U', true, $field_group['ID'] );
} else {
$field_group['modified'] = strtotime();
}
// Prepare for export.
$field_group = acf_prepare_field_group_for_export( $field_group );
// Save and return true if bytes were written.
$result = file_put_contents( $file, acf_json_encode( $field_group ) );
return is_int( $result );
}