public
boolean
|
#
isInThePage( )
Allows the user to check if the current page belongs to the admin pages of
the factory component.
Returns
boolean
Since
3.7.9
|
public
|
#
addHelpText( mixed $sHTMLContent, mixed $sHTMLSidebarContent = "" )
Adds the given HTML text to the contextual help pane.
The help tab will be the meta box title and all the added text will be
inserted into the content area within the tab.
Since
2.1.0
Example
$this->addHelpText(
__( 'This text will appear in the contextual help pane.', 'your-text-domain' ),
__( 'This description goes to the sidebar of the help pane.', 'your-text-domain' )
);
Remark
This method just adds the given text into the class property. The actual
registration will be performed with the
replyToRegisterHelpTabTextForMetaBox() method.
|
public
|
#
addSettingSection( array|string $aSectionset )
A singular form of the adSettingSections() method which takes
only a single parameter.
This is useful when adding section arrays in loops.
Parameters
- $aSectionset
array|string $aSection the section array. If a string is passed, it is considered as a target
page slug that will be used as a page slug element from the next call so that
the element can be omitted.
Section Definition Array
- section_id - (string) the section ID. Avoid using
non-alphabetic characters except underscore and numbers.
- title - (optional, string) the title of the section.
- capability - (optional, string) the access level of the
section. If the page visitor does not have sufficient capability, the section
will be invisible to them.
- if - (optional, boolean) if the passed value is false, the
section will not be registered.
- order - (optional, integer) the order number of the
section. The higher the number is, the lower the position it gets.
- help - (optional, string) the help description added to the
contextual help tab.
- help_aside - (optional, string) the additional help
description for the side bar of the contextual help tab.
- section_tab_slug - (optional, string) the unique section
tab slug to display the section in a tabbed container with other sections that
have the same section tab slug.
- hidden - (optional, boolean) [3.3.1+] whether or not the
section should be hidden. Default:
<span
class="php-keyword1">false</span> .
- attributes - (optional, string) [3.3.1+] An attribute array
that applies to the section container element. e.g.
array(
'data-custom_data' => 'my_custom_data' ) The following sub-elements
are supported.
- tab - (optional, array) An sub-attribute array that applies
to the section tab
<li> tag element.
- class - (optional, array) [3.3.1+] class selector(s)
appended to the section container element. The following sub-elements are
supported.
- tab - (optional, array) An sub-class array that applies to
the section tab
<li> tag element.
- collapsible - (optional, array) [3.4.0+] class selector(s)
appended to the section container element. The following sub-elements are
supported.
- title - (optional, string) the section title will be
assigned by default in the section formatting method.
- is_collapsed - (optional, boolean) whether it is already
collapsed or expanded.
- toggle_all_button - (optional, boolean|string|array) the
position of where to display the toggle-all button that toggles the folding
state of all collapsible sections. Accepts the following values. 'top-right',
'top-left', 'bottom-right', 'bottom-left'. If true is passed, the default
'top-right' will be used. To not to display, do not set any or pass
false or null .
- collapse_others_on_expand - (optional, boolean) whether the
other collapsible sections should be folded when the section is unfolded. If the
below
container argument is set to section , this
argument value does not take effect.
- container - (optional, string) the container element that
collapsible styling gets applied to. Either 'sections' or 'section' is accepted.
Use 'section' for repeatable sections.
- type - [3.7.0+] (optional, string) either
box
or button . Default: box . The button type
only is supported when the container argument is set to
section .
` $this->addSettingSections( array( 'section_id' =>
'collapsible_repeatable_section', 'title' => __( 'Collapsible Repeatable
Section', 'admin-page-framework-demo' ), 'collapsible' => array(
'toggle_all_button' => array( 'top-left', 'bottom-left' ), 'container' =>
'section', ), 'repeatable' => true, ) ); `
- repeatable - (optional, boolean|array) [3.0.0+] Indicates
whether or not the section is repeatable. To set a minimum/maximum number of
sections, pass an array with the key,
min , and max .
e.g. array( 'min' => 3, 'max' => 10 )
- max - (optional, integer) The maximum number of repeated
fields.
- min - (optional, integer) The minimum number of repeated
fields.
- disabled - (optional, boolean|array) [3.8.13+]
- message - (optional, string) the message to show when the
user clicks on the
Add repeatable button.
- caption - (optional, string) the title of the modal window
that displays the message. Default: Warning
- box_width - (optional, integer) the width of the modal
window that displays the message. Default: 300
- box_width - (optional, integer) the height of the modal
window that displays the message. Default: 100.
- sortable - (optional, boolean) [3.6.0+] whether the section
is sortable or not. In order for this option to be effective, the
repeatable argument must be enabled.
- content - (optional, string) [3.6.1+] a custom section
output.
- tip - (optional, string) [3.7.0+] a tool tip which pops up
when the user hovers their mouse over the ? mark icon beside the title..
- show_debug_info - (optional, boolean) [3.8.8+] Whether to
show debug information such as field definition tool-tips.
Since
3.0.0 Changed the scope to public from protected.
Remark
The actual registration will be performed in the
_replyToRegisterSettings() method with the admin_menu
hook.
The $oForm property should be created in each extended class.
|
public
|
#
addSettingField( array|string $asFieldset )
Adds the given field array items into the field array property.
Identical to the addSettingFields() method except that this method does not
accept enumerated parameters.
Examples
$this->addSettingField(
array(
'field_id' => 'metabox_text_field',
'type' => 'text',
'title' => __( 'Text Input', 'admin-page-framework-demo' ),
'description' => __( 'The description for the field.', 'admin-page-framework-demo' ),
'help' => 'This is help text.',
'help_aside' => 'This is additional help text which goes to the side bar of the help pane.',
)
);
Parameters
- $asFieldset
array|string $asField A field definition array or a string of the target section id.
Built-in Field Types
- [text](./class-AdminPageFramework_FieldType_text.html) - a normal field to
enter short text input.
- [password](./class-AdminPageFramework_FieldType_text.html) - a masked text
input field.
- [textarea](./class-AdminPageFramework_FieldType_textarea.html) - a text
input field with multiple lines. It supports rich text editors.
- [radio](./class-AdminPageFramework_FieldType_radio.html) - a set of radio
buttons that lets the user pick an option.
- [checkbox](./class-AdminPageFramework_FieldType_checkbox.html) - a check box
that lets the user enable/disable an item.
- [select](./class-AdminPageFramework_FieldType_select.html) - a drop-down
list that lest the user pick one or more item(s) from a list.
- [hidden](./class-AdminPageFramework_FieldType_hidden.html) - a field with
invisible input values.
- [file](./class-AdminPageFramework_FieldType_file.html) - a file uploader
that lets the user upload files.
- [image](./class-AdminPageFramework_FieldType_image.html) - a text field with
an image uploader that lets the user set the image URL.
- [media](./class-AdminPageFramework_FieldType_media.html) - a text field with
a media uploader that lets the user set the file URL.
- [color](./class-AdminPageFramework_FieldType_color.html) - a text field with
a color picker.
- [submit](./class-AdminPageFramework_FieldType_submit.html) - a submit button
that lets the user send the form.
- [export](./class-AdminPageFramework_FieldType_export.html) - a custom submit
field that lets the user export stored data.
- [import](./class-AdminPageFramework_FieldType_import.html) - a custom
combination field of file and submit fields that let the user import data.
- [posttype](./class-AdminPageFramework_FieldType_posttype.html) - a
check-list of post types enabled on the site.
- [taxonomy](./class-AdminPageFramework_FieldType_taxonomy.html) - a set of
check-lists of taxonomies enabled on the site in a tabbed box.
- [size](./class-AdminPageFramework_FieldType_size.html) - a combination field
of the text and the select fields that let the user set sizes with a selectable
unit.
- [section_title](./class-AdminPageFramework_FieldType_section_title.html) -
[3.0.0+] a text field type that will be placed in the section title so that it
lets the user set the section title. Note that only one field with this field
type is allowed per a section.
- [system](./class-AdminPageFramework_FieldType_system.html) - [3.3.0+] a
custom text area field that displays the system information including the PHP
settings, the framework version, MySQL version etc.
- [inline_mixed](./class-AdminPageFramework_FieldType_inline_mixed.html) -
[3.8.0+] a field that include inner fields with different field types.
Field Definition Arguments
- field_id - (required, string) the field ID. Avoid using
non-alphabetic characters except underscore and numbers.
- type - (optional, string) the type of the field. The
supported types are listed below. When creating nested fields, this argument can
be omitted.
- section_id - (optional, string) the section ID that the
field belongs to. If not set, the internal
_default section ID will
be assigned.
- title - (optional, string) the title of the section.
- description - (optional, string) the description of the
field which is inserted into the after the input field tag.
- tip - (optional, string) the tip for the field which is
displayed when the mouse is hovered over the field title.
- capability - (optional, string) the access level of the
section. If the page visitor does not have sufficient capability, the section
will be invisible to them.
- error_message - (optional, string) the error message to
display above the input field.
- before_field - (optional, string) the HTML string to insert
before the input field output.
- after_field - (optional, string) the HTML string to insert
after the input field output.
- if - (optional, boolean) if the passed value is false, the
section will not be registered.
- order - (optional, integer) the order number of the
section. The higher the number is, the lower the position it gets.
- label - (optional, string) the text label(s) associated
with and displayed along with the input field. Some input types can ignore this
key.
- default - (optional, string|array) the default value(s)
assigned to the input tag's value attribute.
- value - (optional, string|array) the value(s) assigned to
the input tag's
value attribute to override the default and the
stored value.
- delimiter - (optional, string) the HTML string that
delimits multiple elements. This is available if the label key is
passed as array. It will be enclosed in inline-block elements so the passed HTML
string should not contain block elements.
- before_input - (optional, string) the HTML string inserted
right before the input tag. It will be enclosed in the
label tag so
the passed HTML string should not contain block elements.
- after_input - (optional, string) the HTML string inserted
right after the input tag. It will be enclosed in the
label tag so
the passed HTML string should not contain block elements.
- label_min_width - (optional, string) the inline style
property of the
min-width of the label tag for the field. If the
unit is not specified, 'px' is applied. Default: 120 . e.g.
100%
- help - (optional, string) the help description added to the
contextual help tab.
- help_aside - (optional, string) the additional help
description for the side bar of the contextual help tab.
- repeatable - [3.0.0+] (optional, array|boolean) whether the
fields should be repeatable. If it yields true, the plus and the minus buttons
appear next to each field that lets the user add/remove the fields. Optionally
an setting array can be passed.
Repeatable Fields Setting Array
- max - the allowed maximum number of fields to be
repeated.
- min - the allowed minimum number of fields to be
repeated.
- disabled - (optional, boolean|array) [3.8.13+]
- message - (optional, string) the message to show when the
user clicks on the
Add repeatable button.
- caption - (optional, string) the title of the modal window
that displays the message. Default: Warning
- box_width - (optional, integer) the width of the modal
window that displays the message. Default: 300
- box_width - (optional, integer) the height of the modal
window that displays the message. Default: 100.
- sortable - [3.0.0+] (optional, boolean) whether the fields
should be sortable. If it yields true, the fields will be enclosed in a
draggable box.
- attributes - [3.0.0+] (optional, array) holds key-value
pairs representing the attribute and its property. Note that some field types
have specific keys in the first dimensions. e.g.
array( 'class' =>
'my_custom_class_selector', 'style' => 'background-color:#777', 'size' =>
20, ) Every field holds the following nested attribute definition arrays.
- fieldrow - the
td tag element containing the
field output.
- fieldset - the
fieldset tag element containing
the field output.
- fields - the
div tag element containing the
sub-fields and the main field.
- field - the
div tag element containing each
field.
- show_title_column - [3.0.0+] (optional, boolean) If true,
the field title column will be omitted from the output.
- hidden - [3.0.0+] (optional, boolean) If true, the entire
field row output will be invisible with the inline style attribute of
style="display:none" .
- save - [3.6.0+] (optional, boolean) If
false ,
the field value will not be saved. Default: true
- content - (optional, string|array) [3.6.1+] a custom
section output. [3.8.0+] Supports an array to be passed for nested and
inline-mixed fields. If an array holding field definitions is set, those fields
will be nested.
Example
$this->addSettingFields(
'my_section_id', // the target section ID - pass dimensional keys of the section
array(
'field_id' => 'Y',
'title' => __( 'Y', 'admin-page-framework-loader' ),
'description' => __( 'By passing an array of field definition to the content argument, you can nest fields.', 'admin-page-framework-loader' )
. ' ' . __( 'Also the type argument can be omitted.', 'admin-page-framework-loader' ),
'content' => array(
array(
'field_id' => 'i',
'title' => __( 'i', 'admin-page-framework-loader' ),
'type' => 'textarea',
),
array(
'field_id' => 'ii',
'title' => __( 'ii', 'admin-page-framework-loader' ),
'type' => 'color',
),
array(
'field_id' => 'iii',
'title' => __( 'iii', 'admin-page-framework-loader' ),
'repeatable' => true,
'sortable' => true,
'content' => array(
array(
'field_id' => 'a',
'title' => __( 'a', 'admin-page-framework-loader' ),
'type' => 'image',
'attributes' => array(
'preview' => array(
'style' => 'max-width: 200px;',
),
),
),
array(
'field_id' => 'b',
'title' => __( 'b', 'admin-page-framework-loader' ),
'content' => array(
array(
'field_id' => 'first',
'title' => __( '1st', 'admin-page-framework-loader' ),
'type' => 'color',
'repeatable' => true,
'sortable' => true,
),
array(
'field_id' => 'second',
'title' => __( '2nd', 'admin-page-framework-loader' ),
'type' => 'size',
),
array(
'field_id' => 'third',
'title' => __( '3rd', 'admin-page-framework-loader' ),
'type' => 'select',
'label' => array(
'x' => 'X',
'y' => 'Y',
'z' => 'Z',
),
),
),
// 'description' => '',
),
array(
'field_id' => 'c',
'title' => __( 'c', 'admin-page-framework-loader' ),
'type' => 'radio',
'label' => array(
'a' => __( 'Apple', 'admin-page-framework-loader' ),
'b' => __( 'Banana', 'admin-page-framework-loader' ),
'c' => __( 'Cherry', 'admin-page-framework-loader' ),
),
'default' => 'b',
),
)
),
),
)
);
- placement - [3.8.0+] (optional, string) Specifies where the
field is rendered. Either
normal section_title or
field_title is accepted. field_title can only be used
by nested fields defined in the content argument. Default:
normal
- show_debug_info - (optional, boolean) [3.8.8+] Whether to
show debug information such as field definition tool-tips. Default:
true .
Since
2.1.2
3.0.0 The scope changed to public to indicate the users will use.
Remark
The $oForm property should be created in each extended class.
|