PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.0.0-beta.3
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.0.0-beta.3
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / class-frontend-form.php

class-frontend-form.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.0.0-beta.3, at includes/class-frontend-form.php

140 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The frontend form class
5 */
6 class WeForms_Frontend extends WPUF_Render_Form {
7
8 public function __construct() {
9 add_shortcode( 'weforms', array( $this, 'render_shortcode' ) );
10 }
11
12 /**
13 * Render contact form shortcode
14 *
15 * @param array $atts
16 * @param string $contents
17 *
18 * @return string
19 */
20 public function render_shortcode( $atts, $contents = '' ) {
21 extract( shortcode_atts( array( 'id' => 0 ), $atts ) );
22 ob_start();
23
24 $is_open = wpuf_is_form_submission_open( $id );
25
26 if ( is_wp_error( $is_open ) ) {
27 return '<div class="wpuf-info">' . $is_open->get_error_message() . '</div>';
28 }
29
30 $form_settings = wpuf_get_form_settings( $id );
31
32 // var_dump( $form_settings );
33 $this->render_form( $id );
34
35 return ob_get_clean();
36 }
37
38 /**
39 * Handles the add post shortcode
40 *
41 * @param $atts
42 */
43 function render_form( $form_id, $post_id = NULL, $preview = false ) {
44 $form_vars = wpuf_get_form_fields( $form_id );
45 $form_settings = wpuf_get_form_settings( $form_id );
46 ?>
47
48 <form class="wpuf-form-add" action="" method="post">
49
50 <ul class="wpuf-form form-label-<?php echo $form_settings['label_position']; ?>">
51 <?php
52 $this->render_items( $form_vars, $post_id, 'contact_form', $form_id, $form_settings );
53 $this->submit_button( $form_id, $form_settings, $post_id );
54 ?>
55 </ul>
56
57 </form>
58
59 <?php
60 weforms_track_form_view( $form_id );
61 }
62
63 function submit_button( $form_id, $form_settings, $post_id ) {
64 ?>
65 <li class="wpuf-submit">
66 <div class="wpuf-label">
67 &nbsp;
68 </div>
69
70 <?php wp_nonce_field( 'wpuf_form_add' ); ?>
71
72 <input type="hidden" name="form_id" value="<?php echo $form_id; ?>">
73 <input type="hidden" name="page_id" value="<?php echo get_post() ? get_the_ID() : '0'; ?>">
74 <input type="hidden" name="action" value="wpuf_submit_contact">
75
76 <input type="submit" name="submit" value="<?php echo $form_settings['submit_text']; ?>" />
77 </li>
78 <?php
79 }
80
81 function field_name( $form_field, $post_id, $type, $form_id ) {
82 // var_dump( $form_field );
83 ?>
84 <div class="wpuf-fields">
85 <div class="wpuf-name-field-wrap format-<?php echo $form_field['format']; ?>">
86 <div class="wpuf-name-field-first-name">
87 <input
88 name="<?php echo $form_field['name'] ?>[first]"
89 type="text"
90 placeholder="<?php echo esc_attr( $form_field['first_name']['placeholder'] ); ?>"
91 value="<?php echo esc_attr( $form_field['first_name']['default'] ); ?>"
92 size="40"
93 data-required="<?php echo $form_field['required'] ?>"
94 data-type="text"
95 class="textfield wpuf_<?php echo $form_field['name']; ?>_<?php echo $form_id; ?>"
96 >
97
98 <?php if ( ! $form_field['hide_subs'] ) : ?>
99 <label class="wpuf-form-sub-label"><?php _e( 'First', 'weforms' ); ?></label>
100 <?php endif; ?>
101 </div>
102
103 <?php if ( $form_field['format'] != 'first-last' ) : ?>
104 <div class="wpuf-name-field-middle-name">
105 <input
106 name="<?php echo $form_field['name'] ?>[middle]"
107 type="text" class="textfield"
108 placeholder="<?php echo esc_attr( $form_field['middle_name']['placeholder'] ); ?>"
109 value="<?php echo esc_attr( $form_field['middle_name']['default'] ); ?>"
110 size="40"
111 >
112
113 <?php if ( ! $form_field['hide_subs'] ) : ?>
114 <label class="wpuf-form-sub-label"><?php _e( 'Middle', 'weforms' ); ?></label>
115 <?php endif; ?>
116 </div>
117 <?php else: ?>
118 <input type="hidden" name="<?php echo $form_field['name'] ?>[middle]" value="">
119 <?php endif; ?>
120
121 <div class="wpuf-name-field-last-name">
122 <input
123 name="<?php echo $form_field['name'] ?>[last]"
124 type="text" class="textfield"
125 placeholder="<?php echo esc_attr( $form_field['last_name']['placeholder'] ); ?>"
126 value="<?php echo esc_attr( $form_field['last_name']['default'] ); ?>"
127 size="40"
128 >
129 <?php if ( ! $form_field['hide_subs'] ) : ?>
130 <label class="wpuf-form-sub-label"><?php _e( 'Last', 'weforms' ); ?></label>
131 <?php endif; ?>
132 </div>
133 </div>
134 </div>
135 <?php
136
137 $this->conditional_logic( $form_field, $form_id );
138 }
139 }
140