Admin Page Framework Documentation

Packages

  • AdminPageFramework
    • Common
      • Factory
      • Form
        • FieldType
      • Utility
    • Factory
      • AdminPage
      • MetaBox
      • NetworkAdmin
      • PageMetaBox
      • PostType
      • TaxonomyField
      • TermMeta
      • UserMeta
      • Widget
    • Utility

Classes

  • AdminPageFramework_FieldType
  • AdminPageFramework_FieldType_checkbox
  • AdminPageFramework_FieldType_color
  • AdminPageFramework_FieldType_contact
  • AdminPageFramework_FieldType_export
  • AdminPageFramework_FieldType_file
  • AdminPageFramework_FieldType_hidden
  • AdminPageFramework_FieldType_image
  • AdminPageFramework_FieldType_import
  • AdminPageFramework_FieldType_inline_mixed
  • AdminPageFramework_FieldType_media
  • AdminPageFramework_FieldType_number
  • AdminPageFramework_FieldType_posttype
  • AdminPageFramework_FieldType_radio
  • AdminPageFramework_FieldType_section_title
  • AdminPageFramework_FieldType_select
  • AdminPageFramework_FieldType_size
  • AdminPageFramework_FieldType_submit
  • AdminPageFramework_FieldType_system
  • AdminPageFramework_FieldType_table
  • AdminPageFramework_FieldType_taxonomy
  • AdminPageFramework_FieldType_text
  • AdminPageFramework_FieldType_textarea

Resources

  • Tutorials
  • Support
  • Reporting Issues

Class AdminPageFramework_FieldType_contact

[3.9.0+] The Contact field type is a custom submit field that helps create custom contact forms by sending data of sibling fields within the same section.

Field Definition Arguments

Field Type Specific Arguments

  • email - (optional, array|string) A string of an email address to send to or it can be an array with the following keys.
    • to - (string|array) The email address to send to or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID.
    • subject - (string|array) The email title or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID.
    • message - (string|array) The email body or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID.
    • headers - (string|array) The email header or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID.
    • attachments - (string|array) The file path(s) or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID
    • name - (string|array) the sender name or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID.
    • from - (string|array) the sender email or an array representing the key structure of the submitted form data holding the value. The first key should be the section ID and the second key is the field ID.
    • is_html - (boolean|array) indicates whether the message should be sent as an html or plain text.
    • data - (array) Extra data appended to the message body.
  • system_message - (optional, array) System messages to display to the user.
    • success - (string) A message to display when an Email is sent.
    • fail - (string) A message to display when an Email is failed to send.
    • error - (string) A message to display when an error occurs.

Common Field Definition Arguments

For common field definition arguments, see AdminPageFramework_Factory_Controller::addSettingField().

Example

$_sSectionID   = 'my_contact_form'; // add your section in prior
$_oCurrentUser = wp_get_current_user();
$oFactory->addSettingFields(
    $_sSectionID, // the target section id
    array(
        'field_id'          => 'name',
        'title'             => __( 'Your Name', 'admin-page-framework-loader' ),
        'type'              => 'text',
        'default'           => $_oCurrentUser->user_firstname || $_oCurrentUser->user_lastname
            ? $_oCurrentUser->user_lastname . ' ' .  $_oCurrentUser->user_lastname
            : '',
        'attributes'        => array(
            'required' => 'required',
            'placeholder'   => __( 'Type your name.', 'admin-page-framewrok-demo' ),
        ),
    ),
    array(
        'field_id'          => 'from',
        'title'             => __( 'Your Email Address', 'admin-page-framework-loader' ),
        'type'              => 'text',
        'default'           => $_oCurrentUser->user_email,
        'attributes'        => array(
            'required'      => 'required',
            'placeholder'   =>  __( 'Type your email here.', 'admin-page-framework-loader' ),
        ),
    ),
    array(
        'field_id'          => 'use_for_commercial_products',
        'title'             => __( 'I use the framework for', 'admin-page-framework-loader' ),
        'type'              => 'radio',
        'default'           => 1,
        'label'             => array(
            1       => __( 'Commercial Products', 'admin-page-framework-loader' ),
            0       => __( 'Non-commercial Products', 'admin-page-framework-loader' ),
        ),
    ),
    array(
        'field_id'          => 'use_for',
        'title'             => __( 'I use the framework for', 'admin-page-framework-loader' ),
        'type'              => 'radio',
        'default'           => 'others',
        'label'             => array(
            'plugins'   => __( 'Plugins', 'admin-page-framework-loader' ),
            'themes'    => __( 'Themes', 'admin-page-framework-loader' ),
            'others'    => __( 'Others', 'admin-page-framework-loader' ),
        ),
    ),
    array(
        'field_id'          => 'subject',
        'title'             => __( 'Subject', 'admin-page-framework-loader' ),
        'type'              => 'text',
        'attributes'        => array(
            'size' => 40,
            'placeholder'   =>  __( 'Type the title here.', 'admin-page-framework-loader' ),
        ),
    ),
    array(
        'field_id'          => 'body',
        'title'             => __( 'Message', 'admin-page-framework-loader' ),
        'type'              => 'textarea',
        'rich'              => array(
            'textarea_rows' => 10,  // set height
            // Or use the below to set height
            // 'editor_height' => 300,
            // @see _WP_Editors::parse_settings()
        ),
        'attributes'        => array(
            'placeholder'   =>  __( 'Type the message here.', 'admin-page-framework-loader' ),
        ),
    ),
    array(
        'field_id'          => 'ip',
        'type'              => 'hidden',
        'value'             => $_SERVER[ "REMOTE_ADDR" ],
    ),
    array(
        'field_id'          => 'send',
        'type'              => 'contact',
        'label_min_width'   => 0,
        'value'             => __( 'Send', 'admin-page-framework-demo' ),
        'attributes'        => array(
            'field' => array(
                'style' => 'float:right; clear:none; display: inline;',
            ),
        ),
        'skip_confirmation' => true,
        'system_message'    => array(
            'success' => __( 'Thanks for the feedback!', 'admin-page-framework-demo' ),
        ),
        'email'             => array(
            // Each argument can accept a string or an array representing the dimensional array key.
            // For example, if there is a field for the email title, and its section id is 'my_section'  and  the field id is 'my_field', pass an array, array( 'my_section', 'my_field' )
            'to'          => 'admin-page-framework@michaeluno.jp',
            'subject'     => array( $_sSectionID, 'subject' ),
            'message'     => array( $_sSectionID ), // the section name enclosed in an array. If it is a field, set it to the second element like array( 'section id', 'field id' ).
            'headers'     => '',
            'attachments' => '',    // the file path
            'is_html'     => true,  // boolean  Whether the mail should be sent as an html text
            'from'        => array( $_sSectionID, 'from' ),
            'name'        => array( $_sSectionID, 'name' ),
        ),
    )
);
Package: AdminPageFramework\Common\Form\FieldType
Since: 3.9.0
Image: http://admin-page-framework.michaeluno.jp/image/common/form/field_type/contact.png
Located at factory/_common/form/field_type/contact/AdminPageFramework_FieldType_contact.php

Methods summary

protected
# construct( )

Since

3.9.0

Overrides

AdminPageFramework_FieldType::construct
protected string
# getField( array $aField )

Parameters

$aField
array
$aField

Returns

string

Since

3.9.0
protected array
# getEnqueuingScripts( )

Returns

array

Since

3.9.0

Overrides

AdminPageFramework_FieldType_submit::getEnqueuingScripts
protected string
# _getHiddenInput_Email( array $aField )

Parameters

$aField
array
$aField

Returns

string
protected
# doOnFieldRegistration( array $aFieldset )

Calls back the callback function if it is set.

Called when the field type is registered.

Parameters

$aFieldset
array
$aFieldset

Since

3.9.0

Overrides

AdminPageFramework_FieldType::doOnFieldRegistration

Magic methods summary

Properties summary

public array $aFieldTypeSlugs
#

Defines the field type slugs used for this field type.

Related

If you find undocumented functionality, please report it here.

Admin Page Framework