PHP Класс Carbon_Fields\Field\Field

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

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

Свойство Тип Описание
$type string Stores the initial $type variable passed to the factory() method

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

Свойство Тип Описание
$autoload boolean Whether or not this value should be auto loaded. Applicable to theme options only.
$base_name string The base field name which is used in the container.
$classes array Custom CSS classes.
$conditional_logic array Stores the field conditional logic rules.
$context string The type of the container this field is in
$default_value mixed Default field value
$help_text string Additional text containing information and guidance for the user
$id string Globally unique field identificator. Generated randomly
$label string Field name used as label during field render
$lazyload boolean Whether or not this field will be initialized when the field is in the viewport (visible).
$name string Sanitized field name used as input name attribute during field render
$name_prefix string Prefix to be prepended to the field name during load, save, delete and render
$required boolean Whether or not this field is required.
$store Carbon_Fields\Datastore\Datastore_Interface Field DataStore instance to which save, load and delete calls are delegated
$templates array Stores all the field Backbone templates
$value mixed Field value
$width integer The width of the field.

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

Метод Описание
add_class ( string | array $classes ) : object Add custom CSS class to the field html container.
add_template ( $name, $callback ) Adds a new Backbone template
admin_enqueue_scripts ( ) Enqueue admin scripts.
admin_hook_scripts ( ) Hook administration scripts.
admin_hook_styles ( ) Hook administration styles.
admin_init ( ) Instance initialization when in the admin area.
boot ( ) Boot the field once the container is attached.
delete ( ) Delegate delete to the field DataStore instance
factory ( string $type, string $name, string $label = null ) : object Create a new field of type $type and name $name and label $label.
get_autoload ( ) : boolean Return whether or not this value should be auto loaded.
get_base_name ( ) : string Return the field base name.
get_classes ( ) : array Get the field custom CSS classes.
get_conditional_logic ( ) : array Get the conditional logic rules
get_context ( ) : string Return the type of the container this field is in
get_datastore ( ) : object Return the DataStore instance used by the field
get_default_value ( ) : mixed Get default field value
get_help_text ( ) : object Return the field help text
get_html_class ( ) : array Return an array of html classes to be used for the field container
get_id ( ) : string HTML id attribute getter.
get_label ( ) : string Return field label.
get_lazyload ( ) : boolean Return whether or not this field should be lazyloaded.
get_name ( ) : string Return the field name
get_templates ( ) : array Returns all the Backbone templates
get_type ( ) : string Returns the type of the field based on the class.
get_value ( ) : mixed Return the field value
get_width ( ) : integer Get the field width.
help_text ( $help_text ) : object Alias for set_help_text()
init ( ) Perform instance initialization after calling setup()
is_required ( ) : boolean Return whether this field is mandatory for the user
load ( ) Delegate load to the field DataStore instance
make ( $type, $name, $label = null ) An alias of factory().
process_value ( ) : array Allows the value of a field to be processed after loading.
save ( ) Delegate save to the field DataStore instance
set_autoload ( boolean $autoload ) : object Whether or not this value should be auto loaded. Applicable to theme options only.
set_base_name ( $name ) Set field base name as defined in the container.
set_conditional_logic ( $rules ) Set the field visibility conditional logic.
set_context ( $context ) : object Assign the type of the container this field is in
set_datastore ( Carbon_Fields\Datastore\Datastore_Interface $store ) : object Assign DataStore instance for use during load, save and delete
set_default_value ( mixed $default_value ) Set default field value
set_help_text ( $help_text ) : object Set additional text to be displayed during field render, containing information and guidance for the user
set_id ( string $id ) HTML id attribute setter
set_label ( string $label ) Set field label.
set_lazyload ( boolean $lazyload ) : object Whether or not this field will be initialized when the field is in the viewport (visible).
set_name ( string $name ) Set field name.
set_prefix ( string $prefix ) : object Set field name prefix. Calling this method will update the current field name and the conditional logic fields.
set_required ( boolean $required ) : object Whether this field is mandatory for the user
set_value ( mixed $value ) Directly modify the field value
set_value_from_input ( array $input = null ) Load the field value from an input array based on it's name
set_width ( integer $width ) : object Set the field width.
template ( ) Prints the main Underscore template
to_json ( boolean $load ) : array Returns an array that holds the field data, suitable for JSON representation.

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

Метод Описание
__construct ( string $name, string $label ) Create a field from a certain type with the specified label.
clean_type ( $type ) : string Cleans up an object class for usage as HTML class
parse_conditional_rules ( array $rules ) : array Validate and parse the conditional logic rules.

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

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

Create a field from a certain type with the specified label.
protected __construct ( string $name, string $label )
$name string Field name
$label string Field label

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

Add custom CSS class to the field html container.
public add_class ( string | array $classes ) : object
$classes string | array
Результат object $this

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

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

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

Called once per field type.
public static admin_enqueue_scripts ( )

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

Hook administration scripts.
public static admin_hook_scripts ( )

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

Hook administration styles.
public static admin_hook_styles ( )

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

Called during field boot.
public admin_init ( )

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

Boot the field once the container is attached.
public boot ( )

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

Cleans up an object class for usage as HTML class
protected clean_type ( $type ) : string
Результат string

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

Delegate delete to the field DataStore instance
public delete ( )

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

Create a new field of type $type and name $name and label $label.
public static factory ( string $type, string $name, string $label = null ) : object
$type string
$name string lower case and underscore-delimited
$label string (optional) Automatically generated from $name if not present
Результат object $field

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

Return whether or not this value should be auto loaded.
public get_autoload ( ) : boolean
Результат boolean

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

Return the field base name.
public get_base_name ( ) : string
Результат string

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

Get the field custom CSS classes.
public get_classes ( ) : array
Результат array

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

Get the conditional logic rules
public get_conditional_logic ( ) : array
Результат array

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

Return the type of the container this field is in
public get_context ( ) : string
Результат string

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

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

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

Get default field value
public get_default_value ( ) : mixed
Результат mixed

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

Return the field help text
public get_help_text ( ) : object
Результат object $this

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

Return an array of html classes to be used for the field container
public get_html_class ( ) : array
Результат array

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

HTML id attribute getter.
public get_id ( ) : string
Результат string

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

Return field label.
public get_label ( ) : string
Результат string

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

Return whether or not this field should be lazyloaded.
public get_lazyload ( ) : boolean
Результат boolean

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

Return the field name
public get_name ( ) : string
Результат string

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

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

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

The class is stripped by the "CarbonFields" prefix. Also the "Field" suffix is removed. Then underscores and backslashes are removed.
public get_type ( ) : string
Результат string

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

Return the field value
public get_value ( ) : mixed
Результат mixed

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

Get the field width.
public get_width ( ) : integer
Результат integer $width

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

Alias for set_help_text()
См. также: set_help_text()
public help_text ( $help_text ) : object
Результат object $this

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

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

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

Return whether this field is mandatory for the user
public is_required ( ) : boolean
Результат boolean

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

Delegate load to the field DataStore instance
public load ( )

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

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

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

Validate and parse the conditional logic rules.
protected parse_conditional_rules ( array $rules ) : array
$rules array
Результат array

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

Can be implemented by the extending class if necessary.
public process_value ( ) : array
Результат array

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

Delegate save to the field DataStore instance
public save ( )

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

Whether or not this value should be auto loaded. Applicable to theme options only.
public set_autoload ( boolean $autoload ) : object
$autoload boolean
Результат object $this

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

Set field base name as defined in the container.
public set_base_name ( $name )

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

Set the field visibility conditional logic.
public set_conditional_logic ( $rules )

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

Assign the type of the container this field is in
public set_context ( $context ) : object
Результат object $this

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

Assign DataStore instance for use during load, save and delete
public set_datastore ( Carbon_Fields\Datastore\Datastore_Interface $store ) : object
$store Carbon_Fields\Datastore\Datastore_Interface
Результат object $this

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

Set default field value
public set_default_value ( mixed $default_value )
$default_value mixed

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

Set additional text to be displayed during field render, containing information and guidance for the user
public set_help_text ( $help_text ) : object
Результат object $this

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

HTML id attribute setter
public set_id ( string $id )
$id string

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

Set field label.
public set_label ( string $label )
$label string If null, the label will be generated from the field name

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

Whether or not this field will be initialized when the field is in the viewport (visible).
public set_lazyload ( boolean $lazyload ) : object
$lazyload boolean
Результат object $this

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

Use only if you are completely aware of what you are doing.
public set_name ( string $name )
$name string Field name, either sanitized or not

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

Set field name prefix. Calling this method will update the current field name and the conditional logic fields.
public set_prefix ( string $prefix ) : object
$prefix string
Результат object $this

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

Whether this field is mandatory for the user
public set_required ( boolean $required ) : object
$required boolean
Результат object $this

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

Directly modify the field value
public set_value ( mixed $value )
$value mixed

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

Load the field value from an input array based on it's name
public set_value_from_input ( array $input = null )
$input array (optional) Array of field names and values. Defaults to $_POST

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

Set the field width.
public set_width ( integer $width ) : object
$width integer
Результат object $this

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

Prints the main Underscore template
public template ( )

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

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

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

Whether or not this value should be auto loaded. Applicable to theme options only.
См. также: set_autoload()
protected bool $autoload
Результат boolean

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

The base field name which is used in the container.
См. также: set_base_name()
protected string $base_name
Результат string

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

Custom CSS classes.
См. также: add_class()
protected array $classes
Результат array

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

Stores the field conditional logic rules.
protected array $conditional_logic
Результат array

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

The type of the container this field is in
См. также: get_context()
protected string $context
Результат string

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

Default field value
protected mixed $default_value
Результат mixed

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

Additional text containing information and guidance for the user
См. также: help_text()
protected string $help_text
Результат string

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

Globally unique field identificator. Generated randomly
protected string $id
Результат string

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

Field name used as label during field render
См. также: factory()
См. также: set_label()
protected string $label
Результат string

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

Whether or not this field will be initialized when the field is in the viewport (visible).
См. также: set_lazyload()
protected bool $lazyload
Результат boolean

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

Sanitized field name used as input name attribute during field render
См. также: factory()
См. также: set_name()
protected string $name
Результат string

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

Prefix to be prepended to the field name during load, save, delete and render
protected string $name_prefix
Результат string

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

Whether or not this field is required.
См. также: set_required()
protected bool $required
Результат boolean

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

Field DataStore instance to which save, load and delete calls are delegated
См. также: set_datastore()
См. также: get_datastore()
protected Datastore_Interface,Carbon_Fields\Datastore $store
Результат Carbon_Fields\Datastore\Datastore_Interface

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

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

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

Stores the initial $type variable passed to the factory() method
См. также: factory
public string $type
Результат string

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

Field value
protected mixed $value
Результат mixed

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

The width of the field.
См. также: set_width()
protected int $width
Результат integer