acf_format_value() ACF 5.0.0
Returns a formatted version of the provided value.
Хуки из функции
Возвращает
Разное..
Использование
acf_format_value( $value, $post_id, $field );
- $value(смешанный) (обязательный)
- The field value.
- $post_id((число/строка)) (обязательный)
- The post id.
- $field(массив) (обязательный)
- The field array.
Список изменений
С версии 5.0.0 | Введена. |
Код acf_format_value() acf format value ACF 5.9.1
function acf_format_value( $value, $post_id, $field ) {
// Allow filter to short-circuit load_value logic.
$check = apply_filters( "acf/pre_format_value", null, $value, $post_id, $field );
if( $check !== null ) {
return $check;
}
// Get field name.
$field_name = $field['name'];
// Check store.
$store = acf_get_store( 'values' );
if( $store->has( "$post_id:$field_name:formatted" ) ) {
return $store->get( "$post_id:$field_name:formatted" );
}
/**
* Filters the $value for use in a template function.
*
* @date 28/09/13
* @since 5.0.0
*
* @param mixed $value The value to preview.
* @param string $post_id The post ID for this value.
* @param array $field The field array.
*/
$value = apply_filters( "acf/format_value", $value, $post_id, $field );
// Update store.
$store->set( "$post_id:$field_name:formatted", $value );
// Return value.
return $value;
}