has_param example


    protected function get_json_encode_options( WP_REST_Request $request ) {
        $options = 0;

        if ( $request->has_param( '_pretty' ) ) {
            $options |= JSON_PRETTY_PRINT;
        }

        /** * Filters the JSON encoding options used to send the REST API response. * * @since 6.1.0 * * @param int $options JSON encoding options {@see json_encode()}. * @param WP_REST_Request $request Current request object. */
        
$request = new WP_REST_Request( $method$path_parts['path'] );
    if ( ! empty( $path_parts['query'] ) ) {
        parse_str( $path_parts['query']$query_params );
        $request->set_query_params( $query_params );
    }

    $response = rest_do_request( $request );
    if ( 200 === $response->status ) {
        $server = rest_get_server();
        /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
        $response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response )$server$request );
        $embed    = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false;
        $data     = (array) $server->response_to_data( $response$embed );

        if ( 'OPTIONS' === $method ) {
            $memo[ $method ][ $path ] = array(
                'body'    => $data,
                'headers' => $response->headers,
            );
        } else {
            $memo[ $path ] = array(
                'body'    => $data,
                'headers' => $response->headers,
            );
if ( ! empty( $date_data ) && $current_date !== $date_data[1] ) {
                list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
                $prepared_post->edit_date                                        = true;
            }
        }

        /* * Sending a null date or date_gmt value resets date and date_gmt to their * default values (`0000-00-00 00:00:00`). */
        if (
            ( ! empty( $schema['properties']['date_gmt'] ) && $request->has_param( 'date_gmt' ) && null === $request['date_gmt'] ) ||
            ( ! empty( $schema['properties']['date'] ) && $request->has_param( 'date' ) && null === $request['date'] )
        ) {
            $prepared_post->post_date_gmt = null;
            $prepared_post->post_date     = null;
        }

        // Post slug.         if ( ! empty( $schema['properties']['slug'] ) && isset( $request['slug'] ) ) {
            $prepared_post->post_name = $request['slug'];
        }

        

        }

        $fields = array_keys( $properties );

        /* * '_links' and '_embedded' are not typically part of the item schema, * but they can be specified in '_fields', so they are added here as a * convenience for checking with rest_is_field_included(). */
        $fields[] = '_links';
        if ( $request->has_param( '_embed' ) ) {
            $fields[] = '_embedded';
        }

        $fields = array_unique( $fields );

        if ( ! isset( $request['_fields'] ) ) {
            return $fields;
        }
        $requested_fields = wp_parse_list( $request['_fields'] );
        if ( 0 === count( $requested_fields ) ) {
            return $fields;
        }
        $parsed_id     = wp_parse_widget_id( $widget_id );
        $widget_object = $wp_widget_factory->get_widget_object( $parsed_id['id_base'] );
        if ( is_null( $sidebar_id ) && $widget_object ) {
            return new WP_Error(
                'rest_widget_not_found',
                __( 'No widget was found with that id.' ),
                array( 'status' => 404 )
            );
        }

        if (
            $request->has_param( 'instance' ) ||
            $request->has_param( 'form_data' )
        ) {
            $maybe_error = $this->save_widget( $request$sidebar_id );
            if ( is_wp_error( $maybe_error ) ) {
                return $maybe_error;
            }
        }

        if ( $request->has_param( 'sidebar' ) ) {
            if ( $sidebar_id !== $request['sidebar'] ) {
                $sidebar_id = $request['sidebar'];
                
Home | Imprint | This part of the site doesn't use cookies.