123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- function acf_get_field_rest_schema( array $field ) {
- $type = acf_get_field_type( $field['type'] );
- $schema = array();
- if ( ! is_object( $type ) || ! method_exists( $type, 'get_rest_schema' ) ) {
- return $schema;
- }
- $schema = $type->get_rest_schema( $field );
-
- return (array) apply_filters( 'acf/rest/get_field_schema', $schema, $field );
- }
- acf_add_filter_variations( 'acf/rest/get_field_schema', array( 'type', 'name', 'key' ), 1 );
- function acf_get_field_rest_links( $post_id, array $field ) {
- $value = acf_get_value( $post_id, $field );
- $type = acf_get_field_type( $field['type'] );
- $links = $type->get_rest_links( $value, $post_id, $field );
-
- return (array) apply_filters( 'acf/rest/get_field_links', $links, $post_id, $field, $value );
- }
- acf_add_filter_variations( 'acf/rest/get_field_links', array( 'type', 'name', 'key' ), 2 );
- function acf_format_value_for_rest( $value, $post_id, $field, $format = 'light' ) {
- if ( $format === 'standard' ) {
- $value_formatted = acf_format_value( $value, $post_id, $field );
- } else {
- $type = acf_get_field_type( $field['type'] );
- $value_formatted = $type->format_value_for_rest( $value, $post_id, $field );
- }
-
- return apply_filters( 'acf/rest/format_value_for_rest', $value_formatted, $post_id, $field, $value, $format );
- }
- acf_add_filter_variations( 'acf/rest/format_value_for_rest', array( 'type', 'name', 'key' ), 2 );
|