Admin Page Framework Documentation
  • Package
  • Class
  • Tree

Packages

  • AdminPageFramework
    • FieldType
    • MetaBox
    • Page
    • PostType
    • TaxonomyField

Classes

  • AdminPageFramework_FieldType

Class AdminPageFramework_FieldType

The base class for the users to create their custom field types.

When a framework user implements a custom field type into his/her work, this class may be extended to create a field definition class.

Steps to Include a Custom Field Type

  1. Define a custom field type with a class extending the AdminPageFramework_FieldType class.
    1. Set the field type slug such as autocomplete with the $aFieldTypeSlugs property.
    2. Set the default field array definition keys with the $aDefaultKeys property.
    3. Write additional code in the setUp() method that will be performed when the field type definition is parsed.
    4. Add scripts and styles with getEnqueuingScripts(), getEnqueuingStyles(), getScripts(), getStyles() etc.
    5. Compose the output HTML structure with the passed $aField field definition array in the getField() method.
  2. Include the definition file and instantiate the class in the script(plugin,theme etc.).
    new MyCustomFieldTypeClass( 'MY_CLASS_NAME' );   // pass the PHP class name that extends the framework's class to the first parameter.
    
  3. Define fields with the custom field type with the addSettingFields() method in the framework extending class.
    $this->addSettingFields(
            array(
                    'field_id'  =>  'my_field_id',
                    'section_id'    =>  'my_section_id',
                    'type'  =>  'my_custom_field_type_slug',    // <-- here put the field type slug
                    '...' => '...'
            )
    );
    
AdminPageFramework_Utility_Array
Extended by AdminPageFramework_Utility_String
Extended by AdminPageFramework_Utility_Path
Extended by AdminPageFramework_Utility_URL
Extended by AdminPageFramework_Utility
Extended by AdminPageFramework_WPUtility_URL
Extended by AdminPageFramework_WPUtility_HTML
Extended by AdminPageFramework_WPUtility_Page
Extended by AdminPageFramework_WPUtility_Hook
Extended by AdminPageFramework_WPUtility_File
Extended by AdminPageFramework_WPUtility_Option
Extended by AdminPageFramework_WPUtility
Extended by AdminPageFramework_FieldType_Base
Extended by AdminPageFramework_FieldType
Abstract
Package: AdminPageFramework\FieldType
Since: 2.1.5
Since: 3.0.0 Changed the name from AdminPageFramework_CustomFieldType to AdminPageFramework_FieldType.
Remark: The user will extend this class to define their custom field types.
Located at field_type/AdminPageFramework_FieldType.php

Methods summary

protected
# setUp( )

Loads the field type necessary components.

Loads the field type necessary components.

This method is triggered when a field definition array that calls this field type is parsed.

Since

3.0.0

Remark

The user will override this method in their class definition.
protected
# getScripts( )

Since

3.0.0

Remark

The user will override this method in their class definition.
protected
# getIEStyles( )

Since

3.0.0

Remark

The user will override this method in their class definition.
protected
# getStyles( )

Since

3.0.0

Remark

The user will override this method in their class definition.
protected
# getField( mixed $aField )

Since

3.0.0

Remark

The user will override this method in their class definition.
protected
# getEnqueuingScripts( )

Returns an array holding the urls of enqueuing scripts.

Returns an array holding the urls of enqueuing scripts.

The returning array should consist of all numeric keys. Each element can be either a string( the url or the path of the source file) or an array of custom argument.

Custom Argument Array

  • src - ( required, string ) The url or path of the target source file
  • handle_id - ( optional, string ) The handle ID of the script.
  • dependencies - ( optional, array ) The dependency array. For more information, see codex.
  • version - ( optional, string ) The stylesheet version number.
  • translation - ( optional, array ) The translation array. The handle ID will be used for the object name.
  • in_footer - ( optional, boolean ) Whether to enqueue the script before < / head > or before < / body > Default: <span class="php-keyword1">false</span>.

Examples

protected function getEnqueuingScripts() {
return array(
        array(  // if you need to set a dependency, pass as a custom argument array.
                'src'   => dirname( __FILE__ ) . '/asset/my_script.js',         // path or url
                'dependencies'  => array( 'jquery' )
        ),
        dirname( __FILE__ ) . '/asset/my_another.js',   // a string value of the target path or url will work as well.
);
}

Since

3.0.0

Remark

The user will override this method in their class definition.
protected
# getEnqueuingStyles( )

Returns an array holding the urls of enqueuing styles.

Returns an array holding the urls of enqueuing styles.

The returning array should consist of all numeric keys. Each element can be either a string( the url or the path of the source file) or an array of custom argument.

Custom Argument Array

  • src - ( required, string ) The url or path of the target source file
  • handle_id - ( optional, string ) The handle ID of the stylesheet.
  • dependencies - ( optional, array ) The dependency array. For more information, see codex.
  • version - ( optional, string ) The stylesheet version number.
  • media - ( optional, string ) the description of the field which is inserted into the after the input field tag.

Examples

protected function getEnqueuingStyles() {
        return array(
                dirname( __FILE__ ) . '/asset/my_style.css',
                array(
                        'src' => dirname( __FILE__ ) . '/asset/my_style2.css',
                        'handle_id' => 'my_style2',
                ),
        );
}

Since

3.0.0

Remark

The user will override this method in their class definition.

Methods inherited from AdminPageFramework_FieldType_Base

__construct(), _getScript_CustomMediaUploaderObject(), _replyToEnqueueMedia(), _replyToFieldLoader(), _replyToFieldTypeSetter(), _replyToGetEnqueuingScripts(), _replyToGetEnqueuingStyles(), _replyToGetField(), _replyToGetInputIEStyles(), _replyToGetScripts(), _replyToGetStyles(), _replyToRemovingMediaLibraryTab(), _replyToReplaceThickBoxText(), enqueueMediaUploader(), getDefinitionArray(), getFieldElementByKey(), replyToRegisterInputFieldType()

Methods inherited from AdminPageFramework_WPUtility_Option

getOption()

Methods inherited from AdminPageFramework_WPUtility_File

getScriptData()

Methods inherited from AdminPageFramework_WPUtility_Hook

addAndApplyFilter(), addAndApplyFilters(), addAndDoAction(), addAndDoActions(), doActions(), getFilterArrayByPrefix()

Methods inherited from AdminPageFramework_WPUtility_Page

getCurrentPostType(), isPostDefinitionPage(), isPostListingPage()

Methods inherited from AdminPageFramework_WPUtility_HTML

generateAttributes(), generateDataAttributes()

Methods inherited from AdminPageFramework_WPUtility_URL

getCurrentAdminURL(), getQueryAdminURL(), getQueryURL(), getSRCFromPath(), resolveSRC()

Methods inherited from AdminPageFramework_Utility

getQueryValueInURLByKey()

Methods inherited from AdminPageFramework_Utility_URL

getCurrentURL()

Methods inherited from AdminPageFramework_Utility_Path

getCallerScriptPath(), getRelativePath()

Methods inherited from AdminPageFramework_Utility_String

fixNumber(), minifyCSS(), sanitizeSlug(), sanitizeString()

Methods inherited from AdminPageFramework_Utility_Array

castArrayContents(), getArrayDimension(), getArrayValueByArrayKeys(), getAsArray(), getCorrespondingArrayValue(), getIntegerElements(), getNonIntegerElements(), invertCastArrayContents(), isAssociativeArray(), isLastElement(), numerizeElements(), shiftTillTrue(), uniteArrays(), uniteArraysRecursive()

Magic methods summary

Properties summary

public array $aFieldTypeSlugs
#

Defines the field type slugs used for this field type.

Defines the field type slugs used for this field type.

The slug is used for the type key in a field definition array.

        $this->addSettingFields(
        array(
                'section_id'    =>      '...',
                'type'  =>      'my_filed_type_slug',   // <--- THIS PART
                'field_id'      =>      '...',
                'title'         =>      '...',
        )
);
protected array $aDefaultKeys
#

Defines the default key-values of this field type.

Defines the default key-values of this field type.

The users will set the values to the defined keys and if not set, the value set in this property array will take effect. The merged array of the user's field definition array and this property array will be passed to the first parameter of the getField() method.

 $this->addSettingFields(
        array(
                'section_id'    =>      '...',
                'type'  =>      '...',
                'field_id'      =>      '...',
                'my_custom_key' => '...',       // <-- THIS PART
        )
);

Example

$aDefaultKeys = array(
        'my_custom_key' => 'my default value',
        'attributes'    => array(
                'size'  =>      30,
                'maxlength'     =>      400,
        ),
);

Remark

$_aDefaultKeys holds shared default key-values defined in the base class.

Properties inherited from AdminPageFramework_FieldType_Base

$_aDefaultKeys, $_sFieldSetType, $oMsg

Admin Page Framework Documentation API documentation generated by ApiGen 2.8.0