PHP Class Fieldmanager_Options, vip-mu-plugins-public

Inheritance: extends Fieldmanager_Field
Afficher le fichier Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Méthodes publiques

Свойство Type Description
$data array Full option data, allows grouping
$first_element array Always prepend this element to the $data
$grouped boolean Is the data grouped? E.g. should we use
$multiple boolean Allow multiple selections?
$options array Shortcut to data which allows a simple associative array
$options_template string Path to an options template to load.

Méthodes publiques

Méthode Description
__construct ( string $label = '', mixed $options = [] ) Add CSS, construct parent
add_options ( array $options ) : void Add options
form_data_element ( $data_row, mixed $value ) A single element for a single bit of data, e.g. '
form_data_elements ( mixed $value ) : string Generate form elements.
option_selected ( string $current_option, array $options, string $attribute ) : string Helper for output functions to toggle a selected options
preload_alter_values ( array $values ) Alter values before rendering
presave ( mixed $value, $current_value = [] ) : sanitized Presave function, which handles sanitization and validation
presave_all ( $values, $current_values ) : mixed[] Override presave_all to handle special cases associated with multiple options fields.
presave_alter_values ( int[] $values, int[] $current_values = [] ) : int[] Presave hook to set taxonomy data, maybe
sanitize ( array | string $value ) : array | string Sanitize function that can handle arrays as well as string values.

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.
add_option_data ( string $name, mixed $value, string $group = null, string | integer $group_id = null ) : void Add option data to the data attribute of this object

Method Details

__construct() public méthode

Add CSS, construct parent
public __construct ( string $label = '', mixed $options = [] )
$label string
$options mixed

add_meta_boxes_to_remove() protected méthode

If $remove_default_meta_boxes is true and the datasource is Fieldmanager_Datasource_Term, this will return a list of all default meta boxes for the specified taxonomies. We only need to return id and context since the page will be handled by the list of post types provided to add_meta_box. Otherwise, this will just return an empty array.
protected add_meta_boxes_to_remove ( &$meta_boxes_to_remove ) : array
Résultat array list of meta boxes to remove

add_option_data() protected méthode

Add option data to the data attribute of this object
protected add_option_data ( string $name, mixed $value, string $group = null, string | integer $group_id = null ) : void
$name string
$value mixed
$group string
$group_id string | integer
Résultat void

add_options() public méthode

Add options
public add_options ( array $options ) : void
$options array
Résultat void

form_data_element() public méthode

A single element for a single bit of data, e.g. '
public form_data_element ( $data_row, mixed $value )
$value mixed

form_data_elements() public méthode

Generate form elements.
public form_data_elements ( mixed $value ) : string
$value mixed
Résultat string HTML

option_selected() public méthode

Helper for output functions to toggle a selected options
public option_selected ( string $current_option, array $options, string $attribute ) : string
$current_option string this option
$options array all valid options
$attribute string
Résultat string $attribute on match, empty on failure.

preload_alter_values() public méthode

Alter values before rendering
public preload_alter_values ( array $values )
$values array

presave() public méthode

Presave function, which handles sanitization and validation
public presave ( mixed $value, $current_value = [] ) : sanitized
$value mixed If a single field expects to manage an array, it must override presave()
Résultat sanitized values.

presave_all() public méthode

Override presave_all to handle special cases associated with multiple options fields.
public presave_all ( $values, $current_values ) : mixed[]
Résultat mixed[] sanitized values

presave_alter_values() public méthode

Presave hook to set taxonomy data, maybe
public presave_alter_values ( int[] $values, int[] $current_values = [] ) : int[]
$values int[]
$current_values int[]
Résultat int[] $values

sanitize() public méthode

Sanitize function that can handle arrays as well as string values.
public sanitize ( array | string $value ) : array | string
$value array | string
Résultat array | string Sanitized $value

Property Details

$data public_oe property

Full option data, allows grouping
public array $data
Résultat array

$first_element public_oe property

Always prepend this element to the $data
public array $first_element
Résultat array

$grouped public_oe property

Is the data grouped? E.g. should we use
public bool $grouped
Résultat boolean

$multiple public_oe property

Allow multiple selections?
public bool $multiple
Résultat boolean

$options public_oe property

Shortcut to data which allows a simple associative array
public array $options
Résultat array

$options_template public_oe property

Path to an options template to load.
public string $options_template
Résultat string