Overview
ThemePlus provides a small set of global helper functions for retrieving and updating option values, checking plugin status, and registering sections and fields. These are the only functions your theme needs to interact with ThemePlus directly.
Option Functions
themeplus_get_option()
Retrieves a saved option value. If no key is provided, returns all options as an array.
php
themeplus_get_option( string $key = null, mixed $default = '' ): mixed
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$key | string|null | null | The option field ID. Pass null to get all options. |
$default | mixed | '' | Value to return if the option is not set. |
Examples
php
// Get a single option
$color = themeplus_get_option( 'primary_color', '#2271b1' );
// Get all options at once (recommended when using multiple fields)
$options = themeplus_get_option();
$color = $options['primary_color'] ?? '#2271b1';
$enabled = $options['enable_preloader'] ?? true;
Performance tip: If your template uses more than two or three options, call
themeplus_get_option()once with no arguments and access values from the returned array. This hits the database only once instead of once per field.
themeplus_update_option()
Updates a single option value in the database.
php
themeplus_update_option( string $key, mixed $value ): bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | The option field ID to update. |
$value | mixed | The new value to store. |
Returns: true on success, false on failure.
Example
php
themeplus_update_option( 'primary_color', '#ff6b6b' );
Status Functions
themeplus_is_active()
Checks whether ThemePlus is installed and active. Safe to call before the plugin has fully loaded — useful for writing theme code that degrades gracefully if the plugin is missing.
php
themeplus_is_active(): bool
Example
php
if ( themeplus_is_active() ) {
$color = themeplus_get_option( 'primary_color', '#2271b1' );
} else {
$color = '#2271b1';
}
themeplus_get_version()
Returns the current ThemePlus plugin version string.
php
themeplus_get_version(): string
Example
php
$version = themeplus_get_version();
// Returns: '1.0.0'
Config Functions
themeplus_framework_config()
Configures the ThemePlus framework with your theme’s white-label settings. Must be called on the after_setup_theme hook.
php
themeplus_framework_config( array $config ): void
See the Framework Configuration article for the full list of available options.
themeplus_add_section()
Registers a new section in the options panel sidebar.
php
themeplus_add_section( array $section ): void
Example
php
themeplus_add_section([
'id' => 'general',
'title' => __('General Settings', 'your-textdomain'),
'icon' => 'fa-solid fa-cog',
'fields' => [],
]);
See the Sections & Subsections article for the full reference.
themeplus_add_subsection()
Registers a subsection under an existing parent section.
php
themeplus_add_subsection( string $parent_id, array $subsection ): void
Parameters
| Parameter | Type | Description |
|---|---|---|
$parent_id | string | The ID of the parent section. |
$subsection | array | Subsection config array with id, title, and fields. |
Example
php
themeplus_add_subsection('header', [
'id' => 'logo',
'title' => __('Logo', 'your-textdomain'),
'fields' => [
[
'id' => 'logo_image',
'type' => 'image',
'title' => __('Logo Image', 'your-textdomain'),
],
],
]);
themeplus_get_sections()
Returns all registered sections as an array.
php
themeplus_get_sections(): array
themeplus_get_section()
Returns a single section by its ID, or null if not found.
php
themeplus_get_section( string $section_id ): array|null
themeplus_get_all_fields()
Returns all registered fields across all sections as a flat array keyed by field ID.
php
themeplus_get_all_fields(): array
Safety Pattern
Always wrap ThemePlus function calls in an existence check when writing theme code. This ensures your theme works correctly even if ThemePlus is deactivated or not yet installed:
php
// For config functions
if ( ! function_exists('themeplus_framework_config') ) {
return;
}
// For option retrieval
if ( function_exists('themeplus_get_option') ) {
$color = themeplus_get_option('primary_color', '#2271b1');
} else {
$color = '#2271b1';
}
// Or use themeplus_is_active() as a single guard
if ( themeplus_is_active() ) {
$options = themeplus_get_option();
}
Function Reference Summary
| Function | Description |
|---|---|
themeplus_get_option( $key, $default ) | Get a single option or all options |
themeplus_update_option( $key, $value ) | Update a single option |
themeplus_is_active() | Check if ThemePlus is active |
themeplus_get_version() | Get the plugin version string |
themeplus_framework_config( $config ) | Configure the framework |
themeplus_add_section( $section ) | Register a section |
themeplus_add_subsection( $parent_id, $subsection ) | Register a subsection |
themeplus_get_sections() | Get all registered sections |
themeplus_get_section( $section_id ) | Get a section by ID |
themeplus_get_all_fields() | Get all registered fields |