$oScreen
$oScreen : object
Stores the screen object.
Provides methods for creating meta boxes.
The class automatically creates WordPress action and filter hooks associated with the class methods. The class methods corresponding to the name of the below actions and filters can be extended to modify the page output. Those methods are the callbacks of the filters and actions.
start_ + extended class name
– triggered at the end of the class constructor.extended class name + _ + field_ + field ID
– receives the form input field output of the given input field ID. The first parameter: output string. The second parameter: the array of option.style_ + extended class name
– receives the output of the CSS rules applied to the pages of the associated post types with the meta box.script_ + extended class name
– receives the output of the JavaScript scripts applied to the pages of the associated post types with the meta box.validation_ + extended class name
– receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.The slugs must not contain a dot(.) or a hyphen(-) since it is used in the callback method name.
__construct(string $strMetaBoxID, string $strTitle, string|array $vPostTypes, string $strContext, string $strPriority, string $strCapability, string $strTextDomain) : void
Constructs the class object instance of AdminPageFramework_MetaBox.
string | $strMetaBoxID | The meta box ID. |
string | $strTitle | The meta box title. |
string|array | $vPostTypes | ( optional ) The post type(s) that the meta box is associated with. |
string | $strContext | ( optional ) The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side') Default: normal. |
string | $strPriority | ( optional ) The priority within the context where the boxes should show ('high', 'core', 'default' or 'low') Default: default. |
string | $strCapability | ( optional ) The access level to the meta box. Default: edit_posts. |
string | $strTextDomain | ( optional ) The text domain applied to the displayed text messages. Default: admin-page-framework. |
setUp() : void
The method for all necessary set-ups.
public function setUp() {
$this->addSettingFields(
array(
'strFieldID' => 'sample_metabox_text_field',
'strTitle' => 'Text Input',
'strDescription' => 'The description for the field.',
'strType' => 'text',
),
array(
'strFieldID' => 'sample_metabox_textarea_field',
'strTitle' => 'Textarea',
'strDescription' => 'The description for the field.',
'strType' => 'textarea',
'vDefault' => 'This is a default text.',
)
);
}
addSettingFields(array $arrField1, array $arrField2, array $_and_more) : void
Adds the given field array items into the field array property.
$this->addSettingFields(
array(
'strFieldID' => 'sample_metabox_text_field',
'strTitle' => 'Text Input',
'strDescription' => 'The description for the field.',
'strType' => 'text',
),
array(
'strFieldID' => 'sample_metabox_textarea_field',
'strTitle' => 'Textarea',
'strDescription' => 'The description for the field.',
'strType' => 'textarea',
'vDefault' => 'This is a default text.',
)
);
array | $arrField1 | The field array. |
array | $arrField2 | Another field array. |
array | $_and_more | Add more fields arrays as many as necessary to the next parameters. |
addHelpText( $strHTMLContent, $strHTMLSidebarContent)
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.
$this->addHelpText(
__( 'This text will appear in the contextual help pane.', 'admin-page-framework-demo' ),
__( 'This description goes to the sidebar of the help pane.', 'admin-page-framework-demo' )
);
$strHTMLContent | ||
$strHTMLSidebarContent |
addHelpTextForFormFields( $strFieldTitle, $strHelpText, $strHelpTextSidebar)
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. On contrary to the addHelpTab() method of the AdminPageFramework_Help class, the help tab title is already determined and the meta box ID and the title will be used.
$strFieldTitle | ||
$strHelpText | ||
$strHelpTextSidebar |
setHelpTab( $strID, $strTitle, $arrContents, $arrSideBarContents)
Sets the contextual help tab.
On contrary to other methods relating to contextual help tabs that just modify the class properties, this finalizes the help tab contents. In other words, the set values here will take effect.
$strID | ||
$strTitle | ||
$arrContents | ||
$arrSideBarContents |