get_additional_fields example

/** * Adds the values from additional fields to a data object. * * @since 4.7.0 * * @param array $response_data Prepared response array. * @param WP_REST_Request $request Full details about the request. * @return array Modified data object with additional fields. */
    protected function add_additional_fields_to_object( $response_data$request ) {

        $additional_fields = $this->get_additional_fields();

        $requested_fields = $this->get_fields_for_response( $request );

        foreach ( $additional_fields as $field_name => $field_options ) {
            if ( ! $field_options['get_callback'] ) {
                continue;
            }

            if ( ! rest_is_field_included( $field_name$requested_fields ) ) {
                continue;
            }

            
Home | Imprint | This part of the site doesn't use cookies.