Property | Type | Description | |
---|---|---|---|
$add_more_label | string | Text for add more button | |
$add_more_position | string | Where the new item should to added ( top/bottom ) of the stack. Used by Add Another button "top|bottom" | |
$attributes | string | boolean[] | Extra HTML attributes to apply to the form element. Use boolean true to apply a standalone attribute, e.g. 'required' => true | |
$data_id | integer | null | ID for $this->data_type, eg $post->ID, generally set internally | |
$data_type | string | null | Data type this element is used in, generally set internally | |
$datasource | Fieldmanager_Datasource | Optionally generate field from datasource. Used by Fieldmanager_Autocomplete and Fieldmanager_Options. | |
$debug | boolean | If true, throw exceptions for illegal behavior | |
$default_value | Default value The default value for the field, if unset | ||
$description | string | Description for the form element | |
$description_after_element | boolean | If true, the description will be displayed after the element. | |
$display_if | array[] | Field name and value on which to display element. Sample: $element->display_if = array( 'src' => 'display-if-src-element', 'value' => 'display-if-src-value' ); | |
$escape | array | 'escape' => array( 'label' => 'wp_kses_post' ) | |
$extra_elements | integer | How many empty fields to display if $limit != 1 when the total fields in the loaded data + $extra_elements > $minimum_count. | |
$field_class | string | CSS class for form element | |
$index | boolean | Save this field additionally to an index | |
$index_filter | callable | null | Function that parses an index value and returns an optionally modified value. | |
$inline_label | boolean | If true, the label and the element will display on the same line. Some elements may not support this. | |
$input_type | string | Input type, mainly to support HTML5 input types. | |
$is_attachment | boolean | Whether or not this field is present on the attachment edit screen | |
$label | string | Label to use for form element | |
$label_after_element | boolean | If true, the label will be displayed after the element. | |
$label_element | string | HTML element to use for label | |
$limit | integer | How many of these fields to display, 0 for no limit | |
$meta_boxes_to_remove | array | If $remove_default_meta_boxes is true, this array will be populated with the list of default meta boxes to remove | |
$minimum_count | integer | 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. | |
$name | string | The name of the form element, As in 'foo' in | |
$one_label_per_item | boolean | Repeat the label for each element if $limit > 1 | |
$remove_default_meta_boxes | boolean | If true, remove any default meta boxes that are overridden by Fieldmanager fields | |
$required | boolean | 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. | |
$sanitize | callback | Function to use to sanitize input | |
$save_empty | boolean | If true, save empty elements to DB (if $this->limit != 1; single elements are always saved) | |
$serialize_data | boolean | Save the fields to their own keys (only works in some contexts). Default is true. | |
$skip_save | boolean | Do not save this field (useful for fields which handle saving their own data) | |
$sortable | boolean | Allow draggable sorting if $limit > 1 | |
$starting_count | integer | DEPREATED: How many of these fields to display initially, if $limit != 1. | |
$template | Template The path to the field template | ||
$validate | callback[] | Functions to use to validate input | |
$validation_messages | string | array | 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/ | |
$validation_rules | string | array | 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/ |
Property | Type | Description | |
---|---|---|---|
$is_proto | boolean | If $is_proto is true, we're rendering the prototype element for a field that can have infinite instances. | |
$is_tab | boolean | Render this element in a tab? | |
$parent | Fieldmanager_Field | Parent element, if applicable. Would be a Fieldmanager_Group unless third-party plugins support this. | |
$seq | integer | If $this->limit > 1, which element in sequence are we currently rendering? |
Method | Description | |
---|---|---|
__construct ( string $label = '', array $options = [] ) | Superclass constructor, just populates options and sanity-checks common elements. | |
_invalid_definition ( string $debug_message = '' ) : void | Die violently. If self::$debug is true, throw an exception. | |
_unauthorized_access ( string $debug_message = '' ) : void | Die violently. If self::$debug is true, throw an exception. | |
activate_submenu_page ( ) | Activate this group in an already-added submenu page | |
add_another ( ) : string | Generates HTML for the "Add Another" button. | |
add_meta_box ( string $title, $post_types, string $context = 'normal', string $priority = 'default' ) | Add this field as a metabox to a post type | |
add_page_form ( string $uniqid ) | Add a form on a frontend page | |
add_quickedit_box ( string $title, $post_types, callable $column_display_callback, string $column_title = '' ) | Add this field to a post type's quick edit box. | |
add_submenu_page ( $parent_slug, $page_title, $menu_title = Null, $capability = 'manage_options', $menu_slug = Null ) | Add this group to an options page | |
add_term_form ( string $title, string | array $taxonomies, boolean $show_on_add = true, boolean $show_on_edit = true, integer $parent = '' ) | Add a form on a term add/edit page | |
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 | |
add_user_form ( string $title = '' ) | Add a form on user pages | |
element_markup ( array $values = [] ) : string | Generates all markup needed for all form elements in this field. | |
escape ( string $field, string $default = 'esc_html' ) : string | Escape a field based on the function in the escape argument. | |
form_element ( $value ) : string | ||
get_collapse_handle ( ) : string | Return HTML for the collapse handle (multi-tools); a separate function to override | |
get_element_attributes ( ) : string | Generates an HTML attribute string based on the value of $this->attributes. | |
get_element_id ( ) : string | Get the ID for the form element itself, uses $this->seq (e.g. which position is this element in). | |
get_element_key ( ) : string | Get the storage key for the form element. | |
get_element_label ( array $classes = [] ) : string | Get an HTML label for this element. | |
get_extra_element_classes ( ) : array | Return extra element classes; overriden by some fields. | |
get_form_name ( $multiple = "" ) : string | Get HTML form name (e.g. questions[answer]). | |
get_form_tree ( ) : array | Recursively build path to this element (e.g. array(grandparent, parent, this) ) | |
get_remove_handle ( ) : string | Return HTML for the remove handle (multi-tools); a separate function to override | |
get_sort_handle ( ) : string | Return HTML for the sort handle (multi-tools); a separate function to override | |
is_group ( ) : boolean | Is the current field a group? | |
is_repeatable ( ) : boolean | Is this element repeatable or does it have a repeatable ancestor? | |
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[] | Presaves all elements in what could be a set of them, dispatches to $this->presave() | |
set_options ( string $label, array $options ) | Build options into properties and throw errors if developers add an unsupported opt. | |
single_element_markup ( mixed $value = Null, boolean $is_proto = False ) : string | Generate wrappers and labels for one form element. | |
wrap_with_multi_tools ( string $html, $classes = [] ) : string | Wrap a chunk of HTML with "remove" and "move" buttons if applicable. |
Method | Description | |
---|---|---|
_failed_validation ( $debug_message = '' ) : void | Fail validation. If self::$debug is true, throw an exception. | |
add_meta_boxes_to_remove ( &$meta_boxes_to_remove ) : void | Helper function to add to the list of meta boxes to remove. This will be defined in child classes that require this functionality. | |
get_seq ( ) : integer | In a multiple element set, return the index of the current element we're rendering. | |
has_proto ( ) : boolean | Are we in the middle of generating a prototype element for repeatable fields? | |
presave_alter_values ( array $values, $current_values = [] ) : array | Hook to alter or respond to all the values of a particular element | |
process_index_value ( mixed $value ) : mixed | Hook to alter handling of an individual index value, which may make sense to change per field type. | |
save_index ( array $values, $current_values ) : void | Optionally save fields to a separate postmeta index for easy lookup with WP_Query Handles internal arrays (e.g. for fieldmanager-options). |
Method | Description | |
---|---|---|
require_base ( ) |
public __construct ( string $label = '', array $options = [] ) | ||
$label | string | title of form field |
$options | array | with keys matching vars of the field in use. |
protected _failed_validation ( $debug_message = '' ) : void | ||
return | void |
public _invalid_definition ( string $debug_message = '' ) : void | ||
$debug_message | string | |
return | void | e.g. return _you_ into a void. |
public _unauthorized_access ( string $debug_message = '' ) : void | ||
$debug_message | string | |
return | void | e.g. return _you_ into a void. |
public add_another ( ) : string | ||
return | string | button HTML. |
protected add_meta_boxes_to_remove ( &$meta_boxes_to_remove ) : void | ||
return | void |
public add_page_form ( string $uniqid ) | ||
$uniqid | string | a unique identifier for this form |
public add_term_form ( string $title, string | array $taxonomies, boolean $show_on_add = true, boolean $show_on_edit = true, integer $parent = '' ) | ||
$title | string | |
$taxonomies | string | array | The taxonomies on which to display this form |
$show_on_add | boolean | Whether or not to show the fields on the add term form |
$show_on_edit | boolean | Whether or not to show the fields on the edit term form |
$parent | integer | Only show this field on child terms of this parent term ID |
public add_term_meta_box ( string $title, string | array $taxonomies, boolean $show_on_add = true, boolean $show_on_edit = true, integer $parent = '' ) | ||
$title | string | |
$taxonomies | string | array | The taxonomies on which to display this form |
$show_on_add | boolean | Whether or not to show the fields on the add term form |
$show_on_edit | boolean | Whether or not to show the fields on the edit term form |
$parent | integer | Only show this field on child terms of this parent term ID |
public add_user_form ( string $title = '' ) | ||
$title | string |
public element_markup ( array $values = [] ) : string | ||
$values | array | the current values of this element, in a tree structure if the element has children. |
return | string | HTML for all form elements. |
public form_element ( $value ) : string | ||
return | string | HTML for the element. Generate HTML for the form element itself. Generally should be just one tag, no wrappers. |
public get_collapse_handle ( ) : string | ||
return | string |
public get_element_attributes ( ) : string | ||
return | string | attributes ready to insert into an HTML tag. |
public get_element_id ( ) : string | ||
return | string | ID for use in a form element. |
public get_element_key ( ) : string | ||
return | string |
public get_element_label ( array $classes = [] ) : string | ||
$classes | array | extra CSS classes. |
return | string | HTML label. |
public get_extra_element_classes ( ) : array | ||
return | array |
public get_form_name ( $multiple = "" ) : string | ||
return | string | form name |
public get_form_tree ( ) : array | ||
return | array | of parents |
public get_remove_handle ( ) : string | ||
return | string |
public get_sort_handle ( ) : string | ||
return | string |
public is_repeatable ( ) : boolean | ||
return | boolean | True if yes, false if no. |
public preload_alter_values ( array $values ) | ||
$values | array |
public presave_all ( $values, $current_values ) : mixed[] | ||
return | mixed[] | sanitized values |
protected presave_alter_values ( array $values, $current_values = [] ) : array | ||
$values | array | |
return | array |
protected process_index_value ( mixed $value ) : mixed | ||
$value | mixed | |
return | mixed |
protected save_index ( array $values, $current_values ) : void | ||
$values | array | |
return | void |
public set_options ( string $label, array $options ) | ||
$label | string | title of form field |
$options | array | with keys matching vars of the field in use. |
public wrap_with_multi_tools ( string $html, $classes = [] ) : string | ||
$html | string | HTML to wrap. |
return | string | wrapped HTML. |
public string $add_more_label | ||
return | string |
public string $add_more_position | ||
return | string |
public string|boolean[] $attributes | ||
return | string | boolean[] |
public Fieldmanager_Datasource $datasource | ||
return | Fieldmanager_Datasource |
public static bool $debug | ||
return | boolean |
public $default_value |
public string $description | ||
return | string |
public bool $description_after_element | ||
return | boolean |
public array[] $display_if | ||
return | array[] |
public array $escape | ||
return | array |
public int $extra_elements | ||
return | integer |
public bool $index | ||
return | boolean |
public bool $inline_label | ||
return | boolean |
public string $input_type | ||
return | string |
public bool $is_attachment | ||
return | boolean |
protected bool $is_proto | ||
return | boolean |
public bool $label_after_element | ||
return | boolean |
public string $label_element | ||
return | string |
public int $limit | ||
return | integer |
public array $meta_boxes_to_remove | ||
return | array |
public int $minimum_count | ||
return | integer |
public string $name | ||
return | string |
public bool $one_label_per_item | ||
return | boolean |
protected Fieldmanager_Field $parent | ||
return | Fieldmanager_Field |
public bool $remove_default_meta_boxes | ||
return | boolean |
public bool $required | ||
return | boolean |
public callback $sanitize | ||
return | callback |
public bool $save_empty | ||
return | boolean |
protected int $seq | ||
return | integer |
public bool $serialize_data | ||
return | boolean |
public bool $skip_save | ||
return | boolean |
public bool $sortable | ||
return | boolean |
public int $starting_count | ||
return | integer |
public callback[] $validate | ||
return | callback[] |