Base URL
All endpoints are prefixed with:visual-portfolio/v1
Endpoints
Get Layouts List
Retrieve a list of all saved portfolio layouts. Endpoint:GET /get_layouts/
Permission: edit_posts
Response:
Update Layout Data
Update portfolio layout configuration. Endpoint:POST /update_layout/
Permission: edit_post (for the specific post)
Parameters:
post_id(integer, required) - Portfolio post IDdata(object, required) - Layout configuration data
Get Filter Items
Retrieve filter items for a portfolio based on content source. Endpoint:POST /get_filter_items/
Permission: edit_posts
Parameters:
content_source(string, required) - Content source type (‘post-based’, ‘images’)post_id(integer, required) - Current post ID for URL generation- Additional parameters based on content source
posts_source(string) - Posts sourcepost_types_set(array) - Post types to includeposts_taxonomies(object) - Taxonomy filtersposts_order_by(string) - Order by fieldposts_order_direction(string) - Order direction
images(array) - Array of image IDsimages_order_by(string) - Order by field
Get Max Pages
Calculate the maximum number of pages for pagination. Endpoint:GET|POST /get-max-pages/
Permission: edit_posts
Parameters:
content_source(string, required) - Content source typeitems_count(integer, required) - Number of items per page- Additional content-specific parameters
Update Gallery Items Count Notice State
Update the visibility state of the gallery items count notice. Endpoint:POST /update_gallery_items_count_notice_state/
Permission: manage_options and edit_post
Parameters:
post_id(integer, required) - Portfolio post IDnotice_state(string, required) - Notice state value
PHP Implementation
Accessing REST Endpoints in PHP
You can make internal REST API requests using WordPress functions. Example:Making External API Calls
Using wp_remote_post:JavaScript Helper Functions
Making Authenticated Requests
With nonce authentication:Error Handling
Common Error Codes
not_allowed- User lacks required permissionsmissing_params- Required parameters not providedno_layouts_found- No portfolio layouts existinvalid_content_source- Invalid content source specifiedpost_id_required- Post ID parameter missinguser_dont_have_permission- User lacks specific permission
Error Response Format
All error responses follow this structure:Handling Errors
JavaScript:Security
Permission Checks
All endpoints implement WordPress capability checks:- edit_posts - Required for reading layouts and filters
- edit_post - Required for updating specific layouts
- manage_options - Required for plugin settings
Nonce Verification
When making requests from the frontend, include the nonce:Data Sanitization
All input data is sanitized using:sanitize_text_field()- For text inputsintval()- For integer valuesVisual_Portfolio_Security::sanitize_attributes()- For attribute arraysVisual_Portfolio_Security::validate_calculate_max_pages_params()- For pagination params