Admin Page Framework - Field Type Pack Documentation
  • Package
  • Class

Packages

  • AdminPageFrameworkFieldTypePack
    • CustomFieldType

Classes

  • AutoCompleteCustomFieldType
  • DateCustomFieldType
  • DateRangeCustomFieldType
  • DateTimeCustomFieldType
  • DateTimeRangeCustomFieldType
  • DialCustomFieldType
  • EDDSoftwareLicensingCustomFieldType
  • FontCustomFieldType
  • GeometryCustomFieldType
  • GridCustomFieldType
  • ImageCheckboxCustomFieldType
  • ImageRadioCustomFieldType
  • LinkCustomFieldType
  • RevealerCustomFieldType
  • TimeCustomFieldType
  • TimeRangeCustomFieldType

Class AutoCompleteCustomFieldType

Defines the auto-complete field type.

Field Type Specific Arguments

  • settings - (array|string) the first parameter value passed to the tokenInput() jQuery plugin method.
  • settings2 - (array) the second parameter value passed to the tokenInput() jQuery plugin method.

Example

array(
    'type'          => 'autocomplete',
    'field_id'      => 'autocomplete_field',
    'title'         => __( 'Default', 'admin-page-framework-field-type-pack' ),
    'description'   => __( 'By default, all the post titles will be fetched in the background and will pop up.', 'admin-page-framework-field-type-pack' ),
),
array(
    'type' => 'autocomplete',
    'field_id' => 'autocomplete_local_data',
    'title' => __( 'Local Data', 'admin-page-framework-field-type-pack' ),
    'settings' => array(
        array( 'id' => 7, 'name' => 'Ruby' ),
        array( 'id' => 11, 'name' => 'Python' ),
        array( 'id' => 13, 'name' => 'JavaScript' ),
        array( 'id' => 17, 'name' => 'ActionScript' ),
        array( 'id' => 19, 'name' => 'Scheme' ),
        array( 'id' => 23, 'name' => 'Lisp' ),
        array( 'id' => 29, 'name' => 'C#' ),
        array( 'id' => 31, 'name' => 'Fortran' ),
        array( 'id' => 37, 'name' => 'Visual Basic' ),
        array( 'id' => 41, 'name' => 'C' ),
        array( 'id' => 43, 'name' => 'C++' ),
        array( 'id' => 47, 'name' => 'Java' ),
    ),
    'settings2' => array(
        'theme' => 'mac',
        'hintText' => __( 'Type a programming language.', 'admin-page-framework-field-type-pack' ),
        'prePopulate' => array(
            array( 'id' => 3, 'name' => 'PHP' ),
            array( 'id' => 5, 'name' => 'APS' ),
        )
    ),
    'description' => __( 'Predefined items are Ruby, Python, JavaScript, ActionScript, Scheme, Lisp, C#, Fortran, Vidual Basic, C, C++, Java.', 'admin-page-framework-field-type-pack' ),
),
array(
    'type' => 'autocomplete',
    'field_id' => 'autocomplete_custom_post_type',
    'title' => __( 'Custom Post Type', 'admin-page-framework-field-type-pack' ),
    'settings' => add_query_arg( array( 'request' => 'autocomplete', 'post_type' => 'apf_posts' ) + $_GET, admin_url( AdminPageFramework_WPUtility::getPageNow() ) ),
    'settings2' => array( // equivalent to the second parameter of the tokenInput() method
        'tokenLimit' => 5,
        'preventDuplicates' =>    true,
        'theme' => 'facebook',
        'searchDelay' => 50, // 50 milliseconds. Default: 300
    ),
),
array(
    'type' => 'autocomplete',
    'field_id' => 'autocomplete_mixed_field_types',
    'title' => __( 'Mixed Post Types', 'admin-page-framework-field-type-pack' ),
    'settings' => add_query_arg(
        array(
            'request' => 'autocomplete',
            'post_types' => 'post, page, apf_posts', // Note that the argument key is not 'post_type'
            'post_status' => 'publish, private',
        ) + $_GET,
        admin_url( AdminPageFramework_WPUtility::getPageNow() )
    ),
    'settings2'     =>  array(
        'theme'         => 'admin_page_framework',
    ),
),
array(
    'type'          => 'autocomplete',
    'field_id'      => 'autocomplete_repeatable_field',
    'title'         => __( 'Repeatable', 'admin-page-framework-field-type-pack' ),
    'repeatable'    => true,
),
array(
    'type'          => 'autocomplete',
    'field_id'      => 'autocomplete_users',
    'title'         => __( 'Search Users', 'admin-page-framework-field-type-pack' ),
    'settings'      => add_query_arg(
        array(
            'request'   => 'autocomplete',
            'type'      => 'user', // Note that the argument key is not 'post_type'
        ) + $_GET,
        admin_url( AdminPageFramework_WPUtility::getPageNow() )
    ),
    'settings2'     =>  array(
        'theme'             => 'admin_page_framework',
        'hintText'          => __( 'Type a user name.', 'auto-post' ),
        'preventDuplicates' => true,
    ),
)
Package: AdminPageFrameworkFieldTypePack\CustomFieldType
Since: 1.0.0
See: http://loopj.com/jquery-tokeninput/
Remark: Utilize the tokeninput jQuery plugin.
Located at custom-field-types/autocomplete-custom-field-type/AutocompleteCustomFieldType.php

Methods summary

protected
# construct( )

User constructor.

Loaded at the end of the constructor.

public
# _replyToReturnAutoCompleteRequest( )

Responds to the request.

public
# _replyToModifyMySQLWhereClauseToSearchUsers( mixed $oWPQuery )

Modifies the WordPress database query.

public
# _replyToModifyMySQLWhereClauseToSearchPosts( mixed $sWhere, mixed $oWPQuery )

Modifies the WordPress database query.

protected
# setUp( )

Loads the field type necessary components.

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

protected
# getEnqueuingScripts( )

Returns an array holding the urls of enqueuing scripts.

The returning array should be composed with 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>.
protected
# getEnqueuingStyles( )

Returns an array holding the urls of enqueuing styles.

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.
protected
# getScripts( )

Returns the field type specific JavaScript script.

protected
# getIEStyles( )

Returns IE specific CSS rules.

protected
# getStyles( )

Returns the field type specific CSS rules.

protected
# getField( mixed $aField )

Returns the output of the field type.

Magic methods summary

Properties summary

public array $aFieldTypeSlugs
#

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' => 'autocomplete', // <--- THIS PART 'field_id' => '...', 'title' => '...', ) );

protected array $aDefaultKeys
#

Defines the default key-values of this field type.

The keys are used for the field definition array.

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

Remark

$_aDefaultKeys holds shared default key-values defined in the base class.
Admin Page Framework - Field Type Pack Documentation generated by ApiGen 2.8.0