@@ -58,9 +58,9 @@ |
||
58 | 58 | <tr> |
59 | 59 | <th>Included AddOns</th> |
60 | 60 | <td>None</td> |
61 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td> |
|
62 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td> |
|
63 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td> |
|
61 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Premium Addons</a></td> |
|
62 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td> |
|
63 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td> |
|
64 | 64 | </tr> |
65 | 65 | </tbody> |
66 | 66 | </table> |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <div class="frmcenter frm_no_entries_form"> |
2 | 2 | <?php |
3 | -if ( $form && isset($form->options['no_save']) && $form->options['no_save'] ) { ?> |
|
3 | +if ( $form && isset( $form->options['no_save'] ) && $form->options['no_save'] ) { ?> |
|
4 | 4 | <h3><?php _e( 'This form is not set to save any entries.', 'formidable' ) ?></h3> |
5 | 5 | <p>If you would like entries in this form to be saved, go to the <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable' ) . '&frm_action=settings&id=' . $form->id ) ?>">form Settings</a> page and uncheck the "Do not store any entries submitted from this form" box.</p> |
6 | 6 | <?php |
7 | 7 | } else if ( $form ) { |
8 | 8 | ?> |
9 | -<div class="frm_no_entries_header"><?php printf(__( 'No Entries for form: %s', 'formidable' ), $form->name); ?></div> |
|
10 | -<p class="frm_no_entries_text"><?php printf( __( 'For instructions on publishing your form see %1$sthe docs%2$s or click "%3$sAdd New%4$s" above to add an entry from here (Requires License)', 'formidable' ), '<a href="https://formidableforms.com/knowledgebase/publish-your-forms/" target="_blank">', '</a> <br/>', '<a href="' . esc_url( admin_url('admin.php?page=formidable-entries&frm_action=new&form=' . $form->id ) ) . '">', '</a>' ); ?></p> |
|
9 | +<div class="frm_no_entries_header"><?php printf( __( 'No Entries for form: %s', 'formidable' ), $form->name ); ?></div> |
|
10 | +<p class="frm_no_entries_text"><?php printf( __( 'For instructions on publishing your form see %1$sthe docs%2$s or click "%3$sAdd New%4$s" above to add an entry from here (Requires License)', 'formidable' ), '<a href="https://formidableforms.com/knowledgebase/publish-your-forms/" target="_blank">', '</a> <br/>', '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&frm_action=new&form=' . $form->id ) ) . '">', '</a>' ); ?></p> |
|
11 | 11 | <?php |
12 | 12 | } else { |
13 | 13 | ?> |
@@ -2,129 +2,129 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | - public static function load_field() { |
|
5 | + public static function load_field() { |
|
6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
8 | 8 | |
9 | - $fields = $_POST['field']; |
|
10 | - if ( empty( $fields ) ) { |
|
11 | - wp_die(); |
|
12 | - } |
|
9 | + $fields = $_POST['field']; |
|
10 | + if ( empty( $fields ) ) { |
|
11 | + wp_die(); |
|
12 | + } |
|
13 | 13 | |
14 | - $_GET['page'] = 'formidable'; |
|
15 | - $fields = stripslashes_deep( $fields ); |
|
14 | + $_GET['page'] = 'formidable'; |
|
15 | + $fields = stripslashes_deep( $fields ); |
|
16 | 16 | |
17 | - $ajax = true; |
|
17 | + $ajax = true; |
|
18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
19 | - $path = FrmAppHelper::plugin_path(); |
|
20 | - $field_html = array(); |
|
21 | - |
|
22 | - foreach ( $fields as $field ) { |
|
23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
24 | - $field = json_decode( $field, true ); |
|
25 | - if ( ! isset( $field['id'] ) ) { |
|
26 | - // this field may have already been loaded |
|
27 | - continue; |
|
28 | - } |
|
19 | + $path = FrmAppHelper::plugin_path(); |
|
20 | + $field_html = array(); |
|
21 | + |
|
22 | + foreach ( $fields as $field ) { |
|
23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
24 | + $field = json_decode( $field, true ); |
|
25 | + if ( ! isset( $field['id'] ) ) { |
|
26 | + // this field may have already been loaded |
|
27 | + continue; |
|
28 | + } |
|
29 | 29 | |
30 | - $field_id = absint( $field['id'] ); |
|
30 | + $field_id = absint( $field['id'] ); |
|
31 | 31 | |
32 | - if ( ! isset( $field['value'] ) ) { |
|
33 | - $field['value'] = ''; |
|
34 | - } |
|
32 | + if ( ! isset( $field['value'] ) ) { |
|
33 | + $field['value'] = ''; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
38 | 38 | |
39 | - ob_start(); |
|
39 | + ob_start(); |
|
40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
42 | - ob_end_clean(); |
|
43 | - } |
|
41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
42 | + ob_end_clean(); |
|
43 | + } |
|
44 | 44 | |
45 | - unset($path); |
|
45 | + unset($path); |
|
46 | 46 | |
47 | - echo json_encode($field_html); |
|
47 | + echo json_encode($field_html); |
|
48 | 48 | |
49 | - wp_die(); |
|
50 | - } |
|
49 | + wp_die(); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Create a new field with ajax |
54 | 54 | */ |
55 | - public static function create() { |
|
55 | + public static function create() { |
|
56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
58 | 58 | |
59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
61 | 61 | |
62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
63 | 63 | |
64 | - // this hook will allow for multiple fields to be added at once |
|
65 | - do_action('frm_after_field_created', $field, $form_id); |
|
64 | + // this hook will allow for multiple fields to be added at once |
|
65 | + do_action('frm_after_field_created', $field, $form_id); |
|
66 | 66 | |
67 | - wp_die(); |
|
68 | - } |
|
67 | + wp_die(); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Set up and create a new field |
|
72 | - * |
|
73 | - * @param string $field_type |
|
74 | - * @param integer $form_id |
|
75 | - * @return array|bool |
|
76 | - */ |
|
70 | + /** |
|
71 | + * Set up and create a new field |
|
72 | + * |
|
73 | + * @param string $field_type |
|
74 | + * @param integer $form_id |
|
75 | + * @return array|bool |
|
76 | + */ |
|
77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
78 | - $values = array(); |
|
79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
81 | - } |
|
78 | + $values = array(); |
|
79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
85 | 85 | |
86 | - $field_id = FrmField::create( $field_values ); |
|
86 | + $field_id = FrmField::create( $field_values ); |
|
87 | 87 | |
88 | - if ( ! $field_id ) { |
|
89 | - return false; |
|
90 | - } |
|
88 | + if ( ! $field_id ) { |
|
89 | + return false; |
|
90 | + } |
|
91 | 91 | |
92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
93 | 93 | |
94 | - return $field; |
|
95 | - } |
|
94 | + return $field; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
100 | 100 | |
101 | - if ( empty($field) ) { |
|
102 | - $field = 'name'; |
|
103 | - } |
|
101 | + if ( empty($field) ) { |
|
102 | + $field = 'name'; |
|
103 | + } |
|
104 | 104 | |
105 | - if ( empty($id) ) { |
|
105 | + if ( empty($id) ) { |
|
106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
108 | - } |
|
108 | + } |
|
109 | 109 | |
110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
111 | 111 | $value = trim( $value ); |
112 | - if ( trim(strip_tags($value)) == '' ) { |
|
113 | - // set blank value if there is no content |
|
114 | - $value = ''; |
|
115 | - } |
|
112 | + if ( trim(strip_tags($value)) == '' ) { |
|
113 | + // set blank value if there is no content |
|
114 | + $value = ''; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
118 | 118 | |
119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
120 | 120 | |
121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
122 | - wp_die(); |
|
123 | - } |
|
122 | + wp_die(); |
|
123 | + } |
|
124 | 124 | |
125 | - public static function update_ajax_option() { |
|
125 | + public static function update_ajax_option() { |
|
126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
128 | 128 | |
129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
130 | 130 | if ( ! $field_id ) { |
@@ -139,144 +139,144 @@ discard block |
||
139 | 139 | unset($new_val); |
140 | 140 | } |
141 | 141 | |
142 | - FrmField::update( $field_id, array( |
|
143 | - 'field_options' => $field->field_options, |
|
142 | + FrmField::update( $field_id, array( |
|
143 | + 'field_options' => $field->field_options, |
|
144 | 144 | 'form_id' => $field->form_id, |
145 | - ) ); |
|
146 | - wp_die(); |
|
147 | - } |
|
145 | + ) ); |
|
146 | + wp_die(); |
|
147 | + } |
|
148 | 148 | |
149 | - public static function duplicate() { |
|
149 | + public static function duplicate() { |
|
150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
152 | 152 | |
153 | - global $wpdb; |
|
153 | + global $wpdb; |
|
154 | 154 | |
155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
157 | 157 | |
158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
159 | - if ( ! $copy_field ) { |
|
160 | - wp_die(); |
|
161 | - } |
|
159 | + if ( ! $copy_field ) { |
|
160 | + wp_die(); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
165 | 165 | |
166 | 166 | $values = array(); |
167 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
167 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
168 | 168 | |
169 | 169 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
170 | 170 | |
171 | - $values['field_order'] = $field_count + 1; |
|
171 | + $values['field_order'] = $field_count + 1; |
|
172 | 172 | |
173 | - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
173 | + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
174 | 174 | |
175 | 175 | $field_id = FrmField::create( $values ); |
176 | 176 | if ( ! $field_id ) { |
177 | 177 | wp_die(); |
178 | 178 | } |
179 | 179 | |
180 | - self::include_single_field($field_id, $values); |
|
180 | + self::include_single_field($field_id, $values); |
|
181 | 181 | |
182 | - wp_die(); |
|
183 | - } |
|
182 | + wp_die(); |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * Load a single field in the form builder along with all needed variables |
|
187 | - */ |
|
188 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
185 | + /** |
|
186 | + * Load a single field in the form builder along with all needed variables |
|
187 | + */ |
|
188 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
189 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
192 | - $id = $form_id ? $form_id : $field['form_id']; |
|
193 | - if ( $field['type'] == 'html' ) { |
|
194 | - $field['stop_filter'] = true; |
|
195 | - } |
|
191 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
192 | + $id = $form_id ? $form_id : $field['form_id']; |
|
193 | + if ( $field['type'] == 'html' ) { |
|
194 | + $field['stop_filter'] = true; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
198 | 198 | |
199 | - return $field; |
|
200 | - } |
|
199 | + return $field; |
|
200 | + } |
|
201 | 201 | |
202 | - public static function destroy() { |
|
202 | + public static function destroy() { |
|
203 | 203 | FrmAppHelper::permission_check('frm_edit_forms'); |
204 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
204 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
205 | 205 | |
206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
207 | 207 | FrmField::destroy( $field_id ); |
208 | - wp_die(); |
|
209 | - } |
|
208 | + wp_die(); |
|
209 | + } |
|
210 | 210 | |
211 | - /* Field Options */ |
|
211 | + /* Field Options */ |
|
212 | 212 | |
213 | - //Add Single Option or Other Option |
|
214 | - public static function add_option() { |
|
213 | + //Add Single Option or Other Option |
|
214 | + public static function add_option() { |
|
215 | 215 | FrmAppHelper::permission_check('frm_edit_forms'); |
216 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
216 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
217 | 217 | |
218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
220 | 220 | |
221 | - //Get the field |
|
222 | - $field = FrmField::getOne($id); |
|
221 | + //Get the field |
|
222 | + $field = FrmField::getOne($id); |
|
223 | 223 | |
224 | 224 | if ( ! empty( $field->options ) ) { |
225 | 225 | $keys = array_keys( $field->options ); |
226 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
227 | - } else { |
|
228 | - $last = 0; |
|
229 | - } |
|
230 | - $opt_key = $last + 1; |
|
226 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
227 | + } else { |
|
228 | + $last = 0; |
|
229 | + } |
|
230 | + $opt_key = $last + 1; |
|
231 | 231 | |
232 | - if ( 'other' == $opt_type ) { |
|
232 | + if ( 'other' == $opt_type ) { |
|
233 | 233 | $opt = esc_html__( 'Other', 'formidable' ); |
234 | - $other_val = ''; |
|
235 | - $opt_key = 'other_' . $opt_key; |
|
236 | - |
|
237 | - //Update value of "other" in DB |
|
238 | - $field_options = maybe_unserialize( $field->field_options ); |
|
239 | - $field_options['other'] = 1; |
|
240 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
241 | - } else { |
|
234 | + $other_val = ''; |
|
235 | + $opt_key = 'other_' . $opt_key; |
|
236 | + |
|
237 | + //Update value of "other" in DB |
|
238 | + $field_options = maybe_unserialize( $field->field_options ); |
|
239 | + $field_options['other'] = 1; |
|
240 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
241 | + } else { |
|
242 | 242 | $first_opt = reset( $field->options ); |
243 | 243 | $next_opt = count( $field->options ); |
244 | - if ( $first_opt != '' ) { |
|
245 | - $next_opt++; |
|
246 | - } |
|
244 | + if ( $first_opt != '' ) { |
|
245 | + $next_opt++; |
|
246 | + } |
|
247 | 247 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
248 | - unset($next_opt); |
|
249 | - } |
|
250 | - $field_val = $opt; |
|
248 | + unset($next_opt); |
|
249 | + } |
|
250 | + $field_val = $opt; |
|
251 | 251 | $field->options[ $opt_key ] = $opt; |
252 | 252 | |
253 | - //Update options in DB |
|
253 | + //Update options in DB |
|
254 | 254 | FrmField::update( $id, array( 'options' => $field->options ) ); |
255 | 255 | |
256 | - $field_data = $field; |
|
257 | - $field = array( |
|
258 | - 'type' => $field_data->type, |
|
259 | - 'id' => $id, |
|
260 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
261 | - 'form_id' => $field_data->form_id, |
|
262 | - 'field_key' => $field_data->field_key, |
|
263 | - ); |
|
256 | + $field_data = $field; |
|
257 | + $field = array( |
|
258 | + 'type' => $field_data->type, |
|
259 | + 'id' => $id, |
|
260 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
261 | + 'form_id' => $field_data->form_id, |
|
262 | + 'field_key' => $field_data->field_key, |
|
263 | + ); |
|
264 | 264 | |
265 | 265 | $field_name = 'item_meta[' . $id . ']'; |
266 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
267 | - $checked = ''; |
|
266 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
267 | + $checked = ''; |
|
268 | 268 | |
269 | - if ( 'other' == $opt_type ) { |
|
269 | + if ( 'other' == $opt_type ) { |
|
270 | 270 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
271 | - } else { |
|
271 | + } else { |
|
272 | 272 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
273 | - } |
|
274 | - wp_die(); |
|
275 | - } |
|
273 | + } |
|
274 | + wp_die(); |
|
275 | + } |
|
276 | 276 | |
277 | - public static function edit_option() { |
|
277 | + public static function edit_option() { |
|
278 | 278 | FrmAppHelper::permission_check('frm_edit_forms'); |
279 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
279 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
280 | 280 | |
281 | 281 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
282 | 282 | $ids = explode( '-', $element_id ); |
@@ -285,43 +285,43 @@ discard block |
||
285 | 285 | $orig_update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
286 | 286 | $update_value = $orig_update_value; |
287 | 287 | if ( strpos( $element_id, 'key_' ) ) { |
288 | - $new_value = $update_value; |
|
289 | - } else { |
|
290 | - $new_label = $update_value; |
|
291 | - } |
|
288 | + $new_value = $update_value; |
|
289 | + } else { |
|
290 | + $new_label = $update_value; |
|
291 | + } |
|
292 | 292 | |
293 | - $field = FrmField::getOne($id); |
|
294 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
293 | + $field = FrmField::getOne($id); |
|
294 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
295 | 295 | |
296 | - $this_opt_id = end($ids); |
|
296 | + $this_opt_id = end($ids); |
|
297 | 297 | $this_opt = (array) $field->options[ $this_opt_id ]; |
298 | 298 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
299 | 299 | |
300 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
301 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
300 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
301 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
302 | 302 | |
303 | - if ( ! isset( $new_label ) ) { |
|
304 | - $new_label = $label; |
|
305 | - } |
|
303 | + if ( ! isset( $new_label ) ) { |
|
304 | + $new_label = $label; |
|
305 | + } |
|
306 | 306 | |
307 | - if ( isset($new_value) || isset($value) ) { |
|
308 | - $update_value = isset($new_value) ? $new_value : $value; |
|
309 | - } |
|
307 | + if ( isset($new_value) || isset($value) ) { |
|
308 | + $update_value = isset($new_value) ? $new_value : $value; |
|
309 | + } |
|
310 | 310 | |
311 | 311 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
312 | 312 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
313 | - } else { |
|
313 | + } else { |
|
314 | 314 | $field->options[ $this_opt_id ] = $orig_update_value; |
315 | - } |
|
315 | + } |
|
316 | 316 | |
317 | 317 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
318 | 318 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
319 | - wp_die(); |
|
320 | - } |
|
319 | + wp_die(); |
|
320 | + } |
|
321 | 321 | |
322 | - public static function delete_option() { |
|
322 | + public static function delete_option() { |
|
323 | 323 | FrmAppHelper::permission_check('frm_edit_forms'); |
324 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
324 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
325 | 325 | |
326 | 326 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
327 | 327 | $field = FrmField::getOne( $field_id ); |
@@ -329,170 +329,170 @@ discard block |
||
329 | 329 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
330 | 330 | |
331 | 331 | $options = $field->options; |
332 | - unset( $options[ $opt_key ] ); |
|
333 | - $response = array( 'other' => true ); |
|
332 | + unset( $options[ $opt_key ] ); |
|
333 | + $response = array( 'other' => true ); |
|
334 | 334 | |
335 | - //If the deleted option is an "other" option |
|
335 | + //If the deleted option is an "other" option |
|
336 | 336 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
337 | - //Assume all other options are gone, unless proven otherwise |
|
338 | - $other = false; |
|
337 | + //Assume all other options are gone, unless proven otherwise |
|
338 | + $other = false; |
|
339 | 339 | |
340 | - //Check if all other options are really gone |
|
341 | - foreach ( $options as $o_key => $o_val ) { |
|
342 | - //If there is still an other option in the field, set other to true |
|
340 | + //Check if all other options are really gone |
|
341 | + foreach ( $options as $o_key => $o_val ) { |
|
342 | + //If there is still an other option in the field, set other to true |
|
343 | 343 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
344 | - $other = true; |
|
345 | - break; |
|
346 | - } |
|
347 | - unset( $o_key, $o_val ); |
|
348 | - } |
|
349 | - |
|
350 | - //If all other options are gone |
|
351 | - if ( false === $other ) { |
|
352 | - $field_options = maybe_unserialize( $field->field_options ); |
|
353 | - $field_options['other'] = 0; |
|
344 | + $other = true; |
|
345 | + break; |
|
346 | + } |
|
347 | + unset( $o_key, $o_val ); |
|
348 | + } |
|
349 | + |
|
350 | + //If all other options are gone |
|
351 | + if ( false === $other ) { |
|
352 | + $field_options = maybe_unserialize( $field->field_options ); |
|
353 | + $field_options['other'] = 0; |
|
354 | 354 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
355 | - $response = array( 'other' => false ); |
|
356 | - } |
|
357 | - } |
|
358 | - echo json_encode( $response ); |
|
355 | + $response = array( 'other' => false ); |
|
356 | + } |
|
357 | + } |
|
358 | + echo json_encode( $response ); |
|
359 | 359 | |
360 | 360 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
361 | 361 | |
362 | - wp_die(); |
|
363 | - } |
|
362 | + wp_die(); |
|
363 | + } |
|
364 | 364 | |
365 | - public static function import_choices() { |
|
366 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
365 | + public static function import_choices() { |
|
366 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
367 | 367 | |
368 | 368 | $field_id = absint( $_REQUEST['field_id'] ); |
369 | 369 | |
370 | - global $current_screen, $hook_suffix; |
|
370 | + global $current_screen, $hook_suffix; |
|
371 | 371 | |
372 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
373 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
374 | - $hook_suffix = ''; |
|
375 | - set_current_screen(); |
|
376 | - } |
|
372 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
373 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
374 | + $hook_suffix = ''; |
|
375 | + set_current_screen(); |
|
376 | + } |
|
377 | 377 | |
378 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
379 | - register_admin_color_schemes(); |
|
380 | - } |
|
378 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
379 | + register_admin_color_schemes(); |
|
380 | + } |
|
381 | 381 | |
382 | 382 | $hook_suffix = ''; |
383 | 383 | $admin_body_class = ''; |
384 | 384 | |
385 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
386 | - $admin_body_class .= ' folded'; |
|
387 | - } |
|
385 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
386 | + $admin_body_class .= ' folded'; |
|
387 | + } |
|
388 | 388 | |
389 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
390 | - $admin_body_class .= ' admin-bar'; |
|
391 | - } |
|
389 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
390 | + $admin_body_class .= ' admin-bar'; |
|
391 | + } |
|
392 | 392 | |
393 | - if ( is_rtl() ) { |
|
394 | - $admin_body_class .= ' rtl'; |
|
395 | - } |
|
393 | + if ( is_rtl() ) { |
|
394 | + $admin_body_class .= ' rtl'; |
|
395 | + } |
|
396 | 396 | |
397 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
398 | - $prepop = array(); |
|
399 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
397 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
398 | + $prepop = array(); |
|
399 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
400 | 400 | |
401 | - $field = FrmField::getOne($field_id); |
|
401 | + $field = FrmField::getOne($field_id); |
|
402 | 402 | |
403 | - wp_enqueue_script( 'utils' ); |
|
403 | + wp_enqueue_script( 'utils' ); |
|
404 | 404 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
405 | - FrmAppHelper::load_admin_wide_js(); |
|
405 | + FrmAppHelper::load_admin_wide_js(); |
|
406 | 406 | |
407 | 407 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
408 | - wp_die(); |
|
409 | - } |
|
408 | + wp_die(); |
|
409 | + } |
|
410 | 410 | |
411 | - public static function import_options() { |
|
411 | + public static function import_options() { |
|
412 | 412 | FrmAppHelper::permission_check('frm_edit_forms'); |
413 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
413 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
414 | 414 | |
415 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
416 | - return; |
|
417 | - } |
|
415 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
416 | + return; |
|
417 | + } |
|
418 | 418 | |
419 | 419 | $field_id = absint( $_POST['field_id'] ); |
420 | - $field = FrmField::getOne($field_id); |
|
420 | + $field = FrmField::getOne($field_id); |
|
421 | 421 | |
422 | 422 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
423 | - return; |
|
424 | - } |
|
423 | + return; |
|
424 | + } |
|
425 | 425 | |
426 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
426 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
427 | 427 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
428 | 428 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
429 | 429 | $opts = array_map( 'trim', $opts ); |
430 | 430 | |
431 | - if ( $field['separate_value'] ) { |
|
432 | - foreach ( $opts as $opt_key => $opt ) { |
|
433 | - if ( strpos($opt, '|') !== false ) { |
|
434 | - $vals = explode('|', $opt); |
|
435 | - if ( $vals[0] != $vals[1] ) { |
|
436 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
437 | - } |
|
438 | - unset($vals); |
|
439 | - } |
|
440 | - unset($opt_key, $opt); |
|
441 | - } |
|
442 | - } |
|
443 | - |
|
444 | - //Keep other options after bulk update |
|
445 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
446 | - $other_array = array(); |
|
447 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
448 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
449 | - $other_array[ $opt_key ] = $opt; |
|
450 | - } |
|
451 | - unset($opt_key, $opt); |
|
452 | - } |
|
453 | - if ( ! empty($other_array) ) { |
|
454 | - $opts = array_merge( $opts, $other_array); |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
459 | - |
|
460 | - $field['options'] = $opts; |
|
461 | - $field_name = $field['name']; |
|
462 | - |
|
463 | - // Get html_id which will be used in single-option.php |
|
464 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
465 | - |
|
466 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
431 | + if ( $field['separate_value'] ) { |
|
432 | + foreach ( $opts as $opt_key => $opt ) { |
|
433 | + if ( strpos($opt, '|') !== false ) { |
|
434 | + $vals = explode('|', $opt); |
|
435 | + if ( $vals[0] != $vals[1] ) { |
|
436 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
437 | + } |
|
438 | + unset($vals); |
|
439 | + } |
|
440 | + unset($opt_key, $opt); |
|
441 | + } |
|
442 | + } |
|
443 | + |
|
444 | + //Keep other options after bulk update |
|
445 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
446 | + $other_array = array(); |
|
447 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
448 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
449 | + $other_array[ $opt_key ] = $opt; |
|
450 | + } |
|
451 | + unset($opt_key, $opt); |
|
452 | + } |
|
453 | + if ( ! empty($other_array) ) { |
|
454 | + $opts = array_merge( $opts, $other_array); |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
459 | + |
|
460 | + $field['options'] = $opts; |
|
461 | + $field_name = $field['name']; |
|
462 | + |
|
463 | + // Get html_id which will be used in single-option.php |
|
464 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
465 | + |
|
466 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
467 | 467 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
468 | - } else { |
|
469 | - FrmFieldsHelper::show_single_option($field); |
|
470 | - } |
|
468 | + } else { |
|
469 | + FrmFieldsHelper::show_single_option($field); |
|
470 | + } |
|
471 | 471 | |
472 | - wp_die(); |
|
473 | - } |
|
472 | + wp_die(); |
|
473 | + } |
|
474 | 474 | |
475 | - public static function update_order() { |
|
475 | + public static function update_order() { |
|
476 | 476 | FrmAppHelper::permission_check('frm_edit_forms'); |
477 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
477 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
478 | 478 | |
479 | 479 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
480 | 480 | foreach ( (array) $fields as $position => $item ) { |
481 | 481 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
482 | 482 | } |
483 | - wp_die(); |
|
484 | - } |
|
483 | + wp_die(); |
|
484 | + } |
|
485 | 485 | |
486 | 486 | public static function change_type( $type ) { |
487 | - $type_switch = array( |
|
488 | - 'scale' => 'radio', |
|
489 | - '10radio' => 'radio', |
|
490 | - 'rte' => 'textarea', |
|
491 | - 'website' => 'url', |
|
492 | - ); |
|
493 | - if ( isset( $type_switch[ $type ] ) ) { |
|
494 | - $type = $type_switch[ $type ]; |
|
495 | - } |
|
487 | + $type_switch = array( |
|
488 | + 'scale' => 'radio', |
|
489 | + '10radio' => 'radio', |
|
490 | + 'rte' => 'textarea', |
|
491 | + 'website' => 'url', |
|
492 | + ); |
|
493 | + if ( isset( $type_switch[ $type ] ) ) { |
|
494 | + $type = $type_switch[ $type ]; |
|
495 | + } |
|
496 | 496 | |
497 | 497 | $pro_fields = FrmField::pro_field_selection(); |
498 | 498 | $types = array_keys( $pro_fields ); |
@@ -500,137 +500,137 @@ discard block |
||
500 | 500 | $type = 'text'; |
501 | 501 | } |
502 | 502 | |
503 | - return $type; |
|
504 | - } |
|
503 | + return $type; |
|
504 | + } |
|
505 | 505 | |
506 | 506 | public static function display_field_options( $display ) { |
507 | 507 | switch ( $display['type'] ) { |
508 | - case 'captcha': |
|
509 | - $display['required'] = false; |
|
510 | - $display['invalid'] = true; |
|
511 | - $display['default_blank'] = false; |
|
508 | + case 'captcha': |
|
509 | + $display['required'] = false; |
|
510 | + $display['invalid'] = true; |
|
511 | + $display['default_blank'] = false; |
|
512 | 512 | $display['captcha_size'] = true; |
513 | - break; |
|
514 | - case 'radio': |
|
515 | - $display['default_blank'] = false; |
|
516 | - break; |
|
517 | - case 'text': |
|
518 | - case 'textarea': |
|
519 | - $display['size'] = true; |
|
520 | - $display['clear_on_focus'] = true; |
|
521 | - break; |
|
522 | - case 'select': |
|
523 | - $display['size'] = true; |
|
524 | - break; |
|
525 | - case 'url': |
|
526 | - case 'website': |
|
527 | - case 'email': |
|
528 | - $display['size'] = true; |
|
529 | - $display['clear_on_focus'] = true; |
|
530 | - $display['invalid'] = true; |
|
531 | - } |
|
532 | - |
|
533 | - return $display; |
|
534 | - } |
|
535 | - |
|
536 | - public static function input_html( $field, $echo = true ) { |
|
537 | - $class = array(); //$field['type']; |
|
538 | - self::add_input_classes($field, $class); |
|
539 | - |
|
540 | - $add_html = array(); |
|
541 | - self::add_html_size($field, $add_html); |
|
542 | - self::add_html_length($field, $add_html); |
|
543 | - self::add_html_placeholder($field, $add_html, $class); |
|
513 | + break; |
|
514 | + case 'radio': |
|
515 | + $display['default_blank'] = false; |
|
516 | + break; |
|
517 | + case 'text': |
|
518 | + case 'textarea': |
|
519 | + $display['size'] = true; |
|
520 | + $display['clear_on_focus'] = true; |
|
521 | + break; |
|
522 | + case 'select': |
|
523 | + $display['size'] = true; |
|
524 | + break; |
|
525 | + case 'url': |
|
526 | + case 'website': |
|
527 | + case 'email': |
|
528 | + $display['size'] = true; |
|
529 | + $display['clear_on_focus'] = true; |
|
530 | + $display['invalid'] = true; |
|
531 | + } |
|
532 | + |
|
533 | + return $display; |
|
534 | + } |
|
535 | + |
|
536 | + public static function input_html( $field, $echo = true ) { |
|
537 | + $class = array(); //$field['type']; |
|
538 | + self::add_input_classes($field, $class); |
|
539 | + |
|
540 | + $add_html = array(); |
|
541 | + self::add_html_size($field, $add_html); |
|
542 | + self::add_html_length($field, $add_html); |
|
543 | + self::add_html_placeholder($field, $add_html, $class); |
|
544 | 544 | self::add_validation_messages( $field, $add_html ); |
545 | 545 | |
546 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
546 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
547 | 547 | |
548 | 548 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
549 | 549 | |
550 | - self::add_shortcodes_to_html($field, $add_html); |
|
550 | + self::add_shortcodes_to_html($field, $add_html); |
|
551 | 551 | |
552 | 552 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
553 | 553 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
554 | 554 | |
555 | - if ( $echo ) { |
|
556 | - echo $add_html; |
|
557 | - } |
|
555 | + if ( $echo ) { |
|
556 | + echo $add_html; |
|
557 | + } |
|
558 | 558 | |
559 | - return $add_html; |
|
560 | - } |
|
559 | + return $add_html; |
|
560 | + } |
|
561 | 561 | |
562 | 562 | private static function add_input_classes( $field, array &$class ) { |
563 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
564 | - $class[] = $field['input_class']; |
|
565 | - } |
|
563 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
564 | + $class[] = $field['input_class']; |
|
565 | + } |
|
566 | 566 | |
567 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
568 | - return; |
|
569 | - } |
|
567 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
568 | + return; |
|
569 | + } |
|
570 | 570 | |
571 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
572 | - $class[] = 'auto_width'; |
|
573 | - } |
|
574 | - } |
|
571 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
572 | + $class[] = 'auto_width'; |
|
573 | + } |
|
574 | + } |
|
575 | 575 | |
576 | 576 | private static function add_html_size( $field, array &$add_html ) { |
577 | 577 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
578 | - return; |
|
579 | - } |
|
578 | + return; |
|
579 | + } |
|
580 | 580 | |
581 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
582 | - return; |
|
583 | - } |
|
581 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
582 | + return; |
|
583 | + } |
|
584 | 584 | |
585 | - if ( is_numeric($field['size']) ) { |
|
586 | - $field['size'] .= 'px'; |
|
587 | - } |
|
585 | + if ( is_numeric($field['size']) ) { |
|
586 | + $field['size'] .= 'px'; |
|
587 | + } |
|
588 | 588 | |
589 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
590 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
589 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
590 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
591 | 591 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
592 | 592 | |
593 | - self::add_html_cols($field, $add_html); |
|
594 | - } |
|
593 | + self::add_html_cols($field, $add_html); |
|
594 | + } |
|
595 | 595 | |
596 | 596 | private static function add_html_cols( $field, array &$add_html ) { |
597 | 597 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
598 | - return; |
|
599 | - } |
|
598 | + return; |
|
599 | + } |
|
600 | 600 | |
601 | - // convert to cols for textareas |
|
602 | - $calc = array( |
|
603 | - '' => 9, |
|
604 | - 'px' => 9, |
|
605 | - 'rem' => 0.444, |
|
606 | - 'em' => 0.544, |
|
607 | - ); |
|
601 | + // convert to cols for textareas |
|
602 | + $calc = array( |
|
603 | + '' => 9, |
|
604 | + 'px' => 9, |
|
605 | + 'rem' => 0.444, |
|
606 | + 'em' => 0.544, |
|
607 | + ); |
|
608 | 608 | |
609 | - // include "col" for valid html |
|
610 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
609 | + // include "col" for valid html |
|
610 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
611 | 611 | |
612 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
613 | - return; |
|
614 | - } |
|
612 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
613 | + return; |
|
614 | + } |
|
615 | 615 | |
616 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
616 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
617 | 617 | |
618 | 618 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
619 | - } |
|
619 | + } |
|
620 | 620 | |
621 | 621 | private static function add_html_length( $field, array &$add_html ) { |
622 | - // check for max setting and if this field accepts maxlength |
|
622 | + // check for max setting and if this field accepts maxlength |
|
623 | 623 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
624 | - return; |
|
625 | - } |
|
624 | + return; |
|
625 | + } |
|
626 | 626 | |
627 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
628 | - // don't load on form builder page |
|
629 | - return; |
|
630 | - } |
|
627 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
628 | + // don't load on form builder page |
|
629 | + return; |
|
630 | + } |
|
631 | 631 | |
632 | 632 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
633 | - } |
|
633 | + } |
|
634 | 634 | |
635 | 635 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
636 | 636 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -638,35 +638,35 @@ discard block |
||
638 | 638 | } |
639 | 639 | |
640 | 640 | $default_value_array = is_array( $field['default_value'] ); |
641 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
641 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
642 | 642 | if ( $default_value_array ) { |
643 | 643 | $field['default_value'] = json_encode( $field['default_value'] ); |
644 | 644 | } |
645 | 645 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
646 | - return; |
|
647 | - } |
|
646 | + return; |
|
647 | + } |
|
648 | 648 | |
649 | 649 | if ( $default_value_array ) { |
650 | 650 | // don't include a json placeholder |
651 | 651 | return; |
652 | 652 | } |
653 | 653 | |
654 | - $frm_settings = FrmAppHelper::get_settings(); |
|
654 | + $frm_settings = FrmAppHelper::get_settings(); |
|
655 | 655 | |
656 | 656 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
657 | - // use HMTL5 placeholder with js fallback |
|
657 | + // use HMTL5 placeholder with js fallback |
|
658 | 658 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
659 | - wp_enqueue_script('jquery-placeholder'); |
|
660 | - } else if ( ! $frm_settings->use_html ) { |
|
659 | + wp_enqueue_script('jquery-placeholder'); |
|
660 | + } else if ( ! $frm_settings->use_html ) { |
|
661 | 661 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
662 | 662 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
663 | - $class[] = 'frm_toggle_default'; |
|
663 | + $class[] = 'frm_toggle_default'; |
|
664 | 664 | |
665 | - if ( $field['value'] == $field['default_value'] ) { |
|
666 | - $class[] = 'frm_default'; |
|
667 | - } |
|
668 | - } |
|
669 | - } |
|
665 | + if ( $field['value'] == $field['default_value'] ) { |
|
666 | + $class[] = 'frm_default'; |
|
667 | + } |
|
668 | + } |
|
669 | + } |
|
670 | 670 | |
671 | 671 | private static function add_validation_messages( $field, array &$add_html ) { |
672 | 672 | if ( FrmField::is_required( $field ) ) { |
@@ -680,44 +680,44 @@ discard block |
||
680 | 680 | } |
681 | 681 | } |
682 | 682 | |
683 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
684 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
685 | - return; |
|
686 | - } |
|
683 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
684 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
685 | + return; |
|
686 | + } |
|
687 | 687 | |
688 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
689 | - if ( 'opt' === $k ) { |
|
690 | - continue; |
|
691 | - } |
|
688 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
689 | + if ( 'opt' === $k ) { |
|
690 | + continue; |
|
691 | + } |
|
692 | 692 | |
693 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
694 | - $add_html[] = $v; |
|
695 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
693 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
694 | + $add_html[] = $v; |
|
695 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
696 | 696 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
697 | - } else { |
|
697 | + } else { |
|
698 | 698 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
699 | - } |
|
700 | - |
|
701 | - unset($k, $v); |
|
702 | - } |
|
703 | - } |
|
704 | - |
|
705 | - public static function check_value( $opt, $opt_key, $field ) { |
|
706 | - if ( is_array( $opt ) ) { |
|
707 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
708 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
709 | - } else { |
|
710 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
711 | - } |
|
712 | - } |
|
713 | - return $opt; |
|
714 | - } |
|
699 | + } |
|
700 | + |
|
701 | + unset($k, $v); |
|
702 | + } |
|
703 | + } |
|
704 | + |
|
705 | + public static function check_value( $opt, $opt_key, $field ) { |
|
706 | + if ( is_array( $opt ) ) { |
|
707 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
708 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
709 | + } else { |
|
710 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
711 | + } |
|
712 | + } |
|
713 | + return $opt; |
|
714 | + } |
|
715 | 715 | |
716 | 716 | public static function check_label( $opt ) { |
717 | - if ( is_array($opt) ) { |
|
718 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
719 | - } |
|
717 | + if ( is_array($opt) ) { |
|
718 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
719 | + } |
|
720 | 720 | |
721 | - return $opt; |
|
722 | - } |
|
721 | + return $opt; |
|
722 | + } |
|
723 | 723 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | 5 | public static function load_field() { |
6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
8 | 8 | |
9 | 9 | $fields = $_POST['field']; |
@@ -34,17 +34,17 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
38 | 38 | |
39 | 39 | ob_start(); |
40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
41 | + $field_html[$field_id] = ob_get_contents(); |
|
42 | 42 | ob_end_clean(); |
43 | 43 | } |
44 | 44 | |
45 | - unset($path); |
|
45 | + unset( $path ); |
|
46 | 46 | |
47 | - echo json_encode($field_html); |
|
47 | + echo json_encode( $field_html ); |
|
48 | 48 | |
49 | 49 | wp_die(); |
50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * Create a new field with ajax |
54 | 54 | */ |
55 | 55 | public static function create() { |
56 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
56 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
57 | 57 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
58 | 58 | |
59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
63 | 63 | |
64 | 64 | // this hook will allow for multiple fields to be added at once |
65 | - do_action('frm_after_field_created', $field, $form_id); |
|
65 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
66 | 66 | |
67 | 67 | wp_die(); |
68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
78 | 78 | $values = array(); |
79 | 79 | if ( FrmAppHelper::pro_is_installed() ) { |
80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
80 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -89,27 +89,27 @@ discard block |
||
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
92 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
93 | 93 | |
94 | 94 | return $field; |
95 | 95 | } |
96 | 96 | |
97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
98 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
98 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
99 | 99 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
100 | 100 | |
101 | - if ( empty($field) ) { |
|
101 | + if ( empty( $field ) ) { |
|
102 | 102 | $field = 'name'; |
103 | 103 | } |
104 | 104 | |
105 | - if ( empty($id) ) { |
|
105 | + if ( empty( $id ) ) { |
|
106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
108 | 108 | } |
109 | 109 | |
110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
111 | 111 | $value = trim( $value ); |
112 | - if ( trim(strip_tags($value)) == '' ) { |
|
112 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
113 | 113 | // set blank value if there is no content |
114 | 114 | $value = ''; |
115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | public static function update_ajax_option() { |
126 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
126 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
127 | 127 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
128 | 128 | |
129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | if ( isset( $_POST['separate_value'] ) ) { |
137 | 137 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
138 | 138 | $field->field_options['separate_value'] = $new_val; |
139 | - unset($new_val); |
|
139 | + unset( $new_val ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | FrmField::update( $field_id, array( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | public static function duplicate() { |
150 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
150 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
151 | 151 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
152 | 152 | |
153 | 153 | global $wpdb; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | wp_die(); |
178 | 178 | } |
179 | 179 | |
180 | - self::include_single_field($field_id, $values); |
|
180 | + self::include_single_field( $field_id, $values ); |
|
181 | 181 | |
182 | 182 | wp_die(); |
183 | 183 | } |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | * Load a single field in the form builder along with all needed variables |
187 | 187 | */ |
188 | 188 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
189 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
191 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
192 | 192 | $id = $form_id ? $form_id : $field['form_id']; |
193 | 193 | if ( $field['type'] == 'html' ) { |
194 | 194 | $field['stop_filter'] = true; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | public static function destroy() { |
203 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
203 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
204 | 204 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
205 | 205 | |
206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | |
213 | 213 | //Add Single Option or Other Option |
214 | 214 | public static function add_option() { |
215 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
215 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
216 | 216 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
217 | 217 | |
218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
220 | 220 | |
221 | 221 | //Get the field |
222 | - $field = FrmField::getOne($id); |
|
222 | + $field = FrmField::getOne( $id ); |
|
223 | 223 | |
224 | 224 | if ( ! empty( $field->options ) ) { |
225 | 225 | $keys = array_keys( $field->options ); |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | $first_opt = reset( $field->options ); |
243 | 243 | $next_opt = count( $field->options ); |
244 | 244 | if ( $first_opt != '' ) { |
245 | - $next_opt++; |
|
245 | + $next_opt ++; |
|
246 | 246 | } |
247 | 247 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
248 | - unset($next_opt); |
|
248 | + unset( $next_opt ); |
|
249 | 249 | } |
250 | 250 | $field_val = $opt; |
251 | - $field->options[ $opt_key ] = $opt; |
|
251 | + $field->options[$opt_key] = $opt; |
|
252 | 252 | |
253 | 253 | //Update options in DB |
254 | 254 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | $field = array( |
258 | 258 | 'type' => $field_data->type, |
259 | 259 | 'id' => $id, |
260 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
260 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
261 | 261 | 'form_id' => $field_data->form_id, |
262 | 262 | 'field_key' => $field_data->field_key, |
263 | 263 | ); |
264 | 264 | |
265 | 265 | $field_name = 'item_meta[' . $id . ']'; |
266 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
266 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
267 | 267 | $checked = ''; |
268 | 268 | |
269 | 269 | if ( 'other' == $opt_type ) { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | public static function edit_option() { |
278 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
278 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
279 | 279 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
280 | 280 | |
281 | 281 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -290,28 +290,28 @@ discard block |
||
290 | 290 | $new_label = $update_value; |
291 | 291 | } |
292 | 292 | |
293 | - $field = FrmField::getOne($id); |
|
293 | + $field = FrmField::getOne( $id ); |
|
294 | 294 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
295 | 295 | |
296 | - $this_opt_id = end($ids); |
|
297 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
298 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
296 | + $this_opt_id = end( $ids ); |
|
297 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
298 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
299 | 299 | |
300 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
301 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
300 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
301 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
302 | 302 | |
303 | 303 | if ( ! isset( $new_label ) ) { |
304 | 304 | $new_label = $label; |
305 | 305 | } |
306 | 306 | |
307 | - if ( isset($new_value) || isset($value) ) { |
|
308 | - $update_value = isset($new_value) ? $new_value : $value; |
|
307 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
308 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
312 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
312 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
313 | 313 | } else { |
314 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
314 | + $field->options[$this_opt_id] = $orig_update_value; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | public static function delete_option() { |
323 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
323 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
324 | 324 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
325 | 325 | |
326 | 326 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
330 | 330 | |
331 | 331 | $options = $field->options; |
332 | - unset( $options[ $opt_key ] ); |
|
332 | + unset( $options[$opt_key] ); |
|
333 | 333 | $response = array( 'other' => true ); |
334 | 334 | |
335 | 335 | //If the deleted option is an "other" option |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | |
397 | 397 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
398 | 398 | $prepop = array(); |
399 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
399 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
400 | 400 | |
401 | - $field = FrmField::getOne($field_id); |
|
401 | + $field = FrmField::getOne( $field_id ); |
|
402 | 402 | |
403 | 403 | wp_enqueue_script( 'utils' ); |
404 | 404 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -409,35 +409,35 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | public static function import_options() { |
412 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
412 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
413 | 413 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
414 | 414 | |
415 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
415 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | 419 | $field_id = absint( $_POST['field_id'] ); |
420 | - $field = FrmField::getOne($field_id); |
|
420 | + $field = FrmField::getOne( $field_id ); |
|
421 | 421 | |
422 | 422 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
423 | 423 | return; |
424 | 424 | } |
425 | 425 | |
426 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
426 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
427 | 427 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
428 | 428 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
429 | 429 | $opts = array_map( 'trim', $opts ); |
430 | 430 | |
431 | 431 | if ( $field['separate_value'] ) { |
432 | 432 | foreach ( $opts as $opt_key => $opt ) { |
433 | - if ( strpos($opt, '|') !== false ) { |
|
434 | - $vals = explode('|', $opt); |
|
433 | + if ( strpos( $opt, '|' ) !== false ) { |
|
434 | + $vals = explode( '|', $opt ); |
|
435 | 435 | if ( $vals[0] != $vals[1] ) { |
436 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
436 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
437 | 437 | } |
438 | - unset($vals); |
|
438 | + unset( $vals ); |
|
439 | 439 | } |
440 | - unset($opt_key, $opt); |
|
440 | + unset( $opt_key, $opt ); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $other_array = array(); |
447 | 447 | foreach ( $field['options'] as $opt_key => $opt ) { |
448 | 448 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
449 | - $other_array[ $opt_key ] = $opt; |
|
449 | + $other_array[$opt_key] = $opt; |
|
450 | 450 | } |
451 | - unset($opt_key, $opt); |
|
451 | + unset( $opt_key, $opt ); |
|
452 | 452 | } |
453 | - if ( ! empty($other_array) ) { |
|
454 | - $opts = array_merge( $opts, $other_array); |
|
453 | + if ( ! empty( $other_array ) ) { |
|
454 | + $opts = array_merge( $opts, $other_array ); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
467 | 467 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
468 | 468 | } else { |
469 | - FrmFieldsHelper::show_single_option($field); |
|
469 | + FrmFieldsHelper::show_single_option( $field ); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | wp_die(); |
473 | 473 | } |
474 | 474 | |
475 | 475 | public static function update_order() { |
476 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
476 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
477 | 477 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
478 | 478 | |
479 | 479 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | 'rte' => 'textarea', |
491 | 491 | 'website' => 'url', |
492 | 492 | ); |
493 | - if ( isset( $type_switch[ $type ] ) ) { |
|
494 | - $type = $type_switch[ $type ]; |
|
493 | + if ( isset( $type_switch[$type] ) ) { |
|
494 | + $type = $type_switch[$type]; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | $pro_fields = FrmField::pro_field_selection(); |
@@ -535,19 +535,19 @@ discard block |
||
535 | 535 | |
536 | 536 | public static function input_html( $field, $echo = true ) { |
537 | 537 | $class = array(); //$field['type']; |
538 | - self::add_input_classes($field, $class); |
|
538 | + self::add_input_classes( $field, $class ); |
|
539 | 539 | |
540 | 540 | $add_html = array(); |
541 | - self::add_html_size($field, $add_html); |
|
542 | - self::add_html_length($field, $add_html); |
|
543 | - self::add_html_placeholder($field, $add_html, $class); |
|
541 | + self::add_html_size( $field, $add_html ); |
|
542 | + self::add_html_length( $field, $add_html ); |
|
543 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
544 | 544 | self::add_validation_messages( $field, $add_html ); |
545 | 545 | |
546 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
546 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
547 | 547 | |
548 | 548 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
549 | 549 | |
550 | - self::add_shortcodes_to_html($field, $add_html); |
|
550 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
551 | 551 | |
552 | 552 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
553 | 553 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | private static function add_input_classes( $field, array &$class ) { |
563 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
563 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
564 | 564 | $class[] = $field['input_class']; |
565 | 565 | } |
566 | 566 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | return; |
569 | 569 | } |
570 | 570 | |
571 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
571 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
572 | 572 | $class[] = 'auto_width'; |
573 | 573 | } |
574 | 574 | } |
@@ -578,19 +578,19 @@ discard block |
||
578 | 578 | return; |
579 | 579 | } |
580 | 580 | |
581 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
581 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
582 | 582 | return; |
583 | 583 | } |
584 | 584 | |
585 | - if ( is_numeric($field['size']) ) { |
|
585 | + if ( is_numeric( $field['size'] ) ) { |
|
586 | 586 | $field['size'] .= 'px'; |
587 | 587 | } |
588 | 588 | |
589 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
589 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
590 | 590 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
591 | 591 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
592 | 592 | |
593 | - self::add_html_cols($field, $add_html); |
|
593 | + self::add_html_cols( $field, $add_html ); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -607,13 +607,13 @@ discard block |
||
607 | 607 | ); |
608 | 608 | |
609 | 609 | // include "col" for valid html |
610 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
610 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
611 | 611 | |
612 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
612 | + if ( ! isset( $calc[$unit] ) ) { |
|
613 | 613 | return; |
614 | 614 | } |
615 | 615 | |
616 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
616 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
617 | 617 | |
618 | 618 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
619 | 619 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | return; |
625 | 625 | } |
626 | 626 | |
627 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
627 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
628 | 628 | // don't load on form builder page |
629 | 629 | return; |
630 | 630 | } |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
657 | 657 | // use HMTL5 placeholder with js fallback |
658 | 658 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
659 | - wp_enqueue_script('jquery-placeholder'); |
|
659 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
660 | 660 | } else if ( ! $frm_settings->use_html ) { |
661 | 661 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
662 | 662 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
@@ -690,15 +690,15 @@ discard block |
||
690 | 690 | continue; |
691 | 691 | } |
692 | 692 | |
693 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
693 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
694 | 694 | $add_html[] = $v; |
695 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
696 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
695 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
696 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
697 | 697 | } else { |
698 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
698 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
699 | 699 | } |
700 | 700 | |
701 | - unset($k, $v); |
|
701 | + unset( $k, $v ); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
@@ -714,8 +714,8 @@ discard block |
||
714 | 714 | } |
715 | 715 | |
716 | 716 | public static function check_label( $opt ) { |
717 | - if ( is_array($opt) ) { |
|
718 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
717 | + if ( is_array( $opt ) ) { |
|
718 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | return $opt; |
@@ -2,201 +2,201 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmEntriesController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
7 | 7 | |
8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
9 | 9 | |
10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
15 | - } |
|
16 | - } |
|
15 | + } |
|
16 | + } |
|
17 | 17 | |
18 | - /* Display in Back End */ |
|
19 | - public static function route() { |
|
18 | + /* Display in Back End */ |
|
19 | + public static function route() { |
|
20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
21 | 21 | |
22 | - switch ( $action ) { |
|
23 | - case 'show': |
|
24 | - case 'destroy': |
|
25 | - case 'destroy_all': |
|
26 | - return self::$action(); |
|
22 | + switch ( $action ) { |
|
23 | + case 'show': |
|
24 | + case 'destroy': |
|
25 | + case 'destroy_all': |
|
26 | + return self::$action(); |
|
27 | 27 | |
28 | - default: |
|
29 | - do_action( 'frm_entry_action_route', $action ); |
|
30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
31 | - return; |
|
32 | - } |
|
28 | + default: |
|
29 | + do_action( 'frm_entry_action_route', $action ); |
|
30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
31 | + return; |
|
32 | + } |
|
33 | 33 | |
34 | - return self::display_list(); |
|
35 | - } |
|
36 | - } |
|
34 | + return self::display_list(); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
41 | - return $help; |
|
42 | - } |
|
39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
41 | + return $help; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
47 | - return $help; |
|
48 | - } |
|
47 | + return $help; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | unset( $action, $page ); |
51 | 51 | |
52 | - $screen->add_help_tab( array( |
|
53 | - 'id' => 'formidable-entries-tab', |
|
54 | - 'title' => __( 'Overview', 'formidable' ), |
|
52 | + $screen->add_help_tab( array( |
|
53 | + 'id' => 'formidable-entries-tab', |
|
54 | + 'title' => __( 'Overview', 'formidable' ), |
|
55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
56 | - )); |
|
56 | + )); |
|
57 | 57 | |
58 | - $screen->set_help_sidebar( |
|
58 | + $screen->set_help_sidebar( |
|
59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
62 | - ); |
|
62 | + ); |
|
63 | 63 | |
64 | - return $help; |
|
65 | - } |
|
64 | + return $help; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | public static function manage_columns( $columns ) { |
68 | - global $frm_vars, $wpdb; |
|
68 | + global $frm_vars, $wpdb; |
|
69 | 69 | $form_id = FrmForm::get_current_form_id(); |
70 | 70 | |
71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
72 | 72 | $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
73 | 73 | |
74 | - if ( ! $form_id ) { |
|
75 | - return $columns; |
|
76 | - } |
|
74 | + if ( ! $form_id ) { |
|
75 | + return $columns; |
|
76 | + } |
|
77 | 77 | |
78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
78 | + $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
79 | 79 | |
80 | - foreach ( $form_cols as $form_col ) { |
|
80 | + foreach ( $form_cols as $form_col ) { |
|
81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
82 | - continue; |
|
83 | - } |
|
82 | + continue; |
|
83 | + } |
|
84 | 84 | |
85 | - if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
85 | + if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
86 | 86 | $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] ); |
87 | 87 | |
88 | - if ( $sub_form_cols ) { |
|
89 | - foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
88 | + if ( $sub_form_cols ) { |
|
89 | + foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
91 | - unset( $sub_form_cols[ $k ] ); |
|
92 | - continue; |
|
93 | - } |
|
91 | + unset( $sub_form_cols[ $k ] ); |
|
92 | + continue; |
|
93 | + } |
|
94 | 94 | $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
95 | - unset($sub_form_col); |
|
96 | - } |
|
97 | - } |
|
98 | - unset($sub_form_cols); |
|
99 | - } else { |
|
100 | - $col_id = $form_col->field_key; |
|
101 | - if ( $form_col->form_id != $form_id ) { |
|
95 | + unset($sub_form_col); |
|
96 | + } |
|
97 | + } |
|
98 | + unset($sub_form_cols); |
|
99 | + } else { |
|
100 | + $col_id = $form_col->field_key; |
|
101 | + if ( $form_col->form_id != $form_id ) { |
|
102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
105 | + if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
106 | 106 | $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
107 | - } |
|
107 | + } |
|
108 | 108 | $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
109 | - } |
|
110 | - } |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | 112 | $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
113 | 113 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
114 | 114 | $columns[ $form_id . '_ip' ] = 'IP'; |
115 | 115 | |
116 | - $frm_vars['cols'] = $columns; |
|
116 | + $frm_vars['cols'] = $columns; |
|
117 | 117 | |
118 | 118 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
119 | 119 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
120 | 120 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - return $columns; |
|
124 | - } |
|
123 | + return $columns; |
|
124 | + } |
|
125 | 125 | |
126 | 126 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
127 | 127 | $menu_name = FrmAppHelper::get_menu_name(); |
128 | 128 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
129 | 129 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
130 | - return $check; |
|
131 | - } |
|
130 | + return $check; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | if ( empty( $prev_value ) ) { |
134 | 134 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
135 | 135 | } |
136 | 136 | |
137 | - global $frm_vars; |
|
138 | - //add a check so we don't create a loop |
|
139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
137 | + global $frm_vars; |
|
138 | + //add a check so we don't create a loop |
|
139 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
140 | 140 | |
141 | - return $check; |
|
142 | - } |
|
141 | + return $check; |
|
142 | + } |
|
143 | 143 | |
144 | - //add hidden columns back from other forms |
|
144 | + //add hidden columns back from other forms |
|
145 | 145 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
146 | 146 | $menu_name = FrmAppHelper::get_menu_name(); |
147 | 147 | $sanitized = sanitize_title( $menu_name ); |
148 | 148 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
149 | 149 | if ( $meta_key != $this_page_name ) { |
150 | - return; |
|
151 | - } |
|
152 | - |
|
153 | - global $frm_vars; |
|
154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
155 | - return; //don't continue if there's no previous value |
|
156 | - } |
|
157 | - |
|
158 | - foreach ( $meta_value as $mk => $mv ) { |
|
159 | - //remove blank values |
|
160 | - if ( empty( $mv ) ) { |
|
161 | - unset( $meta_value[ $mk ] ); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - $cur_form_prefix = reset($meta_value); |
|
166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
167 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
168 | - $save = false; |
|
169 | - |
|
170 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
150 | + return; |
|
151 | + } |
|
152 | + |
|
153 | + global $frm_vars; |
|
154 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
155 | + return; //don't continue if there's no previous value |
|
156 | + } |
|
157 | + |
|
158 | + foreach ( $meta_value as $mk => $mv ) { |
|
159 | + //remove blank values |
|
160 | + if ( empty( $mv ) ) { |
|
161 | + unset( $meta_value[ $mk ] ); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + $cur_form_prefix = reset($meta_value); |
|
166 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
167 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
168 | + $save = false; |
|
169 | + |
|
170 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
171 | 171 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
172 | - //don't add blank cols or process included cols |
|
173 | - continue; |
|
174 | - } |
|
172 | + //don't add blank cols or process included cols |
|
173 | + continue; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | $form_prefix = explode( '_', $prev_hidden ); |
177 | - $form_prefix = $form_prefix[0]; |
|
178 | - if ( $form_prefix == $cur_form_prefix ) { |
|
179 | - //don't add back columns that are meant to be hidden |
|
180 | - continue; |
|
181 | - } |
|
177 | + $form_prefix = $form_prefix[0]; |
|
178 | + if ( $form_prefix == $cur_form_prefix ) { |
|
179 | + //don't add back columns that are meant to be hidden |
|
180 | + continue; |
|
181 | + } |
|
182 | 182 | |
183 | - $meta_value[] = $prev_hidden; |
|
184 | - $save = true; |
|
185 | - unset($form_prefix); |
|
186 | - } |
|
183 | + $meta_value[] = $prev_hidden; |
|
184 | + $save = true; |
|
185 | + unset($form_prefix); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | if ( $save ) { |
189 | - $user = wp_get_current_user(); |
|
189 | + $user = wp_get_current_user(); |
|
190 | 190 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
191 | - } |
|
192 | - } |
|
191 | + } |
|
192 | + } |
|
193 | 193 | |
194 | 194 | public static function save_per_page( $save, $option, $value ) { |
195 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
196 | - $save = (int) $value; |
|
197 | - } |
|
198 | - return $save; |
|
199 | - } |
|
195 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
196 | + $save = (int) $value; |
|
197 | + } |
|
198 | + return $save; |
|
199 | + } |
|
200 | 200 | |
201 | 201 | public static function sortable_columns() { |
202 | 202 | $form_id = FrmForm::get_current_form_id(); |
@@ -222,122 +222,122 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | public static function hidden_columns( $result ) { |
225 | - global $frm_vars; |
|
225 | + global $frm_vars; |
|
226 | 226 | |
227 | 227 | $form_id = FrmForm::get_current_form_id(); |
228 | 228 | |
229 | - $return = false; |
|
230 | - foreach ( (array) $result as $r ) { |
|
231 | - if ( ! empty( $r ) ) { |
|
232 | - $form_prefix = explode( '_', $r ); |
|
233 | - $form_prefix = $form_prefix[0]; |
|
229 | + $return = false; |
|
230 | + foreach ( (array) $result as $r ) { |
|
231 | + if ( ! empty( $r ) ) { |
|
232 | + $form_prefix = explode( '_', $r ); |
|
233 | + $form_prefix = $form_prefix[0]; |
|
234 | 234 | |
235 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
236 | - $return = true; |
|
237 | - break; |
|
238 | - } |
|
235 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
236 | + $return = true; |
|
237 | + break; |
|
238 | + } |
|
239 | 239 | |
240 | - unset($form_prefix); |
|
241 | - } |
|
242 | - } |
|
240 | + unset($form_prefix); |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | - if ( $return ) { |
|
244 | + if ( $return ) { |
|
245 | 245 | return $result; |
246 | 246 | } |
247 | 247 | |
248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
249 | - $max_columns = 8; |
|
250 | - if ( $i <= $max_columns ) { |
|
248 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
249 | + $max_columns = 8; |
|
250 | + if ( $i <= $max_columns ) { |
|
251 | 251 | return $result; |
252 | 252 | } |
253 | 253 | |
254 | - global $frm_vars; |
|
255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
257 | - } |
|
254 | + global $frm_vars; |
|
255 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
256 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
257 | + } |
|
258 | 258 | |
259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
260 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
261 | - } else { |
|
262 | - $cols = $frm_vars['cols']; |
|
263 | - $cols = array_reverse($cols, true); |
|
259 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
260 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
261 | + } else { |
|
262 | + $cols = $frm_vars['cols']; |
|
263 | + $cols = array_reverse($cols, true); |
|
264 | 264 | |
265 | 265 | $result[] = $form_id . '_id'; |
266 | - $i--; |
|
266 | + $i--; |
|
267 | 267 | |
268 | 268 | $result[] = $form_id . '_item_key'; |
269 | - $i--; |
|
269 | + $i--; |
|
270 | 270 | |
271 | 271 | foreach ( $cols as $col_key => $col ) { |
272 | - if ( $i > $max_columns ) { |
|
272 | + if ( $i > $max_columns ) { |
|
273 | 273 | $result[] = $col_key; |
274 | 274 | } |
275 | - //remove some columns by default |
|
276 | - $i--; |
|
277 | - unset($col_key, $col); |
|
278 | - } |
|
279 | - } |
|
275 | + //remove some columns by default |
|
276 | + $i--; |
|
277 | + unset($col_key, $col); |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | - return $result; |
|
282 | - } |
|
281 | + return $result; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | public static function display_list( $message = '', $errors = array() ) { |
285 | - global $wpdb, $frm_vars; |
|
285 | + global $wpdb, $frm_vars; |
|
286 | 286 | |
287 | 287 | $form = FrmForm::get_current_form(); |
288 | 288 | $params = FrmForm::get_admin_params( $form ); |
289 | 289 | |
290 | - if ( $form ) { |
|
291 | - $params['form'] = $form->id; |
|
292 | - $frm_vars['current_form'] = $form; |
|
290 | + if ( $form ) { |
|
291 | + $params['form'] = $form->id; |
|
292 | + $frm_vars['current_form'] = $form; |
|
293 | 293 | |
294 | - if ( 'trash' == $form->status ) { |
|
295 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
296 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
297 | - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
298 | - unset( $time_to_delete, $delete_timestamp ); |
|
299 | - } |
|
294 | + if ( 'trash' == $form->status ) { |
|
295 | + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
296 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
297 | + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
298 | + unset( $time_to_delete, $delete_timestamp ); |
|
299 | + } |
|
300 | 300 | } |
301 | 301 | |
302 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
302 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
303 | 303 | |
304 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
304 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
305 | 305 | |
306 | - $pagenum = $wp_list_table->get_pagenum(); |
|
306 | + $pagenum = $wp_list_table->get_pagenum(); |
|
307 | 307 | |
308 | - $wp_list_table->prepare_items(); |
|
308 | + $wp_list_table->prepare_items(); |
|
309 | 309 | |
310 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
311 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
310 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
311 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
313 | - if ( headers_sent() ) { |
|
314 | - echo FrmAppHelper::js_redirect($url); |
|
315 | - } else { |
|
316 | - wp_redirect( esc_url_raw( $url ) ); |
|
317 | - } |
|
318 | - die(); |
|
319 | - } |
|
320 | - |
|
321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
322 | - $message = __( 'Your import is complete', 'formidable' ); |
|
323 | - } |
|
313 | + if ( headers_sent() ) { |
|
314 | + echo FrmAppHelper::js_redirect($url); |
|
315 | + } else { |
|
316 | + wp_redirect( esc_url_raw( $url ) ); |
|
317 | + } |
|
318 | + die(); |
|
319 | + } |
|
320 | + |
|
321 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
322 | + $message = __( 'Your import is complete', 'formidable' ); |
|
323 | + } |
|
324 | 324 | |
325 | 325 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - /* Back End CRUD */ |
|
328 | + /* Back End CRUD */ |
|
329 | 329 | public static function show( $id = 0 ) { |
330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
330 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
331 | 331 | |
332 | - if ( ! $id ) { |
|
332 | + if ( ! $id ) { |
|
333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
334 | 334 | |
335 | - if ( ! $id ) { |
|
335 | + if ( ! $id ) { |
|
336 | 336 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
337 | - } |
|
338 | - } |
|
337 | + } |
|
338 | + } |
|
339 | 339 | |
340 | - $entry = FrmEntry::getOne($id, true); |
|
340 | + $entry = FrmEntry::getOne($id, true); |
|
341 | 341 | if ( ! $entry ) { |
342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,110 +345,110 @@ discard block |
||
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - $data = maybe_unserialize($entry->description); |
|
348 | + $data = maybe_unserialize($entry->description); |
|
349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
350 | 350 | $data = array( 'referrer' => $data ); |
351 | 351 | } |
352 | 352 | |
353 | 353 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
354 | - $to_emails = array(); |
|
354 | + $to_emails = array(); |
|
355 | 355 | |
356 | 356 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
357 | - } |
|
357 | + } |
|
358 | 358 | |
359 | - public static function destroy() { |
|
360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
359 | + public static function destroy() { |
|
360 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
361 | 361 | |
362 | 362 | $params = FrmForm::get_admin_params(); |
363 | 363 | |
364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
365 | - //unlink entry from post |
|
366 | - global $wpdb; |
|
364 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
365 | + //unlink entry from post |
|
366 | + global $wpdb; |
|
367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
368 | - } |
|
368 | + } |
|
369 | 369 | |
370 | - $message = ''; |
|
371 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
372 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
373 | - } |
|
370 | + $message = ''; |
|
371 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
372 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
373 | + } |
|
374 | 374 | |
375 | - self::display_list( $message ); |
|
376 | - } |
|
375 | + self::display_list( $message ); |
|
376 | + } |
|
377 | 377 | |
378 | - public static function destroy_all() { |
|
379 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
380 | - $frm_settings = FrmAppHelper::get_settings(); |
|
381 | - wp_die( $frm_settings->admin_permission ); |
|
382 | - } |
|
378 | + public static function destroy_all() { |
|
379 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
380 | + $frm_settings = FrmAppHelper::get_settings(); |
|
381 | + wp_die( $frm_settings->admin_permission ); |
|
382 | + } |
|
383 | 383 | |
384 | - global $wpdb; |
|
384 | + global $wpdb; |
|
385 | 385 | $params = FrmForm::get_admin_params(); |
386 | - $message = ''; |
|
387 | - $errors = array(); |
|
388 | - $form_id = (int) $params['form']; |
|
386 | + $message = ''; |
|
387 | + $errors = array(); |
|
388 | + $form_id = (int) $params['form']; |
|
389 | 389 | |
390 | - if ( $form_id ) { |
|
391 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
390 | + if ( $form_id ) { |
|
391 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
392 | 392 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
393 | 393 | |
394 | - if ( $action ) { |
|
395 | - // this action takes a while, so only trigger it if there are posts to delete |
|
396 | - foreach ( $entry_ids as $entry_id ) { |
|
397 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
398 | - unset( $entry_id ); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
403 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
404 | - if ( $results ) { |
|
394 | + if ( $action ) { |
|
395 | + // this action takes a while, so only trigger it if there are posts to delete |
|
396 | + foreach ( $entry_ids as $entry_id ) { |
|
397 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
398 | + unset( $entry_id ); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
403 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
404 | + if ( $results ) { |
|
405 | 405 | FrmEntry::clear_cache(); |
406 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
407 | - } |
|
408 | - } else { |
|
409 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
410 | - } |
|
411 | - |
|
412 | - self::display_list( $message, $errors ); |
|
413 | - } |
|
414 | - |
|
415 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
416 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
417 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
418 | - } |
|
419 | - |
|
420 | - public static function get_form( $filename, $form, $title, $description ) { |
|
421 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
422 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
423 | - } |
|
424 | - |
|
425 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
406 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
407 | + } |
|
408 | + } else { |
|
409 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
410 | + } |
|
411 | + |
|
412 | + self::display_list( $message, $errors ); |
|
413 | + } |
|
414 | + |
|
415 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
416 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
417 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
418 | + } |
|
419 | + |
|
420 | + public static function get_form( $filename, $form, $title, $description ) { |
|
421 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
422 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
423 | + } |
|
424 | + |
|
425 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
426 | 426 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
427 | 427 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
428 | - return; |
|
429 | - } |
|
428 | + return; |
|
429 | + } |
|
430 | 430 | |
431 | - global $frm_vars; |
|
431 | + global $frm_vars; |
|
432 | 432 | |
433 | 433 | $form = FrmForm::getOne( $form_id ); |
434 | - if ( ! $form ) { |
|
435 | - return; |
|
436 | - } |
|
434 | + if ( ! $form ) { |
|
435 | + return; |
|
436 | + } |
|
437 | 437 | |
438 | 438 | $params = FrmForm::get_params( $form ); |
439 | 439 | |
440 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
441 | - $frm_vars['form_params'] = array(); |
|
442 | - } |
|
440 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
441 | + $frm_vars['form_params'] = array(); |
|
442 | + } |
|
443 | 443 | $frm_vars['form_params'][ $form->id ] = $params; |
444 | 444 | |
445 | 445 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
446 | - return; |
|
447 | - } |
|
446 | + return; |
|
447 | + } |
|
448 | 448 | |
449 | - if ( $errors == '' && ! $ajax ) { |
|
449 | + if ( $errors == '' && ! $ajax ) { |
|
450 | 450 | $errors = FrmEntryValidate::validate( $_POST ); |
451 | - } |
|
451 | + } |
|
452 | 452 | |
453 | 453 | /** |
454 | 454 | * Use this filter to add trigger actions and add errors after |
@@ -459,54 +459,54 @@ discard block |
||
459 | 459 | |
460 | 460 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
461 | 461 | |
462 | - if ( empty( $errors ) ) { |
|
462 | + if ( empty( $errors ) ) { |
|
463 | 463 | $_POST['frm_skip_cookie'] = 1; |
464 | - if ( $params['action'] == 'create' ) { |
|
464 | + if ( $params['action'] == 'create' ) { |
|
465 | 465 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
466 | 466 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
467 | - } |
|
468 | - } |
|
467 | + } |
|
468 | + } |
|
469 | 469 | |
470 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
470 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
471 | 471 | unset( $_POST['frm_skip_cookie'] ); |
472 | - } |
|
473 | - } |
|
474 | - |
|
475 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
476 | - self::_delete_entry( $atts['id'], $form ); |
|
477 | - return $url; |
|
478 | - } |
|
479 | - |
|
480 | - //Delete entry if not redirected |
|
481 | - public static function delete_entry_after_save( $atts ) { |
|
482 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
483 | - } |
|
484 | - |
|
485 | - private static function _delete_entry( $entry_id, $form ) { |
|
486 | - if ( ! $form ) { |
|
487 | - return; |
|
488 | - } |
|
489 | - |
|
490 | - $form->options = maybe_unserialize( $form->options ); |
|
491 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
492 | - FrmEntry::destroy( $entry_id ); |
|
493 | - } |
|
494 | - } |
|
472 | + } |
|
473 | + } |
|
474 | + |
|
475 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
476 | + self::_delete_entry( $atts['id'], $form ); |
|
477 | + return $url; |
|
478 | + } |
|
479 | + |
|
480 | + //Delete entry if not redirected |
|
481 | + public static function delete_entry_after_save( $atts ) { |
|
482 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
483 | + } |
|
484 | + |
|
485 | + private static function _delete_entry( $entry_id, $form ) { |
|
486 | + if ( ! $form ) { |
|
487 | + return; |
|
488 | + } |
|
489 | + |
|
490 | + $form->options = maybe_unserialize( $form->options ); |
|
491 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
492 | + FrmEntry::destroy( $entry_id ); |
|
493 | + } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | public static function show_entry_shortcode( $atts ) { |
497 | 497 | return FrmEntryFormat::show_entry( $atts ); |
498 | 498 | } |
499 | 499 | |
500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
501 | + $plain_text = add_filter('frm_plain_text_email', true); |
|
502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
503 | 503 | |
504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
505 | - return $value; |
|
506 | - } |
|
504 | + if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
505 | + return $value; |
|
506 | + } |
|
507 | 507 | |
508 | - return $value; |
|
509 | - } |
|
508 | + return $value; |
|
509 | + } |
|
510 | 510 | |
511 | 511 | public static function get_params( $form = null ) { |
512 | 512 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' ); |
@@ -514,15 +514,15 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | public static function entry_sidebar( $entry ) { |
517 | - $data = maybe_unserialize($entry->description); |
|
518 | - $date_format = get_option('date_format'); |
|
519 | - $time_format = get_option('time_format'); |
|
517 | + $data = maybe_unserialize($entry->description); |
|
518 | + $date_format = get_option('date_format'); |
|
519 | + $time_format = get_option('time_format'); |
|
520 | 520 | if ( isset( $data['browser'] ) ) { |
521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
522 | 522 | } |
523 | 523 | |
524 | 524 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
525 | - } |
|
525 | + } |
|
526 | 526 | |
527 | 527 | /*********************************************************************** |
528 | 528 | * Deprecated Functions |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | public static function menu() { |
6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
7 | 7 | |
8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
9 | 9 | |
10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'id' => 'formidable-entries-tab', |
54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
56 | - )); |
|
56 | + ) ); |
|
57 | 57 | |
58 | 58 | $screen->set_help_sidebar( |
59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | global $frm_vars, $wpdb; |
69 | 69 | $form_id = FrmForm::get_current_form_id(); |
70 | 70 | |
71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
71 | + $columns[$form_id . '_id'] = 'ID'; |
|
72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
73 | 73 | |
74 | 74 | if ( ! $form_id ) { |
75 | 75 | return $columns; |
76 | 76 | } |
77 | 77 | |
78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
78 | + $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
79 | 79 | |
80 | 80 | foreach ( $form_cols as $form_col ) { |
81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
@@ -88,30 +88,30 @@ discard block |
||
88 | 88 | if ( $sub_form_cols ) { |
89 | 89 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
91 | - unset( $sub_form_cols[ $k ] ); |
|
91 | + unset( $sub_form_cols[$k] ); |
|
92 | 92 | continue; |
93 | 93 | } |
94 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
95 | - unset($sub_form_col); |
|
94 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
95 | + unset( $sub_form_col ); |
|
96 | 96 | } |
97 | 97 | } |
98 | - unset($sub_form_cols); |
|
98 | + unset( $sub_form_cols ); |
|
99 | 99 | } else { |
100 | 100 | $col_id = $form_col->field_key; |
101 | 101 | if ( $form_col->form_id != $form_id ) { |
102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
103 | 103 | } |
104 | 104 | |
105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
106 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
105 | + if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) { |
|
106 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
107 | 107 | } |
108 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
108 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
113 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
114 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
112 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
113 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
114 | + $columns[$form_id . '_ip'] = 'IP'; |
|
115 | 115 | |
116 | 116 | $frm_vars['cols'] = $columns; |
117 | 117 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | global $frm_vars; |
138 | 138 | //add a check so we don't create a loop |
139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
139 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
140 | 140 | |
141 | 141 | return $check; |
142 | 142 | } |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | global $frm_vars; |
154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
154 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
155 | 155 | return; //don't continue if there's no previous value |
156 | 156 | } |
157 | 157 | |
158 | 158 | foreach ( $meta_value as $mk => $mv ) { |
159 | 159 | //remove blank values |
160 | 160 | if ( empty( $mv ) ) { |
161 | - unset( $meta_value[ $mk ] ); |
|
161 | + unset( $meta_value[$mk] ); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - $cur_form_prefix = reset($meta_value); |
|
166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
165 | + $cur_form_prefix = reset( $meta_value ); |
|
166 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
167 | 167 | $cur_form_prefix = $cur_form_prefix[0]; |
168 | 168 | $save = false; |
169 | 169 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $meta_value[] = $prev_hidden; |
184 | 184 | $save = true; |
185 | - unset($form_prefix); |
|
185 | + unset( $form_prefix ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | if ( $save ) { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | foreach ( $fields as $field ) { |
215 | 215 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
216 | 216 | // Can't sort on checkboxes because they are stored serialized, or post fields |
217 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
217 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | break; |
238 | 238 | } |
239 | 239 | |
240 | - unset($form_prefix); |
|
240 | + unset( $form_prefix ); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -245,36 +245,36 @@ discard block |
||
245 | 245 | return $result; |
246 | 246 | } |
247 | 247 | |
248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
248 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
249 | 249 | $max_columns = 8; |
250 | 250 | if ( $i <= $max_columns ) { |
251 | 251 | return $result; |
252 | 252 | } |
253 | 253 | |
254 | 254 | global $frm_vars; |
255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
255 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
256 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
257 | 257 | } |
258 | 258 | |
259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
259 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) { |
|
260 | 260 | $result = $frm_vars['current_form']->options['hidden_cols']; |
261 | 261 | } else { |
262 | 262 | $cols = $frm_vars['cols']; |
263 | - $cols = array_reverse($cols, true); |
|
263 | + $cols = array_reverse( $cols, true ); |
|
264 | 264 | |
265 | 265 | $result[] = $form_id . '_id'; |
266 | - $i--; |
|
266 | + $i --; |
|
267 | 267 | |
268 | 268 | $result[] = $form_id . '_item_key'; |
269 | - $i--; |
|
269 | + $i --; |
|
270 | 270 | |
271 | 271 | foreach ( $cols as $col_key => $col ) { |
272 | 272 | if ( $i > $max_columns ) { |
273 | 273 | $result[] = $col_key; |
274 | 274 | } |
275 | 275 | //remove some columns by default |
276 | - $i--; |
|
277 | - unset($col_key, $col); |
|
276 | + $i --; |
|
277 | + unset( $col_key, $col ); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
313 | 313 | if ( headers_sent() ) { |
314 | - echo FrmAppHelper::js_redirect($url); |
|
314 | + echo FrmAppHelper::js_redirect( $url ); |
|
315 | 315 | } else { |
316 | 316 | wp_redirect( esc_url_raw( $url ) ); |
317 | 317 | } |
318 | 318 | die(); |
319 | 319 | } |
320 | 320 | |
321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
321 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
322 | 322 | $message = __( 'Your import is complete', 'formidable' ); |
323 | 323 | } |
324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | /* Back End CRUD */ |
329 | 329 | public static function show( $id = 0 ) { |
330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
330 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
331 | 331 | |
332 | 332 | if ( ! $id ) { |
333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - $entry = FrmEntry::getOne($id, true); |
|
340 | + $entry = FrmEntry::getOne( $id, true ); |
|
341 | 341 | if ( ! $entry ) { |
342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - $data = maybe_unserialize($entry->description); |
|
348 | + $data = maybe_unserialize( $entry->description ); |
|
349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
350 | 350 | $data = array( 'referrer' => $data ); |
351 | 351 | } |
@@ -357,11 +357,11 @@ discard block |
||
357 | 357 | } |
358 | 358 | |
359 | 359 | public static function destroy() { |
360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
360 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
361 | 361 | |
362 | 362 | $params = FrmForm::get_admin_params(); |
363 | 363 | |
364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
364 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
365 | 365 | //unlink entry from post |
366 | 366 | global $wpdb; |
367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | if ( ! isset( $frm_vars['form_params'] ) ) { |
441 | 441 | $frm_vars['form_params'] = array(); |
442 | 442 | } |
443 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
443 | + $frm_vars['form_params'][$form->id] = $params; |
|
444 | 444 | |
445 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
445 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
446 | 446 | return; |
447 | 447 | } |
448 | 448 | |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | */ |
458 | 458 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
459 | 459 | |
460 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
460 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
461 | 461 | |
462 | 462 | if ( empty( $errors ) ) { |
463 | 463 | $_POST['frm_skip_cookie'] = 1; |
464 | 464 | if ( $params['action'] == 'create' ) { |
465 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
466 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
465 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
466 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
501 | + $plain_text = add_filter( 'frm_plain_text_email', true ); |
|
502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
503 | 503 | |
504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
504 | + if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) { |
|
505 | 505 | return $value; |
506 | 506 | } |
507 | 507 | |
@@ -514,9 +514,9 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | public static function entry_sidebar( $entry ) { |
517 | - $data = maybe_unserialize($entry->description); |
|
518 | - $date_format = get_option('date_format'); |
|
519 | - $time_format = get_option('time_format'); |
|
517 | + $data = maybe_unserialize( $entry->description ); |
|
518 | + $date_format = get_option( 'date_format' ); |
|
519 | + $time_format = get_option( 'time_format' ); |
|
520 | 520 | if ( isset( $data['browser'] ) ) { |
521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
522 | 522 | } |
@@ -14,44 +14,44 @@ |
||
14 | 14 | <div class="inside"> |
15 | 15 | <table class="form-table"><tbody> |
16 | 16 | <?php |
17 | - $first_h3 = 'frm_first_h3'; |
|
18 | - foreach ( $fields as $field ) { |
|
17 | + $first_h3 = 'frm_first_h3'; |
|
18 | + foreach ( $fields as $field ) { |
|
19 | 19 | if ( in_array( $field->type, array( 'captcha', 'html', 'end_divider', 'form' ) ) ) { |
20 | - continue; |
|
21 | - } |
|
20 | + continue; |
|
21 | + } |
|
22 | 22 | |
23 | - if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
24 | - ?> |
|
23 | + if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
24 | + ?> |
|
25 | 25 | </tbody></table> |
26 | 26 | <br/><h3 class="<?php echo esc_attr( $first_h3 ) ?>"><?php echo esc_html( $field->name ) ?></h3> |
27 | 27 | <table class="form-table"><tbody> |
28 | 28 | <?php |
29 | - $first_h3 = ''; |
|
30 | - } else { |
|
31 | - ?> |
|
29 | + $first_h3 = ''; |
|
30 | + } else { |
|
31 | + ?> |
|
32 | 32 | <tr> |
33 | 33 | <th scope="row"><?php echo esc_html( $field->name ) ?>:</th> |
34 | 34 | <td> |
35 | 35 | <?php |
36 | 36 | $embedded_field_id = ( $entry->form_id != $field->form_id ) ? 'form' . $field->form_id : 0; |
37 | - $atts = array( |
|
38 | - 'type' => $field->type, 'post_id' => $entry->post_id, |
|
39 | - 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, |
|
40 | - 'embedded_field_id' => $embedded_field_id, |
|
41 | - ); |
|
37 | + $atts = array( |
|
38 | + 'type' => $field->type, 'post_id' => $entry->post_id, |
|
39 | + 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, |
|
40 | + 'embedded_field_id' => $embedded_field_id, |
|
41 | + ); |
|
42 | 42 | $display_value = FrmEntriesHelper::prepare_display_value( $entry, $field, $atts ); |
43 | 43 | echo $display_value; |
44 | 44 | |
45 | - if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
46 | - $to_emails[] = $display_value; |
|
47 | - } |
|
48 | - ?> |
|
45 | + if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
46 | + $to_emails[] = $display_value; |
|
47 | + } |
|
48 | + ?> |
|
49 | 49 | </td> |
50 | 50 | </tr> |
51 | 51 | <?php } |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | - ?> |
|
54 | + ?> |
|
55 | 55 | |
56 | 56 | <?php if ( $entry->parent_item_id ) { ?> |
57 | 57 | <tr><th><?php _e( 'Parent Entry ID', 'formidable' ) ?>:</th> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <div id="form_show_entry_page" class="wrap"> |
2 | 2 | <h2 class="frm_no_print"><?php _e( 'View Entry', 'formidable' ) ?> |
3 | - <?php do_action('frm_entry_inside_h2', $entry->form_id); ?> |
|
3 | + <?php do_action( 'frm_entry_inside_h2', $entry->form_id ); ?> |
|
4 | 4 | </h2> |
5 | 5 | |
6 | 6 | <div class="frm_forms"> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | <div id="poststuff"> |
9 | 9 | <div id="post-body" class="metabox-holder columns-2"> |
10 | 10 | <div id="post-body-content"> |
11 | - <?php FrmAppController::get_form_nav($entry->form_id, true); ?> |
|
11 | + <?php FrmAppController::get_form_nav( $entry->form_id, true ); ?> |
|
12 | 12 | <div class="postbox"> |
13 | 13 | <h3 class="hndle"><span><?php _e( 'Entry', 'formidable' ) ?></span></h3> |
14 | 14 | <div class="inside"> |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | continue; |
21 | 21 | } |
22 | 22 | |
23 | - if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
23 | + if ( in_array( $field->type, array( 'break', 'divider' ) ) ) { |
|
24 | 24 | ?> |
25 | 25 | </tbody></table> |
26 | 26 | <br/><h3 class="<?php echo esc_attr( $first_h3 ) ?>"><?php echo esc_html( $field->name ) ?></h3> |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $display_value = FrmEntriesHelper::prepare_display_value( $entry, $field, $atts ); |
43 | 43 | echo $display_value; |
44 | 44 | |
45 | - if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
45 | + if ( is_email( $display_value ) && ! in_array( $display_value, $to_emails ) ) { |
|
46 | 46 | $to_emails[] = $display_value; |
47 | 47 | } |
48 | 48 | ?> |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | </td></tr> |
60 | 60 | <?php } ?> |
61 | 61 | </tbody></table> |
62 | - <?php do_action('frm_show_entry', $entry); ?> |
|
62 | + <?php do_action( 'frm_show_entry', $entry ); ?> |
|
63 | 63 | </div> |
64 | 64 | </div> |
65 | 65 | |
66 | - <?php do_action('frm_after_show_entry', $entry); ?> |
|
66 | + <?php do_action( 'frm_after_show_entry', $entry ); ?> |
|
67 | 67 | |
68 | 68 | </div> |
69 | 69 | <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-show.php' ); ?> |
@@ -2,80 +2,80 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmNotification { |
4 | 4 | public function __construct() { |
5 | - if ( ! defined('ABSPATH') ) { |
|
6 | - die('You are not allowed to call this page directly.'); |
|
7 | - } |
|
8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
9 | - } |
|
5 | + if ( ! defined('ABSPATH') ) { |
|
6 | + die('You are not allowed to call this page directly.'); |
|
7 | + } |
|
8 | + add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
9 | + } |
|
10 | 10 | |
11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
12 | - $notification = $action->post_content; |
|
13 | - $email_key = $action->ID; |
|
12 | + $notification = $action->post_content; |
|
13 | + $email_key = $action->ID; |
|
14 | 14 | |
15 | - // Set the subject |
|
16 | - if ( empty($notification['email_subject']) ) { |
|
17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
18 | - } |
|
15 | + // Set the subject |
|
16 | + if ( empty($notification['email_subject']) ) { |
|
17 | + $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
18 | + } |
|
19 | 19 | |
20 | - $plain_text = $notification['plain_text'] ? true : false; |
|
20 | + $plain_text = $notification['plain_text'] ? true : false; |
|
21 | 21 | |
22 | - //Filter these fields |
|
23 | - $filter_fields = array( |
|
24 | - 'email_to', 'cc', 'bcc', |
|
25 | - 'reply_to', 'from', |
|
26 | - 'email_subject', 'email_message', |
|
27 | - ); |
|
22 | + //Filter these fields |
|
23 | + $filter_fields = array( |
|
24 | + 'email_to', 'cc', 'bcc', |
|
25 | + 'reply_to', 'from', |
|
26 | + 'email_subject', 'email_message', |
|
27 | + ); |
|
28 | 28 | |
29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
29 | + add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
30 | 30 | |
31 | - //Get all values in entry in order to get User ID field ID |
|
32 | - $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
31 | + //Get all values in entry in order to get User ID field ID |
|
32 | + $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
33 | 33 | $user_id_field = ''; |
34 | 34 | $user_id_key = ''; |
35 | - foreach ( $values as $value ) { |
|
36 | - if ( $value->field_type == 'user_id' ) { |
|
37 | - $user_id_field = $value->field_id; |
|
38 | - $user_id_key = $value->field_key; |
|
39 | - break; |
|
40 | - } |
|
41 | - unset($value); |
|
42 | - } |
|
43 | - |
|
44 | - //Filter and prepare the email fields |
|
45 | - foreach ( $filter_fields as $f ) { |
|
46 | - //Don't allow empty From |
|
35 | + foreach ( $values as $value ) { |
|
36 | + if ( $value->field_type == 'user_id' ) { |
|
37 | + $user_id_field = $value->field_id; |
|
38 | + $user_id_key = $value->field_key; |
|
39 | + break; |
|
40 | + } |
|
41 | + unset($value); |
|
42 | + } |
|
43 | + |
|
44 | + //Filter and prepare the email fields |
|
45 | + foreach ( $filter_fields as $f ) { |
|
46 | + //Don't allow empty From |
|
47 | 47 | if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
48 | 48 | $notification[ $f ] = '[admin_email]'; |
49 | 49 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
50 | 50 | //Remove brackets |
51 | - //Add a space in case there isn't one |
|
51 | + //Add a space in case there isn't one |
|
52 | 52 | $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
53 | 53 | $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
54 | 54 | |
55 | - //Switch userID shortcode to email address |
|
55 | + //Switch userID shortcode to email address |
|
56 | 56 | if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
57 | 57 | $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
58 | - $user_email = $user_data->user_email; |
|
58 | + $user_email = $user_data->user_email; |
|
59 | 59 | $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
60 | - } |
|
61 | - } |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | 63 | $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
64 | - } |
|
64 | + } |
|
65 | 65 | |
66 | - //Put recipients, cc, and bcc into an array if they aren't empty |
|
66 | + //Put recipients, cc, and bcc into an array if they aren't empty |
|
67 | 67 | $to_emails = self::explode_emails( $notification['email_to'] ); |
68 | 68 | $cc = self::explode_emails( $notification['cc'] ); |
69 | 69 | $bcc = self::explode_emails( $notification['bcc'] ); |
70 | 70 | |
71 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
71 | + $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
72 | 72 | |
73 | - // Stop now if there aren't any recipients |
|
74 | - if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
75 | - return; |
|
76 | - } |
|
73 | + // Stop now if there aren't any recipients |
|
74 | + if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
75 | + return; |
|
76 | + } |
|
77 | 77 | |
78 | - $to_emails = array_unique( (array) $to_emails ); |
|
78 | + $to_emails = array_unique( (array) $to_emails ); |
|
79 | 79 | |
80 | 80 | $prev_mail_body = $notification['email_message']; |
81 | 81 | $mail_body = FrmEntriesHelper::replace_default_message( $prev_mail_body, array( |
@@ -83,48 +83,48 @@ discard block |
||
83 | 83 | 'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ), |
84 | 84 | ) ); |
85 | 85 | |
86 | - // Add the user info if it isn't already included |
|
87 | - if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
88 | - $data = maybe_unserialize($entry->description); |
|
86 | + // Add the user info if it isn't already included |
|
87 | + if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
88 | + $data = maybe_unserialize($entry->description); |
|
89 | 89 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
90 | 90 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
91 | 91 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
92 | 92 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
93 | - } |
|
94 | - unset($prev_mail_body); |
|
95 | - |
|
96 | - // Add attachments |
|
97 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
98 | - |
|
99 | - if ( ! empty($notification['email_subject']) ) { |
|
100 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
101 | - } |
|
102 | - |
|
103 | - // check for a phone number |
|
104 | - foreach ( (array) $to_emails as $email_key => $e ) { |
|
105 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
106 | - $e = explode(' ', $e); |
|
107 | - |
|
108 | - //If to_email has name <[email protected]> format |
|
109 | - if ( is_email(end($e)) ) { |
|
110 | - continue; |
|
111 | - } |
|
112 | - |
|
113 | - do_action('frm_send_to_not_email', array( |
|
114 | - 'e' => $e, |
|
115 | - 'subject' => $notification['email_subject'], |
|
116 | - 'mail_body' => $mail_body, |
|
117 | - 'reply_to' => $notification['reply_to'], |
|
118 | - 'from' => $notification['from'], |
|
119 | - 'plain_text' => $plain_text, |
|
120 | - 'attachments' => $attachments, |
|
121 | - 'form' => $form, |
|
122 | - 'email_key' => $email_key, |
|
123 | - ) ); |
|
93 | + } |
|
94 | + unset($prev_mail_body); |
|
95 | + |
|
96 | + // Add attachments |
|
97 | + $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
98 | + |
|
99 | + if ( ! empty($notification['email_subject']) ) { |
|
100 | + $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
101 | + } |
|
102 | + |
|
103 | + // check for a phone number |
|
104 | + foreach ( (array) $to_emails as $email_key => $e ) { |
|
105 | + if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
106 | + $e = explode(' ', $e); |
|
107 | + |
|
108 | + //If to_email has name <[email protected]> format |
|
109 | + if ( is_email(end($e)) ) { |
|
110 | + continue; |
|
111 | + } |
|
112 | + |
|
113 | + do_action('frm_send_to_not_email', array( |
|
114 | + 'e' => $e, |
|
115 | + 'subject' => $notification['email_subject'], |
|
116 | + 'mail_body' => $mail_body, |
|
117 | + 'reply_to' => $notification['reply_to'], |
|
118 | + 'from' => $notification['from'], |
|
119 | + 'plain_text' => $plain_text, |
|
120 | + 'attachments' => $attachments, |
|
121 | + 'form' => $form, |
|
122 | + 'email_key' => $email_key, |
|
123 | + ) ); |
|
124 | 124 | |
125 | 125 | unset( $to_emails[ $email_key ] ); |
126 | - } |
|
127 | - } |
|
126 | + } |
|
127 | + } |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Send a separate email for email address in the "to" section |
@@ -132,38 +132,38 @@ discard block |
||
132 | 132 | */ |
133 | 133 | $send_single_recipient = apply_filters( 'frm_send_separate_emails', false, compact( 'action', 'entry', 'form' ) ); |
134 | 134 | |
135 | - // Send the email now |
|
136 | - $sent_to = self::send_email( array( |
|
137 | - 'to_email' => $to_emails, |
|
138 | - 'subject' => $notification['email_subject'], |
|
139 | - 'message' => $mail_body, |
|
140 | - 'from' => $notification['from'], |
|
141 | - 'plain_text' => $plain_text, |
|
142 | - 'reply_to' => $notification['reply_to'], |
|
143 | - 'attachments' => $attachments, |
|
144 | - 'cc' => $cc, |
|
145 | - 'bcc' => $bcc, |
|
135 | + // Send the email now |
|
136 | + $sent_to = self::send_email( array( |
|
137 | + 'to_email' => $to_emails, |
|
138 | + 'subject' => $notification['email_subject'], |
|
139 | + 'message' => $mail_body, |
|
140 | + 'from' => $notification['from'], |
|
141 | + 'plain_text' => $plain_text, |
|
142 | + 'reply_to' => $notification['reply_to'], |
|
143 | + 'attachments' => $attachments, |
|
144 | + 'cc' => $cc, |
|
145 | + 'bcc' => $bcc, |
|
146 | 146 | 'single_recipient' => $send_single_recipient, |
147 | - ) ); |
|
147 | + ) ); |
|
148 | 148 | |
149 | - return $sent_to; |
|
150 | - } |
|
149 | + return $sent_to; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | public function entry_created( $entry_id, $form_id ) { |
153 | 153 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
154 | 154 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
155 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
156 | - } |
|
155 | + FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
156 | + } |
|
157 | 157 | |
158 | 158 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
159 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
159 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
160 | 160 | |
161 | - return self::send_email(compact( |
|
162 | - 'to_email', 'subject', 'message', |
|
163 | - 'from', 'from_name', 'plain_text', |
|
164 | - 'attachments', 'reply_to' |
|
165 | - )); |
|
166 | - } |
|
161 | + return self::send_email(compact( |
|
162 | + 'to_email', 'subject', 'message', |
|
163 | + 'from', 'from_name', 'plain_text', |
|
164 | + 'attachments', 'reply_to' |
|
165 | + )); |
|
166 | + } |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Extract the emails from cc and bcc. Allow separation by , or ;. |
@@ -181,53 +181,53 @@ discard block |
||
181 | 181 | return $emails; |
182 | 182 | } |
183 | 183 | |
184 | - /** |
|
185 | - * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
186 | - * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
187 | - * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
188 | - * "First Last" <[email protected]> |
|
189 | - * |
|
190 | - * Things that won't work: First Last (with no email entered) |
|
191 | - * @since 2.0 |
|
192 | - * @param array $atts array of email fields, pass by reference |
|
193 | - * @param $admin_email |
|
194 | - */ |
|
195 | - private static function format_email_fields( &$atts, $admin_email ) { |
|
196 | - |
|
197 | - // If from is empty or is set to admin_email, set it now |
|
198 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
199 | - |
|
200 | - // Filter values in these fields |
|
184 | + /** |
|
185 | + * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
186 | + * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
187 | + * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
188 | + * "First Last" <[email protected]> |
|
189 | + * |
|
190 | + * Things that won't work: First Last (with no email entered) |
|
191 | + * @since 2.0 |
|
192 | + * @param array $atts array of email fields, pass by reference |
|
193 | + * @param $admin_email |
|
194 | + */ |
|
195 | + private static function format_email_fields( &$atts, $admin_email ) { |
|
196 | + |
|
197 | + // If from is empty or is set to admin_email, set it now |
|
198 | + $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
199 | + |
|
200 | + // Filter values in these fields |
|
201 | 201 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
202 | 202 | |
203 | - foreach ( $filter_fields as $f ) { |
|
204 | - // If empty, just skip it |
|
203 | + foreach ( $filter_fields as $f ) { |
|
204 | + // If empty, just skip it |
|
205 | 205 | if ( empty( $atts[ $f ] ) ) { |
206 | - continue; |
|
207 | - } |
|
206 | + continue; |
|
207 | + } |
|
208 | 208 | |
209 | - // to_email, cc, and bcc can be an array |
|
209 | + // to_email, cc, and bcc can be an array |
|
210 | 210 | if ( is_array( $atts[ $f ] ) ) { |
211 | 211 | foreach ( $atts[ $f ] as $key => $val ) { |
212 | - self::format_single_field( $atts, $f, $val, $key ); |
|
213 | - unset( $key, $val ); |
|
214 | - } |
|
215 | - unset($f); |
|
216 | - continue; |
|
217 | - } |
|
212 | + self::format_single_field( $atts, $f, $val, $key ); |
|
213 | + unset( $key, $val ); |
|
214 | + } |
|
215 | + unset($f); |
|
216 | + continue; |
|
217 | + } |
|
218 | 218 | |
219 | 219 | self::format_single_field( $atts, $f, $atts[ $f ] ); |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - // If reply-to isn't set, make it match the from settings |
|
223 | - if ( empty( $atts['reply_to'] ) ) { |
|
224 | - $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
225 | - } |
|
222 | + // If reply-to isn't set, make it match the from settings |
|
223 | + if ( empty( $atts['reply_to'] ) ) { |
|
224 | + $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
225 | + } |
|
226 | 226 | |
227 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
228 | - $atts['to_email'] = $admin_email; |
|
229 | - } |
|
230 | - } |
|
227 | + if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
228 | + $atts['to_email'] = $admin_email; |
|
229 | + } |
|
230 | + } |
|
231 | 231 | |
232 | 232 | private static function get_email_from_formatted_string( $value ) { |
233 | 233 | if ( strpos( $value, '<' ) !== false ) { |
@@ -237,48 +237,48 @@ discard block |
||
237 | 237 | return $value; |
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
241 | - * Format individual email fields |
|
242 | - * |
|
243 | - * @since 2.0 |
|
244 | - * @param array $atts pass by reference |
|
245 | - * @param string $f (to, from, reply_to, etc) |
|
246 | - * @param string $val value saved in field |
|
247 | - * @param int $key if in array, this will be set |
|
248 | - */ |
|
249 | - private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
250 | - $val = trim($val); |
|
251 | - |
|
252 | - // If just a plain email is used |
|
253 | - if ( is_email($val) ) { |
|
254 | - // add sender's name if not included in $from |
|
255 | - if ( $f == 'from' ) { |
|
240 | + /** |
|
241 | + * Format individual email fields |
|
242 | + * |
|
243 | + * @since 2.0 |
|
244 | + * @param array $atts pass by reference |
|
245 | + * @param string $f (to, from, reply_to, etc) |
|
246 | + * @param string $val value saved in field |
|
247 | + * @param int $key if in array, this will be set |
|
248 | + */ |
|
249 | + private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
250 | + $val = trim($val); |
|
251 | + |
|
252 | + // If just a plain email is used |
|
253 | + if ( is_email($val) ) { |
|
254 | + // add sender's name if not included in $from |
|
255 | + if ( $f == 'from' ) { |
|
256 | 256 | $part_2 = $atts[ $f ]; |
257 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
258 | - } else { |
|
259 | - return; |
|
260 | - } |
|
261 | - } else { |
|
262 | - $parts = explode(' ', $val); |
|
263 | - $part_2 = end($parts); |
|
264 | - |
|
265 | - // If inputted correcly, $part_2 should be an email |
|
266 | - if ( is_email( $part_2 ) ) { |
|
267 | - $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
268 | - } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
257 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
258 | + } else { |
|
259 | + return; |
|
260 | + } |
|
261 | + } else { |
|
262 | + $parts = explode(' ', $val); |
|
263 | + $part_2 = end($parts); |
|
264 | + |
|
265 | + // If inputted correcly, $part_2 should be an email |
|
266 | + if ( is_email( $part_2 ) ) { |
|
267 | + $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
268 | + } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
269 | 269 | // In case someone just puts a name in the From or Reply To field |
270 | 270 | $part_1 = $val; |
271 | - $part_2 = get_option('admin_email'); |
|
272 | - } else { |
|
271 | + $part_2 = get_option('admin_email'); |
|
272 | + } else { |
|
273 | 273 | // In case someone just puts a name in any other email field |
274 | - if ( false !== $key ) { |
|
274 | + if ( false !== $key ) { |
|
275 | 275 | unset( $atts[ $f ][ $key ] ); |
276 | - return; |
|
277 | - } |
|
276 | + return; |
|
277 | + } |
|
278 | 278 | $atts[ $f ] = ''; |
279 | - return; |
|
280 | - } |
|
281 | - } |
|
279 | + return; |
|
280 | + } |
|
281 | + } |
|
282 | 282 | |
283 | 283 | // if sending the email from a yahoo address, change it to the WordPress default |
284 | 284 | if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) { |
@@ -291,60 +291,60 @@ discard block |
||
291 | 291 | $part_2 = 'wordpress@' . $sitename; |
292 | 292 | } |
293 | 293 | |
294 | - // Set up formatted value |
|
294 | + // Set up formatted value |
|
295 | 295 | $final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>'; |
296 | 296 | |
297 | - // If value is an array |
|
298 | - if ( false !== $key ) { |
|
297 | + // If value is an array |
|
298 | + if ( false !== $key ) { |
|
299 | 299 | $atts[ $f ][ $key ] = $final_val; |
300 | - return; |
|
301 | - } |
|
300 | + return; |
|
301 | + } |
|
302 | 302 | $atts[ $f ] = $final_val; |
303 | - } |
|
303 | + } |
|
304 | 304 | |
305 | 305 | public static function send_email( $atts ) { |
306 | - $admin_email = get_option('admin_email'); |
|
307 | - $defaults = array( |
|
308 | - 'to_email' => $admin_email, |
|
309 | - 'subject' => '', |
|
310 | - 'message' => '', |
|
311 | - 'from' => $admin_email, |
|
312 | - 'from_name' => '', |
|
313 | - 'cc' => '', |
|
314 | - 'bcc' => '', |
|
315 | - 'plain_text' => true, |
|
316 | - 'reply_to' => $admin_email, |
|
317 | - 'attachments' => array(), |
|
306 | + $admin_email = get_option('admin_email'); |
|
307 | + $defaults = array( |
|
308 | + 'to_email' => $admin_email, |
|
309 | + 'subject' => '', |
|
310 | + 'message' => '', |
|
311 | + 'from' => $admin_email, |
|
312 | + 'from_name' => '', |
|
313 | + 'cc' => '', |
|
314 | + 'bcc' => '', |
|
315 | + 'plain_text' => true, |
|
316 | + 'reply_to' => $admin_email, |
|
317 | + 'attachments' => array(), |
|
318 | 318 | 'single_recipient' => false, |
319 | - ); |
|
320 | - $atts = wp_parse_args($atts, $defaults); |
|
319 | + ); |
|
320 | + $atts = wp_parse_args($atts, $defaults); |
|
321 | 321 | |
322 | - // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
323 | - self::format_email_fields( $atts, $admin_email ); |
|
322 | + // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
323 | + self::format_email_fields( $atts, $admin_email ); |
|
324 | 324 | |
325 | - $header = array(); |
|
326 | - $header[] = 'From: ' . $atts['from']; |
|
325 | + $header = array(); |
|
326 | + $header[] = 'From: ' . $atts['from']; |
|
327 | 327 | |
328 | - //Allow for cc and bcc arrays |
|
328 | + //Allow for cc and bcc arrays |
|
329 | 329 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
330 | 330 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
331 | - foreach ( $array_fields as $key => $a_field ) { |
|
332 | - if ( empty($a_field) ) { |
|
333 | - continue; |
|
334 | - } |
|
331 | + foreach ( $array_fields as $key => $a_field ) { |
|
332 | + if ( empty($a_field) ) { |
|
333 | + continue; |
|
334 | + } |
|
335 | 335 | |
336 | 336 | foreach ( (array) $a_field as $email ) { |
337 | 337 | $cc[ $key ][] = $email; |
338 | - } |
|
339 | - unset($key, $a_field); |
|
340 | - } |
|
338 | + } |
|
339 | + unset($key, $a_field); |
|
340 | + } |
|
341 | 341 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
342 | 342 | |
343 | 343 | foreach ( $cc as $k => $v ) { |
344 | 344 | $header[] = $k . ': ' . implode( ',', $v ); |
345 | 345 | } |
346 | 346 | |
347 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
347 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
348 | 348 | $atts['charset'] = get_option('blog_charset'); |
349 | 349 | |
350 | 350 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | |
354 | 354 | $atts['message'] = do_shortcode( $atts['message'] ); |
355 | 355 | |
356 | - if ( $atts['plain_text'] ) { |
|
356 | + if ( $atts['plain_text'] ) { |
|
357 | 357 | $atts['message'] = wp_specialchars_decode( strip_tags( $atts['message'] ), ENT_QUOTES ); |
358 | - } else { |
|
358 | + } else { |
|
359 | 359 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
360 | - add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
361 | - } |
|
360 | + add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
361 | + } |
|
362 | 362 | $atts['message'] = apply_filters( 'frm_email_message', $atts['message'], $atts ); |
363 | 363 | |
364 | 364 | /** |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | // remove the filter now so other emails can still use it |
389 | 389 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
390 | 390 | |
391 | - if ( $sent ) { |
|
391 | + if ( $sent ) { |
|
392 | 392 | return self::return_emails_sent( $atts ); |
393 | - } |
|
394 | - } |
|
393 | + } |
|
394 | + } |
|
395 | 395 | |
396 | 396 | private static function send_single_email( $recipient, $atts, $header ) { |
397 | 397 | $header = apply_filters( 'frm_email_header', $header, array( |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmNotification { |
4 | 4 | public function __construct() { |
5 | - if ( ! defined('ABSPATH') ) { |
|
6 | - die('You are not allowed to call this page directly.'); |
|
5 | + if ( ! defined( 'ABSPATH' ) ) { |
|
6 | + die( 'You are not allowed to call this page directly.' ); |
|
7 | 7 | } |
8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
8 | + add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 ); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | $email_key = $action->ID; |
14 | 14 | |
15 | 15 | // Set the subject |
16 | - if ( empty($notification['email_subject']) ) { |
|
17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
16 | + if ( empty( $notification['email_subject'] ) ) { |
|
17 | + $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | $plain_text = $notification['plain_text'] ? true : false; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'email_subject', 'email_message', |
27 | 27 | ); |
28 | 28 | |
29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
29 | + add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) ); |
|
30 | 30 | |
31 | 31 | //Get all values in entry in order to get User ID field ID |
32 | 32 | $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | $user_id_key = $value->field_key; |
39 | 39 | break; |
40 | 40 | } |
41 | - unset($value); |
|
41 | + unset( $value ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | //Filter and prepare the email fields |
45 | 45 | foreach ( $filter_fields as $f ) { |
46 | 46 | //Don't allow empty From |
47 | - if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
|
48 | - $notification[ $f ] = '[admin_email]'; |
|
47 | + if ( $f == 'from' && empty( $notification[$f] ) ) { |
|
48 | + $notification[$f] = '[admin_email]'; |
|
49 | 49 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
50 | 50 | //Remove brackets |
51 | 51 | //Add a space in case there isn't one |
52 | - $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
|
53 | - $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
|
52 | + $notification[$f] = str_replace( '<', ' ', $notification[$f] ); |
|
53 | + $notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] ); |
|
54 | 54 | |
55 | 55 | //Switch userID shortcode to email address |
56 | - if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
|
57 | - $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
|
56 | + if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) { |
|
57 | + $user_data = get_userdata( $entry->metas[$user_id_field] ); |
|
58 | 58 | $user_email = $user_data->user_email; |
59 | - $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
|
59 | + $notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
|
63 | + $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | //Put recipients, cc, and bcc into an array if they aren't empty |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $cc = self::explode_emails( $notification['cc'] ); |
69 | 69 | $bcc = self::explode_emails( $notification['bcc'] ); |
70 | 70 | |
71 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
71 | + $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) ); |
|
72 | 72 | |
73 | 73 | // Stop now if there aren't any recipients |
74 | 74 | if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
@@ -85,32 +85,32 @@ discard block |
||
85 | 85 | |
86 | 86 | // Add the user info if it isn't already included |
87 | 87 | if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
88 | - $data = maybe_unserialize($entry->description); |
|
88 | + $data = maybe_unserialize( $entry->description ); |
|
89 | 89 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
90 | 90 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
91 | 91 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
92 | 92 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
93 | 93 | } |
94 | - unset($prev_mail_body); |
|
94 | + unset( $prev_mail_body ); |
|
95 | 95 | |
96 | 96 | // Add attachments |
97 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
97 | + $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) ); |
|
98 | 98 | |
99 | - if ( ! empty($notification['email_subject']) ) { |
|
100 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
99 | + if ( ! empty( $notification['email_subject'] ) ) { |
|
100 | + $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) ); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // check for a phone number |
104 | 104 | foreach ( (array) $to_emails as $email_key => $e ) { |
105 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
106 | - $e = explode(' ', $e); |
|
105 | + if ( $e != '[admin_email]' && ! is_email( $e ) ) { |
|
106 | + $e = explode( ' ', $e ); |
|
107 | 107 | |
108 | 108 | //If to_email has name <[email protected]> format |
109 | - if ( is_email(end($e)) ) { |
|
109 | + if ( is_email( end( $e ) ) ) { |
|
110 | 110 | continue; |
111 | 111 | } |
112 | 112 | |
113 | - do_action('frm_send_to_not_email', array( |
|
113 | + do_action( 'frm_send_to_not_email', array( |
|
114 | 114 | 'e' => $e, |
115 | 115 | 'subject' => $notification['email_subject'], |
116 | 116 | 'mail_body' => $mail_body, |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'email_key' => $email_key, |
123 | 123 | ) ); |
124 | 124 | |
125 | - unset( $to_emails[ $email_key ] ); |
|
125 | + unset( $to_emails[$email_key] ); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | public function entry_created( $entry_id, $form_id ) { |
153 | 153 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
154 | 154 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
155 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
155 | + FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
159 | 159 | _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
160 | 160 | |
161 | - return self::send_email(compact( |
|
161 | + return self::send_email( compact( |
|
162 | 162 | 'to_email', 'subject', 'message', |
163 | 163 | 'from', 'from_name', 'plain_text', |
164 | 164 | 'attachments', 'reply_to' |
165 | - )); |
|
165 | + ) ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -195,28 +195,28 @@ discard block |
||
195 | 195 | private static function format_email_fields( &$atts, $admin_email ) { |
196 | 196 | |
197 | 197 | // If from is empty or is set to admin_email, set it now |
198 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
198 | + $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
199 | 199 | |
200 | 200 | // Filter values in these fields |
201 | 201 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
202 | 202 | |
203 | 203 | foreach ( $filter_fields as $f ) { |
204 | 204 | // If empty, just skip it |
205 | - if ( empty( $atts[ $f ] ) ) { |
|
205 | + if ( empty( $atts[$f] ) ) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // to_email, cc, and bcc can be an array |
210 | - if ( is_array( $atts[ $f ] ) ) { |
|
211 | - foreach ( $atts[ $f ] as $key => $val ) { |
|
210 | + if ( is_array( $atts[$f] ) ) { |
|
211 | + foreach ( $atts[$f] as $key => $val ) { |
|
212 | 212 | self::format_single_field( $atts, $f, $val, $key ); |
213 | 213 | unset( $key, $val ); |
214 | 214 | } |
215 | - unset($f); |
|
215 | + unset( $f ); |
|
216 | 216 | continue; |
217 | 217 | } |
218 | 218 | |
219 | - self::format_single_field( $atts, $f, $atts[ $f ] ); |
|
219 | + self::format_single_field( $atts, $f, $atts[$f] ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | // If reply-to isn't set, make it match the from settings |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
225 | 225 | } |
226 | 226 | |
227 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
227 | + if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) { |
|
228 | 228 | $atts['to_email'] = $admin_email; |
229 | 229 | } |
230 | 230 | } |
@@ -247,20 +247,20 @@ discard block |
||
247 | 247 | * @param int $key if in array, this will be set |
248 | 248 | */ |
249 | 249 | private static function format_single_field( &$atts, $f, $val, $key = false ) { |
250 | - $val = trim($val); |
|
250 | + $val = trim( $val ); |
|
251 | 251 | |
252 | 252 | // If just a plain email is used |
253 | - if ( is_email($val) ) { |
|
253 | + if ( is_email( $val ) ) { |
|
254 | 254 | // add sender's name if not included in $from |
255 | 255 | if ( $f == 'from' ) { |
256 | - $part_2 = $atts[ $f ]; |
|
257 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
256 | + $part_2 = $atts[$f]; |
|
257 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
258 | 258 | } else { |
259 | 259 | return; |
260 | 260 | } |
261 | 261 | } else { |
262 | - $parts = explode(' ', $val); |
|
263 | - $part_2 = end($parts); |
|
262 | + $parts = explode( ' ', $val ); |
|
263 | + $part_2 = end( $parts ); |
|
264 | 264 | |
265 | 265 | // If inputted correcly, $part_2 should be an email |
266 | 266 | if ( is_email( $part_2 ) ) { |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
269 | 269 | // In case someone just puts a name in the From or Reply To field |
270 | 270 | $part_1 = $val; |
271 | - $part_2 = get_option('admin_email'); |
|
271 | + $part_2 = get_option( 'admin_email' ); |
|
272 | 272 | } else { |
273 | 273 | // In case someone just puts a name in any other email field |
274 | 274 | if ( false !== $key ) { |
275 | - unset( $atts[ $f ][ $key ] ); |
|
275 | + unset( $atts[$f][$key] ); |
|
276 | 276 | return; |
277 | 277 | } |
278 | - $atts[ $f ] = ''; |
|
278 | + $atts[$f] = ''; |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | } |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | |
297 | 297 | // If value is an array |
298 | 298 | if ( false !== $key ) { |
299 | - $atts[ $f ][ $key ] = $final_val; |
|
299 | + $atts[$f][$key] = $final_val; |
|
300 | 300 | return; |
301 | 301 | } |
302 | - $atts[ $f ] = $final_val; |
|
302 | + $atts[$f] = $final_val; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | public static function send_email( $atts ) { |
306 | - $admin_email = get_option('admin_email'); |
|
306 | + $admin_email = get_option( 'admin_email' ); |
|
307 | 307 | $defaults = array( |
308 | 308 | 'to_email' => $admin_email, |
309 | 309 | 'subject' => '', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | 'attachments' => array(), |
318 | 318 | 'single_recipient' => false, |
319 | 319 | ); |
320 | - $atts = wp_parse_args($atts, $defaults); |
|
320 | + $atts = wp_parse_args( $atts, $defaults ); |
|
321 | 321 | |
322 | 322 | // Put To, BCC, CC, Reply To, and From fields in the correct format |
323 | 323 | self::format_email_fields( $atts, $admin_email ); |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
330 | 330 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
331 | 331 | foreach ( $array_fields as $key => $a_field ) { |
332 | - if ( empty($a_field) ) { |
|
332 | + if ( empty( $a_field ) ) { |
|
333 | 333 | continue; |
334 | 334 | } |
335 | 335 | |
336 | 336 | foreach ( (array) $a_field as $email ) { |
337 | - $cc[ $key ][] = $email; |
|
337 | + $cc[$key][] = $email; |
|
338 | 338 | } |
339 | - unset($key, $a_field); |
|
339 | + unset( $key, $a_field ); |
|
340 | 340 | } |
341 | 341 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
342 | 342 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | $header[] = $k . ': ' . implode( ',', $v ); |
345 | 345 | } |
346 | 346 | |
347 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
348 | - $atts['charset'] = get_option('blog_charset'); |
|
347 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
348 | + $atts['charset'] = get_option( 'blog_charset' ); |
|
349 | 349 | |
350 | 350 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
351 | 351 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $atts['charset'] ) . '"'; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | |
415 | 415 | private static function encode_subject( $charset, &$subject ) { |
416 | - if ( apply_filters('frm_encode_subject', 1, $subject ) ) { |
|
416 | + if ( apply_filters( 'frm_encode_subject', 1, $subject ) ) { |
|
417 | 417 | $subject = '=?' . $charset . '?B?' . base64_encode( $subject ) . '?='; |
418 | 418 | } |
419 | 419 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | if ( apply_filters( 'frm_echo_emails', false ) ) { |
431 | 431 | $temp = str_replace( '<', '<', $sent_to ); |
432 | - echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
|
432 | + echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); |
|
433 | 433 | } |
434 | 434 | return $sent_to; |
435 | 435 | } |
@@ -1,388 +1,388 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('ABSPATH') ) { |
3 | - die('You are not allowed to call this page directly.'); |
|
3 | + die('You are not allowed to call this page directly.'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
7 | 7 | |
8 | - /** |
|
9 | - * @return int|boolean id on success or false on failure |
|
10 | - */ |
|
11 | - public static function create( $values ) { |
|
12 | - global $wpdb; |
|
8 | + /** |
|
9 | + * @return int|boolean id on success or false on failure |
|
10 | + */ |
|
11 | + public static function create( $values ) { |
|
12 | + global $wpdb; |
|
13 | 13 | |
14 | - $new_values = array( |
|
14 | + $new_values = array( |
|
15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
16 | - 'name' => $values['name'], |
|
17 | - 'description' => $values['description'], |
|
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
16 | + 'name' => $values['name'], |
|
17 | + 'description' => $values['description'], |
|
18 | + 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
25 | - ); |
|
22 | + 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
25 | + ); |
|
26 | 26 | |
27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | + $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | + $new_values['options'] = serialize($options); |
|
36 | 36 | |
37 | - //if(isset($values['id']) && is_numeric($values['id'])) |
|
38 | - // $new_values['id'] = $values['id']; |
|
37 | + //if(isset($values['id']) && is_numeric($values['id'])) |
|
38 | + // $new_values['id'] = $values['id']; |
|
39 | 39 | |
40 | 40 | $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
41 | 41 | |
42 | - $id = $wpdb->insert_id; |
|
42 | + $id = $wpdb->insert_id; |
|
43 | 43 | |
44 | 44 | // Clear form caching |
45 | 45 | self::clear_form_cache(); |
46 | 46 | |
47 | - return $id; |
|
48 | - } |
|
47 | + return $id; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return int|boolean ID on success or false on failure |
|
52 | - */ |
|
53 | - public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
54 | - global $wpdb; |
|
50 | + /** |
|
51 | + * @return int|boolean ID on success or false on failure |
|
52 | + */ |
|
53 | + public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
54 | + global $wpdb; |
|
55 | 55 | |
56 | - $values = self::getOne( $id, $blog_id ); |
|
57 | - if ( ! $values ) { |
|
58 | - return false; |
|
59 | - } |
|
56 | + $values = self::getOne( $id, $blog_id ); |
|
57 | + if ( ! $values ) { |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - $new_key = $copy_keys ? $values->form_key : ''; |
|
61 | + $new_key = $copy_keys ? $values->form_key : ''; |
|
62 | 62 | |
63 | - $new_values = array( |
|
63 | + $new_values = array( |
|
64 | 64 | 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
65 | - 'name' => $values->name, |
|
66 | - 'description' => $values->description, |
|
67 | - 'status' => $template ? 'published' : 'draft', |
|
68 | - 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
69 | - 'editable' => $values->editable ? $values->editable : 0, |
|
70 | - 'created_at' => current_time('mysql', 1), |
|
71 | - 'is_template' => $template ? 1 : 0, |
|
72 | - ); |
|
73 | - |
|
74 | - if ( $blog_id ) { |
|
75 | - $new_values['status'] = 'published'; |
|
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
78 | - $new_options['copy'] = false; |
|
79 | - $new_values['options'] = $new_options; |
|
80 | - } else { |
|
81 | - $new_values['options'] = $values->options; |
|
82 | - } |
|
83 | - |
|
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
86 | - } |
|
65 | + 'name' => $values->name, |
|
66 | + 'description' => $values->description, |
|
67 | + 'status' => $template ? 'published' : 'draft', |
|
68 | + 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
69 | + 'editable' => $values->editable ? $values->editable : 0, |
|
70 | + 'created_at' => current_time('mysql', 1), |
|
71 | + 'is_template' => $template ? 1 : 0, |
|
72 | + ); |
|
73 | + |
|
74 | + if ( $blog_id ) { |
|
75 | + $new_values['status'] = 'published'; |
|
76 | + $new_options = maybe_unserialize($values->options); |
|
77 | + $new_options['email_to'] = get_option('admin_email'); |
|
78 | + $new_options['copy'] = false; |
|
79 | + $new_values['options'] = $new_options; |
|
80 | + } else { |
|
81 | + $new_values['options'] = $values->options; |
|
82 | + } |
|
83 | + |
|
84 | + if ( is_array($new_values['options']) ) { |
|
85 | + $new_values['options'] = serialize($new_values['options']); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
89 | 89 | |
90 | - if ( $query_results ) { |
|
90 | + if ( $query_results ) { |
|
91 | 91 | // Clear form caching |
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | - $form_id = $wpdb->insert_id; |
|
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
94 | + $form_id = $wpdb->insert_id; |
|
95 | + FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
96 | 96 | |
97 | - // update form settings after fields are created |
|
97 | + // update form settings after fields are created |
|
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
99 | - return $form_id; |
|
100 | - } |
|
99 | + return $form_id; |
|
100 | + } |
|
101 | 101 | |
102 | - return false; |
|
103 | - } |
|
102 | + return false; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | public static function after_duplicate( $form_id, $values ) { |
106 | 106 | $new_opts = maybe_unserialize( $values['options'] ); |
107 | 107 | $values['options'] = $new_opts; |
108 | 108 | |
109 | - if ( isset($new_opts['success_msg']) ) { |
|
110 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
111 | - } |
|
109 | + if ( isset($new_opts['success_msg']) ) { |
|
110 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
111 | + } |
|
112 | 112 | |
113 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
113 | + $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
114 | 114 | |
115 | - if ( $new_opts != $values['options'] ) { |
|
116 | - global $wpdb; |
|
115 | + if ( $new_opts != $values['options'] ) { |
|
116 | + global $wpdb; |
|
117 | 117 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) ); |
118 | - } |
|
119 | - } |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * @return int|boolean |
|
123 | - */ |
|
124 | - public static function update( $id, $values, $create_link = false ) { |
|
125 | - global $wpdb; |
|
121 | + /** |
|
122 | + * @return int|boolean |
|
123 | + */ |
|
124 | + public static function update( $id, $values, $create_link = false ) { |
|
125 | + global $wpdb; |
|
126 | 126 | |
127 | - if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
128 | - $values['status'] = 'published'; |
|
129 | - } |
|
127 | + if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
128 | + $values['status'] = 'published'; |
|
129 | + } |
|
130 | 130 | |
131 | - if ( isset($values['form_key']) ) { |
|
131 | + if ( isset($values['form_key']) ) { |
|
132 | 132 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
133 | - } |
|
133 | + } |
|
134 | 134 | |
135 | - $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
|
135 | + $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
|
136 | 136 | |
137 | - $new_values = self::set_update_options( array(), $values); |
|
137 | + $new_values = self::set_update_options( array(), $values); |
|
138 | 138 | |
139 | - foreach ( $values as $value_key => $value ) { |
|
139 | + foreach ( $values as $value_key => $value ) { |
|
140 | 140 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
141 | 141 | $new_values[ $value_key ] = $value; |
142 | - } |
|
143 | - } |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
146 | - $new_values['status'] = $values['new_status']; |
|
147 | - } |
|
145 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
146 | + $new_values['status'] = $values['new_status']; |
|
147 | + } |
|
148 | 148 | |
149 | - if ( ! empty( $new_values ) ) { |
|
149 | + if ( ! empty( $new_values ) ) { |
|
150 | 150 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
151 | - if ( $query_results ) { |
|
151 | + if ( $query_results ) { |
|
152 | 152 | self::clear_form_cache(); |
153 | - } |
|
154 | - } else { |
|
155 | - $query_results = true; |
|
156 | - } |
|
157 | - unset($new_values); |
|
153 | + } |
|
154 | + } else { |
|
155 | + $query_results = true; |
|
156 | + } |
|
157 | + unset($new_values); |
|
158 | 158 | |
159 | - $values = self::update_fields($id, $values); |
|
159 | + $values = self::update_fields($id, $values); |
|
160 | 160 | |
161 | 161 | do_action( 'frm_update_form', $id, $values ); |
162 | 162 | do_action( 'frm_update_form_' . $id, $values ); |
163 | 163 | |
164 | - return $query_results; |
|
165 | - } |
|
164 | + return $query_results; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @return array |
|
169 | - */ |
|
167 | + /** |
|
168 | + * @return array |
|
169 | + */ |
|
170 | 170 | public static function set_update_options( $new_values, $values ) { |
171 | - if ( ! isset($values['options']) ) { |
|
172 | - return $new_values; |
|
173 | - } |
|
171 | + if ( ! isset($values['options']) ) { |
|
172 | + return $new_values; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
176 | 176 | FrmFormsHelper::fill_form_options( $options, $values ); |
177 | 177 | |
178 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
179 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
180 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
181 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
178 | + $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
179 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
180 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
181 | + $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
182 | 182 | |
183 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
184 | - $new_values['options'] = serialize($options); |
|
183 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
184 | + $new_values['options'] = serialize($options); |
|
185 | 185 | |
186 | - return $new_values; |
|
187 | - } |
|
186 | + return $new_values; |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * @return array |
|
192 | - */ |
|
190 | + /** |
|
191 | + * @return array |
|
192 | + */ |
|
193 | 193 | public static function update_fields( $id, $values ) { |
194 | 194 | |
195 | - if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
196 | - return $values; |
|
197 | - } |
|
195 | + if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
196 | + return $values; |
|
197 | + } |
|
198 | 198 | |
199 | - $all_fields = FrmField::get_all_for_form($id); |
|
200 | - if ( empty($all_fields) ) { |
|
201 | - return $values; |
|
202 | - } |
|
199 | + $all_fields = FrmField::get_all_for_form($id); |
|
200 | + if ( empty($all_fields) ) { |
|
201 | + return $values; |
|
202 | + } |
|
203 | 203 | |
204 | - if ( ! isset($values['item_meta']) ) { |
|
205 | - $values['item_meta'] = array(); |
|
206 | - } |
|
204 | + if ( ! isset($values['item_meta']) ) { |
|
205 | + $values['item_meta'] = array(); |
|
206 | + } |
|
207 | 207 | |
208 | - $field_array = array(); |
|
209 | - $existing_keys = array_keys($values['item_meta']); |
|
210 | - foreach ( $all_fields as $fid ) { |
|
211 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
208 | + $field_array = array(); |
|
209 | + $existing_keys = array_keys($values['item_meta']); |
|
210 | + foreach ( $all_fields as $fid ) { |
|
211 | + if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
212 | 212 | $values['item_meta'][ $fid->id ] = ''; |
213 | - } |
|
213 | + } |
|
214 | 214 | $field_array[ $fid->id ] = $fid; |
215 | - } |
|
216 | - unset($all_fields); |
|
215 | + } |
|
216 | + unset($all_fields); |
|
217 | 217 | |
218 | - foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
218 | + foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
219 | 219 | if ( isset( $field_array[ $field_id ] ) ) { |
220 | 220 | $field = $field_array[ $field_id ]; |
221 | - } else { |
|
222 | - $field = FrmField::getOne($field_id); |
|
223 | - } |
|
221 | + } else { |
|
222 | + $field = FrmField::getOne($field_id); |
|
223 | + } |
|
224 | 224 | |
225 | - if ( ! $field ) { |
|
226 | - continue; |
|
227 | - } |
|
225 | + if ( ! $field ) { |
|
226 | + continue; |
|
227 | + } |
|
228 | 228 | |
229 | 229 | $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
230 | 230 | if ( $is_settings_page ) { |
231 | - //updating the settings page |
|
231 | + //updating the settings page |
|
232 | 232 | if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
233 | 233 | $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
234 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
234 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
235 | 235 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
236 | - } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
237 | - $prev_opts = $field->field_options; |
|
238 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
239 | - if ( $prev_opts != $field->field_options ) { |
|
236 | + } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
237 | + $prev_opts = $field->field_options; |
|
238 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
239 | + if ( $prev_opts != $field->field_options ) { |
|
240 | 240 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
241 | - } |
|
242 | - unset($prev_opts); |
|
243 | - } |
|
244 | - } |
|
241 | + } |
|
242 | + unset($prev_opts); |
|
243 | + } |
|
244 | + } |
|
245 | 245 | |
246 | 246 | if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) { |
247 | - continue; |
|
248 | - } |
|
247 | + continue; |
|
248 | + } |
|
249 | 249 | |
250 | - //updating the form |
|
250 | + //updating the form |
|
251 | 251 | $update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true ); |
252 | 252 | unset( $update_options['custom_html'] ); // don't check for POST html |
253 | 253 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
254 | 254 | |
255 | 255 | foreach ( $update_options as $opt => $default ) { |
256 | 256 | $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
257 | - } |
|
257 | + } |
|
258 | 258 | |
259 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
259 | + $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
260 | 260 | $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
261 | 261 | $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
262 | 262 | $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
263 | 263 | $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
264 | 264 | $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
265 | 265 | |
266 | - FrmField::update($field_id, array( |
|
267 | - 'field_key' => $field_key, 'type' => $field_type, |
|
268 | - 'default_value' => $default_value, 'field_options' => $field->field_options, |
|
269 | - 'description' => $field_description, 'required' => $required, |
|
270 | - ) ); |
|
266 | + FrmField::update($field_id, array( |
|
267 | + 'field_key' => $field_key, 'type' => $field_type, |
|
268 | + 'default_value' => $default_value, 'field_options' => $field->field_options, |
|
269 | + 'description' => $field_description, 'required' => $required, |
|
270 | + ) ); |
|
271 | 271 | |
272 | - FrmField::delete_form_transient($field->form_id); |
|
273 | - } |
|
272 | + FrmField::delete_form_transient($field->form_id); |
|
273 | + } |
|
274 | 274 | self::clear_form_cache(); |
275 | 275 | |
276 | - return $values; |
|
277 | - } |
|
276 | + return $values; |
|
277 | + } |
|
278 | 278 | |
279 | - /** |
|
280 | - * @param string $status |
|
281 | - * @return int|boolean |
|
282 | - */ |
|
279 | + /** |
|
280 | + * @param string $status |
|
281 | + * @return int|boolean |
|
282 | + */ |
|
283 | 283 | public static function set_status( $id, $status ) { |
284 | - if ( 'trash' == $status ) { |
|
285 | - return self::trash($id); |
|
286 | - } |
|
284 | + if ( 'trash' == $status ) { |
|
285 | + return self::trash($id); |
|
286 | + } |
|
287 | 287 | |
288 | 288 | $statuses = array( 'published', 'draft', 'trash' ); |
289 | - if ( ! in_array( $status, $statuses ) ) { |
|
290 | - return false; |
|
291 | - } |
|
289 | + if ( ! in_array( $status, $statuses ) ) { |
|
290 | + return false; |
|
291 | + } |
|
292 | 292 | |
293 | - global $wpdb; |
|
293 | + global $wpdb; |
|
294 | 294 | |
295 | - if ( is_array($id) ) { |
|
295 | + if ( is_array($id) ) { |
|
296 | 296 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
297 | 297 | FrmDb::get_where_clause_and_values( $where ); |
298 | 298 | array_unshift( $where['values'], $status ); |
299 | 299 | |
300 | 300 | $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); |
301 | - } else { |
|
301 | + } else { |
|
302 | 302 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) ); |
303 | 303 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) ); |
304 | - } |
|
304 | + } |
|
305 | 305 | |
306 | - if ( $query_results ) { |
|
306 | + if ( $query_results ) { |
|
307 | 307 | self::clear_form_cache(); |
308 | - } |
|
308 | + } |
|
309 | 309 | |
310 | - return $query_results; |
|
311 | - } |
|
310 | + return $query_results; |
|
311 | + } |
|
312 | 312 | |
313 | - /** |
|
314 | - * @return int|boolean |
|
315 | - */ |
|
313 | + /** |
|
314 | + * @return int|boolean |
|
315 | + */ |
|
316 | 316 | public static function trash( $id ) { |
317 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
318 | - return self::destroy( $id ); |
|
319 | - } |
|
317 | + if ( ! EMPTY_TRASH_DAYS ) { |
|
318 | + return self::destroy( $id ); |
|
319 | + } |
|
320 | 320 | |
321 | - $form = self::getOne($id); |
|
322 | - if ( ! $form ) { |
|
323 | - return false; |
|
324 | - } |
|
321 | + $form = self::getOne($id); |
|
322 | + if ( ! $form ) { |
|
323 | + return false; |
|
324 | + } |
|
325 | 325 | |
326 | - $options = $form->options; |
|
327 | - $options['trash_time'] = time(); |
|
326 | + $options = $form->options; |
|
327 | + $options['trash_time'] = time(); |
|
328 | 328 | |
329 | - global $wpdb; |
|
330 | - $query_results = $wpdb->update( |
|
329 | + global $wpdb; |
|
330 | + $query_results = $wpdb->update( |
|
331 | 331 | $wpdb->prefix . 'frm_forms', |
332 | 332 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
333 | 333 | array( 'id' => $id ) |
334 | - ); |
|
334 | + ); |
|
335 | 335 | |
336 | - $wpdb->update( |
|
336 | + $wpdb->update( |
|
337 | 337 | $wpdb->prefix . 'frm_forms', |
338 | 338 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
339 | 339 | array( 'parent_form_id' => $id ) |
340 | - ); |
|
340 | + ); |
|
341 | 341 | |
342 | - if ( $query_results ) { |
|
342 | + if ( $query_results ) { |
|
343 | 343 | self::clear_form_cache(); |
344 | - } |
|
344 | + } |
|
345 | 345 | |
346 | - return $query_results; |
|
347 | - } |
|
346 | + return $query_results; |
|
347 | + } |
|
348 | 348 | |
349 | - /** |
|
350 | - * @return int|boolean |
|
351 | - */ |
|
349 | + /** |
|
350 | + * @return int|boolean |
|
351 | + */ |
|
352 | 352 | public static function destroy( $id ) { |
353 | - global $wpdb; |
|
353 | + global $wpdb; |
|
354 | 354 | |
355 | - $form = self::getOne($id); |
|
356 | - if ( ! $form ) { |
|
357 | - return false; |
|
358 | - } |
|
355 | + $form = self::getOne($id); |
|
356 | + if ( ! $form ) { |
|
357 | + return false; |
|
358 | + } |
|
359 | 359 | $id = $form->id; |
360 | 360 | |
361 | - // Disconnect the entries from this form |
|
361 | + // Disconnect the entries from this form |
|
362 | 362 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
363 | - foreach ( $entries as $entry_id ) { |
|
364 | - FrmEntry::destroy($entry_id); |
|
365 | - unset($entry_id); |
|
366 | - } |
|
363 | + foreach ( $entries as $entry_id ) { |
|
364 | + FrmEntry::destroy($entry_id); |
|
365 | + unset($entry_id); |
|
366 | + } |
|
367 | 367 | |
368 | - // Disconnect the fields from this form |
|
368 | + // Disconnect the fields from this form |
|
369 | 369 | $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
370 | 370 | |
371 | 371 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
372 | - if ( $query_results ) { |
|
373 | - // Delete all form actions linked to this form |
|
374 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
375 | - $action_control->destroy($id, 'all'); |
|
372 | + if ( $query_results ) { |
|
373 | + // Delete all form actions linked to this form |
|
374 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
375 | + $action_control->destroy($id, 'all'); |
|
376 | 376 | |
377 | 377 | // Clear form caching |
378 | 378 | self::clear_form_cache(); |
379 | 379 | |
380 | 380 | do_action( 'frm_destroy_form', $id ); |
381 | 381 | do_action( 'frm_destroy_form_' . $id ); |
382 | - } |
|
382 | + } |
|
383 | 383 | |
384 | - return $query_results; |
|
385 | - } |
|
384 | + return $query_results; |
|
385 | + } |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Delete trashed forms based on how long they have been trashed |
@@ -414,49 +414,49 @@ discard block |
||
414 | 414 | return $count; |
415 | 415 | } |
416 | 416 | |
417 | - /** |
|
418 | - * @return string form name |
|
419 | - */ |
|
420 | - public static function &getName( $id ) { |
|
421 | - global $wpdb; |
|
422 | - |
|
423 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
424 | - if ( $form ) { |
|
425 | - $r = stripslashes($form->name); |
|
426 | - return $r; |
|
427 | - } |
|
428 | - |
|
429 | - $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
430 | - $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
431 | - $r = stripslashes($r); |
|
432 | - |
|
433 | - return $r; |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * @param string $key |
|
438 | - * @return int form id |
|
439 | - */ |
|
417 | + /** |
|
418 | + * @return string form name |
|
419 | + */ |
|
420 | + public static function &getName( $id ) { |
|
421 | + global $wpdb; |
|
422 | + |
|
423 | + $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
424 | + if ( $form ) { |
|
425 | + $r = stripslashes($form->name); |
|
426 | + return $r; |
|
427 | + } |
|
428 | + |
|
429 | + $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
430 | + $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
431 | + $r = stripslashes($r); |
|
432 | + |
|
433 | + return $r; |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * @param string $key |
|
438 | + * @return int form id |
|
439 | + */ |
|
440 | 440 | public static function &getIdByKey( $key ) { |
441 | - $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
442 | - return $id; |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * @param int $id |
|
447 | - * @return string form key |
|
448 | - */ |
|
441 | + $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
442 | + return $id; |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * @param int $id |
|
447 | + * @return string form key |
|
448 | + */ |
|
449 | 449 | public static function &getKeyById( $id ) { |
450 | - $id = (int) $id; |
|
451 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
452 | - if ( $cache ) { |
|
453 | - return $cache->form_key; |
|
454 | - } |
|
450 | + $id = (int) $id; |
|
451 | + $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
452 | + if ( $cache ) { |
|
453 | + return $cache->form_key; |
|
454 | + } |
|
455 | 455 | |
456 | - $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
456 | + $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
457 | 457 | |
458 | - return $key; |
|
459 | - } |
|
458 | + return $key; |
|
459 | + } |
|
460 | 460 | |
461 | 461 | /** |
462 | 462 | * If $form is numeric, get the form object |
@@ -469,47 +469,47 @@ discard block |
||
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | - /** |
|
473 | - * @return object form |
|
474 | - */ |
|
475 | - public static function getOne( $id, $blog_id = false ) { |
|
476 | - global $wpdb; |
|
472 | + /** |
|
473 | + * @return object form |
|
474 | + */ |
|
475 | + public static function getOne( $id, $blog_id = false ) { |
|
476 | + global $wpdb; |
|
477 | 477 | |
478 | - if ( $blog_id && is_multisite() ) { |
|
479 | - global $wpmuBaseTablePrefix; |
|
478 | + if ( $blog_id && is_multisite() ) { |
|
479 | + global $wpmuBaseTablePrefix; |
|
480 | 480 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
481 | 481 | |
482 | 482 | $table_name = $prefix . 'frm_forms'; |
483 | - } else { |
|
483 | + } else { |
|
484 | 484 | $table_name = $wpdb->prefix . 'frm_forms'; |
485 | - $cache = wp_cache_get($id, 'frm_form'); |
|
486 | - if ( $cache ) { |
|
487 | - if ( isset($cache->options) ) { |
|
488 | - $cache->options = maybe_unserialize($cache->options); |
|
489 | - } |
|
485 | + $cache = wp_cache_get($id, 'frm_form'); |
|
486 | + if ( $cache ) { |
|
487 | + if ( isset($cache->options) ) { |
|
488 | + $cache->options = maybe_unserialize($cache->options); |
|
489 | + } |
|
490 | 490 | |
491 | - return stripslashes_deep($cache); |
|
492 | - } |
|
493 | - } |
|
491 | + return stripslashes_deep($cache); |
|
492 | + } |
|
493 | + } |
|
494 | 494 | |
495 | - if ( is_numeric($id) ) { |
|
496 | - $where = array( 'id' => $id ); |
|
497 | - } else { |
|
498 | - $where = array( 'form_key' => $id ); |
|
499 | - } |
|
495 | + if ( is_numeric($id) ) { |
|
496 | + $where = array( 'id' => $id ); |
|
497 | + } else { |
|
498 | + $where = array( 'form_key' => $id ); |
|
499 | + } |
|
500 | 500 | |
501 | - $results = FrmDb::get_row( $table_name, $where ); |
|
501 | + $results = FrmDb::get_row( $table_name, $where ); |
|
502 | 502 | |
503 | - if ( isset($results->options) ) { |
|
503 | + if ( isset($results->options) ) { |
|
504 | 504 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
505 | - $results->options = maybe_unserialize($results->options); |
|
506 | - } |
|
507 | - return stripslashes_deep($results); |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * @return object|array of objects |
|
512 | - */ |
|
505 | + $results->options = maybe_unserialize($results->options); |
|
506 | + } |
|
507 | + return stripslashes_deep($results); |
|
508 | + } |
|
509 | + |
|
510 | + /** |
|
511 | + * @return object|array of objects |
|
512 | + */ |
|
513 | 513 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
514 | 514 | if ( is_array( $where ) && ! empty( $where ) ) { |
515 | 515 | $results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) ); |
@@ -533,8 +533,8 @@ discard block |
||
533 | 533 | $results = reset( $results ); |
534 | 534 | } |
535 | 535 | |
536 | - return stripslashes_deep($results); |
|
537 | - } |
|
536 | + return stripslashes_deep($results); |
|
537 | + } |
|
538 | 538 | |
539 | 539 | /** |
540 | 540 | * Get all published forms |
@@ -552,47 +552,47 @@ discard block |
||
552 | 552 | return $forms; |
553 | 553 | } |
554 | 554 | |
555 | - /** |
|
556 | - * @return int count of forms |
|
557 | - */ |
|
558 | - public static function &get_count() { |
|
559 | - global $wpdb; |
|
555 | + /** |
|
556 | + * @return int count of forms |
|
557 | + */ |
|
558 | + public static function &get_count() { |
|
559 | + global $wpdb; |
|
560 | 560 | |
561 | - $cache_key = 'frm_form_counts'; |
|
561 | + $cache_key = 'frm_form_counts'; |
|
562 | 562 | |
563 | - $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
564 | - if ( false !== $counts ) { |
|
565 | - return $counts; |
|
566 | - } |
|
563 | + $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
564 | + if ( false !== $counts ) { |
|
565 | + return $counts; |
|
566 | + } |
|
567 | 567 | |
568 | - $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
568 | + $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
569 | 569 | |
570 | 570 | $statuses = array( 'published', 'draft', 'template', 'trash' ); |
571 | - $counts = array_fill_keys( $statuses, 0 ); |
|
571 | + $counts = array_fill_keys( $statuses, 0 ); |
|
572 | 572 | |
573 | - foreach ( $results as $row ) { |
|
574 | - if ( 'trash' != $row->status ) { |
|
575 | - if ( $row->is_template ) { |
|
573 | + foreach ( $results as $row ) { |
|
574 | + if ( 'trash' != $row->status ) { |
|
575 | + if ( $row->is_template ) { |
|
576 | 576 | $counts['template']++; |
577 | - } else { |
|
577 | + } else { |
|
578 | 578 | $counts['published']++; |
579 | - } |
|
580 | - } else { |
|
579 | + } |
|
580 | + } else { |
|
581 | 581 | $counts['trash']++; |
582 | - } |
|
582 | + } |
|
583 | 583 | |
584 | - if ( 'draft' == $row->status ) { |
|
584 | + if ( 'draft' == $row->status ) { |
|
585 | 585 | $counts['draft']++; |
586 | - } |
|
586 | + } |
|
587 | 587 | |
588 | - unset($row); |
|
589 | - } |
|
588 | + unset($row); |
|
589 | + } |
|
590 | 590 | |
591 | - $counts = (object) $counts; |
|
591 | + $counts = (object) $counts; |
|
592 | 592 | FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' ); |
593 | 593 | |
594 | - return $counts; |
|
595 | - } |
|
594 | + return $counts; |
|
595 | + } |
|
596 | 596 | |
597 | 597 | /** |
598 | 598 | * Clear form caching |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | FrmAppHelper::cache_delete_group( 'frm_form' ); |
606 | 606 | } |
607 | 607 | |
608 | - /** |
|
609 | - * @return array of errors |
|
610 | - */ |
|
608 | + /** |
|
609 | + * @return array of errors |
|
610 | + */ |
|
611 | 611 | public static function validate( $values ) { |
612 | - $errors = array(); |
|
612 | + $errors = array(); |
|
613 | 613 | |
614 | - return apply_filters('frm_validate_form', $errors, $values); |
|
615 | - } |
|
614 | + return apply_filters('frm_validate_form', $errors, $values); |
|
615 | + } |
|
616 | 616 | |
617 | 617 | public static function get_params( $form = null ) { |
618 | 618 | global $frm_vars; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
3 | - die('You are not allowed to call this page directly.'); |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + die( 'You are not allowed to call this page directly.' ); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
16 | 16 | 'name' => $values['name'], |
17 | 17 | 'description' => $values['description'], |
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
18 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
22 | + 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
31 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
32 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
35 | + $new_values['options'] = serialize( $options ); |
|
36 | 36 | |
37 | 37 | //if(isset($values['id']) && is_numeric($values['id'])) |
38 | 38 | // $new_values['id'] = $values['id']; |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | 'status' => $template ? 'published' : 'draft', |
68 | 68 | 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
69 | 69 | 'editable' => $values->editable ? $values->editable : 0, |
70 | - 'created_at' => current_time('mysql', 1), |
|
70 | + 'created_at' => current_time( 'mysql', 1 ), |
|
71 | 71 | 'is_template' => $template ? 1 : 0, |
72 | 72 | ); |
73 | 73 | |
74 | 74 | if ( $blog_id ) { |
75 | 75 | $new_values['status'] = 'published'; |
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
76 | + $new_options = maybe_unserialize( $values->options ); |
|
77 | + $new_options['email_to'] = get_option( 'admin_email' ); |
|
78 | 78 | $new_options['copy'] = false; |
79 | 79 | $new_values['options'] = $new_options; |
80 | 80 | } else { |
81 | 81 | $new_values['options'] = $values->options; |
82 | 82 | } |
83 | 83 | |
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
84 | + if ( is_array( $new_values['options'] ) ) { |
|
85 | + $new_values['options'] = serialize( $new_values['options'] ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | 94 | $form_id = $wpdb->insert_id; |
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
95 | + FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id ); |
|
96 | 96 | |
97 | 97 | // update form settings after fields are created |
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $new_opts = maybe_unserialize( $values['options'] ); |
107 | 107 | $values['options'] = $new_opts; |
108 | 108 | |
109 | - if ( isset($new_opts['success_msg']) ) { |
|
110 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
109 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
110 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
111 | 111 | } |
112 | 112 | |
113 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
113 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
114 | 114 | |
115 | 115 | if ( $new_opts != $values['options'] ) { |
116 | 116 | global $wpdb; |
@@ -128,17 +128,17 @@ discard block |
||
128 | 128 | $values['status'] = 'published'; |
129 | 129 | } |
130 | 130 | |
131 | - if ( isset($values['form_key']) ) { |
|
131 | + if ( isset( $values['form_key'] ) ) { |
|
132 | 132 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
133 | 133 | } |
134 | 134 | |
135 | 135 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
136 | 136 | |
137 | - $new_values = self::set_update_options( array(), $values); |
|
137 | + $new_values = self::set_update_options( array(), $values ); |
|
138 | 138 | |
139 | 139 | foreach ( $values as $value_key => $value ) { |
140 | 140 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
141 | - $new_values[ $value_key ] = $value; |
|
141 | + $new_values[$value_key] = $value; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | } else { |
155 | 155 | $query_results = true; |
156 | 156 | } |
157 | - unset($new_values); |
|
157 | + unset( $new_values ); |
|
158 | 158 | |
159 | - $values = self::update_fields($id, $values); |
|
159 | + $values = self::update_fields( $id, $values ); |
|
160 | 160 | |
161 | 161 | do_action( 'frm_update_form', $id, $values ); |
162 | 162 | do_action( 'frm_update_form_' . $id, $values ); |
@@ -168,20 +168,20 @@ discard block |
||
168 | 168 | * @return array |
169 | 169 | */ |
170 | 170 | public static function set_update_options( $new_values, $values ) { |
171 | - if ( ! isset($values['options']) ) { |
|
171 | + if ( ! isset( $values['options'] ) ) { |
|
172 | 172 | return $new_values; |
173 | 173 | } |
174 | 174 | |
175 | 175 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
176 | 176 | FrmFormsHelper::fill_form_options( $options, $values ); |
177 | 177 | |
178 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
179 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
180 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
181 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
178 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
179 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
180 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
181 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
182 | 182 | |
183 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
184 | - $new_values['options'] = serialize($options); |
|
183 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
184 | + $new_values['options'] = serialize( $options ); |
|
185 | 185 | |
186 | 186 | return $new_values; |
187 | 187 | } |
@@ -192,54 +192,54 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public static function update_fields( $id, $values ) { |
194 | 194 | |
195 | - if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
195 | + if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
196 | 196 | return $values; |
197 | 197 | } |
198 | 198 | |
199 | - $all_fields = FrmField::get_all_for_form($id); |
|
200 | - if ( empty($all_fields) ) { |
|
199 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
200 | + if ( empty( $all_fields ) ) { |
|
201 | 201 | return $values; |
202 | 202 | } |
203 | 203 | |
204 | - if ( ! isset($values['item_meta']) ) { |
|
204 | + if ( ! isset( $values['item_meta'] ) ) { |
|
205 | 205 | $values['item_meta'] = array(); |
206 | 206 | } |
207 | 207 | |
208 | 208 | $field_array = array(); |
209 | - $existing_keys = array_keys($values['item_meta']); |
|
209 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
210 | 210 | foreach ( $all_fields as $fid ) { |
211 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
212 | - $values['item_meta'][ $fid->id ] = ''; |
|
211 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
212 | + $values['item_meta'][$fid->id] = ''; |
|
213 | 213 | } |
214 | - $field_array[ $fid->id ] = $fid; |
|
214 | + $field_array[$fid->id] = $fid; |
|
215 | 215 | } |
216 | - unset($all_fields); |
|
216 | + unset( $all_fields ); |
|
217 | 217 | |
218 | 218 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
219 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
220 | - $field = $field_array[ $field_id ]; |
|
219 | + if ( isset( $field_array[$field_id] ) ) { |
|
220 | + $field = $field_array[$field_id]; |
|
221 | 221 | } else { |
222 | - $field = FrmField::getOne($field_id); |
|
222 | + $field = FrmField::getOne( $field_id ); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | if ( ! $field ) { |
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
229 | - $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
|
229 | + $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ); |
|
230 | 230 | if ( $is_settings_page ) { |
231 | 231 | //updating the settings page |
232 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
233 | - $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
234 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
232 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
233 | + $field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
234 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
235 | 235 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
236 | 236 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
237 | 237 | $prev_opts = $field->field_options; |
238 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
238 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
239 | 239 | if ( $prev_opts != $field->field_options ) { |
240 | 240 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
241 | 241 | } |
242 | - unset($prev_opts); |
|
242 | + unset( $prev_opts ); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
254 | 254 | |
255 | 255 | foreach ( $update_options as $opt => $default ) { |
256 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
|
256 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default; |
|
257 | 257 | } |
258 | 258 | |
259 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
260 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
261 | - $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
|
262 | - $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
|
263 | - $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
|
264 | - $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
|
259 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
260 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
261 | + $field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key; |
|
262 | + $required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false; |
|
263 | + $field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type; |
|
264 | + $field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description; |
|
265 | 265 | |
266 | - FrmField::update($field_id, array( |
|
266 | + FrmField::update( $field_id, array( |
|
267 | 267 | 'field_key' => $field_key, 'type' => $field_type, |
268 | 268 | 'default_value' => $default_value, 'field_options' => $field->field_options, |
269 | 269 | 'description' => $field_description, 'required' => $required, |
270 | 270 | ) ); |
271 | 271 | |
272 | - FrmField::delete_form_transient($field->form_id); |
|
272 | + FrmField::delete_form_transient( $field->form_id ); |
|
273 | 273 | } |
274 | 274 | self::clear_form_cache(); |
275 | 275 | |
@@ -282,17 +282,17 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public static function set_status( $id, $status ) { |
284 | 284 | if ( 'trash' == $status ) { |
285 | - return self::trash($id); |
|
285 | + return self::trash( $id ); |
|
286 | 286 | } |
287 | 287 | |
288 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
288 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
289 | 289 | if ( ! in_array( $status, $statuses ) ) { |
290 | 290 | return false; |
291 | 291 | } |
292 | 292 | |
293 | 293 | global $wpdb; |
294 | 294 | |
295 | - if ( is_array($id) ) { |
|
295 | + if ( is_array( $id ) ) { |
|
296 | 296 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
297 | 297 | FrmDb::get_where_clause_and_values( $where ); |
298 | 298 | array_unshift( $where['values'], $status ); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | return self::destroy( $id ); |
319 | 319 | } |
320 | 320 | |
321 | - $form = self::getOne($id); |
|
321 | + $form = self::getOne( $id ); |
|
322 | 322 | if ( ! $form ) { |
323 | 323 | return false; |
324 | 324 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public static function destroy( $id ) { |
353 | 353 | global $wpdb; |
354 | 354 | |
355 | - $form = self::getOne($id); |
|
355 | + $form = self::getOne( $id ); |
|
356 | 356 | if ( ! $form ) { |
357 | 357 | return false; |
358 | 358 | } |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | // Disconnect the entries from this form |
362 | 362 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
363 | 363 | foreach ( $entries as $entry_id ) { |
364 | - FrmEntry::destroy($entry_id); |
|
365 | - unset($entry_id); |
|
364 | + FrmEntry::destroy( $entry_id ); |
|
365 | + unset( $entry_id ); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | // Disconnect the fields from this form |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | if ( $query_results ) { |
373 | 373 | // Delete all form actions linked to this form |
374 | 374 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
375 | - $action_control->destroy($id, 'all'); |
|
375 | + $action_control->destroy( $id, 'all' ); |
|
376 | 376 | |
377 | 377 | // Clear form caching |
378 | 378 | self::clear_form_cache(); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $form->options = maybe_unserialize( $form->options ); |
407 | 407 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
408 | 408 | self::destroy( $form->id ); |
409 | - $count++; |
|
409 | + $count ++; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | unset( $form ); |
@@ -420,15 +420,15 @@ discard block |
||
420 | 420 | public static function &getName( $id ) { |
421 | 421 | global $wpdb; |
422 | 422 | |
423 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
423 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
424 | 424 | if ( $form ) { |
425 | - $r = stripslashes($form->name); |
|
425 | + $r = stripslashes( $form->name ); |
|
426 | 426 | return $r; |
427 | 427 | } |
428 | 428 | |
429 | 429 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
430 | 430 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
431 | - $r = stripslashes($r); |
|
431 | + $r = stripslashes( $r ); |
|
432 | 432 | |
433 | 433 | return $r; |
434 | 434 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | public static function &getKeyById( $id ) { |
450 | 450 | $id = (int) $id; |
451 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
451 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
452 | 452 | if ( $cache ) { |
453 | 453 | return $cache->form_key; |
454 | 454 | } |
@@ -482,17 +482,17 @@ discard block |
||
482 | 482 | $table_name = $prefix . 'frm_forms'; |
483 | 483 | } else { |
484 | 484 | $table_name = $wpdb->prefix . 'frm_forms'; |
485 | - $cache = wp_cache_get($id, 'frm_form'); |
|
485 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
486 | 486 | if ( $cache ) { |
487 | - if ( isset($cache->options) ) { |
|
488 | - $cache->options = maybe_unserialize($cache->options); |
|
487 | + if ( isset( $cache->options ) ) { |
|
488 | + $cache->options = maybe_unserialize( $cache->options ); |
|
489 | 489 | } |
490 | 490 | |
491 | - return stripslashes_deep($cache); |
|
491 | + return stripslashes_deep( $cache ); |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | - if ( is_numeric($id) ) { |
|
495 | + if ( is_numeric( $id ) ) { |
|
496 | 496 | $where = array( 'id' => $id ); |
497 | 497 | } else { |
498 | 498 | $where = array( 'form_key' => $id ); |
@@ -500,11 +500,11 @@ discard block |
||
500 | 500 | |
501 | 501 | $results = FrmDb::get_row( $table_name, $where ); |
502 | 502 | |
503 | - if ( isset($results->options) ) { |
|
503 | + if ( isset( $results->options ) ) { |
|
504 | 504 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
505 | - $results->options = maybe_unserialize($results->options); |
|
505 | + $results->options = maybe_unserialize( $results->options ); |
|
506 | 506 | } |
507 | - return stripslashes_deep($results); |
|
507 | + return stripslashes_deep( $results ); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $results = reset( $results ); |
534 | 534 | } |
535 | 535 | |
536 | - return stripslashes_deep($results); |
|
536 | + return stripslashes_deep( $results ); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
@@ -573,19 +573,19 @@ discard block |
||
573 | 573 | foreach ( $results as $row ) { |
574 | 574 | if ( 'trash' != $row->status ) { |
575 | 575 | if ( $row->is_template ) { |
576 | - $counts['template']++; |
|
576 | + $counts['template'] ++; |
|
577 | 577 | } else { |
578 | - $counts['published']++; |
|
578 | + $counts['published'] ++; |
|
579 | 579 | } |
580 | 580 | } else { |
581 | - $counts['trash']++; |
|
581 | + $counts['trash'] ++; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | if ( 'draft' == $row->status ) { |
585 | - $counts['draft']++; |
|
585 | + $counts['draft'] ++; |
|
586 | 586 | } |
587 | 587 | |
588 | - unset($row); |
|
588 | + unset( $row ); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | $counts = (object) $counts; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | public static function validate( $values ) { |
612 | 612 | $errors = array(); |
613 | 613 | |
614 | - return apply_filters('frm_validate_form', $errors, $values); |
|
614 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | public static function get_params( $form = null ) { |
@@ -623,11 +623,11 @@ discard block |
||
623 | 623 | self::maybe_get_form( $form ); |
624 | 624 | } |
625 | 625 | |
626 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
627 | - return $frm_vars['form_params'][ $form->id ]; |
|
626 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
627 | + return $frm_vars['form_params'][$form->id]; |
|
628 | 628 | } |
629 | 629 | |
630 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
630 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
631 | 631 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
632 | 632 | |
633 | 633 | $default_values = array( |
@@ -645,15 +645,15 @@ discard block |
||
645 | 645 | //if there are two forms on the same page, make sure not to submit both |
646 | 646 | foreach ( $default_values as $var => $default ) { |
647 | 647 | if ( $var == 'action' ) { |
648 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
648 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
649 | 649 | } else { |
650 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
650 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
651 | 651 | } |
652 | 652 | unset( $var, $default ); |
653 | 653 | } |
654 | 654 | } else { |
655 | 655 | foreach ( $default_values as $var => $default ) { |
656 | - $values[ $var ] = $default; |
|
656 | + $values[$var] = $default; |
|
657 | 657 | unset( $var, $default ); |
658 | 658 | } |
659 | 659 | } |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | public static function list_page_params() { |
669 | 669 | $values = array(); |
670 | 670 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
671 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
671 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | return $values; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
689 | 689 | 'keep_post' => '', |
690 | 690 | ) as $var => $default ) { |
691 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
691 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | return $values; |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | $small_form = new stdClass(); |
731 | 731 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
732 | 732 | $small_form->{$var} = $form->{$var}; |
733 | - unset($var); |
|
733 | + unset( $var ); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | $frm_vars['forms_loaded'][] = $small_form; |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $frm_vars['load_css'] = true; |
741 | 741 | } |
742 | 742 | |
743 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
743 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | public static function show_submit( $form ) { |
@@ -1,27 +1,27 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmEntryValidate { |
4 | - public static function validate( $values, $exclude = false ) { |
|
5 | - global $wpdb; |
|
4 | + public static function validate( $values, $exclude = false ) { |
|
5 | + global $wpdb; |
|
6 | 6 | |
7 | - FrmEntry::sanitize_entry_post( $values ); |
|
8 | - $errors = array(); |
|
7 | + FrmEntry::sanitize_entry_post( $values ); |
|
8 | + $errors = array(); |
|
9 | 9 | |
10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
12 | - return $errors; |
|
13 | - } |
|
10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
12 | + return $errors; |
|
13 | + } |
|
14 | 14 | |
15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
17 | - } |
|
16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
20 | 20 | $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
21 | 21 | $_POST['item_key'] = $values['item_key']; |
22 | 22 | } |
23 | 23 | |
24 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
25 | 25 | // Don't get subfields |
26 | 26 | $where['fr.parent_form_id'] = array( null, 0 ); |
27 | 27 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -29,42 +29,42 @@ discard block |
||
29 | 29 | $where['fi.type not'] = $exclude; |
30 | 30 | } |
31 | 31 | |
32 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
32 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
33 | 33 | |
34 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
35 | - $args = array( 'exclude' => $exclude ); |
|
34 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
35 | + $args = array( 'exclude' => $exclude ); |
|
36 | 36 | |
37 | - foreach ( $posted_fields as $posted_field ) { |
|
38 | - self::validate_field($posted_field, $errors, $values, $args); |
|
39 | - unset($posted_field); |
|
40 | - } |
|
37 | + foreach ( $posted_fields as $posted_field ) { |
|
38 | + self::validate_field($posted_field, $errors, $values, $args); |
|
39 | + unset($posted_field); |
|
40 | + } |
|
41 | 41 | |
42 | - // check for spam |
|
43 | - self::spam_check( $exclude, $values, $errors ); |
|
42 | + // check for spam |
|
43 | + self::spam_check( $exclude, $values, $errors ); |
|
44 | 44 | |
45 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
45 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
46 | 46 | |
47 | - return $errors; |
|
48 | - } |
|
47 | + return $errors; |
|
48 | + } |
|
49 | 49 | |
50 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
51 | - $defaults = array( |
|
52 | - 'id' => $posted_field->id, |
|
53 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
54 | - 'key_pointer' => '', // the pointer in the posted array |
|
55 | - 'exclude' => array(), // exclude these field types from validation |
|
56 | - ); |
|
57 | - $args = wp_parse_args( $args, $defaults ); |
|
50 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
51 | + $defaults = array( |
|
52 | + 'id' => $posted_field->id, |
|
53 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
54 | + 'key_pointer' => '', // the pointer in the posted array |
|
55 | + 'exclude' => array(), // exclude these field types from validation |
|
56 | + ); |
|
57 | + $args = wp_parse_args( $args, $defaults ); |
|
58 | 58 | |
59 | - if ( empty($args['parent_field_id']) ) { |
|
59 | + if ( empty($args['parent_field_id']) ) { |
|
60 | 60 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
61 | - } else { |
|
62 | - // value is from a nested form |
|
63 | - $value = $values; |
|
64 | - } |
|
61 | + } else { |
|
62 | + // value is from a nested form |
|
63 | + $value = $values; |
|
64 | + } |
|
65 | 65 | |
66 | - // Check for values in "Other" fields |
|
67 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
66 | + // Check for values in "Other" fields |
|
67 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
68 | 68 | |
69 | 69 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
70 | 70 | |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | $value = reset($value); |
74 | 74 | } |
75 | 75 | |
76 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
76 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
77 | 77 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
78 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
79 | - $_POST['item_name'] = $value; |
|
80 | - } |
|
78 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
79 | + $_POST['item_name'] = $value; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | if ( $value != '' ) { |
83 | 83 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
87 | 87 | } |
88 | 88 | |
89 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
89 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
90 | 90 | |
91 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
91 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
92 | 92 | |
93 | 93 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
94 | 94 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | 97 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
98 | 98 | if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) { |
@@ -102,32 +102,32 @@ discard block |
||
102 | 102 | |
103 | 103 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
104 | 104 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
105 | - return; |
|
106 | - } |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | - if ( trim($value) == 'http://' ) { |
|
109 | - $value = ''; |
|
110 | - } else { |
|
111 | - $value = esc_url_raw( $value ); |
|
108 | + if ( trim($value) == 'http://' ) { |
|
109 | + $value = ''; |
|
110 | + } else { |
|
111 | + $value = esc_url_raw( $value ); |
|
112 | 112 | $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | - // validate the url format |
|
115 | + // validate the url format |
|
116 | 116 | if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) { |
117 | 117 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
118 | 118 | } |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
122 | - if ( $value == '' || $field->type != 'email' ) { |
|
123 | - return; |
|
124 | - } |
|
122 | + if ( $value == '' || $field->type != 'email' ) { |
|
123 | + return; |
|
124 | + } |
|
125 | 125 | |
126 | - //validate the email format |
|
127 | - if ( ! is_email($value) ) { |
|
126 | + //validate the email format |
|
127 | + if ( ! is_email($value) ) { |
|
128 | 128 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
129 | - } |
|
130 | - } |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | 132 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
133 | 133 | //validate the number format |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | public static function validate_recaptcha( &$errors, $field, $args ) { |
224 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
225 | - return; |
|
226 | - } |
|
224 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
225 | + return; |
|
226 | + } |
|
227 | 227 | |
228 | 228 | $frm_settings = FrmAppHelper::get_settings(); |
229 | 229 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -231,57 +231,57 @@ discard block |
||
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
235 | - // If captcha is missing, check if it was already verified |
|
234 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
235 | + // If captcha is missing, check if it was already verified |
|
236 | 236 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
237 | - // There was no captcha submitted |
|
237 | + // There was no captcha submitted |
|
238 | 238 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
239 | - } |
|
240 | - return; |
|
241 | - } |
|
239 | + } |
|
240 | + return; |
|
241 | + } |
|
242 | 242 | |
243 | - $arg_array = array( |
|
244 | - 'body' => array( |
|
243 | + $arg_array = array( |
|
244 | + 'body' => array( |
|
245 | 245 | 'secret' => $frm_settings->privkey, |
246 | 246 | 'response' => $_POST['g-recaptcha-response'], |
247 | 247 | 'remoteip' => FrmAppHelper::get_ip_address(), |
248 | 248 | ), |
249 | 249 | ); |
250 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
251 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
250 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
251 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
252 | 252 | |
253 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
254 | - // What happens when the CAPTCHA was entered incorrectly |
|
253 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
254 | + // What happens when the CAPTCHA was entered incorrectly |
|
255 | 255 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
256 | - } else if ( is_wp_error( $resp ) ) { |
|
256 | + } else if ( is_wp_error( $resp ) ) { |
|
257 | 257 | $error_string = $resp->get_error_message(); |
258 | 258 | $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
259 | 259 | $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
260 | - } |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * check for spam |
|
265 | - * @param boolean $exclude |
|
266 | - * @param array $values |
|
267 | - * @param array $errors by reference |
|
268 | - */ |
|
269 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
270 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
271 | - // only check spam if there are no other errors |
|
272 | - return; |
|
273 | - } |
|
274 | - |
|
275 | - if ( self::blacklist_check( $values ) ) { |
|
276 | - $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' ); |
|
277 | - } |
|
278 | - |
|
279 | - if ( self::is_akismet_spam( $values ) ) { |
|
260 | + } |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * check for spam |
|
265 | + * @param boolean $exclude |
|
266 | + * @param array $values |
|
267 | + * @param array $errors by reference |
|
268 | + */ |
|
269 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
270 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
271 | + // only check spam if there are no other errors |
|
272 | + return; |
|
273 | + } |
|
274 | + |
|
275 | + if ( self::blacklist_check( $values ) ) { |
|
276 | + $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' ); |
|
277 | + } |
|
278 | + |
|
279 | + if ( self::is_akismet_spam( $values ) ) { |
|
280 | 280 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
281 | 281 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
282 | 282 | } |
283 | - } |
|
284 | - } |
|
283 | + } |
|
284 | + } |
|
285 | 285 | |
286 | 286 | private static function is_akismet_spam( $values ) { |
287 | 287 | global $wpcom_api_key; |
@@ -293,15 +293,15 @@ discard block |
||
293 | 293 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
294 | 294 | } |
295 | 295 | |
296 | - public static function blacklist_check( $values ) { |
|
297 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
298 | - return false; |
|
299 | - } |
|
296 | + public static function blacklist_check( $values ) { |
|
297 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
298 | + return false; |
|
299 | + } |
|
300 | 300 | |
301 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
302 | - if ( empty( $mod_keys ) ) { |
|
303 | - return false; |
|
304 | - } |
|
301 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
302 | + if ( empty( $mod_keys ) ) { |
|
303 | + return false; |
|
304 | + } |
|
305 | 305 | |
306 | 306 | $content = FrmEntriesHelper::entry_array_to_string( $values ); |
307 | 307 | if ( empty( $content ) ) { |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $user_info = self::get_spam_check_user_info( $values ); |
314 | 314 | |
315 | 315 | return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent ); |
316 | - } |
|
316 | + } |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Check entries for Akismet spam |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | FrmEntry::sanitize_entry_post( $values ); |
8 | 8 | $errors = array(); |
9 | 9 | |
10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
10 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
11 | 11 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
12 | 12 | return $errors; |
13 | 13 | } |
14 | 14 | |
15 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
15 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
16 | 16 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
17 | 17 | } |
18 | 18 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $_POST['item_key'] = $values['item_key']; |
22 | 22 | } |
23 | 23 | |
24 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
25 | 25 | // Don't get subfields |
26 | 26 | $where['fr.parent_form_id'] = array( null, 0 ); |
27 | 27 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | $where['fi.type not'] = $exclude; |
30 | 30 | } |
31 | 31 | |
32 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
32 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
33 | 33 | |
34 | 34 | // Pass exclude value to validate_field function so it can be used for repeating sections |
35 | 35 | $args = array( 'exclude' => $exclude ); |
36 | 36 | |
37 | 37 | foreach ( $posted_fields as $posted_field ) { |
38 | - self::validate_field($posted_field, $errors, $values, $args); |
|
39 | - unset($posted_field); |
|
38 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
39 | + unset( $posted_field ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // check for spam |
43 | 43 | self::spam_check( $exclude, $values, $errors ); |
44 | 44 | |
45 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
45 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
46 | 46 | |
47 | 47 | return $errors; |
48 | 48 | } |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | ); |
57 | 57 | $args = wp_parse_args( $args, $defaults ); |
58 | 58 | |
59 | - if ( empty($args['parent_field_id']) ) { |
|
60 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
59 | + if ( empty( $args['parent_field_id'] ) ) { |
|
60 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
61 | 61 | } else { |
62 | 62 | // value is from a nested form |
63 | 63 | $value = $values; |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
70 | 70 | |
71 | 71 | // Reset arrays with only one value if it's not a field where array keys need to be preserved |
72 | - if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
73 | - $value = reset($value); |
|
72 | + if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
73 | + $value = reset( $value ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
77 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
77 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
78 | 78 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
79 | 79 | $_POST['item_name'] = $value; |
80 | 80 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
87 | 87 | } |
88 | 88 | |
89 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
89 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
90 | 90 | |
91 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
91 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
92 | 92 | |
93 | 93 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
94 | 94 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - if ( trim($value) == 'http://' ) { |
|
108 | + if ( trim( $value ) == 'http://' ) { |
|
109 | 109 | $value = ''; |
110 | 110 | } else { |
111 | 111 | $value = esc_url_raw( $value ); |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // validate the url format |
116 | - if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) { |
|
117 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
116 | + if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) { |
|
117 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | //validate the email format |
127 | - if ( ! is_email($value) ) { |
|
128 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
127 | + if ( ! is_email( $value ) ) { |
|
128 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | - if ( ! is_numeric( $value) ) { |
|
139 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
138 | + if ( ! is_numeric( $value ) ) { |
|
139 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // validate number settings |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
147 | 147 | //minnum maxnum |
148 | 148 | if ( (float) $value < $field->field_options['minnum'] ) { |
149 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
149 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
150 | 150 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
151 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
151 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $pattern = self::phone_format( $field ); |
161 | 161 | |
162 | 162 | if ( ! preg_match( $pattern, $value ) ) { |
163 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
163 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
234 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
235 | 235 | // If captcha is missing, check if it was already verified |
236 | 236 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
237 | 237 | // There was no captcha submitted |
238 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
238 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
239 | 239 | } |
240 | 240 | return; |
241 | 241 | } |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | ), |
249 | 249 | ); |
250 | 250 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
251 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
251 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
252 | 252 | |
253 | 253 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
254 | 254 | // What happens when the CAPTCHA was entered incorrectly |
255 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
255 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
256 | 256 | } else if ( is_wp_error( $resp ) ) { |
257 | 257 | $error_string = $resp->get_error_message(); |
258 | - $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
259 | - $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
|
258 | + $errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
259 | + $errors['field' . $args['id']] .= ' ' . $error_string; |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | private static function is_akismet_spam( $values ) { |
287 | 287 | global $wpcom_api_key; |
288 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
288 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | } |
295 | 295 | |
296 | 296 | public static function blacklist_check( $values ) { |
297 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
297 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
351 | 351 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
352 | 352 | $datas['blog_lang'] = get_locale(); |
353 | - $datas['blog_charset'] = get_option('blog_charset'); |
|
353 | + $datas['blog_charset'] = get_option( 'blog_charset' ); |
|
354 | 354 | |
355 | 355 | if ( akismet_test_mode() ) { |
356 | 356 | $datas['is_test'] = 'true'; |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | |
405 | 405 | // Send any potentially useful $_SERVER vars, but avoid sending junk we don't need. |
406 | 406 | if ( $include_value ) { |
407 | - $datas[ $key ] = $value; |
|
407 | + $datas[$key] = $value; |
|
408 | 408 | } |
409 | 409 | unset( $key, $value ); |
410 | 410 | } |
@@ -23,30 +23,30 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function import_xml( $file ) { |
26 | - $defaults = array( |
|
27 | - 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
28 | - 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
29 | - 'styles' => 0, |
|
30 | - ); |
|
31 | - |
|
32 | - $imported = array( |
|
33 | - 'imported' => $defaults, |
|
26 | + $defaults = array( |
|
27 | + 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
28 | + 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
29 | + 'styles' => 0, |
|
30 | + ); |
|
31 | + |
|
32 | + $imported = array( |
|
33 | + 'imported' => $defaults, |
|
34 | 34 | 'updated' => $defaults, |
35 | 35 | 'forms' => array(), |
36 | 36 | 'terms' => array(), |
37 | - ); |
|
37 | + ); |
|
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset($defaults); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
43 | - } |
|
42 | + define('WP_IMPORTING', true); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
46 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
47 | - } |
|
46 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
47 | + } |
|
48 | 48 | |
49 | - $dom = new DOMDocument; |
|
49 | + $dom = new DOMDocument; |
|
50 | 50 | $success = $dom->loadXML( file_get_contents( $file ) ); |
51 | 51 | if ( ! $success ) { |
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
@@ -64,45 +64,45 @@ discard block |
||
64 | 64 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
65 | 65 | } |
66 | 66 | |
67 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
67 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | - // grab cats, tags, and terms, or forms or posts |
|
70 | - if ( isset($xml->{$item_type} ) ) { |
|
69 | + // grab cats, tags, and terms, or forms or posts |
|
70 | + if ( isset($xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | - } |
|
75 | - } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | - return $return; |
|
80 | - } |
|
79 | + return $return; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
83 | - foreach ( $terms as $t ) { |
|
83 | + foreach ( $terms as $t ) { |
|
84 | 84 | if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
85 | - continue; |
|
85 | + continue; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $parent = self::get_term_parent_id( $t ); |
89 | 89 | |
90 | 90 | $term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array( |
91 | - 'slug' => (string) $t->term_slug, |
|
92 | - 'description' => (string) $t->term_description, |
|
91 | + 'slug' => (string) $t->term_slug, |
|
92 | + 'description' => (string) $t->term_description, |
|
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | - )); |
|
94 | + )); |
|
95 | 95 | |
96 | 96 | if ( $term && is_array( $term ) ) { |
97 | - $imported['imported']['terms']++; |
|
97 | + $imported['imported']['terms']++; |
|
98 | 98 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | unset( $term, $t ); |
102 | 102 | } |
103 | 103 | |
104 | 104 | return $imported; |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * @since 2.0.8 |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | self::put_child_forms_first( $forms ); |
128 | 128 | |
129 | 129 | foreach ( $forms as $item ) { |
130 | - $form = self::fill_form( $item ); |
|
130 | + $form = self::fill_form( $item ); |
|
131 | 131 | |
132 | 132 | self::update_custom_style_setting_on_import( $form ); |
133 | 133 | |
134 | - $this_form = self::maybe_get_form( $form ); |
|
134 | + $this_form = self::maybe_get_form( $form ); |
|
135 | 135 | |
136 | 136 | $old_id = false; |
137 | 137 | $form_fields = false; |
@@ -143,35 +143,35 @@ discard block |
||
143 | 143 | $form_fields = self::get_form_fields( $form_id ); |
144 | 144 | } else { |
145 | 145 | $form_id = FrmForm::create( $form ); |
146 | - if ( $form_id ) { |
|
147 | - $imported['imported']['forms']++; |
|
148 | - // Keep track of whether this specific form was updated or not |
|
146 | + if ( $form_id ) { |
|
147 | + $imported['imported']['forms']++; |
|
148 | + // Keep track of whether this specific form was updated or not |
|
149 | 149 | $imported['form_status'][ $form_id ] = 'imported'; |
150 | 150 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
151 | - } |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
155 | 155 | |
156 | 156 | self::delete_removed_fields( $form_fields ); |
157 | 157 | |
158 | - // Update field ids/keys to new ones |
|
158 | + // Update field ids/keys to new ones |
|
159 | 159 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
160 | 160 | |
161 | 161 | $imported['forms'][ (int) $item->id ] = $form_id; |
162 | 162 | |
163 | - // Send pre 2.0 form options through function that creates actions |
|
164 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
163 | + // Send pre 2.0 form options through function that creates actions |
|
164 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
165 | 165 | |
166 | 166 | do_action( 'frm_after_import_form', $form_id, $form ); |
167 | 167 | |
168 | - unset($form, $item); |
|
168 | + unset($form, $item); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
172 | 172 | |
173 | 173 | return $imported; |
174 | - } |
|
174 | + } |
|
175 | 175 | |
176 | 176 | private static function fill_form( $item ) { |
177 | 177 | $form = array( |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | - * Put child forms first so they will be imported before parents |
|
243 | - * |
|
244 | - * @since 2.0.16 |
|
245 | - * @param array $forms |
|
246 | - */ |
|
242 | + * Put child forms first so they will be imported before parents |
|
243 | + * |
|
244 | + * @since 2.0.16 |
|
245 | + * @param array $forms |
|
246 | + */ |
|
247 | 247 | private static function put_child_forms_first( &$forms ) { |
248 | 248 | $child_forms = array(); |
249 | 249 | $regular_forms = array(); |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Keep track of all imported child forms |
|
266 | - * |
|
267 | - * @since 2.0.16 |
|
268 | - * @param int $form_id |
|
269 | - * @param int $parent_form_id |
|
270 | - * @param array $child_forms |
|
271 | - */ |
|
265 | + * Keep track of all imported child forms |
|
266 | + * |
|
267 | + * @since 2.0.16 |
|
268 | + * @param int $form_id |
|
269 | + * @param int $parent_form_id |
|
270 | + * @param array $child_forms |
|
271 | + */ |
|
272 | 272 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
273 | 273 | if ( $parent_form_id ) { |
274 | 274 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
279 | - * Update the parent_form_id on imported child forms |
|
280 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
281 | - * |
|
282 | - * @since 2.0.6 |
|
283 | - * @param array $imported_forms |
|
284 | - * @param array $child_forms |
|
285 | - */ |
|
279 | + * Update the parent_form_id on imported child forms |
|
280 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
281 | + * |
|
282 | + * @since 2.0.6 |
|
283 | + * @param array $imported_forms |
|
284 | + * @param array $child_forms |
|
285 | + */ |
|
286 | 286 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
287 | 287 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
288 | 288 | |
@@ -296,28 +296,28 @@ discard block |
||
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
299 | - * Import all fields for a form |
|
300 | - * @since 2.0.13 |
|
301 | - * |
|
302 | - * TODO: Cut down on params |
|
303 | - */ |
|
299 | + * Import all fields for a form |
|
300 | + * @since 2.0.13 |
|
301 | + * |
|
302 | + * TODO: Cut down on params |
|
303 | + */ |
|
304 | 304 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
305 | 305 | $in_section = 0; |
306 | 306 | |
307 | 307 | foreach ( $xml_fields as $field ) { |
308 | 308 | $f = self::fill_field( $field, $form_id ); |
309 | 309 | |
310 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
311 | - 'text', 'email', 'url', 'textarea', |
|
312 | - 'number','phone', 'date', 'time', |
|
313 | - 'hidden', 'password', 'tag', 'image', |
|
314 | - )) ) { |
|
315 | - if ( count($f['default_value']) === 1 ) { |
|
310 | + if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
311 | + 'text', 'email', 'url', 'textarea', |
|
312 | + 'number','phone', 'date', 'time', |
|
313 | + 'hidden', 'password', 'tag', 'image', |
|
314 | + )) ) { |
|
315 | + if ( count($f['default_value']) === 1 ) { |
|
316 | 316 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
317 | - } else { |
|
318 | - $f['default_value'] = reset($f['default_value']); |
|
319 | - } |
|
320 | - } |
|
317 | + } else { |
|
318 | + $f['default_value'] = reset($f['default_value']); |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | 322 | self::maybe_update_in_section_variable( $in_section, $f ); |
323 | 323 | self::maybe_update_form_select( $f, $imported ); |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
400 | - * |
|
401 | - * @since 2.0.16 |
|
402 | - * @param array $f |
|
403 | - * @param array $imported |
|
404 | - */ |
|
399 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
400 | + * |
|
401 | + * @since 2.0.16 |
|
402 | + * @param array $f |
|
403 | + * @param array $imported |
|
404 | + */ |
|
405 | 405 | private static function maybe_update_form_select( &$f, $imported ) { |
406 | 406 | if ( ! isset( $imported['forms'] ) ) { |
407 | 407 | return; |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
456 | - * Updates the custom style setting on import |
|
457 | - * Convert the post slug to an ID |
|
458 | - * |
|
459 | - * @since 2.0.19 |
|
460 | - * @param array $form |
|
461 | - * |
|
462 | - */ |
|
456 | + * Updates the custom style setting on import |
|
457 | + * Convert the post slug to an ID |
|
458 | + * |
|
459 | + * @since 2.0.19 |
|
460 | + * @param array $form |
|
461 | + * |
|
462 | + */ |
|
463 | 463 | private static function update_custom_style_setting_on_import( &$form ) { |
464 | 464 | if ( ! isset( $form['options']['custom_style'] ) ) { |
465 | 465 | return; |
@@ -513,16 +513,16 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | public static function import_xml_views( $views, $imported ) { |
516 | - $imported['posts'] = array(); |
|
517 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
516 | + $imported['posts'] = array(); |
|
517 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
518 | 518 | |
519 | - $post_types = array( |
|
520 | - 'frm_display' => 'views', |
|
521 | - $form_action_type => 'actions', |
|
522 | - 'frm_styles' => 'styles', |
|
523 | - ); |
|
519 | + $post_types = array( |
|
520 | + 'frm_display' => 'views', |
|
521 | + $form_action_type => 'actions', |
|
522 | + 'frm_styles' => 'styles', |
|
523 | + ); |
|
524 | 524 | |
525 | - foreach ( $views as $item ) { |
|
525 | + foreach ( $views as $item ) { |
|
526 | 526 | $post = array( |
527 | 527 | 'post_title' => (string) $item->title, |
528 | 528 | 'post_name' => (string) $item->post_name, |
@@ -541,52 +541,52 @@ discard block |
||
541 | 541 | 'post_date' => (string) $item->post_date, |
542 | 542 | 'post_date_gmt' => (string) $item->post_date_gmt, |
543 | 543 | 'ping_status' => (string) $item->ping_status, |
544 | - 'postmeta' => array(), |
|
545 | - 'tax_input' => array(), |
|
544 | + 'postmeta' => array(), |
|
545 | + 'tax_input' => array(), |
|
546 | 546 | ); |
547 | 547 | |
548 | - $old_id = $post['post_id']; |
|
549 | - self::populate_post($post, $item, $imported); |
|
548 | + $old_id = $post['post_id']; |
|
549 | + self::populate_post($post, $item, $imported); |
|
550 | 550 | |
551 | 551 | unset($item); |
552 | 552 | |
553 | 553 | $post_id = false; |
554 | - if ( $post['post_type'] == $form_action_type ) { |
|
555 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
554 | + if ( $post['post_type'] == $form_action_type ) { |
|
555 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
556 | 556 | if ( $action_control && is_object( $action_control ) ) { |
557 | 557 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
558 | 558 | } |
559 | - unset($action_control); |
|
560 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
561 | - // Properly encode post content before inserting the post |
|
562 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
563 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
564 | - |
|
565 | - // Create/update post now |
|
566 | - $post_id = wp_insert_post( $post ); |
|
567 | - } else { |
|
568 | - // Create/update post now |
|
569 | - $post_id = wp_insert_post( $post ); |
|
570 | - } |
|
571 | - |
|
572 | - if ( ! is_numeric($post_id) ) { |
|
573 | - continue; |
|
574 | - } |
|
575 | - |
|
576 | - self::update_postmeta($post, $post_id); |
|
577 | - |
|
578 | - $this_type = 'posts'; |
|
559 | + unset($action_control); |
|
560 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
561 | + // Properly encode post content before inserting the post |
|
562 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
563 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
564 | + |
|
565 | + // Create/update post now |
|
566 | + $post_id = wp_insert_post( $post ); |
|
567 | + } else { |
|
568 | + // Create/update post now |
|
569 | + $post_id = wp_insert_post( $post ); |
|
570 | + } |
|
571 | + |
|
572 | + if ( ! is_numeric($post_id) ) { |
|
573 | + continue; |
|
574 | + } |
|
575 | + |
|
576 | + self::update_postmeta($post, $post_id); |
|
577 | + |
|
578 | + $this_type = 'posts'; |
|
579 | 579 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
580 | 580 | $this_type = $post_types[ $post['post_type'] ]; |
581 | - } |
|
581 | + } |
|
582 | 582 | |
583 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
584 | - $imported['updated'][ $this_type ]++; |
|
585 | - } else { |
|
586 | - $imported['imported'][ $this_type ]++; |
|
587 | - } |
|
583 | + if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
584 | + $imported['updated'][ $this_type ]++; |
|
585 | + } else { |
|
586 | + $imported['imported'][ $this_type ]++; |
|
587 | + } |
|
588 | 588 | |
589 | - unset($post); |
|
589 | + unset($post); |
|
590 | 590 | |
591 | 591 | $imported['posts'][ (int) $old_id ] = $post_id; |
592 | 592 | } |
@@ -594,16 +594,16 @@ discard block |
||
594 | 594 | self::maybe_update_stylesheet( $imported ); |
595 | 595 | |
596 | 596 | return $imported; |
597 | - } |
|
597 | + } |
|
598 | 598 | |
599 | - private static function populate_post( &$post, $item, $imported ) { |
|
599 | + private static function populate_post( &$post, $item, $imported ) { |
|
600 | 600 | if ( isset($item->attachment_url) ) { |
601 | 601 | $post['attachment_url'] = (string) $item->attachment_url; |
602 | 602 | } |
603 | 603 | |
604 | 604 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
605 | - // update to new form id |
|
606 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
605 | + // update to new form id |
|
606 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | // Don't allow default styles to take over a site's default style |
@@ -612,144 +612,144 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | foreach ( $item->postmeta as $meta ) { |
615 | - self::populate_postmeta($post, $meta, $imported); |
|
615 | + self::populate_postmeta($post, $meta, $imported); |
|
616 | 616 | unset($meta); |
617 | 617 | } |
618 | 618 | |
619 | - self::populate_taxonomies($post, $item); |
|
619 | + self::populate_taxonomies($post, $item); |
|
620 | 620 | |
621 | - self::maybe_editing_post($post); |
|
622 | - } |
|
621 | + self::maybe_editing_post($post); |
|
622 | + } |
|
623 | 623 | |
624 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
625 | - global $frm_duplicate_ids; |
|
624 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
625 | + global $frm_duplicate_ids; |
|
626 | 626 | |
627 | - $m = array( |
|
627 | + $m = array( |
|
628 | 628 | 'key' => (string) $meta->meta_key, |
629 | 629 | 'value' => (string) $meta->meta_value, |
630 | 630 | ); |
631 | 631 | |
632 | 632 | //switch old form and field ids to new ones |
633 | 633 | if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
634 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
634 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
635 | 635 | } else { |
636 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
636 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
637 | 637 | |
638 | - if ( ! empty($frm_duplicate_ids) ) { |
|
638 | + if ( ! empty($frm_duplicate_ids) ) { |
|
639 | 639 | |
640 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
641 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
642 | - } else if ( $m['key'] == 'frm_options' ) { |
|
640 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
641 | + $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
642 | + } else if ( $m['key'] == 'frm_options' ) { |
|
643 | 643 | |
644 | 644 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
645 | 645 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
646 | 646 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
647 | - } |
|
648 | - } |
|
649 | - |
|
650 | - $check_dup_array = array(); |
|
651 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
652 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
653 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
654 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
655 | - $check_dup_array[] = 'order_by'; |
|
656 | - } |
|
657 | - } |
|
658 | - |
|
659 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
660 | - $check_dup_array[] = 'where'; |
|
661 | - } |
|
662 | - |
|
663 | - foreach ( $check_dup_array as $check_k ) { |
|
647 | + } |
|
648 | + } |
|
649 | + |
|
650 | + $check_dup_array = array(); |
|
651 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
652 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
653 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
654 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
655 | + $check_dup_array[] = 'order_by'; |
|
656 | + } |
|
657 | + } |
|
658 | + |
|
659 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
660 | + $check_dup_array[] = 'where'; |
|
661 | + } |
|
662 | + |
|
663 | + foreach ( $check_dup_array as $check_k ) { |
|
664 | 664 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
665 | 665 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
666 | 666 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
667 | - } |
|
668 | - unset($mk, $mv); |
|
669 | - } |
|
670 | - } |
|
671 | - } |
|
672 | - } |
|
667 | + } |
|
668 | + unset($mk, $mv); |
|
669 | + } |
|
670 | + } |
|
671 | + } |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | if ( ! is_array($m['value']) ) { |
676 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
676 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
680 | - } |
|
681 | - |
|
682 | - /** |
|
683 | - * Add terms to post |
|
684 | - * @param array $post by reference |
|
685 | - * @param object $item The XML object data |
|
686 | - */ |
|
687 | - private static function populate_taxonomies( &$post, $item ) { |
|
680 | + } |
|
681 | + |
|
682 | + /** |
|
683 | + * Add terms to post |
|
684 | + * @param array $post by reference |
|
685 | + * @param object $item The XML object data |
|
686 | + */ |
|
687 | + private static function populate_taxonomies( &$post, $item ) { |
|
688 | 688 | foreach ( $item->category as $c ) { |
689 | 689 | $att = $c->attributes(); |
690 | 690 | if ( ! isset( $att['nicename'] ) ) { |
691 | - continue; |
|
692 | - } |
|
693 | - |
|
694 | - $taxonomy = (string) $att['domain']; |
|
695 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
696 | - $name = (string) $att['nicename']; |
|
697 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
698 | - if ( $h_term ) { |
|
699 | - $name = $h_term->term_id; |
|
700 | - } |
|
701 | - unset($h_term); |
|
702 | - } else { |
|
703 | - $name = (string) $c; |
|
704 | - } |
|
691 | + continue; |
|
692 | + } |
|
693 | + |
|
694 | + $taxonomy = (string) $att['domain']; |
|
695 | + if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
696 | + $name = (string) $att['nicename']; |
|
697 | + $h_term = get_term_by('slug', $name, $taxonomy); |
|
698 | + if ( $h_term ) { |
|
699 | + $name = $h_term->term_id; |
|
700 | + } |
|
701 | + unset($h_term); |
|
702 | + } else { |
|
703 | + $name = (string) $c; |
|
704 | + } |
|
705 | 705 | |
706 | 706 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
707 | 707 | $post['tax_input'][ $taxonomy ] = array(); |
708 | 708 | } |
709 | 709 | |
710 | 710 | $post['tax_input'][ $taxonomy ][] = $name; |
711 | - unset($name); |
|
711 | + unset($name); |
|
712 | 712 | } |
713 | - } |
|
713 | + } |
|
714 | 714 | |
715 | - /** |
|
716 | - * Edit post if the key and created time match |
|
717 | - */ |
|
718 | - private static function maybe_editing_post( &$post ) { |
|
715 | + /** |
|
716 | + * Edit post if the key and created time match |
|
717 | + */ |
|
718 | + private static function maybe_editing_post( &$post ) { |
|
719 | 719 | $match_by = array( |
720 | - 'post_type' => $post['post_type'], |
|
721 | - 'name' => $post['post_name'], |
|
722 | - 'post_status' => $post['post_status'], |
|
723 | - 'posts_per_page' => 1, |
|
720 | + 'post_type' => $post['post_type'], |
|
721 | + 'name' => $post['post_name'], |
|
722 | + 'post_status' => $post['post_status'], |
|
723 | + 'posts_per_page' => 1, |
|
724 | 724 | ); |
725 | 725 | |
726 | 726 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
727 | - $match_by['include'] = $post['post_id']; |
|
728 | - unset($match_by['name']); |
|
727 | + $match_by['include'] = $post['post_id']; |
|
728 | + unset($match_by['name']); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | $editing = get_posts($match_by); |
732 | 732 | |
733 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
734 | - // set the id of the post to edit |
|
735 | - $post['ID'] = current($editing)->ID; |
|
736 | - } |
|
737 | - } |
|
733 | + if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
734 | + // set the id of the post to edit |
|
735 | + $post['ID'] = current($editing)->ID; |
|
736 | + } |
|
737 | + } |
|
738 | 738 | |
739 | - private static function update_postmeta( &$post, $post_id ) { |
|
740 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
741 | - if ( '_edit_last' == $k ) { |
|
742 | - $v = FrmAppHelper::get_user_id_param($v); |
|
743 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
744 | - //change the attachment ID |
|
745 | - $v = FrmProXMLHelper::get_file_id($v); |
|
746 | - } |
|
739 | + private static function update_postmeta( &$post, $post_id ) { |
|
740 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
741 | + if ( '_edit_last' == $k ) { |
|
742 | + $v = FrmAppHelper::get_user_id_param($v); |
|
743 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
744 | + //change the attachment ID |
|
745 | + $v = FrmProXMLHelper::get_file_id($v); |
|
746 | + } |
|
747 | 747 | |
748 | - update_post_meta($post_id, $k, $v); |
|
748 | + update_post_meta($post_id, $k, $v); |
|
749 | 749 | |
750 | - unset($k, $v); |
|
751 | - } |
|
752 | - } |
|
750 | + unset($k, $v); |
|
751 | + } |
|
752 | + } |
|
753 | 753 | |
754 | 754 | private static function maybe_update_stylesheet( $imported ) { |
755 | 755 | $new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ); |
@@ -765,72 +765,72 @@ discard block |
||
765 | 765 | } |
766 | 766 | } |
767 | 767 | |
768 | - /** |
|
769 | - * @param string $message |
|
770 | - */ |
|
768 | + /** |
|
769 | + * @param string $message |
|
770 | + */ |
|
771 | 771 | public static function parse_message( $result, &$message, &$errors ) { |
772 | - if ( is_wp_error($result) ) { |
|
773 | - $errors[] = $result->get_error_message(); |
|
774 | - } else if ( ! $result ) { |
|
775 | - return; |
|
776 | - } |
|
777 | - |
|
778 | - if ( ! is_array($result) ) { |
|
779 | - $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
780 | - return; |
|
781 | - } |
|
782 | - |
|
783 | - $t_strings = array( |
|
784 | - 'imported' => __( 'Imported', 'formidable' ), |
|
785 | - 'updated' => __( 'Updated', 'formidable' ), |
|
786 | - ); |
|
787 | - |
|
788 | - $message = '<ul>'; |
|
789 | - foreach ( $result as $type => $results ) { |
|
772 | + if ( is_wp_error($result) ) { |
|
773 | + $errors[] = $result->get_error_message(); |
|
774 | + } else if ( ! $result ) { |
|
775 | + return; |
|
776 | + } |
|
777 | + |
|
778 | + if ( ! is_array($result) ) { |
|
779 | + $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
780 | + return; |
|
781 | + } |
|
782 | + |
|
783 | + $t_strings = array( |
|
784 | + 'imported' => __( 'Imported', 'formidable' ), |
|
785 | + 'updated' => __( 'Updated', 'formidable' ), |
|
786 | + ); |
|
787 | + |
|
788 | + $message = '<ul>'; |
|
789 | + foreach ( $result as $type => $results ) { |
|
790 | 790 | if ( ! isset( $t_strings[ $type ] ) ) { |
791 | - // only print imported and updated |
|
792 | - continue; |
|
793 | - } |
|
791 | + // only print imported and updated |
|
792 | + continue; |
|
793 | + } |
|
794 | 794 | |
795 | - $s_message = array(); |
|
796 | - foreach ( $results as $k => $m ) { |
|
797 | - self::item_count_message($m, $k, $s_message); |
|
798 | - unset($k, $m); |
|
799 | - } |
|
795 | + $s_message = array(); |
|
796 | + foreach ( $results as $k => $m ) { |
|
797 | + self::item_count_message($m, $k, $s_message); |
|
798 | + unset($k, $m); |
|
799 | + } |
|
800 | 800 | |
801 | - if ( ! empty($s_message) ) { |
|
801 | + if ( ! empty($s_message) ) { |
|
802 | 802 | $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
803 | - $message .= implode(', ', $s_message); |
|
804 | - $message .= '</li>'; |
|
805 | - } |
|
806 | - } |
|
807 | - |
|
808 | - if ( $message == '<ul>' ) { |
|
809 | - $message = ''; |
|
810 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
811 | - } else { |
|
812 | - $message .= '</ul>'; |
|
813 | - } |
|
814 | - } |
|
803 | + $message .= implode(', ', $s_message); |
|
804 | + $message .= '</li>'; |
|
805 | + } |
|
806 | + } |
|
807 | + |
|
808 | + if ( $message == '<ul>' ) { |
|
809 | + $message = ''; |
|
810 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
811 | + } else { |
|
812 | + $message .= '</ul>'; |
|
813 | + } |
|
814 | + } |
|
815 | 815 | |
816 | 816 | public static function item_count_message( $m, $type, &$s_message ) { |
817 | - if ( ! $m ) { |
|
818 | - return; |
|
819 | - } |
|
820 | - |
|
821 | - $strings = array( |
|
822 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
823 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
824 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
825 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
826 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
827 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
828 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
829 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
830 | - ); |
|
817 | + if ( ! $m ) { |
|
818 | + return; |
|
819 | + } |
|
820 | + |
|
821 | + $strings = array( |
|
822 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
823 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
824 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
825 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
826 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
827 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
828 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
829 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
830 | + ); |
|
831 | 831 | |
832 | 832 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
833 | - } |
|
833 | + } |
|
834 | 834 | |
835 | 835 | /** |
836 | 836 | * Prepare the form options for export |
@@ -861,16 +861,16 @@ discard block |
||
861 | 861 | } |
862 | 862 | |
863 | 863 | public static function cdata( $str ) { |
864 | - $str = maybe_unserialize($str); |
|
865 | - if ( is_array($str) ) { |
|
866 | - $str = json_encode($str); |
|
864 | + $str = maybe_unserialize($str); |
|
865 | + if ( is_array($str) ) { |
|
866 | + $str = json_encode($str); |
|
867 | 867 | } else if ( seems_utf8( $str ) == false ) { |
868 | 868 | $str = utf8_encode( $str ); |
869 | 869 | } |
870 | 870 | |
871 | - if ( is_numeric($str) ) { |
|
872 | - return $str; |
|
873 | - } |
|
871 | + if ( is_numeric($str) ) { |
|
872 | + return $str; |
|
873 | + } |
|
874 | 874 | |
875 | 875 | self::remove_invalid_characters_from_xml( $str ); |
876 | 876 | |
@@ -891,58 +891,58 @@ discard block |
||
891 | 891 | $str = str_replace( '\x1F', '', $str ); |
892 | 892 | } |
893 | 893 | |
894 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
895 | - // Get post type |
|
896 | - $post_type = FrmFormActionsController::$action_post_type; |
|
897 | - |
|
898 | - // Set up imported index, if not set up yet |
|
899 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
900 | - $imported['imported']['actions'] = 0; |
|
901 | - } |
|
902 | - |
|
903 | - // Migrate post settings to action |
|
904 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
905 | - |
|
906 | - // Migrate email settings to action |
|
907 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
908 | - } |
|
909 | - |
|
910 | - /** |
|
911 | - * Migrate post settings to form action |
|
912 | - * |
|
913 | - * @param string $post_type |
|
914 | - */ |
|
915 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
916 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
917 | - return; |
|
918 | - } |
|
919 | - |
|
920 | - $new_action = array( |
|
921 | - 'post_type' => $post_type, |
|
922 | - 'post_excerpt' => 'wppost', |
|
894 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
895 | + // Get post type |
|
896 | + $post_type = FrmFormActionsController::$action_post_type; |
|
897 | + |
|
898 | + // Set up imported index, if not set up yet |
|
899 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
900 | + $imported['imported']['actions'] = 0; |
|
901 | + } |
|
902 | + |
|
903 | + // Migrate post settings to action |
|
904 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
905 | + |
|
906 | + // Migrate email settings to action |
|
907 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
908 | + } |
|
909 | + |
|
910 | + /** |
|
911 | + * Migrate post settings to form action |
|
912 | + * |
|
913 | + * @param string $post_type |
|
914 | + */ |
|
915 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
916 | + if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
917 | + return; |
|
918 | + } |
|
919 | + |
|
920 | + $new_action = array( |
|
921 | + 'post_type' => $post_type, |
|
922 | + 'post_excerpt' => 'wppost', |
|
923 | 923 | 'post_title' => __( 'Create Posts', 'formidable' ), |
924 | - 'menu_order' => $form_id, |
|
925 | - 'post_status' => 'publish', |
|
926 | - 'post_content' => array(), |
|
924 | + 'menu_order' => $form_id, |
|
925 | + 'post_status' => 'publish', |
|
926 | + 'post_content' => array(), |
|
927 | 927 | 'post_name' => $form_id . '_wppost_1', |
928 | - ); |
|
928 | + ); |
|
929 | 929 | |
930 | - $post_settings = array( |
|
931 | - 'post_type', 'post_category', 'post_content', |
|
932 | - 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
930 | + $post_settings = array( |
|
931 | + 'post_type', 'post_category', 'post_content', |
|
932 | + 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
933 | 933 | 'post_status', 'post_custom_fields', 'post_password', |
934 | - ); |
|
934 | + ); |
|
935 | 935 | |
936 | - foreach ( $post_settings as $post_setting ) { |
|
936 | + foreach ( $post_settings as $post_setting ) { |
|
937 | 937 | if ( isset( $form_options[ $post_setting ] ) ) { |
938 | 938 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
939 | - } |
|
940 | - unset($post_setting); |
|
941 | - } |
|
939 | + } |
|
940 | + unset($post_setting); |
|
941 | + } |
|
942 | 942 | |
943 | 943 | $new_action['event'] = array( 'create', 'update' ); |
944 | 944 | |
945 | - if ( $switch ) { |
|
945 | + if ( $switch ) { |
|
946 | 946 | // Fields with string or int saved |
947 | 947 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
948 | 948 | |
@@ -950,22 +950,22 @@ discard block |
||
950 | 950 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
951 | 951 | |
952 | 952 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
953 | - } |
|
954 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
953 | + } |
|
954 | + $new_action['post_content'] = json_encode($new_action['post_content']); |
|
955 | 955 | |
956 | - $exists = get_posts( array( |
|
957 | - 'name' => $new_action['post_name'], |
|
958 | - 'post_type' => $new_action['post_type'], |
|
959 | - 'post_status' => $new_action['post_status'], |
|
960 | - 'numberposts' => 1, |
|
961 | - ) ); |
|
956 | + $exists = get_posts( array( |
|
957 | + 'name' => $new_action['post_name'], |
|
958 | + 'post_type' => $new_action['post_type'], |
|
959 | + 'post_status' => $new_action['post_status'], |
|
960 | + 'numberposts' => 1, |
|
961 | + ) ); |
|
962 | 962 | |
963 | - if ( ! $exists ) { |
|
963 | + if ( ! $exists ) { |
|
964 | 964 | // this isn't an email, but we need to use a class that will always be included |
965 | 965 | FrmAppHelper::save_json_post( $new_action ); |
966 | - $imported['imported']['actions']++; |
|
967 | - } |
|
968 | - } |
|
966 | + $imported['imported']['actions']++; |
|
967 | + } |
|
968 | + } |
|
969 | 969 | |
970 | 970 | /** |
971 | 971 | * Switch old field IDs for new field IDs in emails and post |
@@ -978,211 +978,211 @@ discard block |
||
978 | 978 | * @return string $post_content - new field IDs |
979 | 979 | */ |
980 | 980 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
981 | - global $frm_duplicate_ids; |
|
981 | + global $frm_duplicate_ids; |
|
982 | 982 | |
983 | - // If there aren't IDs that were switched, end now |
|
984 | - if ( ! $frm_duplicate_ids ) { |
|
985 | - return; |
|
986 | - } |
|
983 | + // If there aren't IDs that were switched, end now |
|
984 | + if ( ! $frm_duplicate_ids ) { |
|
985 | + return; |
|
986 | + } |
|
987 | 987 | |
988 | - // Get old IDs |
|
989 | - $old = array_keys( $frm_duplicate_ids ); |
|
988 | + // Get old IDs |
|
989 | + $old = array_keys( $frm_duplicate_ids ); |
|
990 | 990 | |
991 | - // Get new IDs |
|
992 | - $new = array_values( $frm_duplicate_ids ); |
|
991 | + // Get new IDs |
|
992 | + $new = array_values( $frm_duplicate_ids ); |
|
993 | 993 | |
994 | - // Do a str_replace with each item to set the new IDs |
|
995 | - foreach ( $post_content as $key => $setting ) { |
|
996 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
997 | - // Replace old IDs with new IDs |
|
994 | + // Do a str_replace with each item to set the new IDs |
|
995 | + foreach ( $post_content as $key => $setting ) { |
|
996 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
997 | + // Replace old IDs with new IDs |
|
998 | 998 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
999 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
1000 | - foreach ( $setting as $k => $val ) { |
|
1001 | - // Replace old IDs with new IDs |
|
999 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
1000 | + foreach ( $setting as $k => $val ) { |
|
1001 | + // Replace old IDs with new IDs |
|
1002 | 1002 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
1003 | - } |
|
1004 | - } |
|
1005 | - unset( $key, $setting ); |
|
1006 | - } |
|
1007 | - return $post_content; |
|
1008 | - } |
|
1009 | - |
|
1010 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
1011 | - // No old notifications or autoresponders to carry over |
|
1003 | + } |
|
1004 | + } |
|
1005 | + unset( $key, $setting ); |
|
1006 | + } |
|
1007 | + return $post_content; |
|
1008 | + } |
|
1009 | + |
|
1010 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
1011 | + // No old notifications or autoresponders to carry over |
|
1012 | 1012 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
1013 | - return; |
|
1014 | - } |
|
1013 | + return; |
|
1014 | + } |
|
1015 | 1015 | |
1016 | - // Initialize notifications array |
|
1017 | - $notifications = array(); |
|
1016 | + // Initialize notifications array |
|
1017 | + $notifications = array(); |
|
1018 | 1018 | |
1019 | - // Migrate regular notifications |
|
1020 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
1019 | + // Migrate regular notifications |
|
1020 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
1021 | 1021 | |
1022 | - // Migrate autoresponders |
|
1023 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
1022 | + // Migrate autoresponders |
|
1023 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
1024 | 1024 | |
1025 | - if ( empty( $notifications ) ) { |
|
1026 | - return; |
|
1027 | - } |
|
1025 | + if ( empty( $notifications ) ) { |
|
1026 | + return; |
|
1027 | + } |
|
1028 | 1028 | |
1029 | - foreach ( $notifications as $new_notification ) { |
|
1030 | - $new_notification['post_type'] = $post_type; |
|
1031 | - $new_notification['post_excerpt'] = 'email'; |
|
1029 | + foreach ( $notifications as $new_notification ) { |
|
1030 | + $new_notification['post_type'] = $post_type; |
|
1031 | + $new_notification['post_excerpt'] = 'email'; |
|
1032 | 1032 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
1033 | - $new_notification['menu_order'] = $form_id; |
|
1034 | - $new_notification['post_status'] = 'publish'; |
|
1033 | + $new_notification['menu_order'] = $form_id; |
|
1034 | + $new_notification['post_status'] = 'publish'; |
|
1035 | 1035 | |
1036 | - // Switch field IDs and keys, if needed |
|
1037 | - if ( $switch ) { |
|
1036 | + // Switch field IDs and keys, if needed |
|
1037 | + if ( $switch ) { |
|
1038 | 1038 | |
1039 | 1039 | // Switch field IDs in email conditional logic |
1040 | 1040 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
1041 | 1041 | |
1042 | 1042 | // Switch all other field IDs in email |
1043 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
1044 | - } |
|
1045 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1046 | - |
|
1047 | - $exists = get_posts( array( |
|
1048 | - 'name' => $new_notification['post_name'], |
|
1049 | - 'post_type' => $new_notification['post_type'], |
|
1050 | - 'post_status' => $new_notification['post_status'], |
|
1051 | - 'numberposts' => 1, |
|
1052 | - ) ); |
|
1053 | - |
|
1054 | - if ( empty($exists) ) { |
|
1043 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
1044 | + } |
|
1045 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1046 | + |
|
1047 | + $exists = get_posts( array( |
|
1048 | + 'name' => $new_notification['post_name'], |
|
1049 | + 'post_type' => $new_notification['post_type'], |
|
1050 | + 'post_status' => $new_notification['post_status'], |
|
1051 | + 'numberposts' => 1, |
|
1052 | + ) ); |
|
1053 | + |
|
1054 | + if ( empty($exists) ) { |
|
1055 | 1055 | FrmAppHelper::save_json_post( $new_notification ); |
1056 | - $imported['imported']['actions']++; |
|
1057 | - } |
|
1058 | - unset($new_notification); |
|
1059 | - } |
|
1060 | - } |
|
1061 | - |
|
1062 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
1063 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
1064 | - // add old settings into notification array |
|
1056 | + $imported['imported']['actions']++; |
|
1057 | + } |
|
1058 | + unset($new_notification); |
|
1059 | + } |
|
1060 | + } |
|
1061 | + |
|
1062 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
1063 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
1064 | + // add old settings into notification array |
|
1065 | 1065 | $form_options['notification'] = array( 0 => $form_options ); |
1066 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
1067 | - // make sure it's in the correct format |
|
1066 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
1067 | + // make sure it's in the correct format |
|
1068 | 1068 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
1069 | - } |
|
1069 | + } |
|
1070 | 1070 | |
1071 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1072 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
1071 | + if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1072 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
1073 | 1073 | |
1074 | - $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
1074 | + $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
1075 | 1075 | |
1076 | - // Format the email data |
|
1077 | - self::format_email_data( $atts, $notification ); |
|
1076 | + // Format the email data |
|
1077 | + self::format_email_data( $atts, $notification ); |
|
1078 | 1078 | |
1079 | 1079 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
1080 | 1080 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - // Setup the new notification |
|
1084 | - $new_notification = array(); |
|
1085 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
1083 | + // Setup the new notification |
|
1084 | + $new_notification = array(); |
|
1085 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
1086 | 1086 | |
1087 | - $notifications[] = $new_notification; |
|
1088 | - } |
|
1089 | - } |
|
1090 | - } |
|
1087 | + $notifications[] = $new_notification; |
|
1088 | + } |
|
1089 | + } |
|
1090 | + } |
|
1091 | 1091 | |
1092 | - private static function format_email_data( &$atts, $notification ) { |
|
1093 | - // Format email_to |
|
1094 | - self::format_email_to_data( $atts, $notification ); |
|
1092 | + private static function format_email_data( &$atts, $notification ) { |
|
1093 | + // Format email_to |
|
1094 | + self::format_email_to_data( $atts, $notification ); |
|
1095 | 1095 | |
1096 | - // Format the reply to email and name |
|
1097 | - $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
1098 | - foreach ( $reply_fields as $f => $val ) { |
|
1096 | + // Format the reply to email and name |
|
1097 | + $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
1098 | + foreach ( $reply_fields as $f => $val ) { |
|
1099 | 1099 | if ( isset( $notification[ $f ] ) ) { |
1100 | 1100 | $atts[ $f ] = $notification[ $f ]; |
1101 | 1101 | if ( 'custom' == $notification[ $f ] ) { |
1102 | 1102 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
1103 | 1103 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
1104 | 1104 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
1105 | - } |
|
1106 | - } |
|
1107 | - unset( $f, $val ); |
|
1108 | - } |
|
1105 | + } |
|
1106 | + } |
|
1107 | + unset( $f, $val ); |
|
1108 | + } |
|
1109 | 1109 | |
1110 | - // Format event |
|
1110 | + // Format event |
|
1111 | 1111 | $atts['event'] = array( 'create' ); |
1112 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
1113 | - $atts['event'][] = 'update'; |
|
1114 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1112 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
1113 | + $atts['event'][] = 'update'; |
|
1114 | + } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1115 | 1115 | $atts['event'] = array( 'update' ); |
1116 | - } |
|
1117 | - } |
|
1116 | + } |
|
1117 | + } |
|
1118 | 1118 | |
1119 | - private static function format_email_to_data( &$atts, $notification ) { |
|
1120 | - if ( isset( $notification['email_to'] ) ) { |
|
1119 | + private static function format_email_to_data( &$atts, $notification ) { |
|
1120 | + if ( isset( $notification['email_to'] ) ) { |
|
1121 | 1121 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
1122 | - } else { |
|
1123 | - $atts['email_to'] = array(); |
|
1124 | - } |
|
1122 | + } else { |
|
1123 | + $atts['email_to'] = array(); |
|
1124 | + } |
|
1125 | 1125 | |
1126 | - if ( isset( $notification['also_email_to'] ) ) { |
|
1127 | - $email_fields = (array) $notification['also_email_to']; |
|
1128 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
1129 | - unset( $email_fields ); |
|
1130 | - } |
|
1126 | + if ( isset( $notification['also_email_to'] ) ) { |
|
1127 | + $email_fields = (array) $notification['also_email_to']; |
|
1128 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
1129 | + unset( $email_fields ); |
|
1130 | + } |
|
1131 | 1131 | |
1132 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
1132 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
1133 | 1133 | |
1134 | - if ( is_numeric( $email_field ) ) { |
|
1134 | + if ( is_numeric( $email_field ) ) { |
|
1135 | 1135 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
1136 | - } |
|
1136 | + } |
|
1137 | 1137 | |
1138 | - if ( strpos( $email_field, '|') ) { |
|
1139 | - $email_opt = explode( '|', $email_field ); |
|
1140 | - if ( isset( $email_opt[0] ) ) { |
|
1138 | + if ( strpos( $email_field, '|') ) { |
|
1139 | + $email_opt = explode( '|', $email_field ); |
|
1140 | + if ( isset( $email_opt[0] ) ) { |
|
1141 | 1141 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
1142 | - } |
|
1143 | - unset( $email_opt ); |
|
1144 | - } |
|
1145 | - } |
|
1146 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1147 | - } |
|
1148 | - |
|
1149 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
1150 | - // Set up new notification |
|
1151 | - $new_notification = array( |
|
1152 | - 'post_content' => array( |
|
1153 | - 'email_to' => $atts['email_to'], |
|
1154 | - 'event' => $atts['event'], |
|
1155 | - ), |
|
1142 | + } |
|
1143 | + unset( $email_opt ); |
|
1144 | + } |
|
1145 | + } |
|
1146 | + $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1147 | + } |
|
1148 | + |
|
1149 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
1150 | + // Set up new notification |
|
1151 | + $new_notification = array( |
|
1152 | + 'post_content' => array( |
|
1153 | + 'email_to' => $atts['email_to'], |
|
1154 | + 'event' => $atts['event'], |
|
1155 | + ), |
|
1156 | 1156 | 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
1157 | - ); |
|
1157 | + ); |
|
1158 | 1158 | |
1159 | - // Add more fields to the new notification |
|
1160 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
1161 | - foreach ( $add_fields as $add_field ) { |
|
1159 | + // Add more fields to the new notification |
|
1160 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
1161 | + foreach ( $add_fields as $add_field ) { |
|
1162 | 1162 | if ( isset( $notification[ $add_field ] ) ) { |
1163 | 1163 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
1164 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
1164 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
1165 | 1165 | $new_notification['post_content'][ $add_field ] = 0; |
1166 | - } else { |
|
1166 | + } else { |
|
1167 | 1167 | $new_notification['post_content'][ $add_field ] = ''; |
1168 | - } |
|
1169 | - unset( $add_field ); |
|
1170 | - } |
|
1168 | + } |
|
1169 | + unset( $add_field ); |
|
1170 | + } |
|
1171 | 1171 | |
1172 | 1172 | // Set reply to |
1173 | 1173 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
1174 | 1174 | |
1175 | - // Set from |
|
1175 | + // Set from |
|
1176 | 1176 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
1177 | 1177 | $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
1178 | - } |
|
1179 | - } |
|
1178 | + } |
|
1179 | + } |
|
1180 | 1180 | |
1181 | 1181 | /** |
1182 | - * Switch field IDs in pre-2.0 email conditional logic |
|
1183 | - * |
|
1184 | - * @param $post_content array, pass by reference |
|
1185 | - */ |
|
1182 | + * Switch field IDs in pre-2.0 email conditional logic |
|
1183 | + * |
|
1184 | + * @param $post_content array, pass by reference |
|
1185 | + */ |
|
1186 | 1186 | private static function switch_email_contition_field_ids( &$post_content ) { |
1187 | 1187 | // Switch field IDs in conditional logic |
1188 | 1188 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1195,36 +1195,36 @@ discard block |
||
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
1198 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
1199 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1200 | - // migrate autoresponder |
|
1201 | - |
|
1202 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1203 | - if ( strpos($email_field, '|') ) { |
|
1204 | - // data from entries field |
|
1205 | - $email_field = explode('|', $email_field); |
|
1206 | - if ( isset($email_field[1]) ) { |
|
1207 | - $email_field = $email_field[1]; |
|
1208 | - } |
|
1209 | - } |
|
1210 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1198 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
1199 | + if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1200 | + // migrate autoresponder |
|
1201 | + |
|
1202 | + $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1203 | + if ( strpos($email_field, '|') ) { |
|
1204 | + // data from entries field |
|
1205 | + $email_field = explode('|', $email_field); |
|
1206 | + if ( isset($email_field[1]) ) { |
|
1207 | + $email_field = $email_field[1]; |
|
1208 | + } |
|
1209 | + } |
|
1210 | + if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1211 | 1211 | $email_field = '[' . $email_field . ']'; |
1212 | - } |
|
1213 | - |
|
1214 | - $notification = $form_options; |
|
1215 | - $new_notification2 = array( |
|
1216 | - 'post_content' => array( |
|
1217 | - 'email_message' => $notification['ar_email_message'], |
|
1218 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1219 | - 'email_to' => $email_field, |
|
1220 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1221 | - 'inc_user_info' => 0, |
|
1222 | - ), |
|
1212 | + } |
|
1213 | + |
|
1214 | + $notification = $form_options; |
|
1215 | + $new_notification2 = array( |
|
1216 | + 'post_content' => array( |
|
1217 | + 'email_message' => $notification['ar_email_message'], |
|
1218 | + 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1219 | + 'email_to' => $email_field, |
|
1220 | + 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1221 | + 'inc_user_info' => 0, |
|
1222 | + ), |
|
1223 | 1223 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
1224 | - ); |
|
1224 | + ); |
|
1225 | 1225 | |
1226 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1227 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1226 | + $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1227 | + $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1228 | 1228 | |
1229 | 1229 | if ( ! empty( $reply_to ) ) { |
1230 | 1230 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -1234,9 +1234,9 @@ discard block |
||
1234 | 1234 | $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | - $notifications[] = $new_notification2; |
|
1238 | - unset( $new_notification2 ); |
|
1239 | - } |
|
1240 | - } |
|
1237 | + $notifications[] = $new_notification2; |
|
1238 | + unset( $new_notification2 ); |
|
1239 | + } |
|
1240 | + } |
|
1241 | 1241 | } |
1242 | 1242 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | 'terms' => array(), |
37 | 37 | ); |
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset( $defaults ); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
42 | + define( 'WP_IMPORTING', true ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
55 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
57 | 57 | } |
58 | 58 | |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | 69 | // grab cats, tags, and terms, or forms or posts |
70 | - if ( isset($xml->{$item_type} ) ) { |
|
70 | + if ( isset( $xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | 79 | return $return; |
80 | 80 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | 'slug' => (string) $t->term_slug, |
92 | 92 | 'description' => (string) $t->term_description, |
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | - )); |
|
94 | + ) ); |
|
95 | 95 | |
96 | 96 | if ( $term && is_array( $term ) ) { |
97 | - $imported['imported']['terms']++; |
|
98 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
97 | + $imported['imported']['terms'] ++; |
|
98 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | unset( $term, $t ); |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | } else { |
145 | 145 | $form_id = FrmForm::create( $form ); |
146 | 146 | if ( $form_id ) { |
147 | - $imported['imported']['forms']++; |
|
147 | + $imported['imported']['forms'] ++; |
|
148 | 148 | // Keep track of whether this specific form was updated or not |
149 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
149 | + $imported['form_status'][$form_id] = 'imported'; |
|
150 | 150 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
151 | 151 | } |
152 | 152 | } |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | // Update field ids/keys to new ones |
159 | 159 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
160 | 160 | |
161 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
161 | + $imported['forms'][(int) $item->id] = $form_id; |
|
162 | 162 | |
163 | 163 | // Send pre 2.0 form options through function that creates actions |
164 | 164 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
165 | 165 | |
166 | 166 | do_action( 'frm_after_import_form', $form_id, $form ); |
167 | 167 | |
168 | - unset($form, $item); |
|
168 | + unset( $form, $item ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | private static function update_form( $this_form, $form, &$imported ) { |
208 | 208 | $form_id = $this_form->id; |
209 | 209 | FrmForm::update( $form_id, $form ); |
210 | - $imported['updated']['forms']++; |
|
210 | + $imported['updated']['forms'] ++; |
|
211 | 211 | // Keep track of whether this specific form was updated or not |
212 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
212 | + $imported['form_status'][$form_id] = 'updated'; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | private static function get_form_fields( $form_id ) { |
216 | 216 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
217 | 217 | $old_fields = array(); |
218 | 218 | foreach ( $form_fields as $f ) { |
219 | - $old_fields[ $f->id ] = $f; |
|
220 | - $old_fields[ $f->field_key ] = $f->id; |
|
221 | - unset($f); |
|
219 | + $old_fields[$f->id] = $f; |
|
220 | + $old_fields[$f->field_key] = $f->id; |
|
221 | + unset( $f ); |
|
222 | 222 | } |
223 | 223 | $form_fields = $old_fields; |
224 | 224 | return $form_fields; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $regular_forms = array(); |
250 | 250 | |
251 | 251 | foreach ( $forms as $form ) { |
252 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
252 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
253 | 253 | |
254 | 254 | if ( $parent_form_id ) { |
255 | 255 | $child_forms[] = $form; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
273 | 273 | if ( $parent_form_id ) { |
274 | - $child_forms[ $form_id ] = $parent_form_id; |
|
274 | + $child_forms[$form_id] = $parent_form_id; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
287 | 287 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
288 | 288 | |
289 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
289 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
290 | 290 | // Update all children with this old parent_form_id |
291 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
291 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
292 | 292 | |
293 | 293 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
294 | 294 | } |
@@ -307,15 +307,15 @@ discard block |
||
307 | 307 | foreach ( $xml_fields as $field ) { |
308 | 308 | $f = self::fill_field( $field, $form_id ); |
309 | 309 | |
310 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
310 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
311 | 311 | 'text', 'email', 'url', 'textarea', |
312 | - 'number','phone', 'date', 'time', |
|
312 | + 'number', 'phone', 'date', 'time', |
|
313 | 313 | 'hidden', 'password', 'tag', 'image', |
314 | - )) ) { |
|
315 | - if ( count($f['default_value']) === 1 ) { |
|
314 | + ) ) ) { |
|
315 | + if ( count( $f['default_value'] ) === 1 ) { |
|
316 | 316 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
317 | 317 | } else { |
318 | - $f['default_value'] = reset($f['default_value']); |
|
318 | + $f['default_value'] = reset( $f['default_value'] ); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,27 +323,27 @@ discard block |
||
323 | 323 | self::maybe_update_form_select( $f, $imported ); |
324 | 324 | self::maybe_update_get_values_form_setting( $imported, $f ); |
325 | 325 | |
326 | - if ( ! empty($this_form) ) { |
|
326 | + if ( ! empty( $this_form ) ) { |
|
327 | 327 | // check for field to edit by field id |
328 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
328 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
329 | 329 | FrmField::update( $f['id'], $f ); |
330 | - $imported['updated']['fields']++; |
|
330 | + $imported['updated']['fields'] ++; |
|
331 | 331 | |
332 | - unset( $form_fields[ $f['id'] ] ); |
|
332 | + unset( $form_fields[$f['id']] ); |
|
333 | 333 | |
334 | 334 | //unset old field key |
335 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
336 | - unset( $form_fields[ $f['field_key'] ] ); |
|
335 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
336 | + unset( $form_fields[$f['field_key']] ); |
|
337 | 337 | } |
338 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
338 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
339 | 339 | // check for field to edit by field key |
340 | - unset($f['id']); |
|
340 | + unset( $f['id'] ); |
|
341 | 341 | |
342 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
343 | - $imported['updated']['fields']++; |
|
342 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
343 | + $imported['updated']['fields'] ++; |
|
344 | 344 | |
345 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
346 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
345 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
346 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
347 | 347 | } else { |
348 | 348 | // if no matching field id or key in this form, create the field |
349 | 349 | self::create_imported_field( $f, $imported ); |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | 'name' => (string) $field->name, |
363 | 363 | 'description' => (string) $field->description, |
364 | 364 | 'type' => (string) $field->type, |
365 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
365 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
366 | 366 | 'field_order' => (int) $field->field_order, |
367 | 367 | 'form_id' => (int) $form_id, |
368 | 368 | 'required' => (int) $field->required, |
369 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
369 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
370 | 370 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
371 | 371 | ); |
372 | 372 | } |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
411 | 411 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
412 | 412 | $form_select = $f['field_options']['form_select']; |
413 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
414 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
413 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
414 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | } |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | |
432 | 432 | if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) { |
433 | 433 | $old_form = $f['field_options']['get_values_form']; |
434 | - if ( isset( $imported['forms'][ $old_form ] ) ) { |
|
435 | - $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ]; |
|
434 | + if ( isset( $imported['forms'][$old_form] ) ) { |
|
435 | + $f['field_options']['get_values_form'] = $imported['forms'][$old_form]; |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | private static function create_imported_field( $f, &$imported ) { |
448 | 448 | $new_id = FrmField::create( $f ); |
449 | 449 | if ( $new_id != false ) { |
450 | - $imported['imported']['fields']++; |
|
450 | + $imported['imported']['fields'] ++; |
|
451 | 451 | do_action( 'frm_after_field_is_imported', $f, $new_id ); |
452 | 452 | } |
453 | 453 | } |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | ); |
547 | 547 | |
548 | 548 | $old_id = $post['post_id']; |
549 | - self::populate_post($post, $item, $imported); |
|
549 | + self::populate_post( $post, $item, $imported ); |
|
550 | 550 | |
551 | - unset($item); |
|
551 | + unset( $item ); |
|
552 | 552 | |
553 | 553 | $post_id = false; |
554 | 554 | if ( $post['post_type'] == $form_action_type ) { |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | if ( $action_control && is_object( $action_control ) ) { |
557 | 557 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
558 | 558 | } |
559 | - unset($action_control); |
|
559 | + unset( $action_control ); |
|
560 | 560 | } else if ( $post['post_type'] == 'frm_styles' ) { |
561 | 561 | // Properly encode post content before inserting the post |
562 | 562 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -569,26 +569,26 @@ discard block |
||
569 | 569 | $post_id = wp_insert_post( $post ); |
570 | 570 | } |
571 | 571 | |
572 | - if ( ! is_numeric($post_id) ) { |
|
572 | + if ( ! is_numeric( $post_id ) ) { |
|
573 | 573 | continue; |
574 | 574 | } |
575 | 575 | |
576 | - self::update_postmeta($post, $post_id); |
|
576 | + self::update_postmeta( $post, $post_id ); |
|
577 | 577 | |
578 | 578 | $this_type = 'posts'; |
579 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
580 | - $this_type = $post_types[ $post['post_type'] ]; |
|
579 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
580 | + $this_type = $post_types[$post['post_type']]; |
|
581 | 581 | } |
582 | 582 | |
583 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
584 | - $imported['updated'][ $this_type ]++; |
|
583 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
584 | + $imported['updated'][$this_type] ++; |
|
585 | 585 | } else { |
586 | - $imported['imported'][ $this_type ]++; |
|
586 | + $imported['imported'][$this_type] ++; |
|
587 | 587 | } |
588 | 588 | |
589 | - unset($post); |
|
589 | + unset( $post ); |
|
590 | 590 | |
591 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
591 | + $imported['posts'][(int) $old_id] = $post_id; |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | self::maybe_update_stylesheet( $imported ); |
@@ -597,13 +597,13 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | private static function populate_post( &$post, $item, $imported ) { |
600 | - if ( isset($item->attachment_url) ) { |
|
600 | + if ( isset( $item->attachment_url ) ) { |
|
601 | 601 | $post['attachment_url'] = (string) $item->attachment_url; |
602 | 602 | } |
603 | 603 | |
604 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
604 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
605 | 605 | // update to new form id |
606 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
606 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | // Don't allow default styles to take over a site's default style |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | foreach ( $item->postmeta as $meta ) { |
615 | - self::populate_postmeta($post, $meta, $imported); |
|
616 | - unset($meta); |
|
615 | + self::populate_postmeta( $post, $meta, $imported ); |
|
616 | + unset( $meta ); |
|
617 | 617 | } |
618 | 618 | |
619 | - self::populate_taxonomies($post, $item); |
|
619 | + self::populate_taxonomies( $post, $item ); |
|
620 | 620 | |
621 | - self::maybe_editing_post($post); |
|
621 | + self::maybe_editing_post( $post ); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -630,27 +630,27 @@ discard block |
||
630 | 630 | ); |
631 | 631 | |
632 | 632 | //switch old form and field ids to new ones |
633 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
634 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
633 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
634 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
635 | 635 | } else { |
636 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
636 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
637 | 637 | |
638 | - if ( ! empty($frm_duplicate_ids) ) { |
|
638 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
639 | 639 | |
640 | 640 | if ( $m['key'] == 'frm_dyncontent' ) { |
641 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
641 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
642 | 642 | } else if ( $m['key'] == 'frm_options' ) { |
643 | 643 | |
644 | 644 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
645 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
646 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
645 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
646 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | |
650 | 650 | $check_dup_array = array(); |
651 | 651 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
652 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
653 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
652 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
653 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
654 | 654 | } else if ( is_array( $m['value']['order_by'] ) ) { |
655 | 655 | $check_dup_array[] = 'order_by'; |
656 | 656 | } |
@@ -661,22 +661,22 @@ discard block |
||
661 | 661 | } |
662 | 662 | |
663 | 663 | foreach ( $check_dup_array as $check_k ) { |
664 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
665 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
666 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
664 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
665 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
666 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
667 | 667 | } |
668 | - unset($mk, $mv); |
|
668 | + unset( $mk, $mv ); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | } |
672 | 672 | } |
673 | 673 | } |
674 | 674 | |
675 | - if ( ! is_array($m['value']) ) { |
|
676 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
675 | + if ( ! is_array( $m['value'] ) ) { |
|
676 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
677 | 677 | } |
678 | 678 | |
679 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
679 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -692,23 +692,23 @@ discard block |
||
692 | 692 | } |
693 | 693 | |
694 | 694 | $taxonomy = (string) $att['domain']; |
695 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
695 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
696 | 696 | $name = (string) $att['nicename']; |
697 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
697 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
698 | 698 | if ( $h_term ) { |
699 | 699 | $name = $h_term->term_id; |
700 | 700 | } |
701 | - unset($h_term); |
|
701 | + unset( $h_term ); |
|
702 | 702 | } else { |
703 | 703 | $name = (string) $c; |
704 | 704 | } |
705 | 705 | |
706 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
707 | - $post['tax_input'][ $taxonomy ] = array(); |
|
706 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
707 | + $post['tax_input'][$taxonomy] = array(); |
|
708 | 708 | } |
709 | 709 | |
710 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
711 | - unset($name); |
|
710 | + $post['tax_input'][$taxonomy][] = $name; |
|
711 | + unset( $name ); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
@@ -725,29 +725,29 @@ discard block |
||
725 | 725 | |
726 | 726 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
727 | 727 | $match_by['include'] = $post['post_id']; |
728 | - unset($match_by['name']); |
|
728 | + unset( $match_by['name'] ); |
|
729 | 729 | } |
730 | 730 | |
731 | - $editing = get_posts($match_by); |
|
731 | + $editing = get_posts( $match_by ); |
|
732 | 732 | |
733 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
733 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
734 | 734 | // set the id of the post to edit |
735 | - $post['ID'] = current($editing)->ID; |
|
735 | + $post['ID'] = current( $editing )->ID; |
|
736 | 736 | } |
737 | 737 | } |
738 | 738 | |
739 | 739 | private static function update_postmeta( &$post, $post_id ) { |
740 | 740 | foreach ( $post['postmeta'] as $k => $v ) { |
741 | 741 | if ( '_edit_last' == $k ) { |
742 | - $v = FrmAppHelper::get_user_id_param($v); |
|
742 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
743 | 743 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
744 | 744 | //change the attachment ID |
745 | - $v = FrmProXMLHelper::get_file_id($v); |
|
745 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
746 | 746 | } |
747 | 747 | |
748 | - update_post_meta($post_id, $k, $v); |
|
748 | + update_post_meta( $post_id, $k, $v ); |
|
749 | 749 | |
750 | - unset($k, $v); |
|
750 | + unset( $k, $v ); |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | * @param string $message |
770 | 770 | */ |
771 | 771 | public static function parse_message( $result, &$message, &$errors ) { |
772 | - if ( is_wp_error($result) ) { |
|
772 | + if ( is_wp_error( $result ) ) { |
|
773 | 773 | $errors[] = $result->get_error_message(); |
774 | 774 | } else if ( ! $result ) { |
775 | 775 | return; |
776 | 776 | } |
777 | 777 | |
778 | - if ( ! is_array($result) ) { |
|
778 | + if ( ! is_array( $result ) ) { |
|
779 | 779 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
780 | 780 | return; |
781 | 781 | } |
@@ -787,20 +787,20 @@ discard block |
||
787 | 787 | |
788 | 788 | $message = '<ul>'; |
789 | 789 | foreach ( $result as $type => $results ) { |
790 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
790 | + if ( ! isset( $t_strings[$type] ) ) { |
|
791 | 791 | // only print imported and updated |
792 | 792 | continue; |
793 | 793 | } |
794 | 794 | |
795 | 795 | $s_message = array(); |
796 | 796 | foreach ( $results as $k => $m ) { |
797 | - self::item_count_message($m, $k, $s_message); |
|
798 | - unset($k, $m); |
|
797 | + self::item_count_message( $m, $k, $s_message ); |
|
798 | + unset( $k, $m ); |
|
799 | 799 | } |
800 | 800 | |
801 | - if ( ! empty($s_message) ) { |
|
802 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
803 | - $message .= implode(', ', $s_message); |
|
801 | + if ( ! empty( $s_message ) ) { |
|
802 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
803 | + $message .= implode( ', ', $s_message ); |
|
804 | 804 | $message .= '</li>'; |
805 | 805 | } |
806 | 806 | } |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
830 | 830 | ); |
831 | 831 | |
832 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
832 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -861,14 +861,14 @@ discard block |
||
861 | 861 | } |
862 | 862 | |
863 | 863 | public static function cdata( $str ) { |
864 | - $str = maybe_unserialize($str); |
|
865 | - if ( is_array($str) ) { |
|
866 | - $str = json_encode($str); |
|
864 | + $str = maybe_unserialize( $str ); |
|
865 | + if ( is_array( $str ) ) { |
|
866 | + $str = json_encode( $str ); |
|
867 | 867 | } else if ( seems_utf8( $str ) == false ) { |
868 | 868 | $str = utf8_encode( $str ); |
869 | 869 | } |
870 | 870 | |
871 | - if ( is_numeric($str) ) { |
|
871 | + if ( is_numeric( $str ) ) { |
|
872 | 872 | return $str; |
873 | 873 | } |
874 | 874 | |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | * @param string $post_type |
914 | 914 | */ |
915 | 915 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
916 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
916 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
917 | 917 | return; |
918 | 918 | } |
919 | 919 | |
@@ -934,10 +934,10 @@ discard block |
||
934 | 934 | ); |
935 | 935 | |
936 | 936 | foreach ( $post_settings as $post_setting ) { |
937 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
938 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
937 | + if ( isset( $form_options[$post_setting] ) ) { |
|
938 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
939 | 939 | } |
940 | - unset($post_setting); |
|
940 | + unset( $post_setting ); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | $new_action['event'] = array( 'create', 'update' ); |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | |
952 | 952 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
953 | 953 | } |
954 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
954 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
955 | 955 | |
956 | 956 | $exists = get_posts( array( |
957 | 957 | 'name' => $new_action['post_name'], |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | if ( ! $exists ) { |
964 | 964 | // this isn't an email, but we need to use a class that will always be included |
965 | 965 | FrmAppHelper::save_json_post( $new_action ); |
966 | - $imported['imported']['actions']++; |
|
966 | + $imported['imported']['actions'] ++; |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | |
@@ -995,11 +995,11 @@ discard block |
||
995 | 995 | foreach ( $post_content as $key => $setting ) { |
996 | 996 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
997 | 997 | // Replace old IDs with new IDs |
998 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
998 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
999 | 999 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
1000 | 1000 | foreach ( $setting as $k => $val ) { |
1001 | 1001 | // Replace old IDs with new IDs |
1002 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
1002 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | unset( $key, $setting ); |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | foreach ( $notifications as $new_notification ) { |
1030 | 1030 | $new_notification['post_type'] = $post_type; |
1031 | 1031 | $new_notification['post_excerpt'] = 'email'; |
1032 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
1032 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
1033 | 1033 | $new_notification['menu_order'] = $form_id; |
1034 | 1034 | $new_notification['post_status'] = 'publish'; |
1035 | 1035 | |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | // Switch all other field IDs in email |
1043 | 1043 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
1044 | 1044 | } |
1045 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1045 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1046 | 1046 | |
1047 | 1047 | $exists = get_posts( array( |
1048 | 1048 | 'name' => $new_notification['post_name'], |
@@ -1051,11 +1051,11 @@ discard block |
||
1051 | 1051 | 'numberposts' => 1, |
1052 | 1052 | ) ); |
1053 | 1053 | |
1054 | - if ( empty($exists) ) { |
|
1054 | + if ( empty( $exists ) ) { |
|
1055 | 1055 | FrmAppHelper::save_json_post( $new_notification ); |
1056 | - $imported['imported']['actions']++; |
|
1056 | + $imported['imported']['actions'] ++; |
|
1057 | 1057 | } |
1058 | - unset($new_notification); |
|
1058 | + unset( $new_notification ); |
|
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1071 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
1072 | 1072 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
1073 | 1073 | |
1074 | 1074 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -1096,12 +1096,12 @@ discard block |
||
1096 | 1096 | // Format the reply to email and name |
1097 | 1097 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
1098 | 1098 | foreach ( $reply_fields as $f => $val ) { |
1099 | - if ( isset( $notification[ $f ] ) ) { |
|
1100 | - $atts[ $f ] = $notification[ $f ]; |
|
1101 | - if ( 'custom' == $notification[ $f ] ) { |
|
1102 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
1103 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
1104 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
1099 | + if ( isset( $notification[$f] ) ) { |
|
1100 | + $atts[$f] = $notification[$f]; |
|
1101 | + if ( 'custom' == $notification[$f] ) { |
|
1102 | + $atts[$f] = $notification['cust_' . $f]; |
|
1103 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
1104 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
1105 | 1105 | } |
1106 | 1106 | } |
1107 | 1107 | unset( $f, $val ); |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | $atts['event'] = array( 'create' ); |
1112 | 1112 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
1113 | 1113 | $atts['event'][] = 'update'; |
1114 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1114 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
1115 | 1115 | $atts['event'] = array( 'update' ); |
1116 | 1116 | } |
1117 | 1117 | } |
@@ -1132,18 +1132,18 @@ discard block |
||
1132 | 1132 | foreach ( $atts['email_to'] as $key => $email_field ) { |
1133 | 1133 | |
1134 | 1134 | if ( is_numeric( $email_field ) ) { |
1135 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
1135 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | - if ( strpos( $email_field, '|') ) { |
|
1138 | + if ( strpos( $email_field, '|' ) ) { |
|
1139 | 1139 | $email_opt = explode( '|', $email_field ); |
1140 | 1140 | if ( isset( $email_opt[0] ) ) { |
1141 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1141 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1142 | 1142 | } |
1143 | 1143 | unset( $email_opt ); |
1144 | 1144 | } |
1145 | 1145 | } |
1146 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1146 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -1159,12 +1159,12 @@ discard block |
||
1159 | 1159 | // Add more fields to the new notification |
1160 | 1160 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
1161 | 1161 | foreach ( $add_fields as $add_field ) { |
1162 | - if ( isset( $notification[ $add_field ] ) ) { |
|
1163 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
1162 | + if ( isset( $notification[$add_field] ) ) { |
|
1163 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
1164 | 1164 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
1165 | - $new_notification['post_content'][ $add_field ] = 0; |
|
1165 | + $new_notification['post_content'][$add_field] = 0; |
|
1166 | 1166 | } else { |
1167 | - $new_notification['post_content'][ $add_field ] = ''; |
|
1167 | + $new_notification['post_content'][$add_field] = ''; |
|
1168 | 1168 | } |
1169 | 1169 | unset( $add_field ); |
1170 | 1170 | } |
@@ -1188,26 +1188,26 @@ discard block |
||
1188 | 1188 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
1189 | 1189 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
1190 | 1190 | if ( is_numeric( $email_key ) ) { |
1191 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1191 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1192 | 1192 | } |
1193 | - unset( $email_key, $val); |
|
1193 | + unset( $email_key, $val ); |
|
1194 | 1194 | } |
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
1199 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1199 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
1200 | 1200 | // migrate autoresponder |
1201 | 1201 | |
1202 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1203 | - if ( strpos($email_field, '|') ) { |
|
1202 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
1203 | + if ( strpos( $email_field, '|' ) ) { |
|
1204 | 1204 | // data from entries field |
1205 | - $email_field = explode('|', $email_field); |
|
1206 | - if ( isset($email_field[1]) ) { |
|
1205 | + $email_field = explode( '|', $email_field ); |
|
1206 | + if ( isset( $email_field[1] ) ) { |
|
1207 | 1207 | $email_field = $email_field[1]; |
1208 | 1208 | } |
1209 | 1209 | } |
1210 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1210 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
1211 | 1211 | $email_field = '[' . $email_field . ']'; |
1212 | 1212 | } |
1213 | 1213 | |
@@ -1215,16 +1215,16 @@ discard block |
||
1215 | 1215 | $new_notification2 = array( |
1216 | 1216 | 'post_content' => array( |
1217 | 1217 | 'email_message' => $notification['ar_email_message'], |
1218 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1218 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
1219 | 1219 | 'email_to' => $email_field, |
1220 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1220 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
1221 | 1221 | 'inc_user_info' => 0, |
1222 | 1222 | ), |
1223 | 1223 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
1224 | 1224 | ); |
1225 | 1225 | |
1226 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1227 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1226 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
1227 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
1228 | 1228 | |
1229 | 1229 | if ( ! empty( $reply_to ) ) { |
1230 | 1230 | $new_notification2['post_content']['reply_to'] = $reply_to; |