PHP Class RWMB_Field

Exibir arquivo Open project: rilwis/meta-box Class Usage Examples

Public Methods

Method Description
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

Protected Methods

Method Description
element_description ( array $field ) : string Display field description.

Method Details

add_actions() public static method

Add actions
public static add_actions ( )

admin_enqueue_scripts() public static method

Enqueue scripts and styles
public static admin_enqueue_scripts ( )

begin_html() public static method

Show begin HTML markup for fields
public static begin_html ( mixed $meta, array $field ) : string
$meta mixed
$field array
return string

call() public static method

This should be replaced by static::$method( $args ) in PHP 5.3.
public static call ( ) : mixed
return mixed

element_description() protected static method

Display field description.
protected static element_description ( array $field ) : string
$field array
return string

end_html() public static method

Show end HTML markup for fields
public static end_html ( mixed $meta, array $field ) : string
$meta mixed
$field array
return string

esc_meta() public static method

Escape meta for field output
public static esc_meta ( mixed $meta ) : mixed
$meta mixed
return mixed

filter() public static method

Filters: - rwmb_{$name} - rwmb_{$field['type']}_{$name} - rwmb_{$field['id']}_{$name}
public static filter ( ) : mixed
return mixed

format_single_value() public static method

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
return string

format_value() public static method

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
return string

get_attributes() public static method

Get the attributes for a field
public static get_attributes ( array $field, mixed $value = null ) : array
$field array
$value mixed
return array

get_class_name() public static method

Get field class name
public static get_class_name ( array $field ) : string
$field array Field array
return string Field class name

get_value() public static method

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.
return mixed Field value

html() public static method

Get field HTML
public static html ( mixed $meta, array $field ) : string
$meta mixed
$field array
return string

localize_script() public static method

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() public static method

Map types
public static map_types ( array $field ) : string
$field array Field array
return string Field mapped type

meta() public static method

Get meta value
public static meta ( integer $post_id, boolean $saved, array $field ) : mixed
$post_id integer
$saved boolean
$field array
return mixed

normalize() public static method

Normalize parameters for field
public static normalize ( array $field ) : array
$field array
return array

raw_meta() public static method

Get raw meta value
public static raw_meta ( integer $post_id, array $field ) : mixed
$post_id integer
$field array
return mixed

render_attributes() public static method

Renders an attribute array into an html attributes string
public static render_attributes ( array $attributes ) : string
$attributes array
return string

save() public static method

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

show() public static method

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() public static method

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.
See also: 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.
return string HTML output of the field

value() public static method

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
return integer