PHP Класс TitanFramework

С версии: 1.0
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$cssInstance TitanFrameworkCSS The CSS class instance used
$optionNamespace string Options will be prefixed with this in the database
$optionsUsed array We store the options (with IDs) here, used for ensuring our serialized option value doesn't get cluttered with unused options
$settings array The current list of settings

Открытые методы

Метод Описание
__construct ( string $optionNamespace ) Creates a new TitanFramework object
addCustomizerSaveFilter ( mixed $value, string $optionName, mixed $oldValue ) : mixed Adds a 'tf_save_option_{namespace}_{optionID}' filter to all Customizer options which are just about to be saved
createAdminPage ( array $settings ) : TitanFrameworkAdminPage Create a admin page
createAdminPanel ( array $settings ) : TitanFrameworkAdminPage Create a admin page
createCSS ( string $CSSString ) : void Generates style rules which can use options as their values
createContainer ( array $settings ) : TitanFrameworkCustomizer | TitanFrameworkAdminPage | TitanFrameworkMetaBox Creates a container (e.g. admin page, meta box, customizer section) depending on the type parameter given in $settings
createCustomizer ( array $settings ) : TitanFrameworkCustomizer Create a customizer section
createMetaBox ( array $settings ) : TitanFrameworkMetaBox Create a meta box
createSampleContentPage ( array $settings ) : TitanFrameworkAdminPage Create a sample content only.
createThemeCustomizerSection ( array $settings ) : TitanFrameworkCustomizer Create a customizer section
deleteAllOptions ( ) : void Deletes ALL the options for the namespace. Even deletes all meta found in all posts.
displayFrameworkError ( string $message, array | object $errorObject = null ) : void Displays an error notice
generateCSS ( ) : string Gets the CSS generated
getAllInstances ( ) : array Gets all active instances of Titan Framework
getInstance ( string $optionNamespace ) : TitanFramework Gets an instance of the framework for the namespace
getInternalAdminPageOption ( string $optionName, mixed $defaultValue = false ) : mixed Gets the admin page option that's loaded into the instance, used by the option class
getOption ( string $optionName, integer $postID = null ) : mixed Get an option
getOptions ( array $optionArray, integer $postID = null ) : array Gets a set of options. Pass an associative array containing the option names as keys and the values you want to be retained if the option names are not implemented.
getURL ( string $script, string $file ) : string Acts the same way as plugins_url( 'script', __FILE__ ) but returns then correct url when called from inside a theme.
loadAdminScripts ( string $hook ) : void Loads all the admin scripts used by Titan Framework
rememberAllOptions ( TitanFrameworkOption $option ) : void Action hook on tf_create_option to remember all the options, used to ensure that our serialized option does not get cluttered with unused options
removeChildThemeOptions ( boolean $continueCreating, array $optionSettings ) : boolean Hook to the tf_create_option_continue filter, to check whether or not to continue adding an option (if the option id was used in $titan->removeOption).
removeOption ( string $optionName ) : void A function available ONLY to CHILD themes to stop the creation of options created by the PARENT theme.
saveInternalAdminPageOptions ( ) : array Saves all the admin (not meta & customizer) options which are currently loaded into this instance
set ( string $setting, string $value ) : void Sets a value in the $setting class variable
setInternalAdminPageOption ( string $optionName, mixed $value ) : boolean Sets the admin page option that's loaded into the instance, used by the option class.
setOption ( string $optionName, mixed $value, integer $postID = null ) : boolean Sets an option

Защищенные методы

Метод Описание
getInternalAdminOptions ( ) : array Gets all the admin page options (not meta & customizer) and loads them from the database into a class variable. This is needed because all our admin page options are contained in a single entry.

Описание методов

__construct() публичный Метод

Creates a new TitanFramework object
С версии: 1.0
public __construct ( string $optionNamespace )
$optionNamespace string The namespace to get options from.

addCustomizerSaveFilter() публичный Метод

This uses the pre_update_option filter to check all the options being saved if it's a theme_mod option. It further checks whether these are Titan customizer options, then attaches the new hook into those.
См. также: pre_update_option filter
С версии: 1.8
public addCustomizerSaveFilter ( mixed $value, string $optionName, mixed $oldValue ) : mixed
$value mixed The value to be saved in the options.
$optionName string The option name.
$oldValue mixed The previously stored value.
Результат mixed The modified value to save

createAdminPage() публичный Метод

Create a admin page
С версии: 1.0
public createAdminPage ( array $settings ) : TitanFrameworkAdminPage
$settings array The arguments for creating the admin page.
Результат TitanFrameworkAdminPage The created admin page

createAdminPanel() публичный Метод

Create a admin page
Устаревший: 1.9 Use createContainer() with 'type' => 'admin-page' or createAdminPanel() instead.
С версии: 1.0
public createAdminPanel ( array $settings ) : TitanFrameworkAdminPage
$settings array The arguments for creating the admin page.
Результат TitanFrameworkAdminPage The created admin page

createCSS() публичный Метод

Generates style rules which can use options as their values
С версии: 1.0
public createCSS ( string $CSSString ) : void
$CSSString string The styles to render.
Результат void

createContainer() публичный Метод

Creates a container (e.g. admin page, meta box, customizer section) depending on the type parameter given in $settings
С версии: 1.9
public createContainer ( array $settings ) : TitanFrameworkCustomizer | TitanFrameworkAdminPage | TitanFrameworkMetaBox
$settings array The arguments for creating the container.
Результат TitanFrameworkCustomizer | TitanFrameworkAdminPage | TitanFrameworkMetaBox The created container

createCustomizer() публичный Метод

Create a customizer section
С версии: 1.9
public createCustomizer ( array $settings ) : TitanFrameworkCustomizer
$settings array The arguments for creating a customizer section.
Результат TitanFrameworkCustomizer The created section

createMetaBox() публичный Метод

Create a meta box
С версии: 1.0
public createMetaBox ( array $settings ) : TitanFrameworkMetaBox
$settings array The arguments for creating the meta box.
Результат TitanFrameworkMetaBox The created meta box

createSampleContentPage() публичный Метод

Use createSampleContent() with 'type' => 'sample-panel' or createSamplePanel() instead.
С версии: 1.11
public createSampleContentPage ( array $settings ) : TitanFrameworkAdminPage
$settings array The arguments for creating the sample conent page.
Результат TitanFrameworkAdminPage The created sample coennt page.

createThemeCustomizerSection() публичный Метод

Create a customizer section
Устаревший: 1.9 Use createContainer() with 'type' => 'customizer' or createCustomizer instead.
С версии: 1.0
public createThemeCustomizerSection ( array $settings ) : TitanFrameworkCustomizer
$settings array The arguments for creating a customizer section.
Результат TitanFrameworkCustomizer The created section

deleteAllOptions() публичный Метод

Mainly used for unit tests
С версии: 1.9
public deleteAllOptions ( ) : void
Результат void

displayFrameworkError() публичный статический Метод

Displays an error notice
С версии: 1.0
public static displayFrameworkError ( string $message, array | object $errorObject = null ) : void
$message string The error message to display.
$errorObject array | object The object to dump inside the error message.
Результат void

generateCSS() публичный Метод

Gets the CSS generated
С версии: 1.6
public generateCSS ( ) : string
Результат string The generated CSS

getAllInstances() публичный статический Метод

Gets all active instances of Titan Framework
С версии: 1.9.2
public static getAllInstances ( ) : array
Результат array An array of TitanFramework objects

getInstance() публичный статический Метод

Gets an instance of the framework for the namespace
С версии: 1.0
public static getInstance ( string $optionNamespace ) : TitanFramework
$optionNamespace string The namespace to get options from.
Результат TitanFramework

getInternalAdminOptions() защищенный Метод

Gets all the admin page options (not meta & customizer) and loads them from the database into a class variable. This is needed because all our admin page options are contained in a single entry.
С версии: 1.9
protected getInternalAdminOptions ( ) : array
Результат array All admin options currently in the instance

getInternalAdminPageOption() публичный Метод

Gets the admin page option that's loaded into the instance, used by the option class
С версии: 1.9
public getInternalAdminPageOption ( string $optionName, mixed $defaultValue = false ) : mixed
$optionName string The ID of the option (not namespaced).
$defaultValue mixed The default value to return if the option isn't available yet.
Результат mixed The option value

getOption() публичный Метод

Get an option
С версии: 1.0
public getOption ( string $optionName, integer $postID = null ) : mixed
$optionName string The name of the option.
$postID integer The post ID if this is a meta option.
Результат mixed The option value

getOptions() публичный Метод

Gets a set of options. Pass an associative array containing the option names as keys and the values you want to be retained if the option names are not implemented.
С версии: 1.9
public getOptions ( array $optionArray, integer $postID = null ) : array
$optionArray array An associative array containing option names as keys.
$postID integer The post ID if this is a meta option.
Результат array An array containing the values saved.

getURL() публичный статический Метод

Acts the same way as plugins_url( 'script', __FILE__ ) but returns then correct url when called from inside a theme.
С версии: 1.1.2
public static getURL ( string $script, string $file ) : string
$script string the script to get the url to, relative to $file.
$file string the current file, should be __FILE__.
Результат string the url to $script

loadAdminScripts() публичный Метод

Loads all the admin scripts used by Titan Framework
С версии: 1.0
public loadAdminScripts ( string $hook ) : void
$hook string The slug of admin page that called the enqueue.
Результат void

rememberAllOptions() публичный Метод

Action hook on tf_create_option to remember all the options, used to ensure that our serialized option does not get cluttered with unused options
С версии: 1.2.1
public rememberAllOptions ( TitanFrameworkOption $option ) : void
$option TitanFrameworkOption The option that was just created.
Результат void

removeChildThemeOptions() публичный Метод

Hook to the tf_create_option_continue filter, to check whether or not to continue adding an option (if the option id was used in $titan->removeOption).
С версии: 1.2.1
public removeChildThemeOptions ( boolean $continueCreating, array $optionSettings ) : boolean
$continueCreating boolean If true, the option will be created.
$optionSettings array The settings for the option to be created.
Результат boolean If true, continue with creating the option. False to stop it..

removeOption() публичный Метод

A function available ONLY to CHILD themes to stop the creation of options created by the PARENT theme.
С версии: 1.2.1
public removeOption ( string $optionName ) : void
$optionName string The id of the option to remove / stop from being created.
Результат void

saveInternalAdminPageOptions() публичный Метод

Saves all the admin (not meta & customizer) options which are currently loaded into this instance
С версии: 1.0
public saveInternalAdminPageOptions ( ) : array
Результат array All admin options currently in the instance

set() публичный Метод

Sets a value in the $setting class variable
С версии: 1.6
public set ( string $setting, string $value ) : void
$setting string The name of the setting.
$value string The value to set.
Результат void

setInternalAdminPageOption() публичный Метод

Doesn't perform a save, only sets the value in the class variable.
С версии: 1.9
public setInternalAdminPageOption ( string $optionName, mixed $value ) : boolean
$optionName string The ID of the option (not namespaced).
$value mixed The value to set.
Результат boolean Always returns true

setOption() публичный Метод

Sets an option
С версии: 1.0
public setOption ( string $optionName, mixed $value, integer $postID = null ) : boolean
$optionName string The name of the option to save.
$value mixed The value of the option.
$postID integer The ID of the parent post if this is a meta box option.
Результат boolean Always returns true

Описание свойств

$cssInstance публичное свойство

The CSS class instance used
public TitanFrameworkCSS $cssInstance
Результат TitanFrameworkCSS

$optionNamespace публичное свойство

Options will be prefixed with this in the database
public string $optionNamespace
Результат string

$optionsUsed публичное свойство

We store the options (with IDs) here, used for ensuring our serialized option value doesn't get cluttered with unused options
public array $optionsUsed
Результат array

$settings публичное свойство

The current list of settings
public array $settings
Результат array