Skip to main content
This page documents the core PHP classes available in Visual Portfolio for developers to extend and integrate with the plugin.

Core Classes

Visual_Portfolio

The main plugin class that bootstraps the Visual Portfolio plugin. Location: class-visual-portfolio.php

Properties

  • $plugin_name (string) - Name of the plugin
  • $plugin_basename (string) - Basename of plugin main file
  • $plugin_path (string) - Path to the plugin directory
  • $plugin_url (string) - URL to the plugin directory
  • $pro_plugin_path (string) - Path to the pro plugin directory (if installed)
  • $pro_plugin_url (string) - URL to the pro plugin directory (if installed)

Methods

instance()
Get the singleton instance of the plugin. Ensures only one instance exists in memory. Returns: The single Visual_Portfolio instance Example:

Visual_Portfolio_Get

Handles portfolio data retrieval and output configuration. Location: classes/class-get-portfolio.php

Methods

get_all_layouts()
Get all available portfolio layouts registered via the vpf_extend_layouts filter. Returns: Array of registered layouts with their controls Example:
get_all_items_styles()
Get all available items styles registered via the vpf_extend_items_styles filter. Returns: Array of registered items styles with their controls
get_options()
Get all available options for a portfolio list. Parameters:
  • $atts (array) - Portfolio attributes including ‘id’ or ‘block_id’
Returns: Array of portfolio options or false if no ID provided Example:
is_preview()
Check if portfolio is displayed in preview mode. Returns: True if in preview mode, false otherwise
allow_taxonomies_for_filter()
Check if a taxonomy is allowed to show in filters. Parameters:
  • $taxonomy (string) - Taxonomy name
Returns: True if taxonomy is allowed, false otherwise
get_output_config()
Prepare configuration that will be used for portfolio output. Parameters:
  • $atts (array) - Portfolio attributes
Returns: Array of output configuration or false on failure

Visual_Portfolio_Assets

Manages static and dynamic asset loading. Location: classes/class-assets.php

Methods

register_script()
Register a JavaScript file. Parameters:
  • $name (string) - Script handle name
  • $path (string) - File path relative to plugin root
  • $dependencies (array) - Array of script dependencies
  • $version (string|null) - Script version
  • $args (array|bool) - Loading strategies (in_footer, strategy)
Example:
enqueue_script()
Register and enqueue a JavaScript file. Parameters: Same as register_script()
register_style()
Register a CSS file. Parameters:
  • $name (string) - Style handle name
  • $path (string) - File path relative to plugin root
  • $dependencies (array) - Array of style dependencies
  • $version (string|null) - Style version
enqueue_style()
Register and enqueue a CSS file. Parameters: Same as register_style()
get_asset_file()
Get asset file data from .asset.php file. Parameters:
  • $filepath (string) - Asset file path
  • $filetype (string) - Asset file type (‘style’ or ‘script’)
Returns: Array with ‘dependencies’ and ‘version’ keys

Visual_Portfolio_Images

Handles image processing, lazy loading, and image size management. Location: classes/class-images.php

Properties

  • $image_processing (bool) - True when image is being processed
  • $allow_vp_lazyload (bool) - Whether VP images use lazyload
  • $allow_wp_lazyload (bool) - Whether WordPress images use lazyload
  • $lazyload_user_exclusions (array) - List of lazyload exclusions

Methods

add_image_sizes()
Register custom image sizes for Visual Portfolio. Registers the following sizes:
  • vp_sm - Small
  • vp_md - Medium
  • vp_lg - Large
  • vp_xl - Extra Large
  • vp_sm_popup - Small popup
  • vp_md_popup - Medium popup
  • vp_xl_popup - Extra Large popup
wp_get_attachment_image_url()
Get the URL of an image attachment. Parameters:
  • $attachment_id (int) - Image attachment ID
  • $size (string|array) - Image size to retrieve
  • $icon (bool) - Whether to treat as icon
Returns: Attachment URL or false if unavailable
get_image_blocked_attributes()
Get blocked attributes to prevent lazy loading. Returns: Array of attribute names that block lazy loading

Visual_Portfolio_Controls

Manages control registration and rendering for the portfolio builder. Location: classes/class-controls.php

Methods

register_categories()
Register control categories. Parameters:
  • $categories (array) - Array of category definitions
register()
Register controls for the portfolio builder. Parameters:
  • $controls (array) - Array of control definitions
Example:
get_registered_array()
Get all registered controls as array. Returns: Array of all registered controls
get_registered_value()
Get registered control value. Parameters:
  • $name (string) - Control name
  • $id (int|false) - Post ID to get value from
Returns: Control value

Visual_Portfolio_Settings

Manages plugin settings and options. Location: classes/class-settings.php

Methods

get_option()
Get plugin option value. Parameters:
  • $option (string) - Option name
  • $section (string) - Section name
  • $deprecated_default (string) - Deprecated default value parameter
Returns: Option value (converts ‘on’/‘off’ to boolean) Example:
update_option()
Update plugin option value. Parameters:
  • $option (string) - Option name
  • $section (string) - Section name
  • $value (string) - New option value

Visual_Portfolio_Templates

Handles template loading and rendering. Location: classes/class-templates.php

Methods

include_template()
Include a template file with security checks. Parameters:
  • $template_name (string) - Template file name (without .php)
  • $args (array) - Variables to extract into template scope
Example:
Template Search Order:
  1. Theme: /visual-portfolio/{$template_name}.php
  2. Pro Plugin: templates/{$template_name}.php
  3. Free Plugin: templates/{$template_name}.php
find_template_styles()
Find CSS template file. Parameters:
  • $template_name (string) - Template name
Returns: Array with ‘path’ and ‘version’ keys
include_template_style()
Include and enqueue a template stylesheet. Parameters:
  • $handle (string) - Style handle name
  • $template_name (string) - Template name
  • $deps (array) - Dependencies
  • $ver (string|bool|null) - Version
  • $media (string) - Media type
is_allowed_template_path()
Check if a resolved file path is within allowed template directories (security check). Parameters:
  • $real_path (string) - The resolved file path
Returns: True if path is allowed

Filters

Extending Layouts

Register custom portfolio layouts. Example:

Extending Items Styles

Register custom item styles.

Template Filters

Filter the template file path before inclusion.
Filter template arguments before extraction.

Lazyload Filters

Enable or disable lazy loading globally.
Add attributes that prevent lazy loading.

Actions

Portfolio Output

Fires before portfolio output is generated.

Asset Loading

Fires when portfolio scripts should be enqueued.

Helper Functions

visual_portfolio()

Get the main Visual Portfolio instance. Returns: Visual_Portfolio singleton instance Example: