name = 'form';
$this->plural = 'forms';
$this->setting = 'modules/forms';
$this->post_type = 'acfe-form';
$this->args = array(
'label' => __('Forms', 'acfe'),
'show_in_menu' => 'edit.php?post_type=acf-field-group',
'hierarchical' => true,
'menu_icon' => 'dashicons-layout',
'labels' => array(
'name' => __('Forms', 'acfe'),
'singular_name' => __('Form', 'acfe'),
'menu_name' => __('Forms', 'acfe'),
'edit_item' => __('Edit Form', 'acfe'),
'add_new' => __('New Form', 'acfe'),
'add_new_item' => __('New Form', 'acfe'),
'enter_title' => __('Form Title', 'acfe'),
),
);
$this->messages = array(
'export_title' => __('Export Forms', 'acfe'),
'export_description' => __('Export Forms', 'acfe'),
'export_select' => __('Select Forms', 'acfe'),
'export_not_found' => __('No form available.', 'acfe'),
'export_not_selected' => __('No forms selected', 'acfe'),
'export_success_single' => __('1 form exported', 'acfe'),
'export_success_multiple' => __('%s forms exported', 'acfe'),
'export_instructions' => __('It is recommended to include this code within the acfe/init hook.', 'acfe'),
'import_title' => __('Import Forms', 'acfe'),
'import_description' => __('Import Forms', 'acfe'),
'import_success_single' => __('1 form imported', 'acfe'),
'import_success_multiple' => __('%s forms imported', 'acfe'),
);
$this->export_files = array(
'single' => 'form',
'multiple' => 'forms',
);
$this->validate = array('name');
$this->columns = array(
'acfe-name' => __('Name', 'acfe'),
'acfe-field-groups' => __('Field Groups', 'acfe'),
'acfe-actions' => __('Actions', 'acfe'),
'acfe-shortcode' => __('Shortcode', 'acfe'),
);
$this->item = array(
'name' => '',
'title' => '',
'active' => true,
'field_groups' => array(),
'settings' => array(
'location' => false,
'honeypot' => true,
'kses' => true,
'uploader' => 'default',
),
'attributes' => array(
'form' => array(
'element' => 'form',
'class' => '',
'id' => '',
),
'fields' => array(
'element' => 'div',
'wrapper_class' => '',
'class' => '',
'label' => 'top',
'instruction' => 'label',
),
'submit' => array(
'value' => __('Submit', 'acfe'),
'button' => '',
'spinner' => '',
)
),
'validation' => array(
'hide_error' => false,
'hide_revalidation' => false,
'hide_unload' => false,
'errors_position' => 'above',
'errors_class' => '',
'messages' => array(
'failure' => __('Validation failed', 'acf'),
'success' => __('Validation successful', 'acf'),
'error' => __('1 field requires attention', 'acf'),
'errors' => __('%d fields require attention', 'acf'),
),
),
'success' => array(
'hide_form' => false,
'scroll' => false,
'shortcode' => false,
'message' => __('Form updated', 'acfe'),
'wrapper' => '
[acfe_form ID=""][acfe_form name=""]
<?php get_header(); ?>
<!-- -->
<?php acfe_form(''); ?>
<?php get_footer(); ?>
' . $item['name'] . '';
}
/**
* edit_column_acfe_field_groups
*
* @param $item
*/
function edit_column_acfe_field_groups($item){
$text = '—';
$field_groups = array();
foreach($item['field_groups'] as $key){
$field_group = acf_get_field_group($key);
if($field_group){
// no field group ID found
if(empty($field_group['ID'])){
// get raw field group from db
$raw_field_group = acf_get_raw_field_group($field_group['key']);
// raw field group found
if($raw_field_group && !empty($raw_field_group['ID'])){
$field_group['ID'] = $raw_field_group['ID'];
}
}
if(!empty($field_group['ID'])){
$field_groups[] = "{$field_group['title']}";
}else{
$field_groups[] = $field_group['title'];
}
}else{
$field_groups[] = '' .$key . '';
}
}
if($field_groups){
$text = implode(', ', $field_groups);
}
echo $text;
}
/**
* edit_column_acfe_actions
*
* @param $form
*/
function edit_column_acfe_actions($form){
$text = '—';
$render = array();
// loop actions
foreach($form['actions'] as $action){
// default label (action type not found)
$label = ucfirst($action['action']);
// get action type
$action_type = acfe_get_form_action_type($action['action']);
// use title alt if exists
if(!empty($action_type)){
$label = $action_type->title_alt;
}
// filters
$label = apply_filters("acfe/form/admin_column/action_label", $label, $action, $action_type, $form);
$label = apply_filters("acfe/form/admin_column/action_label/form={$form['name']}", $label, $action, $action_type, $form);
$label = apply_filters("acfe/form/admin_column/action_label/action={$action['action']}", $label, $action, $action_type, $form);
// do not show if empty label
if(!empty($label)){
$render[] = $action_type->title_alt;
}
}
if($render){
$text = implode(', ', $render);
}
echo $text;
}
/**
* edit_column_acfe_shortcode
*
* @param $item
*/
function edit_column_acfe_shortcode($item){
echo "[acfe_form name=\"{$item['name']}\"]";
}
/**
* export_code
*
* @param $return
* @param $code
* @param $args
*
* @return string
*/
function export_code($code, $args){
return "acfe_register_form({$code});";
}
}
acfe_register_module('acfe_module_form');
endif;
function acfe_register_form($item){
acfe_get_module('form')->add_local_item($item);
}