/** * Add dropzone markup. * * @return void */ public function upload_field() { $filetypes = $this->get_allowed_filetypes(); $filetypes = explode(',', $filetypes); $accept = array(); foreach ($filetypes as $key => $type) { $filetypes[$key] = "<code>.{$type}</code>"; array_push($accept, ".{$type}"); } $filetypes = implode(', ', $filetypes); $accept = implode(',', $accept); /** * Output the upload field using a custom field */ $attachments_args = apply_filters('wpas_ticket_attachments_field_args', array('name' => $this->index, 'args' => array('required' => false, 'capability' => 'edit_ticket', 'field_type' => 'upload', 'multiple' => true, 'label' => __('Attachments', 'wpas'), 'desc' => sprintf(__(' You can upload up to %d files (maximum %d MB each) of the following types: %s', 'wpas'), (int) wpas_get_option('attachments_max'), (int) wpas_get_option('filesize_max'), apply_filters('wpas_attachments_filetypes_display', $filetypes))))); $attachments = new WPAS_Custom_Field($this->index, $attachments_args); echo $attachments->get_output(); ?> <!-- <div class="wpas-form-group wpas-attachment-container">--> <!-- <label for="wpas-file-upload">--><?php //_e( 'Attachments', 'wpas' ); ?> <!--</label>--> <!-- <input type="file" name="--><?php //echo $this->index; ?> <!--[]" id="wpas-file-upload" class="wpas-form-control" accept="--><?php //echo $accept; ?> <!--" multiple>--> <!-- <p class="wpas-help-block">--><?php //printf( __( ' You can upload up to %d files (maximum %d MB each) of the following types: %s', 'wpas' ), (int) wpas_get_option( 'attachments_max' ), (int) wpas_get_option( 'filesize_max' ), apply_filters('wpas_attachments_filetypes_display', $filetypes ) ); ?> <!--</p>--> <!-- </div>--> <?php }
/** * Add dropzone markup. * * @return void */ public function upload_field() { $filetypes = $this->get_allowed_filetypes(); $filetypes = explode(',', $filetypes); $accept = array(); foreach ($filetypes as $key => $type) { $filetypes[$key] = "<code>.{$type}</code>"; array_push($accept, ".{$type}"); } $filetypes = implode(', ', $filetypes); $accept = implode(',', $accept); /** * Output the upload field using a custom field */ $attachments_args = apply_filters('wpas_ticket_attachments_field_args', array('name' => $this->index, 'args' => array('required' => false, 'capability' => 'edit_ticket', 'field_type' => 'upload', 'multiple' => true, 'label' => __('Attachments', 'awesome-support'), 'desc' => sprintf(__(' You can upload up to %d files (maximum %d MB each) of the following types: %s', 'awesome-support'), (int) wpas_get_option('attachments_max'), (int) wpas_get_option('filesize_max'), apply_filters('wpas_attachments_filetypes_display', $filetypes))))); $attachments = new WPAS_Custom_Field($this->index, $attachments_args); echo $attachments->get_output(); }
/** * Display the custom fields on submission form. * * @since 3.2.0 * @return void */ public function submission_form_fields() { $fields = $this->get_custom_fields(); if (!empty($fields)) { foreach ($fields as $name => $field) { /* Do not display core fields */ if (true === $field['args']['core']) { continue; } $this_field = new WPAS_Custom_Field($name, $field); $output = $this_field->get_output(); echo $output; } } }
<h3><?php _e('Register', 'awesome-support'); ?> </h3> <?php $first_name = new WPAS_Custom_Field('first_name', array('name' => 'first_name', 'args' => array('required' => true, 'field_type' => 'text', 'label' => __('First Name', 'awesome-support'), 'placeholder' => __('First Name', 'awesome-support'), 'sanitize' => 'sanitize_text_field'))); echo $first_name->get_output(); $last_name = new WPAS_Custom_Field('last_name', array('name' => 'last_name', 'args' => array('required' => true, 'field_type' => 'text', 'label' => __('Last Name', 'awesome-support'), 'placeholder' => __('Last Name', 'awesome-support'), 'sanitize' => 'sanitize_text_field'))); echo $last_name->get_output(); $email = new WPAS_Custom_Field('email', array('name' => 'email', 'args' => array('required' => true, 'field_type' => 'email', 'label' => __('Email', 'awesome-support'), 'placeholder' => __('Email', 'awesome-support'), 'sanitize' => 'sanitize_text_field'))); echo $email->get_output(); $pwd = new WPAS_Custom_Field('password', array('name' => 'password', 'args' => array('required' => true, 'field_type' => 'password', 'label' => __('Enter a password', 'awesome-support'), 'placeholder' => __('Password', 'awesome-support'), 'sanitize' => 'sanitize_text_field'))); echo $pwd->get_output(); $showpwd = new WPAS_Custom_Field('pwdshow', array('name' => 'pwdshow', 'args' => array('required' => false, 'field_type' => 'checkbox', 'sanitize' => 'sanitize_text_field', 'options' => array('1' => _x('Show Password', 'Login form', 'awesome-support'))))); echo $showpwd->get_output(); /** * wpas_after_registration_fields hook * * @Awesome_Support::terms_and_conditions_checkbox() */ do_action('wpas_after_registration_fields'); wpas_do_field('register', $redirect_to); wp_nonce_field('register', 'user_registration', false, true); wpas_make_button(__('Create Account', 'awesome-support'), array('onsubmit' => __('Creating Account...', 'awesome-support'))); ?> </form> <?php } ?> </div>
/** * The wpas_submission_form_inside_before has to be placed * inside the form, right in between the form opening tag * and the subject field. * * @since 3.0.0 */ do_action('wpas_submission_form_inside_before_subject'); /** * Filter the subject field arguments * * @since 3.2.0 */ $subject_args = apply_filters('wpas_subject_field_args', array('name' => 'title', 'args' => array('required' => true, 'field_type' => 'text', 'label' => __('Complain (max 50 char)', 'wpas'), 'sanitize' => 'sanitize_text_field'))); $subject = new WPAS_Custom_Field('title', $subject_args); echo $subject->get_output(); /** * The wpas_submission_form_inside_after_subject hook has to be placed * right after the subject field. * * This hook is very important as this is where the custom fields are hooked. * Without this hook custom fields would not display at all. * * @since 3.0.0 */ do_action('wpas_submission_form_inside_after_subject'); /** * Filter the description field arguments * * @since 3.2.0 */
*/ do_action('wpas_submission_form_inside_before_subject'); $subject = new WPAS_Custom_Field('title', array('name' => 'title', 'args' => array('required' => true, 'field_type' => 'text', 'label' => 'Subject'))); echo $subject->get_output(); /** * The wpas_submission_form_inside_after_subject hook has to be placed * right after the subject field. * * This hook is very important as this is where the custom fields are hooked. * Without this hook custom fields would not display at all. * * @since 3.0.0 */ do_action('wpas_submission_form_inside_after_subject'); $body = new WPAS_Custom_Field('message', array('name' => 'message', 'args' => array('required' => true, 'field_type' => 'wysiwyg', 'label' => 'Description'))); echo $body->get_output(); /** * The wpas_submission_form_inside_before hook has to be placed * right before the submission button. * * @since 3.0.0 */ do_action('wpas_submission_form_inside_before_submit'); wp_nonce_field('new_ticket', 'wpas_nonce', false, true); wpas_make_button(__('Submit ticket', 'wpas'), array('name' => 'wpas-submit', 'onsubmit' => __('Please Wait...', 'wpas'))); /** * The wpas_submission_form_inside_before hook has to be placed * right before the form closing tag. * * @since 3.0.0 */
/** * Add the terms and conditions checkbox. * * Adds a checkbox to the registration form if there are * terms and conditions set in the plugin settings. * * @since 3.0.0 * @return void */ function wpas_terms_and_conditions_checkbox() { $terms = wpas_get_option('terms_conditions', ''); if (empty($terms)) { return; } $terms = new WPAS_Custom_Field('terms', array('name' => 'terms', 'args' => array('required' => true, 'field_type' => 'checkbox', 'sanitize' => 'sanitize_text_field', 'options' => array('1' => sprintf(__('I accept the %sterms and conditions%s', 'awesome-support'), '<a href="#wpas-modalterms" class="wpas-modal-trigger">', '</a>'))))); echo $terms->get_output(); }