acf_field_page_link::format_value() public ACF 3.6
This filter is appied to the $value after it is loaded from the db and before it is returned to the template
{} Это метод класса: acf_field_page_link{}
Хуков нет.
Возвращает
$value. (mixed) the modified value
Использование
$acf_field_page_link = new acf_field_page_link(); $acf_field_page_link->format_value( $value, $post_id, $field );
- (mixed)($value) (обязательный)
- the value which was loaded from the database
- (mixed)($post_id) (обязательный)
- the $post_id from which the value was loaded
- (array)($field) (обязательный)
- the field array holding all the field options
Список изменений
С версии 3.6 | Введена. |
Код acf_field_page_link::format_value() acf field page link::format value ACF 5.9.1
function format_value( $value, $post_id, $field ) {
// ACF4 null
if( $value === 'null' ) {
return false;
}
// bail early if no value
if( empty($value) ) {
return $value;
}
// get posts
$value = $this->get_posts( $value, $field );
// set choices
foreach( array_keys($value) as $i ) {
// vars
$post = acf_extract_var( $value, $i );
// convert $post to permalink
if( is_object($post) ) {
$post = get_permalink( $post );
}
// append back to $value
$value[ $i ] = $post;
}
// convert back from array if neccessary
if( !$field['multiple'] ) {
$value = array_shift($value);
}
// return value
return $value;
}