Skip to main content

Overview

Visual Portfolio uses a comprehensive control system to manage all settings for layouts, items, filters, and pagination. Controls are dynamically registered and organized into categories for better user experience.

Control System Architecture

The control system is defined in /home/daytona/workspace/source/classes/class-controls.php and provides:
  • Dynamic control registration
  • Category organization
  • Conditional display logic
  • Style generation
  • Value callbacks
  • Sanitization

Default Control Arguments

Every control supports these base arguments (lines 49-130):

Control Types

Text Controls

text - Single line text input
textarea - Multi-line text

Numeric Controls

number - Numeric input
range - Slider control

Boolean Controls

checkbox - Checkbox toggle
toggle - Toggle switch

Selection Controls

select - Dropdown selection
select2 - Enhanced select with search

Visual Controls

color - Color picker
align - Alignment control

Advanced Controls

code_editor - Code editor with syntax highlighting
gallery - Image gallery manager
elements_selector - Element location selector
sortable - Drag-and-drop sortable list

Display Controls

notice - Information notice
html - Custom HTML content

Control Categories

Controls are organized into categories for better UX. Common categories include:
  • content-source - Content source selection
  • content-source-general - General content settings
  • content-source-images - Image source settings
  • content-source-post-based - Post query settings
  • layouts - Layout selection and options
  • items-style - Item styling options
  • filter - Filter settings
  • sort - Sorting options
  • pagination - Pagination settings
  • custom_css - Custom CSS editor

Registering Categories

Conditional Display

Controls support sophisticated conditional logic:

Supported Operators

  • == - Equals
  • !== - Not equals
  • > - Greater than
  • < - Less than
  • >= - Greater than or equal
  • <= - Less than or equal

Multiple Conditions

All conditions in the array must be true (AND logic):

Style Generation

Controls can automatically generate CSS:

Multiple Styles

One control can generate multiple CSS rules:

Value Callbacks

Use callbacks to provide dynamic values:

AJAX Dynamic Controls

Dynamic controls automatically load via AJAX when dependencies change (line 136-187).

Sanitization

Always sanitize user input:

Common Sanitization Functions

Boolean String Fields

Some controls use string boolean values for dropdown options (lines 304-332):
Conversion is automatic for saved layouts (vp_lists post type) in lines 421-442.

Registering Custom Controls

Basic Registration

Advanced Registration

Getting Control Values

Retrieve control values programmatically:

Filtering Controls

Filter Control Registration

Filter Control Value

Filter Registered Controls

WPML Integration

Enable translation for string controls:

Setup Wizard

Include controls in the setup wizard:

Best Practices

  1. Naming Convention - Use descriptive names with underscores (e.g., items_gap, show_filter)
  2. Default Values - Always provide sensible defaults
  3. Sanitization - Always sanitize user input with callbacks
  4. Conditions - Use conditions to show/hide related controls
  5. Categories - Organize controls into logical categories
  6. Descriptions - Provide helpful descriptions for complex controls
  7. Performance - Set reload_iframe to false for non-visual controls
  8. Validation - Validate min/max values for numeric inputs
  9. Accessibility - Use proper labels for screen readers
  10. Documentation - Comment complex control configurations

Common Patterns

Layout-Specific Settings

Responsive Settings