Last active
December 15, 2016 18:06
-
-
Save rawcreative/0936404decd47eb275087c72b8743d1e to your computer and use it in GitHub Desktop.
Unyson Contact Form as Post type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined( 'FW' ) ) { | |
die( 'Forbidden' ); | |
} | |
$options = array( | |
'main' => array( | |
'type' => 'box', | |
'title' => '', | |
'options' => array( | |
'id' => array( | |
'type' => 'unique', | |
), | |
'builder' => array( | |
'type' => 'tab', | |
'title' => __( 'Form Fields', 'fw' ), | |
'options' => array( | |
'form' => array( | |
'label' => false, | |
'type' => 'form-builder', | |
'value' => array( | |
'json' => apply_filters('fw:ext:forms:builder:load-item:form-header-title', true) | |
? json_encode( array( | |
array( | |
'type' => 'form-header-title', | |
'shortcode' => 'form_header_title', | |
'width' => '', | |
'options' => array( | |
'title' => '', | |
'subtitle' => '', | |
) | |
) | |
) ) | |
: '[]' | |
), | |
'fixed_header' => true, | |
), | |
), | |
), | |
'settings' => array( | |
'type' => 'tab', | |
'title' => __( 'Settings', 'fw' ), | |
'options' => array( | |
'settings-options' => array( | |
'title' => __( 'Options', 'fw' ), | |
'type' => 'tab', | |
'options' => array( | |
'form_text_settings' => array( | |
'type' => 'group', | |
'options' => array( | |
'subject-group' => array( | |
'type' => 'group', | |
'options' => array( | |
'subject_message' => array( | |
'type' => 'text', | |
'label' => __( 'Subject Message', 'fw' ), | |
'desc' => __( 'This text will be used as subject message for the email', 'fw' ), | |
'value' => __( 'New message', 'fw' ), | |
), | |
) | |
), | |
'submit-button-group' => array( | |
'type' => 'group', | |
'options' => array( | |
'submit_button_text' => array( | |
'type' => 'text', | |
'label' => __( 'Submit Button', 'fw' ), | |
'desc' => __( 'This text will appear in submit button', 'fw' ), | |
'value' => __( 'Send', 'fw' ), | |
), | |
) | |
), | |
'success-group' => array( | |
'type' => 'group', | |
'options' => array( | |
'success_message' => array( | |
'type' => 'text', | |
'label' => __( 'Success Message', 'fw' ), | |
'desc' => __( 'This text will be displayed when the form will successfully send', 'fw' ), | |
'value' => __( 'Message sent!', 'fw' ), | |
), | |
) | |
), | |
'failure_message' => array( | |
'type' => 'text', | |
'label' => __( 'Failure Message', 'fw' ), | |
'desc' => __( 'This text will be displayed when the form will fail to be sent', 'fw' ), | |
'value' => __( 'Oops something went wrong.', 'fw' ), | |
), | |
), | |
), | |
'form_email_settings' => array( | |
'type' => 'group', | |
'options' => array( | |
'email_to' => array( | |
'type' => 'text', | |
'label' => __( 'Email To', 'fw' ), | |
'help' => __( 'We recommend you to use an email that you verify often', 'fw' ), | |
'desc' => __( 'The form will be sent to this email address.', 'fw' ), | |
), | |
), | |
), | |
) | |
), | |
'mailer-options' => array( | |
'title' => __( 'Mailer', 'fw' ), | |
'type' => 'tab', | |
'options' => array( | |
'mailer' => array( | |
'label' => false, | |
'type' => 'mailer' | |
) | |
) | |
) | |
), | |
) | |
) | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register theme post types and taxonomies | |
*/ | |
function _createLabels($singular, $plural, $overrides = []) { | |
$defaults = [ | |
'name' => __( $plural, 'raw' ), | |
'singular_name' => __( $singular, 'raw' ), | |
'menu_name' => __( $plural, 'raw' ), | |
'name_admin_bar' => __( $singular, 'raw' ), | |
'add_new' => __( 'Add New', 'raw' ), | |
'add_new_item' => __( 'Add New '.$singular, 'raw' ), | |
'new_item' => __( 'New '.$singular, 'raw' ), | |
'edit_item' => __( 'Edit '.$singular, 'raw' ), | |
'view_item' => __( 'View '.$singular, 'raw' ), | |
'view_items' => __( 'View '.$plural, 'raw' ), | |
'all_items' => __( 'All '.$plural, 'raw' ), | |
'search_items' => __( 'Search '.$plural, 'raw' ), | |
'parent_item_colon' => __( 'Parent '.$plural.':', 'raw' ), | |
'attributes' => __( $singular.' Attributes', 'raw' ), | |
'not_found' => __( 'No '.strtolower($plural).' found.', 'raw' ), | |
'not_found_in_trash' => __( 'No '.strtolower($plural).' found in Trash.', 'raw' ) | |
]; | |
return wp_parse_args($overrides, $defaults); | |
} | |
$args = array( | |
'labels' => _createLabels('Form', 'Forms'), | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'form' ), | |
'capability_type' => 'post', | |
'has_archive' => true, | |
'hierarchical' => false, | |
'menu_position' => 20, | |
'menu_icon' => 'dashicons-welcome-write-blog', | |
'supports' => array( 'title', 'thumbnail', 'page-attributes' ) | |
); | |
register_post_type('form', $args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment