PHP Class Fieldmanager_Group, vip-mu-plugins-public

Groups shouldn't just be thought of as a top-level collection of fields (like a meta box). Groups can be infinitely nested, they can be used to create tabbed interfaces, and so on. Groups submit data as nested arrays.
Inheritance: extends Fieldmanager_Field
Afficher le fichier Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Méthodes publiques

Свойство Type Description
$add_to_prefix boolean If false, Fieldmanager will not check for collisions among the meta keys created for this group's fields and other registered fields.
$children Fieldmanager_Field[] Children elements of this group. Not much point in creating an empty group.
$collapsed boolean If true, this group is collapsed by default.
$collapsible boolean If true, this group can be collapsed by clicking its header.
$field_class string Override field class
$group_is_empty callable | null Function that tells whether the group is empty or not. Gets an array of form values.
$has_unserialized_descendants boolean This field is set based on its descendants, but you can deliberately set it yourself if your situation is one where this cannot be determined automatically (for instance, where descendants are added after the group has been constructed).
$label_element string Override label element
$label_format string If specified, $label_format combined with $label_token will override $label, but only if $(label).find(label_token).val() is not null.
$label_macro array Label macro is a more convenient shortcut to label_format and label_token. The first element of the two-element array is the title with a placeholder (%s), and the second element is simply the name of the child element to pull from, e.g.: array( 'Section: %s', 'section_title' )
$label_token string CSS selector to an element to get the token for the label format
$persist_active_tab boolean Persist the active tab on the group between sessions
$tab_limit integer How many tabs, maximum?
$tabbed boolean | string Use tabbed groups. Currently supports "horizontal" or "vertical". Default is false, which means that the group will not be tabbed.

Protected Properties

Свойство Type Description
$child_count boolean Iterator value for how many children we have rendered.

Méthodes publiques

Méthode Description
__construct ( $label = '', $options = [] ) Constructor; add CSS if we're looking at a tabbed view
add_child ( Fieldmanager_Field $child ) : void Add a child element to this group.
form_element ( mixed $value = NULL ) Render the element, iterating over children and calling their form_element() functions.
get_element_label ( array $classes = [] ) : string Get an HTML label for this element.
get_extra_element_classes ( ) : array Maybe add the collapsible class for groups
presave ( $values, $current_values = [] ) : mixed[] Presave override for groups which dispatches to child presave_all methods.
wrap_with_multi_tools ( string $html, $classes = [] ) : string Groups have their own drag and remove tools in the label.

Méthodes protégées

Méthode Description
add_meta_boxes_to_remove ( &$meta_boxes_to_remove ) : array Helper function to get the list of default meta boxes to remove.

Method Details

__construct() public méthode

Constructor; add CSS if we're looking at a tabbed view
public __construct ( $label = '', $options = [] )

add_child() public méthode

Add a child element to this group.
public add_child ( Fieldmanager_Field $child ) : void
$child Fieldmanager_Field
Résultat void

add_meta_boxes_to_remove() protected méthode

For Fieldmanager_Group, iterate over all children to see if they have meta boxes to remove. If $remove_default_meta_boxes is true for this group, set all children to also remove any default meta boxes if applicable.
protected add_meta_boxes_to_remove ( &$meta_boxes_to_remove ) : array
$meta_boxes_to_remove the array of meta boxes to remove
Résultat array list of meta boxes to remove

form_element() public méthode

Render the element, iterating over children and calling their form_element() functions.
public form_element ( mixed $value = NULL )
$value mixed

get_element_label() public méthode

Get an HTML label for this element.
public get_element_label ( array $classes = [] ) : string
$classes array extra CSS classes.
Résultat string HTML label.

get_extra_element_classes() public méthode

Maybe add the collapsible class for groups
public get_extra_element_classes ( ) : array
Résultat array

presave() public méthode

Presave override for groups which dispatches to child presave_all methods.
public presave ( $values, $current_values = [] ) : mixed[]
Résultat mixed[] values

wrap_with_multi_tools() public méthode

Groups have their own drag and remove tools in the label.
public wrap_with_multi_tools ( string $html, $classes = [] ) : string
$html string
Résultat string

Property Details

$add_to_prefix public_oe property

If false, Fieldmanager will not check for collisions among the meta keys created for this group's fields and other registered fields.
public bool $add_to_prefix
Résultat boolean

$child_count protected_oe property

Iterator value for how many children we have rendered.
protected bool $child_count
Résultat boolean

$children public_oe property

Children elements of this group. Not much point in creating an empty group.
public Fieldmanager_Field[] $children
Résultat Fieldmanager_Field[]

$collapsed public_oe property

If true, this group is collapsed by default.
public bool $collapsed
Résultat boolean

$collapsible public_oe property

If true, this group can be collapsed by clicking its header.
public bool $collapsible
Résultat boolean

$field_class public_oe property

Override field class
public string $field_class
Résultat string

$group_is_empty public_oe property

Function that tells whether the group is empty or not. Gets an array of form values.
public callable|null $group_is_empty
Résultat callable | null

$has_unserialized_descendants public_oe property

This field is set based on its descendants, but you can deliberately set it yourself if your situation is one where this cannot be determined automatically (for instance, where descendants are added after the group has been constructed).
public bool $has_unserialized_descendants
Résultat boolean

$label_element public_oe property

Override label element
public string $label_element
Résultat string

$label_format public_oe property

If specified, $label_format combined with $label_token will override $label, but only if $(label).find(label_token).val() is not null.
public string $label_format
Résultat string

$label_macro public_oe property

Label macro is a more convenient shortcut to label_format and label_token. The first element of the two-element array is the title with a placeholder (%s), and the second element is simply the name of the child element to pull from, e.g.: array( 'Section: %s', 'section_title' )
public array $label_macro
Résultat array

$label_token public_oe property

CSS selector to an element to get the token for the label format
public string $label_token
Résultat string

$persist_active_tab public_oe property

Persist the active tab on the group between sessions
public bool $persist_active_tab
Résultat boolean

$tab_limit public_oe property

How many tabs, maximum?
public int $tab_limit
Résultat integer

$tabbed public_oe property

Use tabbed groups. Currently supports "horizontal" or "vertical". Default is false, which means that the group will not be tabbed.
public bool|string $tabbed
Résultat boolean | string