Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nk-crew/visual-portfolio/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Visual Portfolio provides native Gutenberg blocks that integrate seamlessly with the WordPress block editor. There are two main blocks available:- Visual Portfolio Block - The main block for creating galleries and portfolio layouts
- Saved Layout Block - A block for displaying pre-configured saved layouts
Visual Portfolio Block
The main Visual Portfolio block (visual-portfolio/block) allows you to create custom galleries and portfolio layouts directly in the block editor.
Block Registration
The block is registered in/home/daytona/workspace/source/gutenberg/block/index.php:27-34:
Block Configuration
The block supports the following features as defined inblock.json:
Dynamic Attributes
Block attributes are dynamically generated from registered controls in/home/daytona/workspace/source/classes/class-gutenberg.php:35-141. The system automatically converts control types to appropriate block attribute types:
- checkbox/toggle →
boolean - number/range →
number - select (multiple) →
array - gallery →
arrayof objects - elements_selector →
object
Block Context
The block can receive context from parent blocks using theusesContext property:
/home/daytona/workspace/source/classes/class-gutenberg.php:145-178.
Loop Block
The Loop block (visual-portfolio/loop) is a container block that provides a complete portfolio structure with filters, gallery, and pagination.
Block Structure
The Loop block uses a predefined template with nested blocks:Content Source Controls
The Loop block displays specific control categories in the sidebar:content-sourcecontent-source-generalcontent-source-imagescontent-source-post-basedcontent-source-social-streamcustom_css
Max Pages Calculation
The Loop block automatically calculates the maximum number of pages via REST API when attributes change:Saved Layout Block
The Saved Layout block (visual-portfolio/saved-layout) displays pre-configured portfolio layouts saved as custom post types.
Block Attributes
WPML Support
The block includes WPML integration for translated layouts:Block Editor Integration
JavaScript Assets
Block editor assets are enqueued in/home/daytona/workspace/source/classes/class-gutenberg.php:183-234:
Global Variables
The following variables are available to JavaScript viaVPGutenbergVariables:
nonce- AJAX nonce for securityplugin_version- Current plugin versionplugin_url- Plugin URL pathattributes- All registered block attributescontrols- All registered controlscontrols_categories- Control categories for organization
Block Render Callback
The block render callback in/home/daytona/workspace/source/gutenberg/block/index.php:45-71 processes attributes and outputs the portfolio:
Using Blocks Programmatically
Creating a Block in Code
Registering Custom Block Attributes
You can filter block attributes before registration:Best Practices
- Use Context - When building nested block structures, use block context to pass data from parent to child blocks
- Validate Attributes - Always validate and sanitize attributes in render callbacks
- Cache Control Data - The plugin caches control data for performance - clear cache when modifying controls
- Preview Mode - Use the
preview_image_exampleattribute to show layout previews in the block inserter - Anchor Support - Enable anchor support for deep linking to specific portfolios on a page
Related
- Visual Editor - Learn about the visual layout editor
- Shortcodes - Alternative method for displaying portfolios
- Settings Overview - Complete guide to all settings