Overview
The Visual Portfolio plugin includes a powerful visual editor that allows you to create and configure portfolio layouts through a dedicated post type interface. This editor provides a live preview and comprehensive settings panel.Saved Layouts (vp_lists)
Visual Portfolio uses a custom post type calledvp_lists to store saved layouts. Each saved layout is a reusable portfolio configuration that can be inserted anywhere on your site.
Accessing the Visual Editor
- Navigate to WordPress Admin → Visual Portfolio → Add New
- The editor will open with a single block:
visual-portfolio/saved-editor - Configure your settings in the sidebar
- Preview changes in real-time in the editor
Editor Architecture
The visual editor is built on top of WordPress Gutenberg and located in/home/daytona/workspace/source/gutenberg/layouts-editor/.
Editor Block
The editor uses a special block (visual-portfolio/saved-editor) that is automatically inserted and always selected:
Editor Enforcement
The editor enforces several rules:- Visual Mode Only - Forces the editor to stay in visual mode
- Single Block - Only allows one editor block per layout
- Always Selected - Keeps the editor block selected for immediate configuration
Settings Storage
Layout settings are stored as WordPress post meta with thevp_ prefix:
Meta Data Caching
The plugin caches layout meta for performance in/home/daytona/workspace/source/classes/class-controls.php:348-366:
Control System
The visual editor uses a robust control system defined inclass-controls.php.
Default Control Arguments
Every control supports these base arguments:Control Types
The editor supports various control types:- text - Single line text input
- textarea - Multi-line text
- number - Numeric input
- range - Slider control
- checkbox - Boolean toggle
- select - Dropdown selection
- color - Color picker with alpha/gradient support
- gallery - Image gallery manager
- code_editor - Code editor with syntax highlighting
- elements_selector - Element location selector
- align - Alignment control
Conditional Controls
Controls can be conditionally shown based on other control values:==, !==, >, <, >=, <=
Style System
Controls can automatically generate CSS:Control Categories
Controls are organized into categories for better UX:Registering Custom Controls
You can register custom controls for the visual editor:Boolean String Fields
Some controls use string boolean values for dropdown options. The plugin automatically handles conversion for saved layouts:/home/daytona/workspace/source/classes/class-controls.php:421-442.
Dynamic Controls
Controls can have dynamic values loaded via AJAX:/home/daytona/workspace/source/classes/class-controls.php:145-187.
Live Preview System
The visual editor includes an iframe-based live preview system:Reload on Change
Controls withreload_iframe set to true will refresh the preview when changed:
Preview Rendering
The preview is rendered using the same output system as the frontend, ensuring WYSIWYG accuracy.Gallery Control
The gallery control is a special control type for managing images:Gallery Data Structure
Custom CSS Control
The editor includes a code editor control for custom CSS:/home/daytona/workspace/source/classes/class-controls.php:398-404.
Best Practices
- Control Names - Use descriptive, unique names with underscores (e.g.,
items_gap,filter_show_count) - Default Values - Always provide sensible defaults for better UX
- Conditions - Use conditional controls to simplify the interface
- Categories - Organize related controls into logical categories
- Validation - Use
sanitize_callbackto validate user input - Performance - Set
reload_iframetofalsefor non-visual controls - WPML Support - Enable
wpmlfor translatable string controls
Sanitization Callbacks
Always sanitize user input:sanitize_text_field()- For text inputssanitize_textarea_field()- For textareasabsint()- For positive integersfloatval()- For decimal numberswp_kses_post()- For HTML content
Related
- Gutenberg Block - Using blocks in the editor
- Shortcodes - Display saved layouts with shortcodes
- Settings Overview - Complete settings reference