prepare_value example

$response[ $name ] = apply_filters( 'rest_pre_get_setting', null, $name$args );

            if ( is_null( $response[ $name ] ) ) {
                // Default to a null value as "null" in the response means "not set".                 $response[ $name ] = get_option( $args['option_name']$args['schema']['default'] );
            }

            /* * Because get_option() is lossy, we have to * cast values to the type they are registered with. */
            $response[ $name ] = $this->prepare_value( $response[ $name ]$args['schema'] );
        }

        return $response;
    }

    /** * Prepares a value for output based off a schema array. * * @since 4.7.0 * * @param mixed $value Value to prepare. * @param array $schema Schema to match. * @return mixed The prepared value. */
Home | Imprint | This part of the site doesn't use cookies.