get_widgets example

/** * Retrieves the list of all widget types. * * @since 5.8.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */
    public function get_items( $request ) {
        $data = array();
        foreach ( $this->get_widgets() as $widget ) {
            $widget_type = $this->prepare_item_for_response( $widget$request );
            $data[]      = $this->prepare_response_for_collection( $widget_type );
        }

        return rest_ensure_response( $data );
    }

    /** * Checks if a given request has access to read a widget type. * * @since 5.8.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. */
Home | Imprint | This part of the site doesn't use cookies.