PHP Класс RWMB_Field

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
add_actions ( ) Add actions
admin_enqueue_scripts ( ) Enqueue scripts and styles
begin_html ( mixed $meta, array $field ) : string Show begin HTML markup for fields
call ( ) : mixed Call a method of a field.
end_html ( mixed $meta, array $field ) : string Show end HTML markup for fields
esc_meta ( mixed $meta ) : mixed Escape meta for field output
filter ( ) : mixed Apply various filters based on field type, id.
format_single_value ( array $field, string $value ) : string Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
format_value ( array $field, string | array $value ) : string Format value for the helper functions.
get_attributes ( array $field, mixed $value = null ) : array Get the attributes for a field
get_class_name ( array $field ) : string Get field class name
get_value ( array $field, array $args = [], integer | null $post_id = null ) : mixed Get the field value The difference between this function and 'meta' function is 'meta' function always returns the escaped value of the field saved in the database, while this function returns more meaningful value of the field, for ex.: for file/image: return array of file/image information instead of file/image IDs
html ( mixed $meta, array $field ) : string Get field HTML
localize_script ( string $handle, string $name, mixed $data ) Localize scripts with prevention of loading localized data twice.
map_types ( array $field ) : string Map types
meta ( integer $post_id, boolean $saved, array $field ) : mixed Get meta value
normalize ( array $field ) : array Normalize parameters for field
raw_meta ( integer $post_id, array $field ) : mixed Get raw meta value
render_attributes ( array $attributes ) : string Renders an attribute array into an html attributes string
save ( $new, $old, $post_id, $field ) Save meta value
show ( array $field, boolean $saved ) Show field HTML Filters are put inside this method, not inside methods such as "meta", "html", "begin_html", etc.
the_value ( array $field, array $args = [], integer | null $post_id = null ) : string Output the field value Depends on field value and field types, each field can extend this method to output its value in its own way See specific field classes for details.
value ( mixed $new, mixed $old, integer $post_id, array $field ) : integer Set value of meta before saving into database

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

Метод Описание
element_description ( array $field ) : string Display field description.

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

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

Add actions
public static add_actions ( )

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

Enqueue scripts and styles
public static admin_enqueue_scripts ( )

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

Show begin HTML markup for fields
public static begin_html ( mixed $meta, array $field ) : string
$meta mixed
$field array
Результат string

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

This should be replaced by static::$method( $args ) in PHP 5.3.
public static call ( ) : mixed
Результат mixed

element_description() защищенный статический Метод

Display field description.
protected static element_description ( array $field ) : string
$field array
Результат string

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

Show end HTML markup for fields
public static end_html ( mixed $meta, array $field ) : string
$meta mixed
$field array
Результат string

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

Escape meta for field output
public static esc_meta ( mixed $meta ) : mixed
$meta mixed
Результат mixed

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

Filters: - rwmb_{$name} - rwmb_{$field['type']}_{$name} - rwmb_{$field['id']}_{$name}
public static filter ( ) : mixed
Результат mixed

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

Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
public static format_single_value ( array $field, string $value ) : string
$field array Field parameter
$value string The value
Результат string

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

Format value for the helper functions.
public static format_value ( array $field, string | array $value ) : string
$field array Field parameter
$value string | array The field meta value
Результат string

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

Get the attributes for a field
public static get_attributes ( array $field, mixed $value = null ) : array
$field array
$value mixed
Результат array

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

Get field class name
public static get_class_name ( array $field ) : string
$field array Field array
Результат string Field class name

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

Each field can extend this function and add more data to the returned value. See specific field classes for details.
public static get_value ( array $field, array $args = [], integer | null $post_id = null ) : mixed
$field array Field parameters
$args array Additional arguments. Rarely used. See specific fields for details
$post_id integer | null Post ID. null for current post. Optional.
Результат mixed Field value

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

Get field HTML
public static html ( mixed $meta, array $field ) : string
$meta mixed
$field array
Результат string

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

Localize scripts with prevention of loading localized data twice.
public static localize_script ( string $handle, string $name, mixed $data )
$handle string Script handle.
$name string Object name.
$data mixed Localized data.

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

Map types
public static map_types ( array $field ) : string
$field array Field array
Результат string Field mapped type

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

Get meta value
public static meta ( integer $post_id, boolean $saved, array $field ) : mixed
$post_id integer
$saved boolean
$field array
Результат mixed

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

Normalize parameters for field
public static normalize ( array $field ) : array
$field array
Результат array

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

Get raw meta value
public static raw_meta ( integer $post_id, array $field ) : mixed
$post_id integer
$field array
Результат mixed

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

Renders an attribute array into an html attributes string
public static render_attributes ( array $attributes ) : string
$attributes array
Результат string

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

Save meta value
public static save ( $new, $old, $post_id, $field )
$new
$old
$post_id
$field

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

That ensures the returned value are always been applied filters This method is not meant to be overwritten in specific fields
public static show ( array $field, boolean $saved )
$field array
$saved boolean

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

Note: we don't echo the field value directly. We return the output HTML of field, which will be used in rwmb_the_field function later.
См. также: rwmb_the_value()
public static the_value ( array $field, array $args = [], integer | null $post_id = null ) : string
$field array Field parameters
$args array Additional arguments. Rarely used. See specific fields for details
$post_id integer | null Post ID. null for current post. Optional.
Результат string HTML output of the field

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

Set value of meta before saving into database
public static value ( mixed $new, mixed $old, integer $post_id, array $field ) : integer
$new mixed
$old mixed
$post_id integer
$field array
Результат integer