Class Fieldmanager_Field
Abstract base class containing core functionality for Fieldmanager fields.
Fields are UI elements that allow a person to interact with data.
Direct known subclasses
Fieldmanager_Autocomplete
,
Fieldmanager_Checkbox
,
Fieldmanager_Password
,
Fieldmanager_RichTextArea
,
Fieldmanager_TextArea
,
Fieldmanager_TextField
,
Fieldmanager_Colorpicker
,
Fieldmanager_Datepicker
,
Fieldmanager_DraggablePost
,
Fieldmanager_Grid
,
Fieldmanager_Group
,
Fieldmanager_Hidden
,
Fieldmanager_Media
,
Fieldmanager_Options
Indirect known subclasses
Fieldmanager_Checkboxes
,
Fieldmanager_Radios
,
Fieldmanager_Select
Methods summary
public
string
|
|
public
|
#
__construct( string $label = '', array $options = array() )
Superclass constructor, just populates options and sanity-checks common elements. It might also die, but only helpfully, to catch errors in development. |
public
|
#
set_options( string $label, array $options )
Build options into properties and throw errors if developers add an unsupported opt. |
public
string
|
#
element_markup( array $values = array() )
Generates all markup needed for all form elements in this field. Could be called directly by a plugin or theme. |
public
string
|
#
single_element_markup( mixed $value = Null, boolean $is_proto = False )
Generate wrappers and labels for one form element. Is called by element_markup(), calls form_element(). |
public
|
|
public
string
|
#
wrap_with_multi_tools( string $html, mixed $classes = array() )
Wrap a chunk of HTML with "remove" and "move" buttons if applicable. |
public
string
|
|
public
array
|
|
public
string
|
#
get_element_id( )
Get the ID for the form element itself, uses $this->seq (e.g. which position is this element in). Relying on the element's ID for anything isn't a great idea since it can be rewritten in JS. |
public
string
|
|
public
boolean
|
|
public
boolean
|
|
public
mixed[]
|
#
presave_all( mixed $values, mixed $current_values )
Presaves all elements in what could be a set of them, dispatches to $this->presave() |
public
sanitized
|
|
public
string
|
#
get_element_attributes( )
Generates an HTML attribute string based on the value of $this->attributes. |
public
string
|
|
public
string
|
|
public
string
|
|
public
string
|
#
get_remove_handle( )
Return HTML for the remove handle (multi-tools); a separate function to override |
public
string
|
#
get_collapse_handle( )
Return HTML for the collapse handle (multi-tools); a separate function to override |
public
array
|
|
public
|
|
public
|
|
public
|
#
add_term_meta_box( string $title, string|array $taxonomies, boolean $show_on_add = true, boolean $show_on_edit = true, integer $parent = '' )
Add fields to the term add/edit page |
public
|
#
add_meta_box( string $title, string|string[] $post_types, string $context = 'normal', string $priority = 'default' )
Add this field as a metabox to a post type |
public
|
#
add_quickedit_box( string $title, string|string[] $post_types, string $column_display_callback, callable $column_title = '' )
Add this field to a post type's quick edit box. |
public
|
#
add_submenu_page( string $parent_slug, mixed $page_title, mixed $menu_title = Null, mixed $capability = 'manage_options', mixed $menu_slug = Null )
Add this group to an options page |
public
|
|
public
|
#
_unauthorized_access( string $debug_message = '' )
Die violently. If self::$debug is true, throw an exception. |
public
|
#
_invalid_definition( string $debug_message = '' )
Die violently. If self::$debug is true, throw an exception. |
public
string
|
Magic methods summary
Properties summary
public static
boolean
|
$debug |
#
If true, throw exceptions for illegal behavior |
public
integer
|
$limit |
#
How many of these fields to display, 0 for no limit |
public
integer
|
$minimum_count |
#
How many of these fields to display at a minimum, if $limit != 1. If $limit == $minimum_count, the "add another" button and the remove tool will be hidden. |
public
integer
|
$extra_elements |
#
How many empty fields to display if $limit != 1 when the total fields in the loaded data + $extra_elements > $minimum_count. |
public
string
|
$add_more_label |
#
Text for add more button |
public
string
|
$name |
#
The name of the form element, As in 'foo' in <input name="foo" /> |
public
string
|
$label |
#
Label to use for form element |
public
boolean
|
$inline_label |
#
If true, the label and the element will display on the same line. Some elements may not support this. |
public
boolean
|
$label_after_element |
#
If true, the label will be displayed after the element. |
public
string
|
$description |
#
Description for the form element |
public
boolean
|
$description_after_element |
#
If true, the description will be displayed after the element. |
public
string|boolean[]
|
$attributes |
#
Extra HTML attributes to apply to the form element. Use boolean true to apply a standalone attribute, e.g. 'required' => true |
public
string
|
$field_class |
#
CSS class for form element |
public
boolean
|
$one_label_per_item |
#
Repeat the label for each element if $limit > 1 |
public
boolean
|
$sortable |
#
Allow draggable sorting if $limit > 1 |
public
string
|
$label_element |
#
HTML element to use for label |
public
callable
|
$sanitize |
#
Function to use to sanitize input |
public
callback[]
|
$validate |
#
Functions to use to validate input |
public
string|array
|
$validation_rules |
#
jQuery validation rule(s) used to validate this field, entered as a string or associative array. These rules will be automatically converted to the appropriate Javascript format. For more information see http://jqueryvalidation.org/documentation/ |
public
string|array
|
$validation_messages |
#
jQuery validation messages used by the rule(s) defined for this field, entered as a string or associative array. These rules will be automatically converted to the appropriate Javascript format. Any messages without a corresponding rule will be ignored. For more information see http://jqueryvalidation.org/documentation/ |
public
boolean
|
$required |
#
Makes the field required on WordPress context forms that already have built-in validation. This is necessary only for the fields used with the term add context. |
public
string|null
|
$data_type |
#
Data type this element is used in, generally set internally |
public
integer|null
|
$data_id |
#
ID for $this->data_type, eg $post->ID, generally set internally |
public
boolean
|
$save_empty |
#
If true, save empty elements to DB (if $this->limit != 1; single elements are always saved) |
public
boolean
|
$skip_save |
#
Do not save this field (useful for fields which handle saving their own data) |
public
boolean
|
$index |
#
Save this field additionally to an index |
public
boolean
|
$serialize_data |
#
Save the fields to their own keys (only works in some contexts). Default is true. |
public
|
$datasource |
#
Optionally generate field from datasource. Used by Fieldmanager_Autocomplete and Fieldmanager_Options. |
public
array[]
|
$display_if |
#
Field name and value on which to display element. Sample: $element->display_if = array( 'src' => 'display-if-src-element', 'value' => 'display-if-src-value' ); |
public
string
|
$add_more_position |
#
Where the new item should to added ( top/bottom ) of the stack. Used by Add Another button "top|bottom" |
public
boolean
|
$remove_default_meta_boxes |
#
If true, remove any default meta boxes that are overridden by Fieldmanager fields |
public
string
|
$template |
#
Template The path to the field template |
public
array
|
$meta_boxes_to_remove |
#
If $remove_default_meta_boxes is true, this array will be populated with the list of default meta boxes to remove |
public
mixed
|
$default_value |
#
Default value The default value for the field, if unset |
public
callable|null
|
$index_filter |
#
Function that parses an index value and returns an optionally modified value. |
public
string
|
$input_type |
#
Input type, mainly to support HTML5 input types. |
public
array
|
$escape |
#
Custom escaping for labels, descriptions, etc. Associative array of $field => $callable arguments, for example: |
public
boolean
|
$is_attachment |
#
Whether or not this field is present on the attachment edit screen |