PHP Class Carbon_Fields\Container\Container

Defines the key container methods and their default implementations.
Afficher le fichier Open project: htmlburger/carbon-fields Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$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

Méthodes publiques

Méthode Description
__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

Private Methods

Méthode Description
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

Method Details

__construct() public méthode

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

_attach() public méthode

Responsible for checking it's OK to attach the container and if it is, calling the container-specific attach() method
See also: attach()
See also: is_valid_attach()
public _attach ( )

_save() public méthode

Responsible for checking the request validity and calling the container-specific save() method
See also: save()
See also: is_valid_save()
public _save ( )

activate_container() public static méthode

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

activate_field() public static méthode

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

add_fields() public méthode

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
Résultat object $this

add_tab() public méthode

Configuration function for adding tab with fields
public add_tab ( string $tab_name, array $fields ) : object
$tab_name string
$fields array
Résultat object $this

add_template() public méthode

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

admin_hook_scripts() public static méthode

Enqueue admin scripts
public static admin_hook_scripts ( )

admin_hook_styles() public static méthode

Enqueue admin styles
public static admin_hook_styles ( )

attach() public méthode

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

boot() public méthode

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

check_setup_settings() public méthode

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

detach() public méthode

Revert the result of attach()
public detach ( )

drop_unique_field_name() public méthode

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

drop_unique_panel_id() public static méthode

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

factory() public static méthode

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
Résultat object $container

get_active_containers() public static méthode

Returns all the active containers created via factory
public static get_active_containers ( ) : array
Résultat array

get_active_fields() public static méthode

Returns all the active fields created via factory
public static get_active_fields ( ) : array
Résultat array

get_datastore() public méthode

Return the DataStore instance used by container fields
public get_datastore ( ) : object
Résultat object $store

get_fields() public méthode

Use only if you are completely aware of what you are doing.
public get_fields ( ) : array
Résultat array

get_nonce_field() public méthode

Return WordPress nonce field
public get_nonce_field ( ) : string
Résultat string

get_nonce_name() public méthode

Return WordPress nonce name used to identify the current container instance
public get_nonce_name ( ) : string
Résultat string

get_tabs() public méthode

Create a default tab if there are any untabbed fields.
public get_tabs ( ) : array
Résultat array

get_tabs_json() public méthode

Build the tabs JSON
public get_tabs_json ( ) : array
Résultat array

get_templates() public méthode

Returns all the Backbone templates
public get_templates ( ) : array
Résultat array

get_untabbed_fields() public méthode

Retrieve all fields that are not defined under a specific tab
public get_untabbed_fields ( ) : array
Résultat array

has_fields() public méthode

Perform a check whether the current container has fields
public has_fields ( ) : boolean
Résultat boolean

init() abstract public méthode

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

init_containers() public static méthode

Initialize containers created via factory
public static init_containers ( ) : object
Résultat object

is_active() public méthode

Perform checks whether the container is active for current request
public is_active ( ) : boolean
Résultat boolean True if the container is active

is_tabbed() public méthode

Whether the container is tabbed or not
public is_tabbed ( ) : boolean
Résultat boolean

is_valid_attach() public méthode

Perform checks whether the container should be attached during the current request
public is_valid_attach ( ) : boolean
Résultat boolean True if the container is allowed to be attached

is_valid_save() public méthode

Checks whether the current request is valid
public is_valid_save ( ) : boolean
Résultat boolean

load() public méthode

Could be used internally during container rendering
public load ( )

make() public static méthode

An alias of factory().
See also: Container::factory()
public static make ( $type, $name )

save() public méthode

Load submitted data and save each field in the container
See also: is_valid_save()
public save ( $data )

set_datastore() public méthode

Assign DataStore instance for use by the container fields
public set_datastore ( object $store ) : object
$store object
Résultat object $this

setup() public méthode

Update container settings and begin initialization
See also: init()
public setup ( array $settings = [] ) : object
$settings array
Résultat object $this

template() public méthode

Prints the container Underscore template
public template ( )

template_tabs() public méthode

Underscore template for tabs
public template_tabs ( )

to_json() public méthode

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.
Résultat array

verify_unique_field_name() public méthode

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

verify_unique_panel_id() public static méthode

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

Property Details

$active_containers public_oe static_oe property

List of containers attached to the current page view
See also: _attach()
public static array $active_containers
Résultat array

$active_fields protected_oe static_oe property

List of fields attached to the current page view
See also: _attach()
protected static array $active_fields
Résultat array

$errors protected_oe property

List of error messages to be displayed on the front-end
protected array $errors
Résultat array

$fields protected_oe property

List of container fields
See also: add_fields()
protected array $fields
Résultat array

$init_containers protected_oe static_oe property

List of containers created via factory that should be initialized
protected static array $init_containers
Résultat array

$notifications protected_oe property

List of notification messages to be displayed on the front-end
protected array $notifications
Résultat array

$registered_field_names protected_oe property

List of registered unique field names for this container instance
See also: verify_unique_field_name()
protected array $registered_field_names
Résultat array

$registered_panel_ids public_oe static_oe property

List of registered unique panel identificators
See also: verify_unique_panel_id()
public static array $registered_panel_ids
Résultat array

$settings public_oe property

List of default container settings
See also: init()
public array $settings
Résultat array

$setup_ready public_oe property

Whether the container was setup
public bool $setup_ready
Résultat boolean

$store protected_oe property

Container DataStore. Propagated to all container fields
See also: set_datastore()
See also: get_datastore()
protected object $store
Résultat object

$tabs protected_oe property

Tabs available
protected $tabs

$templates protected_oe property

Stores all the container Backbone templates
See also: factory()
See also: add_template()
protected array $templates
Résultat array

$title public_oe property

Title of the container
public string $title
Résultat string