PHP Класс Carbon_Fields\Container\Container

Defines the key container methods and their default implementations.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$active_containers array List of containers attached to the current page view
$registered_panel_ids array List of registered unique panel identificators
$settings array List of default container settings
$setup_ready boolean Whether the container was setup
$title string Title of the container

Защищенные свойства (Protected)

Свойство Тип Описание
$active_fields array List of fields attached to the current page view
$errors array List of error messages to be displayed on the front-end
$fields array List of container fields
$init_containers array List of containers created via factory that should be initialized
$notifications array List of notification messages to be displayed on the front-end
$registered_field_names array List of registered unique field names for this container instance
$store object Container DataStore. Propagated to all container fields
$tabs Tabs available
$templates array Stores all the container Backbone templates

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

Метод Описание
__construct ( string $title ) Create a new container
_attach ( ) Called first as part of the container attachment procedure.
_save ( ) Called first as part of the container save procedure.
activate_container ( $container ) Adds a container to the active containers array and triggers an action
activate_field ( $field ) Adds a field to the active fields array and triggers an action
add_fields ( array $fields ) : object Append array of fields to the current fields set. All items of the array must be instances of Field and their names should be unique for all Carbon containers.
add_tab ( string $tab_name, array $fields ) : object Configuration function for adding tab with fields
add_template ( $name, $callback ) Adds a new Backbone template
admin_hook_scripts ( ) Enqueue admin scripts
admin_hook_styles ( ) Enqueue admin styles
attach ( ) Attach the container rendering and helping methods to concrete WordPress Action hooks
boot ( ) Boot the container once it's attached.
check_setup_settings ( array &$settings = [] ) Check if all required container settings have been specified
detach ( ) Revert the result of attach()
drop_unique_field_name ( string $name ) Remove field name $name from the list of unique field names
drop_unique_panel_id ( string $id ) Remove container identificator $id from the list of unique container ids
factory ( string $type, string $name ) : object Create a new container of type $type and name $name and label $label.
get_active_containers ( ) : array Returns all the active containers created via factory
get_active_fields ( ) : array Returns all the active fields created via factory
get_datastore ( ) : object Return the DataStore instance used by container fields
get_fields ( ) : array Returns the private container array of fields.
get_nonce_field ( ) : string Return WordPress nonce field
get_nonce_name ( ) : string Return WordPress nonce name used to identify the current container instance
get_tabs ( ) : array Retrieve all tabs.
get_tabs_json ( ) : array Build the tabs JSON
get_templates ( ) : array Returns all the Backbone templates
get_untabbed_fields ( ) : array Retrieve all fields that are not defined under a specific tab
has_fields ( ) : boolean Perform a check whether the current container has fields
init ( ) Perform instance initialization after calling setup()
init_containers ( ) : object Initialize containers created via factory
is_active ( ) : boolean Perform checks whether the container is active for current request
is_tabbed ( ) : boolean Whether the container is tabbed or not
is_valid_attach ( ) : boolean Perform checks whether the container should be attached during the current request
is_valid_save ( ) : boolean Checks whether the current request is valid
load ( ) Load the value for each field in the container.
make ( $type, $name ) An alias of factory().
save ( $data ) Load submitted data and save each field in the container
set_datastore ( object $store ) : object Assign DataStore instance for use by the container fields
setup ( array $settings = [] ) : object Update container settings and begin initialization
template ( ) Prints the container Underscore template
template_tabs ( ) Underscore template for tabs
to_json ( boolean $load ) : array Returns an array that holds the container data, suitable for JSON representation.
verify_unique_field_name ( string $name ) Perform checks whether there is a field registered with the name $name.
verify_unique_panel_id ( $id ) Perform checks whether there is a container registered with identificator $id

Приватные методы

Метод Описание
create_tab ( string $tab_name, array $fields, integer $queue_end = self::TABS_TAIL ) : object Internal function that creates the tab and associates it with particular field set

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

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

Create a new container
public __construct ( string $title )
$title string Unique title of the container

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

Responsible for checking it's OK to attach the container and if it is, calling the container-specific attach() method
См. также: attach()
См. также: is_valid_attach()
public _attach ( )

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

Responsible for checking the request validity and calling the container-specific save() method
См. также: save()
См. также: is_valid_save()
public _save ( )

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

Adds a container to the active containers array and triggers an action
public static activate_container ( $container )

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

Adds a field to the active fields array and triggers an action
public static activate_field ( $field )

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

If a field does not have DataStore already, the container data store is assigned to them instead.
public add_fields ( array $fields ) : object
$fields array
Результат object $this

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

Configuration function for adding tab with fields
public add_tab ( string $tab_name, array $fields ) : object
$tab_name string
$fields array
Результат object $this

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

Adds a new Backbone template
public add_template ( $name, $callback )

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

Enqueue admin scripts
public static admin_hook_scripts ( )

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

Enqueue admin styles
public static admin_hook_styles ( )

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

Attach the container rendering and helping methods to concrete WordPress Action hooks
public attach ( )

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

Boot the container once it's attached.
public boot ( )

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

Check if all required container settings have been specified
public check_setup_settings ( array &$settings = [] )
$settings array Container settings

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

Revert the result of attach()
public detach ( )

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

Remove field name $name from the list of unique field names
public drop_unique_field_name ( string $name )
$name string

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

Remove container identificator $id from the list of unique container ids
public static drop_unique_panel_id ( string $id )
$id string

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

Create a new container of type $type and name $name and label $label.
public static factory ( string $type, string $name ) : object
$type string
$name string Human-readable name of the container
Результат object $container

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

Returns all the active containers created via factory
public static get_active_containers ( ) : array
Результат array

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

Returns all the active fields created via factory
public static get_active_fields ( ) : array
Результат array

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

Return the DataStore instance used by container fields
public get_datastore ( ) : object
Результат object $store

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

Use only if you are completely aware of what you are doing.
public get_fields ( ) : array
Результат array

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

Return WordPress nonce field
public get_nonce_field ( ) : string
Результат string

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

Return WordPress nonce name used to identify the current container instance
public get_nonce_name ( ) : string
Результат string

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

Create a default tab if there are any untabbed fields.
public get_tabs ( ) : array
Результат array

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

Build the tabs JSON
public get_tabs_json ( ) : array
Результат array

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

Returns all the Backbone templates
public get_templates ( ) : array
Результат array

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

Retrieve all fields that are not defined under a specific tab
public get_untabbed_fields ( ) : array
Результат array

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

Perform a check whether the current container has fields
public has_fields ( ) : boolean
Результат boolean

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

Perform instance initialization after calling setup()
abstract public init ( )

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

Initialize containers created via factory
public static init_containers ( ) : object
Результат object

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

Perform checks whether the container is active for current request
public is_active ( ) : boolean
Результат boolean True if the container is active

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

Whether the container is tabbed or not
public is_tabbed ( ) : boolean
Результат boolean

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

Perform checks whether the container should be attached during the current request
public is_valid_attach ( ) : boolean
Результат boolean True if the container is allowed to be attached

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

Checks whether the current request is valid
public is_valid_save ( ) : boolean
Результат boolean

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

Could be used internally during container rendering
public load ( )

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

An alias of factory().
См. также: Container::factory()
public static make ( $type, $name )

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

Load submitted data and save each field in the container
См. также: is_valid_save()
public save ( $data )

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

Assign DataStore instance for use by the container fields
public set_datastore ( object $store ) : object
$store object
Результат object $this

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

Update container settings and begin initialization
См. также: init()
public setup ( array $settings = [] ) : object
$settings array
Результат object $this

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

Prints the container Underscore template
public template ( )

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

Underscore template for tabs
public template_tabs ( )

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

This data will be available in the Underscore template and the Backbone Model.
public to_json ( boolean $load ) : array
$load boolean Should the value be loaded from the database or use the value from the current instance.
Результат array

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

If not, the field name is recorded.
public verify_unique_field_name ( string $name )
$name string

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

Perform checks whether there is a container registered with identificator $id
public static verify_unique_panel_id ( $id )

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

$active_containers публичное статическое свойство

List of containers attached to the current page view
См. также: _attach()
public static array $active_containers
Результат array

$active_fields защищенное статическое свойство

List of fields attached to the current page view
См. также: _attach()
protected static array $active_fields
Результат array

$errors защищенное свойство

List of error messages to be displayed on the front-end
protected array $errors
Результат array

$fields защищенное свойство

List of container fields
См. также: add_fields()
protected array $fields
Результат array

$init_containers защищенное статическое свойство

List of containers created via factory that should be initialized
protected static array $init_containers
Результат array

$notifications защищенное свойство

List of notification messages to be displayed on the front-end
protected array $notifications
Результат array

$registered_field_names защищенное свойство

List of registered unique field names for this container instance
См. также: verify_unique_field_name()
protected array $registered_field_names
Результат array

$registered_panel_ids публичное статическое свойство

List of registered unique panel identificators
См. также: verify_unique_panel_id()
public static array $registered_panel_ids
Результат array

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

List of default container settings
См. также: init()
public array $settings
Результат array

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

Whether the container was setup
public bool $setup_ready
Результат boolean

$store защищенное свойство

Container DataStore. Propagated to all container fields
См. также: set_datastore()
См. также: get_datastore()
protected object $store
Результат object

$tabs защищенное свойство

Tabs available
protected $tabs

$templates защищенное свойство

Stores all the container Backbone templates
См. также: factory()
См. также: add_template()
protected array $templates
Результат array

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

Title of the container
public string $title
Результат string