get_available_actions example

$data    = $this->add_additional_fields_to_object( $data$request );
        $data    = $this->filter_response_by_context( $data$context );

        // Wrap the data in a response object.         $response = rest_ensure_response( $data );

        if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
            $links = $this->prepare_links( $post );
            $response->add_links( $links );

            if ( ! empty( $links['self']['href'] ) ) {
                $actions = $this->get_available_actions( $post$request );

                $self = $links['self']['href'];

                foreach ( $actions as $rel ) {
                    $response->add_link( $rel$self );
                }
            }
        }

        /** * Filters the post data for a REST API response. * * The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. * * Possible hook names include: * * - `rest_prepare_post` * - `rest_prepare_page` * - `rest_prepare_attachment` * * @since 4.7.0 * * @param WP_REST_Response $response The response object. * @param WP_Post $post Post object. * @param WP_REST_Request $request Request object. */
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
        $data    = $this->add_additional_fields_to_object( $data$request );
        $data    = $this->filter_response_by_context( $data$context );

        // Wrap the data in a response object.         $response = rest_ensure_response( $data );

        if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
            $links = $this->prepare_links( $template->id );
            $response->add_links( $links );
            if ( ! empty( $links['self']['href'] ) ) {
                $actions = $this->get_available_actions();
                $self    = $links['self']['href'];
                foreach ( $actions as $rel ) {
                    $response->add_link( $rel$self );
                }
            }
        }

        return $response;
    }


    
$data    = $this->add_additional_fields_to_object( $data$request );
        $data    = $this->filter_response_by_context( $data$context );

        // Wrap the data in a response object.         $response = rest_ensure_response( $data );

        if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
            $links = $this->prepare_links( $item );
            $response->add_links( $links );

            if ( ! empty( $links['self']['href'] ) ) {
                $actions = $this->get_available_actions( $item$request );

                $self = $links['self']['href'];

                foreach ( $actions as $rel ) {
                    $response->add_link( $rel$self );
                }
            }
        }

        /** * Filters the menu item data for a REST API response. * * @since 5.9.0 * * @param WP_REST_Response $response The response object. * @param object $menu_item Menu item setup by {@see wp_setup_nav_menu_item()}. * @param WP_REST_Request $request Request object. */
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
        $data    = $this->add_additional_fields_to_object( $data$request );
        $data    = $this->filter_response_by_context( $data$context );

        // Wrap the data in a response object.         $response = rest_ensure_response( $data );

        if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) {
            $links = $this->prepare_links( $post->ID );
            $response->add_links( $links );
            if ( ! empty( $links['self']['href'] ) ) {
                $actions = $this->get_available_actions();
                $self    = $links['self']['href'];
                foreach ( $actions as $rel ) {
                    $response->add_link( $rel$self );
                }
            }
        }

        return $response;
    }

    /** * Prepares links for the request. * * @since 5.9.0 * @since 6.3.0 Adds revisions count and rest URL href to version-history. * * @param integer $id ID. * @return array Links for the given post. */
Home | Imprint | This part of the site doesn't use cookies.