@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $display = apply_filters('frm_display_field_options', array( |
4 | - 'type' => $field['type'], 'field_data' => $field, |
|
5 | - 'required' => true, 'unique' => false, 'read_only' => false, |
|
6 | - 'description' => true, 'options' => true, 'label_position' => true, |
|
7 | - 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
|
8 | - 'default_blank' => true, 'css' => true, 'conf_field' => false, |
|
4 | + 'type' => $field['type'], 'field_data' => $field, |
|
5 | + 'required' => true, 'unique' => false, 'read_only' => false, |
|
6 | + 'description' => true, 'options' => true, 'label_position' => true, |
|
7 | + 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
|
8 | + 'default_blank' => true, 'css' => true, 'conf_field' => false, |
|
9 | 9 | 'max' => true, 'captcha_size' => false, |
10 | 10 | )); |
11 | 11 | |
@@ -25,19 +25,19 @@ discard block |
||
25 | 25 | $frm_settings = FrmAppHelper::get_settings(); |
26 | 26 | |
27 | 27 | if ( ! isset( $frm_all_field_selection ) ) { |
28 | - if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
29 | - $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
30 | - } else { |
|
28 | + if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
29 | + $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
30 | + } else { |
|
31 | 31 | $pro_field_selection = FrmField::pro_field_selection(); |
32 | 32 | $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection ); |
33 | - } |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection; |
37 | 37 | |
38 | 38 | |
39 | 39 | if ( ! isset( $ajax ) ) { |
40 | - $li_classes .= ' ui-state-default widgets-holder-wrap'; ?> |
|
40 | + $li_classes .= ' ui-state-default widgets-holder-wrap'; ?> |
|
41 | 41 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?>" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo ( 'divider' == $field['type'] ) ? esc_attr( $field['form_select'] ) : esc_attr( $field['form_id'] ); ?>"> |
42 | 42 | <?php |
43 | 43 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | </span> |
60 | 60 | <?php } |
61 | 61 | |
62 | - ?> |
|
62 | + ?> |
|
63 | 63 | <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
64 | 64 | |
65 | 65 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
106 | 106 | <div class="frm-show-click frm_small_top_margin"><?php |
107 | 107 | |
108 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
109 | - echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
108 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
109 | + echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
110 | 110 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
111 | 111 | ?> |
112 | 112 | <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>"> |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | <a href="javascript:void(0);" id="other_button_<?php echo esc_attr( $field['id'] ); ?>" data-opttype="other" data-ftype="<?php echo esc_attr( $field['type'] ) ?>" class="button frm_cb_button frm_add_opt<?php echo ( in_array( $field['type'], array( 'radio', 'select' ) ) && $field['other'] == true ? ' frm_hidden' : '' ); ?>"><?php _e( 'Add "Other"', 'formidable' ) ?></a> |
118 | 118 | <input type="hidden" value="<?php echo esc_attr( $field['other'] ); ?>" id="other_input_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[other_<?php echo esc_attr( $field['id'] ); ?>]"> |
119 | 119 | <?php |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
122 | + if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
123 | 123 | <a href="<?php echo esc_url(admin_url('admin-ajax.php') .'?action=frm_import_choices&field_id='. $field['id'] .'&TB_iframe=1') ?>" title="<?php echo FrmAppHelper::truncate(esc_attr(strip_tags(str_replace('"', '"', $field['name']))), 20) . ' '. __( 'Field Choices', 'formidable' ); ?>" class="thickbox frm_orange"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
124 | 124 | <?php } ?> |
125 | 125 | </div> |
126 | 126 | <?php |
127 | - } |
|
127 | + } |
|
128 | 128 | ?> |
129 | 129 | </div> |
130 | 130 | <?php |
@@ -156,28 +156,28 @@ discard block |
||
156 | 156 | if ( $display['required'] ) { ?> |
157 | 157 | <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
158 | 158 | <?php |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | 161 | if ( $display['unique'] ) { |
162 | - if ( ! isset( $field['unique'] ) ) { |
|
163 | - $field['unique'] = false; |
|
164 | - } |
|
165 | - ?> |
|
162 | + if ( ! isset( $field['unique'] ) ) { |
|
163 | + $field['unique'] = false; |
|
164 | + } |
|
165 | + ?> |
|
166 | 166 | <label for="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Unique: Do not allow the same response multiple times. For example, if one user enters \'Joe\', then no one else will be allowed to enter the same name.', 'formidable' ) ?>"><input type="checkbox" name="field_options[unique_<?php echo esc_attr( $field['id'] ) ?>]" id="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" value="1" <?php checked( $field['unique'], 1 ); ?> class="frm_mark_unique" /> <?php _e( 'Unique', 'formidable' ) ?></label> |
167 | 167 | <?php |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | 170 | if ( $display['read_only'] ) { |
171 | - if ( ! isset( $field['read_only'] ) ) { |
|
172 | - $field['read_only'] = false; |
|
171 | + if ( ! isset( $field['read_only'] ) ) { |
|
172 | + $field['read_only'] = false; |
|
173 | 173 | } |
174 | - ?> |
|
174 | + ?> |
|
175 | 175 | <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label> |
176 | 176 | <?php } |
177 | 177 | |
178 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
178 | + do_action('frm_field_options_form_top', $field, $display, $values); |
|
179 | 179 | |
180 | - ?> |
|
180 | + ?> |
|
181 | 181 | <?php |
182 | 182 | if ( $display['required'] ) { ?> |
183 | 183 | <div class="frm_required_details<?php echo esc_attr( $field['id'] . ( $field['required'] ? '' : ' frm_hidden' ) ); ?>"> |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | <?php _e( 'automatic width', 'formidable' ) ?> |
234 | 234 | </label> |
235 | 235 | <?php |
236 | - } |
|
236 | + } |
|
237 | 237 | } else { ?> |
238 | 238 | <input type="text" name="field_options[size_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['size'] ); ?>" size="5" /> <span class="howto"><?php _e( 'pixels wide', 'formidable' ) ?></span> |
239 | 239 | |
240 | 240 | <?php if ( $display['max'] ) { ?> |
241 | 241 | <input type="text" name="field_options[max_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['max'] ); ?>" size="5" /> <span class="howto"><?php echo ( $field['type'] == 'textarea' || $field['type'] == 'rte' ) ? __( 'rows high', 'formidable' ) : __( 'characters maximum', 'formidable' ) ?></span> |
242 | 242 | <?php } |
243 | - } ?> |
|
243 | + } ?> |
|
244 | 244 | </td> |
245 | 245 | </tr> |
246 | 246 | <?php } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } ?> |
259 | 259 | <?php do_action('frm_field_options_form', $field, $display, $values); |
260 | 260 | |
261 | - if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
|
261 | + if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
|
262 | 262 | <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
263 | 263 | <td colspan="2"> |
264 | 264 | <div class="menu-settings"> |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | <input type="text" name="field_options[blank_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['blank'] ); ?>" /> |
272 | 272 | </p> |
273 | 273 | <?php |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | 276 | if ( $display['invalid'] ) { ?> |
277 | 277 | <p><label><?php _e( 'Invalid Format', 'formidable' ) ?></label> |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | <input type="text" name="field_options[unique_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['unique_msg'] ); ?>" /> |
287 | 287 | </p> |
288 | 288 | <?php |
289 | - } |
|
289 | + } |
|
290 | 290 | |
291 | 291 | if ( $display['conf_field'] ) { ?> |
292 | 292 | <p class="frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | <input type="text" name="field_options[conf_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_msg'] ); ?>" /> |
295 | 295 | </p> |
296 | 296 | <?php |
297 | - } ?> |
|
297 | + } ?> |
|
298 | 298 | </div> |
299 | 299 | </div> |
300 | 300 | </td> |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$display = apply_filters('frm_display_field_options', array( |
|
3 | +$display = apply_filters( 'frm_display_field_options', array( |
|
4 | 4 | 'type' => $field['type'], 'field_data' => $field, |
5 | 5 | 'required' => true, 'unique' => false, 'read_only' => false, |
6 | 6 | 'description' => true, 'options' => true, 'label_position' => true, |
7 | 7 | 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
8 | 8 | 'default_blank' => true, 'css' => true, 'conf_field' => false, |
9 | 9 | 'max' => true, 'captcha_size' => false, |
10 | -)); |
|
10 | +) ); |
|
11 | 11 | |
12 | -$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_'. $display['type']; |
|
13 | -$li_classes = apply_filters('frm_build_field_class', $li_classes, $field ); |
|
12 | +$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type']; |
|
13 | +$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field ); |
|
14 | 14 | |
15 | 15 | if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) { |
16 | 16 | ?> |
17 | 17 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
18 | 18 | <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" /> |
19 | -<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span> |
|
19 | +<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span> |
|
20 | 20 | </li> |
21 | 21 | <?php |
22 | 22 | return; |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | $frm_settings = FrmAppHelper::get_settings(); |
26 | 26 | |
27 | 27 | if ( ! isset( $frm_all_field_selection ) ) { |
28 | - if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
29 | - $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
28 | + if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) { |
|
29 | + $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection ); |
|
30 | 30 | } else { |
31 | 31 | $pro_field_selection = FrmField::pro_field_selection(); |
32 | 32 | $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection ); |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a> |
52 | 52 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a> |
53 | 53 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a> |
54 | - <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" /> |
|
55 | - <?php do_action('frm_extra_field_actions', $field['id']); ?> |
|
54 | + <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" /> |
|
55 | + <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?> |
|
56 | 56 | <?php if ( $display['required'] ) { ?> |
57 | 57 | <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>"> |
58 | 58 | <a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a> |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | <?php } |
61 | 61 | |
62 | 62 | ?> |
63 | - <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
63 | + <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
64 | 64 | |
65 | 65 | |
66 | 66 | <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container"> |
67 | 67 | <div class="frm_form_fields" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
68 | 68 | <?php |
69 | -include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/show-build.php'); |
|
69 | +include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/show-build.php' ); |
|
70 | 70 | |
71 | 71 | if ( $display['clear_on_focus'] ) { |
72 | 72 | FrmFieldsHelper::clear_on_focus_html( $field, $display ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | </div> |
79 | 79 | <?php |
80 | 80 | if ( $display['description'] ) { ?> |
81 | - <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
81 | + <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
82 | 82 | <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" /> |
83 | 83 | |
84 | 84 | <?php } ?> |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_container" class="frm_conf_field_container frm_form_fields frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
89 | 89 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_conf_container"> |
90 | 90 | <div class="frm_form_fields"> |
91 | - <input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" <?php do_action('frm_field_input_html', $field) ?> /> |
|
91 | + <input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" <?php do_action( 'frm_field_input_html', $field ) ?> /> |
|
92 | 92 | </div> |
93 | - <div class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div> |
|
93 | + <div class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div> |
|
94 | 94 | <input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" /> |
95 | 95 | </div> |
96 | 96 | <?php if ( $display['clear_on_focus'] ) { ?> |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
106 | 106 | <div class="frm-show-click frm_small_top_margin"><?php |
107 | 107 | |
108 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
109 | - echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
108 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
109 | + echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>'; |
|
110 | 110 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
111 | 111 | ?> |
112 | 112 | <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>"> |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | <?php |
120 | 120 | } |
121 | 121 | |
122 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
123 | - <a href="<?php echo esc_url(admin_url('admin-ajax.php') .'?action=frm_import_choices&field_id='. $field['id'] .'&TB_iframe=1') ?>" title="<?php echo FrmAppHelper::truncate(esc_attr(strip_tags(str_replace('"', '"', $field['name']))), 20) . ' '. __( 'Field Choices', 'formidable' ); ?>" class="thickbox frm_orange"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
|
122 | + if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?> |
|
123 | + <a href="<?php echo esc_url( admin_url( 'admin-ajax.php' ) . '?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ?>" title="<?php echo FrmAppHelper::truncate( esc_attr( strip_tags( str_replace( '"', '"', $field['name'] ) ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ); ?>" class="thickbox frm_orange"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
|
124 | 124 | <?php } ?> |
125 | 125 | </div> |
126 | 126 | <?php |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | <?php |
131 | 131 | } |
132 | 132 | |
133 | -do_action('frm_before_field_options', $field); |
|
133 | +do_action( 'frm_before_field_options', $field ); |
|
134 | 134 | |
135 | 135 | if ( $display['options'] ) { ?> |
136 | 136 | <div class="widget"> |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | </div> |
141 | 141 | <div class="widget-inside"> |
142 | 142 | <table class="form-table frm_clear_none"> |
143 | - <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?> |
|
143 | + <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?> |
|
144 | 144 | <tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td> |
145 | 145 | <td> |
146 | - <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
146 | + <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
147 | 147 | <?php |
148 | 148 | foreach ( $field_types as $fkey => $ftype ) { ?> |
149 | - <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option> |
|
149 | + <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option> |
|
150 | 150 | <?php |
151 | 151 | unset( $fkey, $ftype ); |
152 | 152 | } ?> |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | <?php |
156 | 156 | if ( $display['required'] ) { ?> |
157 | - <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
|
157 | + <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"' : ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
|
158 | 158 | <?php |
159 | 159 | } |
160 | 160 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label> |
176 | 176 | <?php } |
177 | 177 | |
178 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
178 | + do_action( 'frm_field_options_form_top', $field, $display, $values ); |
|
179 | 179 | |
180 | 180 | ?> |
181 | 181 | <?php |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | if ( $display['label_position'] ) { ?> |
212 | 212 | <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td> |
213 | 213 | <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]"> |
214 | - <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
215 | - <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
216 | - <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
217 | - <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
218 | - <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
219 | - <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
220 | - <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
214 | + <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
215 | + <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
216 | + <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
217 | + <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
218 | + <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
219 | + <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
220 | + <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
221 | 221 | </select> |
222 | 222 | </td> |
223 | 223 | </tr> |
@@ -249,17 +249,17 @@ discard block |
||
249 | 249 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span> |
250 | 250 | </td> |
251 | 251 | <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]"> |
252 | - <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
253 | - <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
252 | + <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
253 | + <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
254 | 254 | </select> |
255 | 255 | </td> |
256 | 256 | </tr> |
257 | 257 | <?php |
258 | 258 | } ?> |
259 | - <?php do_action('frm_field_options_form', $field, $display, $values); |
|
259 | + <?php do_action( 'frm_field_options_form', $field, $display, $values ); |
|
260 | 260 | |
261 | 261 | if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
262 | - <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
262 | + <tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
263 | 263 | <td colspan="2"> |
264 | 264 | <div class="menu-settings"> |
265 | 265 | <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3> |
@@ -323,4 +323,4 @@ discard block |
||
323 | 323 | <?php |
324 | 324 | } |
325 | 325 | |
326 | -unset($display); |
|
326 | +unset( $display ); |
@@ -64,8 +64,8 @@ |
||
64 | 64 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=destroy&id=' . $style->ID ) ); ?>" id="frm_delete_style" class="submitdelete deletion" onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to delete that style?', 'formidable' ) ?>')"><?php _e( 'Delete Style', 'formidable' ) ?></a> |
65 | 65 | <?php } ?> |
66 | 66 | <?php |
67 | - if ( $style->ID ) { |
|
68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
67 | + if ( $style->ID ) { |
|
68 | + echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
69 | 69 | } ?> |
70 | 70 | <div class="publishing-action"> |
71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -2,14 +2,14 @@ discard block |
||
2 | 2 | <div class="wrap"> |
3 | 3 | <?php FrmStylesHelper::style_menu(); ?> |
4 | 4 | |
5 | - <?php include(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
5 | + <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
6 | 6 | |
7 | 7 | <?php do_action( 'frm_style_switcher', $style, $styles ) ?> |
8 | 8 | |
9 | 9 | <form id="frm_styling_form" action="" name="frm_styling_form" method="post"> |
10 | 10 | <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" /> |
11 | 11 | <input type="hidden" name="frm_action" value="save" /> |
12 | - <textarea name="<?php echo esc_attr( $frm_style->get_field_name('custom_css') ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
12 | + <textarea name="<?php echo esc_attr( $frm_style->get_field_name( 'custom_css' ) ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
13 | 13 | <?php wp_nonce_field( 'frm_style_nonce', 'frm_style' ); ?> |
14 | 14 | |
15 | 15 | <div id="nav-menus-frame"> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | <div class="styling_settings"> |
20 | 20 | <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" /> |
21 | - <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact('style', 'frm_style') ); ?> |
|
21 | + <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact( 'style', 'frm_style' ) ); ?> |
|
22 | 22 | </div> |
23 | 23 | |
24 | 24 | </div><!-- /#menu-settings-column --> |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | <div class="major-publishing-actions"> |
32 | 32 | <label class="menu-name-label howto open-label" for="menu-name"> |
33 | 33 | <span><?php _e( 'Style Name', 'formidable' ) ?></span> |
34 | - <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name('post_title', '') ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
34 | + <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name( 'post_title', '' ) ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
35 | 35 | </label> |
36 | 36 | |
37 | - <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr($style->menu_order) ?>" /> |
|
37 | + <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr( $style->menu_order ) ?>" /> |
|
38 | 38 | <label class="menu-name-label howto open-label default-style-box" for="menu_order"> |
39 | 39 | <span> |
40 | 40 | <?php if ( $style->menu_order ) { ?> |
41 | - <input name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="hidden" value="1" /> |
|
42 | - <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
41 | + <input name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="hidden" value="1" /> |
|
42 | + <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
43 | 43 | <?php } else { ?> |
44 | - <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
44 | + <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
45 | 45 | <?php } ?> |
46 | 46 | <?php _e( 'Make default style', 'formidable' ) ?></span> |
47 | 47 | </label> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <div id="post-body"> |
55 | 55 | <div id="post-body-content"> |
56 | 56 | |
57 | - <?php include( dirname(__FILE__) .'/_sample_form.php') ?> |
|
57 | + <?php include( dirname( __FILE__ ) . '/_sample_form.php' ) ?> |
|
58 | 58 | |
59 | 59 | </div><!-- /#post-body-content --> |
60 | 60 | </div><!-- /#post-body --> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <?php } ?> |
66 | 66 | <?php |
67 | 67 | if ( $style->ID ) { |
68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
68 | + echo '<span class="howto"><span>.frm_style_' . esc_attr( $style->post_name ) . '</span></span>'; |
|
69 | 69 | } ?> |
70 | 70 | <div class="publishing-action"> |
71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -375,6 +375,9 @@ |
||
375 | 375 | $reset_fields = true; |
376 | 376 | } |
377 | 377 | |
378 | + /** |
|
379 | + * @return string |
|
380 | + */ |
|
378 | 381 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
379 | 382 | foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) { |
380 | 383 | if ( $code == 'form_name' ) { |
@@ -12,38 +12,38 @@ discard block |
||
12 | 12 | |
13 | 13 | public static function get_direct_link( $key, $form = false ) { |
14 | 14 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form='. $key ) ); |
15 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
16 | - |
|
17 | - return $target_url; |
|
18 | - } |
|
19 | - |
|
20 | - public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
21 | - $defaults = array( |
|
22 | - 'blank' => true, |
|
23 | - 'field_id' => false, |
|
24 | - 'onchange' => false, |
|
25 | - 'exclude' => false, |
|
26 | - 'class' => '', |
|
15 | + $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
16 | + |
|
17 | + return $target_url; |
|
18 | + } |
|
19 | + |
|
20 | + public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
21 | + $defaults = array( |
|
22 | + 'blank' => true, |
|
23 | + 'field_id' => false, |
|
24 | + 'onchange' => false, |
|
25 | + 'exclude' => false, |
|
26 | + 'class' => '', |
|
27 | 27 | 'inc_children' => 'exclude', |
28 | - ); |
|
29 | - $args = wp_parse_args( $args, $defaults ); |
|
28 | + ); |
|
29 | + $args = wp_parse_args( $args, $defaults ); |
|
30 | 30 | |
31 | - if ( ! $args['field_id'] ) { |
|
32 | - $args['field_id'] = $field_name; |
|
33 | - } |
|
31 | + if ( ! $args['field_id'] ) { |
|
32 | + $args['field_id'] = $field_name; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | $query = array(); |
36 | - if ( $args['exclude'] ) { |
|
36 | + if ( $args['exclude'] ) { |
|
37 | 37 | $query['id !'] = $args['exclude']; |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
40 | + $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
41 | 41 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
42 | 42 | $add_html = array(); |
43 | 43 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
44 | 44 | self::add_html_attr( $args['class'], 'class', $add_html ); |
45 | 45 | |
46 | - ?> |
|
46 | + ?> |
|
47 | 47 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>> |
48 | 48 | <?php if ( $args['blank'] ) { ?> |
49 | 49 | <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option> |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | <?php } ?> |
56 | 56 | </select> |
57 | 57 | <?php |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @param string $class |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - public static function form_switcher() { |
|
73 | + public static function form_switcher() { |
|
74 | 74 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
75 | 75 | $forms = FrmForm::get_published_forms( $where ); |
76 | 76 | |
@@ -79,32 +79,32 @@ discard block |
||
79 | 79 | unset( $args['form'] ); |
80 | 80 | } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
81 | 81 | unset( $args['id'] ); |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | 84 | $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
85 | 85 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
86 | - $args['frm_action'] = 'list'; |
|
87 | - $args['form'] = 0; |
|
86 | + $args['frm_action'] = 'list'; |
|
87 | + $args['form'] = 0; |
|
88 | 88 | } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
89 | - $args['frm_action'] = 'edit'; |
|
89 | + $args['frm_action'] = 'edit'; |
|
90 | 90 | } else if ( isset( $_GET['post'] ) ) { |
91 | - $args['form'] = 0; |
|
92 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
93 | - } |
|
91 | + $args['form'] = 0; |
|
92 | + $base = admin_url('edit.php?post_type=frm_display'); |
|
93 | + } |
|
94 | 94 | |
95 | - ?> |
|
95 | + ?> |
|
96 | 96 | <li class="dropdown last" id="frm_bs_dropdown"> |
97 | 97 | <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a> |
98 | 98 | <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop"> |
99 | 99 | <?php |
100 | 100 | foreach ( $forms as $form ) { |
101 | 101 | if ( isset( $args['id'] ) ) { |
102 | - $args['id'] = $form->id; |
|
102 | + $args['id'] = $form->id; |
|
103 | 103 | } |
104 | - if ( isset( $args['form'] ) ) { |
|
105 | - $args['form'] = $form->id; |
|
104 | + if ( isset( $args['form'] ) ) { |
|
105 | + $args['form'] = $form->id; |
|
106 | 106 | } |
107 | - ?> |
|
107 | + ?> |
|
108 | 108 | <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
109 | 109 | <?php |
110 | 110 | unset( $form ); |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | </ul> |
113 | 113 | </li> |
114 | 114 | <?php |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
118 | - echo ($sort_col == $col) ? 'sorted' : 'sortable'; |
|
119 | - echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc'; |
|
120 | - } |
|
118 | + echo ($sort_col == $col) ? 'sorted' : 'sortable'; |
|
119 | + echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc'; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | public static function get_success_message( $atts ) { |
123 | 123 | $message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] ); |
@@ -126,110 +126,110 @@ discard block |
||
126 | 126 | return $message; |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Used when a form is created |
|
131 | - */ |
|
132 | - public static function setup_new_vars( $values = array() ) { |
|
133 | - global $wpdb; |
|
129 | + /** |
|
130 | + * Used when a form is created |
|
131 | + */ |
|
132 | + public static function setup_new_vars( $values = array() ) { |
|
133 | + global $wpdb; |
|
134 | 134 | |
135 | - if ( ! empty( $values ) ) { |
|
136 | - $post_values = $values; |
|
137 | - } else { |
|
138 | - $values = array(); |
|
139 | - $post_values = isset($_POST) ? $_POST : array(); |
|
140 | - } |
|
135 | + if ( ! empty( $values ) ) { |
|
136 | + $post_values = $values; |
|
137 | + } else { |
|
138 | + $values = array(); |
|
139 | + $post_values = isset($_POST) ? $_POST : array(); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) { |
143 | 143 | if ( ! isset( $values[ $var ] ) ) { |
144 | 144 | $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
145 | - } |
|
146 | - } |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
148 | + $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
149 | 149 | |
150 | 150 | foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) { |
151 | - if ( ! isset( $values[ $var ] ) ) { |
|
151 | + if ( ! isset( $values[ $var ] ) ) { |
|
152 | 152 | $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
153 | - } |
|
154 | - } |
|
153 | + } |
|
154 | + } |
|
155 | 155 | |
156 | - if ( ! isset( $values['form_key'] ) ) { |
|
157 | - $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key'); |
|
158 | - } |
|
156 | + if ( ! isset( $values['form_key'] ) ) { |
|
157 | + $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key'); |
|
158 | + } |
|
159 | 159 | |
160 | - $values = self::fill_default_opts($values, false, $post_values); |
|
160 | + $values = self::fill_default_opts($values, false, $post_values); |
|
161 | 161 | |
162 | - if ( $post_values && isset($post_values['options']['custom_style']) ) { |
|
163 | - $values['custom_style'] = $post_values['options']['custom_style']; |
|
164 | - } else { |
|
165 | - $frm_settings = FrmAppHelper::get_settings(); |
|
166 | - $values['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
167 | - } |
|
162 | + if ( $post_values && isset($post_values['options']['custom_style']) ) { |
|
163 | + $values['custom_style'] = $post_values['options']['custom_style']; |
|
164 | + } else { |
|
165 | + $frm_settings = FrmAppHelper::get_settings(); |
|
166 | + $values['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
167 | + } |
|
168 | 168 | |
169 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
170 | - } |
|
169 | + return apply_filters('frm_setup_new_form_vars', $values); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Used when editing a form |
|
174 | - */ |
|
175 | - public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
172 | + /** |
|
173 | + * Used when editing a form |
|
174 | + */ |
|
175 | + public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
176 | 176 | if ( empty( $post_values ) ) { |
177 | 177 | $post_values = stripslashes_deep( $_POST ); |
178 | 178 | } |
179 | 179 | |
180 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
181 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
182 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
183 | - $values['status'] = $record->status; |
|
180 | + $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
181 | + $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
182 | + $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
183 | + $values['status'] = $record->status; |
|
184 | 184 | |
185 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
185 | + $values = self::fill_default_opts($values, $record, $post_values); |
|
186 | 186 | |
187 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
188 | - } |
|
187 | + return apply_filters('frm_setup_edit_form_vars', $values); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public static function fill_default_opts( $values, $record, $post_values ) { |
191 | 191 | |
192 | - $defaults = self::get_default_opts(); |
|
192 | + $defaults = self::get_default_opts(); |
|
193 | 193 | foreach ( $defaults as $var => $default ) { |
194 | - if ( is_array($default) ) { |
|
195 | - if ( ! isset( $values[ $var ] ) ) { |
|
194 | + if ( is_array($default) ) { |
|
195 | + if ( ! isset( $values[ $var ] ) ) { |
|
196 | 196 | $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - foreach ( $default as $k => $v ) { |
|
199 | + foreach ( $default as $k => $v ) { |
|
200 | 200 | $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v); |
201 | 201 | |
202 | - if ( is_array( $v ) ) { |
|
203 | - foreach ( $v as $k1 => $v1 ) { |
|
202 | + if ( is_array( $v ) ) { |
|
203 | + foreach ( $v as $k1 => $v1 ) { |
|
204 | 204 | $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
205 | - unset( $k1, $v1 ); |
|
206 | - } |
|
207 | - } |
|
205 | + unset( $k1, $v1 ); |
|
206 | + } |
|
207 | + } |
|
208 | 208 | |
209 | - unset($k, $v); |
|
210 | - } |
|
211 | - } else { |
|
209 | + unset($k, $v); |
|
210 | + } |
|
211 | + } else { |
|
212 | 212 | $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - unset($var, $default); |
|
216 | - } |
|
215 | + unset($var, $default); |
|
216 | + } |
|
217 | 217 | |
218 | - return $values; |
|
219 | - } |
|
218 | + return $values; |
|
219 | + } |
|
220 | 220 | |
221 | - public static function get_default_opts() { |
|
222 | - $frm_settings = FrmAppHelper::get_settings(); |
|
221 | + public static function get_default_opts() { |
|
222 | + $frm_settings = FrmAppHelper::get_settings(); |
|
223 | 223 | |
224 | - return array( |
|
225 | - 'submit_value' => $frm_settings->submit_value, 'success_action' => 'message', |
|
226 | - 'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '', |
|
227 | - 'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1, |
|
228 | - 'before_html' => self::get_default_html('before'), |
|
229 | - 'after_html' => '', |
|
230 | - 'submit_html' => self::get_default_html('submit'), |
|
231 | - ); |
|
232 | - } |
|
224 | + return array( |
|
225 | + 'submit_value' => $frm_settings->submit_value, 'success_action' => 'message', |
|
226 | + 'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '', |
|
227 | + 'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1, |
|
228 | + 'before_html' => self::get_default_html('before'), |
|
229 | + 'after_html' => '', |
|
230 | + 'submit_html' => self::get_default_html('submit'), |
|
231 | + ); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * @param array $options |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - /** |
|
248 | - * @param string $loc |
|
249 | - */ |
|
247 | + /** |
|
248 | + * @param string $loc |
|
249 | + */ |
|
250 | 250 | public static function get_default_html( $loc ) { |
251 | 251 | if ( $loc == 'submit' ) { |
252 | - $sending = __( 'Sending', 'formidable' ); |
|
253 | - $draft_link = self::get_draft_link(); |
|
254 | - $img = '[frmurl]/images/ajax_loader.gif'; |
|
255 | - $default_html = <<<SUBMIT_HTML |
|
252 | + $sending = __( 'Sending', 'formidable' ); |
|
253 | + $draft_link = self::get_draft_link(); |
|
254 | + $img = '[frmurl]/images/ajax_loader.gif'; |
|
255 | + $default_html = <<<SUBMIT_HTML |
|
256 | 256 | <div class="frm_submit"> |
257 | 257 | [if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button] |
258 | 258 | <input type="submit" value="[button_label]" [button_action] /> |
@@ -261,49 +261,49 @@ discard block |
||
261 | 261 | </div> |
262 | 262 | SUBMIT_HTML; |
263 | 263 | } else if ( $loc == 'before' ) { |
264 | - $default_html = <<<BEFORE_HTML |
|
264 | + $default_html = <<<BEFORE_HTML |
|
265 | 265 | <legend class="frm_hidden">[form_name]</legend> |
266 | 266 | [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name] |
267 | 267 | [if form_description]<div class="frm_description">[form_description]</div>[/if form_description] |
268 | 268 | BEFORE_HTML; |
269 | 269 | } else { |
270 | - $default_html = ''; |
|
271 | - } |
|
270 | + $default_html = ''; |
|
271 | + } |
|
272 | 272 | |
273 | - return $default_html; |
|
274 | - } |
|
273 | + return $default_html; |
|
274 | + } |
|
275 | 275 | |
276 | - public static function get_draft_link() { |
|
277 | - $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
278 | - return $link; |
|
279 | - } |
|
276 | + public static function get_draft_link() { |
|
277 | + $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
278 | + return $link; |
|
279 | + } |
|
280 | 280 | |
281 | 281 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
282 | - $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values); |
|
283 | - if ( ! strpos($button, '[button_action]') ) { |
|
284 | - return; |
|
285 | - } |
|
282 | + $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values); |
|
283 | + if ( ! strpos($button, '[button_action]') ) { |
|
284 | + return; |
|
285 | + } |
|
286 | 286 | |
287 | - $button_parts = explode('[button_action]', $button); |
|
288 | - echo $button_parts[0]; |
|
289 | - //echo ' id="frm_submit_"'; |
|
287 | + $button_parts = explode('[button_action]', $button); |
|
288 | + echo $button_parts[0]; |
|
289 | + //echo ' id="frm_submit_"'; |
|
290 | 290 | |
291 | - $classes = apply_filters('frm_submit_button_class', array(), $form); |
|
292 | - if ( ! empty($classes) ) { |
|
291 | + $classes = apply_filters('frm_submit_button_class', array(), $form); |
|
292 | + if ( ! empty($classes) ) { |
|
293 | 293 | echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"'; |
294 | - } |
|
295 | - |
|
296 | - do_action('frm_submit_button_action', $form, $form_action); |
|
297 | - echo $button_parts[1]; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Automatically add end section fields if they don't exist (2.0 migration) |
|
302 | - * @since 2.0 |
|
303 | - * |
|
304 | - * @param boolean $reset_fields |
|
305 | - */ |
|
306 | - public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
294 | + } |
|
295 | + |
|
296 | + do_action('frm_submit_button_action', $form, $form_action); |
|
297 | + echo $button_parts[1]; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Automatically add end section fields if they don't exist (2.0 migration) |
|
302 | + * @since 2.0 |
|
303 | + * |
|
304 | + * @param boolean $reset_fields |
|
305 | + */ |
|
306 | + public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
307 | 307 | if ( empty( $fields ) ) { |
308 | 308 | return; |
309 | 309 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $open = $prev_order = false; |
313 | 313 | $add_order = 0; |
314 | 314 | $last_field = false; |
315 | - foreach ( $fields as $field ) { |
|
315 | + foreach ( $fields as $field ) { |
|
316 | 316 | if ( $prev_order === $field->field_order ) { |
317 | 317 | $add_order++; |
318 | 318 | } |
@@ -323,48 +323,48 @@ discard block |
||
323 | 323 | FrmField::update( $field->id, array( 'field_order' => $field->field_order ) ); |
324 | 324 | } |
325 | 325 | |
326 | - switch ( $field->type ) { |
|
327 | - case 'divider': |
|
328 | - // create an end section if open |
|
326 | + switch ( $field->type ) { |
|
327 | + case 'divider': |
|
328 | + // create an end section if open |
|
329 | 329 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
330 | 330 | |
331 | - // mark it open for the next end section |
|
332 | - $open = true; |
|
333 | - break; |
|
334 | - case 'break'; |
|
331 | + // mark it open for the next end section |
|
332 | + $open = true; |
|
333 | + break; |
|
334 | + case 'break'; |
|
335 | 335 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
336 | - break; |
|
337 | - case 'end_divider': |
|
338 | - if ( ! $open ) { |
|
339 | - // the section isn't open, so this is an extra field that needs to be removed |
|
340 | - FrmField::destroy( $field->id ); |
|
341 | - $reset_fields = true; |
|
342 | - } |
|
343 | - |
|
344 | - // There is already an end section here, so there is no need to create one |
|
345 | - $open = false; |
|
346 | - } |
|
336 | + break; |
|
337 | + case 'end_divider': |
|
338 | + if ( ! $open ) { |
|
339 | + // the section isn't open, so this is an extra field that needs to be removed |
|
340 | + FrmField::destroy( $field->id ); |
|
341 | + $reset_fields = true; |
|
342 | + } |
|
343 | + |
|
344 | + // There is already an end section here, so there is no need to create one |
|
345 | + $open = false; |
|
346 | + } |
|
347 | 347 | $prev_order = $field->field_order; |
348 | 348 | |
349 | 349 | $last_field = $field; |
350 | 350 | unset( $field ); |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | 353 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field ); |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Create end section field if it doesn't exist. This is for migration from < 2.0 |
358 | 358 | * Fix any ordering that may be messed up |
359 | 359 | */ |
360 | 360 | public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) { |
361 | - if ( ! $open ) { |
|
362 | - return; |
|
363 | - } |
|
361 | + if ( ! $open ) { |
|
362 | + return; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | $end_section_values['field_order'] = $field->field_order + 1; |
366 | 366 | |
367 | - FrmField::create( $end_section_values ); |
|
367 | + FrmField::create( $end_section_values ); |
|
368 | 368 | |
369 | 369 | if ( $move == 'move' ) { |
370 | 370 | // bump the order of current field unless we're at the end of the form |
@@ -372,38 +372,38 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | $add_order += 2; |
375 | - $open = false; |
|
376 | - $reset_fields = true; |
|
377 | - } |
|
375 | + $open = false; |
|
376 | + $reset_fields = true; |
|
377 | + } |
|
378 | 378 | |
379 | - public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
|
379 | + public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
|
380 | 380 | foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) { |
381 | - if ( $code == 'form_name' ) { |
|
382 | - $replace_with = $form->name; |
|
383 | - } else if ( $code == 'form_description' ) { |
|
384 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
385 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
386 | - $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
387 | - } else { |
|
388 | - $replace_with = ''; |
|
389 | - } |
|
381 | + if ( $code == 'form_name' ) { |
|
382 | + $replace_with = $form->name; |
|
383 | + } else if ( $code == 'form_description' ) { |
|
384 | + $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
385 | + } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
386 | + $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
387 | + } else { |
|
388 | + $replace_with = ''; |
|
389 | + } |
|
390 | 390 | |
391 | - FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
392 | - } |
|
391 | + FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
392 | + } |
|
393 | 393 | |
394 | - //replace [form_key] |
|
395 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
394 | + //replace [form_key] |
|
395 | + $html = str_replace('[form_key]', $form->form_key, $html); |
|
396 | 396 | |
397 | - //replace [frmurl] |
|
398 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
397 | + //replace [frmurl] |
|
398 | + $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
399 | 399 | |
400 | 400 | if ( strpos( $html, '[button_label]' ) ) { |
401 | 401 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
402 | 402 | $replace_with = apply_filters( 'frm_submit_button', $title, $form ); |
403 | 403 | $html = str_replace( '[button_label]', $replace_with, $html ); |
404 | - } |
|
404 | + } |
|
405 | 405 | |
406 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
406 | + $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
407 | 407 | |
408 | 408 | if ( strpos( $html, '[if back_button]' ) ) { |
409 | 409 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -417,32 +417,32 @@ discard block |
||
417 | 417 | $html = do_shortcode( $html ); |
418 | 418 | } |
419 | 419 | |
420 | - return $html; |
|
421 | - } |
|
420 | + return $html; |
|
421 | + } |
|
422 | 422 | |
423 | 423 | public static function submit_button_label( $submit ) { |
424 | - if ( ! $submit || empty($submit) ) { |
|
425 | - $frm_settings = FrmAppHelper::get_settings(); |
|
426 | - $submit = $frm_settings->submit_value; |
|
427 | - } |
|
424 | + if ( ! $submit || empty($submit) ) { |
|
425 | + $frm_settings = FrmAppHelper::get_settings(); |
|
426 | + $submit = $frm_settings->submit_value; |
|
427 | + } |
|
428 | 428 | |
429 | - return $submit; |
|
430 | - } |
|
429 | + return $submit; |
|
430 | + } |
|
431 | 431 | |
432 | 432 | public static function get_form_style_class( $form = false ) { |
433 | - $style = self::get_form_style($form); |
|
434 | - $class = ' with_frm_style'; |
|
435 | - |
|
436 | - if ( empty($style) ) { |
|
437 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
438 | - return $class; |
|
439 | - } else { |
|
440 | - return; |
|
441 | - } |
|
442 | - } |
|
443 | - |
|
444 | - //If submit button needs to be inline or centered |
|
445 | - if ( is_object($form) ) { |
|
433 | + $style = self::get_form_style($form); |
|
434 | + $class = ' with_frm_style'; |
|
435 | + |
|
436 | + if ( empty($style) ) { |
|
437 | + if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
438 | + return $class; |
|
439 | + } else { |
|
440 | + return; |
|
441 | + } |
|
442 | + } |
|
443 | + |
|
444 | + //If submit button needs to be inline or centered |
|
445 | + if ( is_object($form) ) { |
|
446 | 446 | $form = $form->options; |
447 | 447 | } |
448 | 448 | |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | $class .= ' frm_center_submit'; |
455 | 455 | } |
456 | 456 | |
457 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
457 | + $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
458 | 458 | |
459 | - return $class; |
|
460 | - } |
|
459 | + return $class; |
|
460 | + } |
|
461 | 461 | |
462 | - /** |
|
463 | - * @param string|boolean $form |
|
464 | - * |
|
465 | - * @return string |
|
466 | - */ |
|
467 | - public static function get_form_style( $form ) { |
|
462 | + /** |
|
463 | + * @param string|boolean $form |
|
464 | + * |
|
465 | + * @return string |
|
466 | + */ |
|
467 | + public static function get_form_style( $form ) { |
|
468 | 468 | $style = 1; |
469 | 469 | if ( empty( $form ) || 'default' == 'form' ) { |
470 | 470 | return $style; |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style; |
485 | 485 | |
486 | 486 | return $style; |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | 489 | /** |
490 | 490 | * Display the validation error messages when an entry is submitted |
@@ -538,74 +538,74 @@ discard block |
||
538 | 538 | } |
539 | 539 | |
540 | 540 | public static function get_scroll_js( $form_id ) { |
541 | - ?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php |
|
542 | - } |
|
541 | + ?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php |
|
542 | + } |
|
543 | 543 | |
544 | 544 | public static function edit_form_link( $form_id ) { |
545 | - if ( is_object($form_id) ) { |
|
546 | - $form = $form_id; |
|
547 | - $name = $form->name; |
|
548 | - $form_id = $form->id; |
|
549 | - } else { |
|
550 | - $name = FrmForm::getName($form_id); |
|
551 | - } |
|
552 | - |
|
553 | - if ( $form_id ) { |
|
545 | + if ( is_object($form_id) ) { |
|
546 | + $form = $form_id; |
|
547 | + $name = $form->name; |
|
548 | + $form_id = $form->id; |
|
549 | + } else { |
|
550 | + $name = FrmForm::getName($form_id); |
|
551 | + } |
|
552 | + |
|
553 | + if ( $form_id ) { |
|
554 | 554 | $val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>'; |
555 | - } else { |
|
556 | - $val = ''; |
|
557 | - } |
|
555 | + } else { |
|
556 | + $val = ''; |
|
557 | + } |
|
558 | 558 | |
559 | - return $val; |
|
559 | + return $val; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | public static function delete_trash_link( $id, $status, $length = 'long' ) { |
563 | - $link = ''; |
|
564 | - $labels = array( |
|
565 | - 'restore' => array( |
|
566 | - 'long' => __( 'Restore from Trash', 'formidable' ), |
|
567 | - 'short' => __( 'Restore', 'formidable' ), |
|
568 | - ), |
|
569 | - 'trash' => array( |
|
570 | - 'long' => __( 'Move to Trash', 'formidable' ), |
|
571 | - 'short' => __( 'Trash', 'formidable' ), |
|
572 | - ), |
|
573 | - 'delete' => array( |
|
574 | - 'long' => __( 'Delete Permanently', 'formidable' ), |
|
575 | - 'short' => __( 'Delete', 'formidable' ), |
|
576 | - ), |
|
577 | - ); |
|
578 | - |
|
579 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
580 | - $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id; |
|
581 | - if ( 'trash' == $status ) { |
|
563 | + $link = ''; |
|
564 | + $labels = array( |
|
565 | + 'restore' => array( |
|
566 | + 'long' => __( 'Restore from Trash', 'formidable' ), |
|
567 | + 'short' => __( 'Restore', 'formidable' ), |
|
568 | + ), |
|
569 | + 'trash' => array( |
|
570 | + 'long' => __( 'Move to Trash', 'formidable' ), |
|
571 | + 'short' => __( 'Trash', 'formidable' ), |
|
572 | + ), |
|
573 | + 'delete' => array( |
|
574 | + 'long' => __( 'Delete Permanently', 'formidable' ), |
|
575 | + 'short' => __( 'Delete', 'formidable' ), |
|
576 | + ), |
|
577 | + ); |
|
578 | + |
|
579 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
580 | + $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id; |
|
581 | + if ( 'trash' == $status ) { |
|
582 | 582 | $link = '<a href="'. esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>'; |
583 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
584 | - if ( EMPTY_TRASH_DAYS ) { |
|
583 | + } else if ( current_user_can('frm_delete_forms') ) { |
|
584 | + if ( EMPTY_TRASH_DAYS ) { |
|
585 | 585 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>'; |
586 | - } else { |
|
586 | + } else { |
|
587 | 587 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url .'&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>'; |
588 | - } |
|
589 | - } |
|
588 | + } |
|
589 | + } |
|
590 | 590 | |
591 | - return $link; |
|
592 | - } |
|
591 | + return $link; |
|
592 | + } |
|
593 | 593 | |
594 | 594 | public static function status_nice_name( $status ) { |
595 | - $nice_names = array( |
|
596 | - 'draft' => __( 'Draft', 'formidable' ), |
|
597 | - 'trash' => __( 'Trash', 'formidable' ), |
|
598 | - 'publish' => __( 'Published', 'formidable' ), |
|
599 | - ); |
|
600 | - |
|
601 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
602 | - $status = 'publish'; |
|
603 | - } |
|
595 | + $nice_names = array( |
|
596 | + 'draft' => __( 'Draft', 'formidable' ), |
|
597 | + 'trash' => __( 'Trash', 'formidable' ), |
|
598 | + 'publish' => __( 'Published', 'formidable' ), |
|
599 | + ); |
|
600 | + |
|
601 | + if ( ! in_array($status, array_keys($nice_names)) ) { |
|
602 | + $status = 'publish'; |
|
603 | + } |
|
604 | 604 | |
605 | 605 | $name = $nice_names[ $status ]; |
606 | 606 | |
607 | - return $name; |
|
608 | - } |
|
607 | + return $name; |
|
608 | + } |
|
609 | 609 | |
610 | 610 | public static function get_params() { |
611 | 611 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' ); |
@@ -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 | |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | } |
12 | 12 | |
13 | 13 | public static function get_direct_link( $key, $form = false ) { |
14 | - $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form='. $key ) ); |
|
15 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
14 | + $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
|
15 | + $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form ); |
|
16 | 16 | |
17 | 17 | return $target_url; |
18 | 18 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $query['id !'] = $args['exclude']; |
38 | 38 | } |
39 | 39 | |
40 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
40 | + $where = apply_filters( 'frm_forms_dropdown', $query, $field_name ); |
|
41 | 41 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
42 | 42 | $add_html = array(); |
43 | 43 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | <?php } ?> |
51 | 51 | <?php foreach ( $forms as $form ) { ?> |
52 | 52 | <option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php |
53 | - echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 33 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ; |
|
53 | + echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 33 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ); |
|
54 | 54 | ?></option> |
55 | 55 | <?php } ?> |
56 | 56 | </select> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function add_html_attr( $class, $param, &$add_html ) { |
68 | 68 | if ( ! empty( $class ) ) { |
69 | - $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
69 | + $add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $args = array( 'id' => 0, 'form' => 0 ); |
78 | 78 | if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) { |
79 | 79 | unset( $args['form'] ); |
80 | - } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
|
80 | + } else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) { |
|
81 | 81 | unset( $args['id'] ); |
82 | 82 | } |
83 | 83 | |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
86 | 86 | $args['frm_action'] = 'list'; |
87 | 87 | $args['form'] = 0; |
88 | - } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
|
88 | + } else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
|
89 | 89 | $args['frm_action'] = 'edit'; |
90 | 90 | } else if ( isset( $_GET['post'] ) ) { |
91 | 91 | $args['form'] = 0; |
92 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
92 | + $base = admin_url( 'edit.php?post_type=frm_display' ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | ?> |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $args['form'] = $form->id; |
106 | 106 | } |
107 | 107 | ?> |
108 | - <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
|
108 | + <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
|
109 | 109 | <?php |
110 | 110 | unset( $form ); |
111 | 111 | } ?> |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
118 | - echo ($sort_col == $col) ? 'sorted' : 'sortable'; |
|
119 | - echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc'; |
|
118 | + echo ( $sort_col == $col ) ? 'sorted' : 'sortable'; |
|
119 | + echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public static function get_success_message( $atts ) { |
@@ -136,37 +136,37 @@ discard block |
||
136 | 136 | $post_values = $values; |
137 | 137 | } else { |
138 | 138 | $values = array(); |
139 | - $post_values = isset($_POST) ? $_POST : array(); |
|
139 | + $post_values = isset( $_POST ) ? $_POST : array(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) { |
143 | - if ( ! isset( $values[ $var ] ) ) { |
|
144 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
143 | + if ( ! isset( $values[$var] ) ) { |
|
144 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
148 | + $values['description'] = FrmAppHelper::use_wpautop( $values['description'] ); |
|
149 | 149 | |
150 | 150 | foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) { |
151 | - if ( ! isset( $values[ $var ] ) ) { |
|
152 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
151 | + if ( ! isset( $values[$var] ) ) { |
|
152 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | if ( ! isset( $values['form_key'] ) ) { |
157 | - $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key'); |
|
157 | + $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
|
158 | 158 | } |
159 | 159 | |
160 | - $values = self::fill_default_opts($values, false, $post_values); |
|
160 | + $values = self::fill_default_opts( $values, false, $post_values ); |
|
161 | 161 | |
162 | - if ( $post_values && isset($post_values['options']['custom_style']) ) { |
|
162 | + if ( $post_values && isset( $post_values['options']['custom_style'] ) ) { |
|
163 | 163 | $values['custom_style'] = $post_values['options']['custom_style']; |
164 | 164 | } else { |
165 | 165 | $frm_settings = FrmAppHelper::get_settings(); |
166 | 166 | $values['custom_style'] = ( $frm_settings->load_style != 'none' ); |
167 | 167 | } |
168 | 168 | |
169 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
169 | + return apply_filters( 'frm_setup_new_form_vars', $values ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -177,42 +177,42 @@ discard block |
||
177 | 177 | $post_values = stripslashes_deep( $_POST ); |
178 | 178 | } |
179 | 179 | |
180 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
181 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
182 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
180 | + $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key; |
|
181 | + $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template; |
|
182 | + $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template; |
|
183 | 183 | $values['status'] = $record->status; |
184 | 184 | |
185 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
185 | + $values = self::fill_default_opts( $values, $record, $post_values ); |
|
186 | 186 | |
187 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
187 | + return apply_filters( 'frm_setup_edit_form_vars', $values ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public static function fill_default_opts( $values, $record, $post_values ) { |
191 | 191 | |
192 | 192 | $defaults = self::get_default_opts(); |
193 | 193 | foreach ( $defaults as $var => $default ) { |
194 | - if ( is_array($default) ) { |
|
195 | - if ( ! isset( $values[ $var ] ) ) { |
|
196 | - $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
|
194 | + if ( is_array( $default ) ) { |
|
195 | + if ( ! isset( $values[$var] ) ) { |
|
196 | + $values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array(); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | foreach ( $default as $k => $v ) { |
200 | - $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v); |
|
200 | + $values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v ); |
|
201 | 201 | |
202 | 202 | if ( is_array( $v ) ) { |
203 | 203 | foreach ( $v as $k1 => $v1 ) { |
204 | - $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
|
204 | + $values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 ); |
|
205 | 205 | unset( $k1, $v1 ); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - unset($k, $v); |
|
209 | + unset( $k, $v ); |
|
210 | 210 | } |
211 | 211 | } else { |
212 | - $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
|
212 | + $values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default ); |
|
213 | 213 | } |
214 | 214 | |
215 | - unset($var, $default); |
|
215 | + unset( $var, $default ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return $values; |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | 'submit_value' => $frm_settings->submit_value, 'success_action' => 'message', |
226 | 226 | 'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '', |
227 | 227 | 'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1, |
228 | - 'before_html' => self::get_default_html('before'), |
|
228 | + 'before_html' => self::get_default_html( 'before' ), |
|
229 | 229 | 'after_html' => '', |
230 | - 'submit_html' => self::get_default_html('submit'), |
|
230 | + 'submit_html' => self::get_default_html( 'submit' ), |
|
231 | 231 | ); |
232 | 232 | } |
233 | 233 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public static function fill_form_options( &$options, $values ) { |
240 | 240 | $defaults = self::get_default_opts(); |
241 | 241 | foreach ( $defaults as $var => $default ) { |
242 | - $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default; |
|
242 | + $options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default; |
|
243 | 243 | unset( $var, $default ); |
244 | 244 | } |
245 | 245 | } |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
282 | - $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values); |
|
283 | - if ( ! strpos($button, '[button_action]') ) { |
|
282 | + $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values ); |
|
283 | + if ( ! strpos( $button, '[button_action]' ) ) { |
|
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - $button_parts = explode('[button_action]', $button); |
|
287 | + $button_parts = explode( '[button_action]', $button ); |
|
288 | 288 | echo $button_parts[0]; |
289 | 289 | //echo ' id="frm_submit_"'; |
290 | 290 | |
291 | - $classes = apply_filters('frm_submit_button_class', array(), $form); |
|
292 | - if ( ! empty($classes) ) { |
|
291 | + $classes = apply_filters( 'frm_submit_button_class', array(), $form ); |
|
292 | + if ( ! empty( $classes ) ) { |
|
293 | 293 | echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"'; |
294 | 294 | } |
295 | 295 | |
296 | - do_action('frm_submit_button_action', $form, $form_action); |
|
296 | + do_action( 'frm_submit_button_action', $form, $form_action ); |
|
297 | 297 | echo $button_parts[1]; |
298 | 298 | } |
299 | 299 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $last_field = false; |
315 | 315 | foreach ( $fields as $field ) { |
316 | 316 | if ( $prev_order === $field->field_order ) { |
317 | - $add_order++; |
|
317 | + $add_order ++; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | if ( $add_order ) { |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | if ( $code == 'form_name' ) { |
382 | 382 | $replace_with = $form->name; |
383 | 383 | } else if ( $code == 'form_description' ) { |
384 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
385 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
384 | + $replace_with = FrmAppHelper::use_wpautop( $form->description ); |
|
385 | + } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) { |
|
386 | 386 | $replace_with = FrmAppHelper::simple_get( 'entry' ); |
387 | 387 | } else { |
388 | 388 | $replace_with = ''; |
389 | 389 | } |
390 | 390 | |
391 | - FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
391 | + FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | //replace [form_key] |
395 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
395 | + $html = str_replace( '[form_key]', $form->form_key, $html ); |
|
396 | 396 | |
397 | 397 | //replace [frmurl] |
398 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
398 | + $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html ); |
|
399 | 399 | |
400 | 400 | if ( strpos( $html, '[button_label]' ) ) { |
401 | 401 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $html = str_replace( '[button_label]', $replace_with, $html ); |
404 | 404 | } |
405 | 405 | |
406 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
406 | + $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values ); |
|
407 | 407 | |
408 | 408 | if ( strpos( $html, '[if back_button]' ) ) { |
409 | 409 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | public static function submit_button_label( $submit ) { |
424 | - if ( ! $submit || empty($submit) ) { |
|
424 | + if ( ! $submit || empty( $submit ) ) { |
|
425 | 425 | $frm_settings = FrmAppHelper::get_settings(); |
426 | 426 | $submit = $frm_settings->submit_value; |
427 | 427 | } |
@@ -430,11 +430,11 @@ discard block |
||
430 | 430 | } |
431 | 431 | |
432 | 432 | public static function get_form_style_class( $form = false ) { |
433 | - $style = self::get_form_style($form); |
|
433 | + $style = self::get_form_style( $form ); |
|
434 | 434 | $class = ' with_frm_style'; |
435 | 435 | |
436 | - if ( empty($style) ) { |
|
437 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
436 | + if ( empty( $style ) ) { |
|
437 | + if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
|
438 | 438 | return $class; |
439 | 439 | } else { |
440 | 440 | return; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | //If submit button needs to be inline or centered |
445 | - if ( is_object($form) ) { |
|
445 | + if ( is_object( $form ) ) { |
|
446 | 446 | $form = $form->options; |
447 | 447 | } |
448 | 448 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $class .= ' frm_center_submit'; |
455 | 455 | } |
456 | 456 | |
457 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
457 | + $class = apply_filters( 'frm_add_form_style_class', $class, $style ); |
|
458 | 458 | |
459 | 459 | return $class; |
460 | 460 | } |
@@ -542,12 +542,12 @@ discard block |
||
542 | 542 | } |
543 | 543 | |
544 | 544 | public static function edit_form_link( $form_id ) { |
545 | - if ( is_object($form_id) ) { |
|
545 | + if ( is_object( $form_id ) ) { |
|
546 | 546 | $form = $form_id; |
547 | 547 | $name = $form->name; |
548 | 548 | $form_id = $form->id; |
549 | 549 | } else { |
550 | - $name = FrmForm::getName($form_id); |
|
550 | + $name = FrmForm::getName( $form_id ); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | if ( $form_id ) { |
@@ -577,14 +577,14 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
580 | - $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id; |
|
580 | + $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id; |
|
581 | 581 | if ( 'trash' == $status ) { |
582 | - $link = '<a href="'. esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>'; |
|
583 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
582 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>'; |
|
583 | + } else if ( current_user_can( 'frm_delete_forms' ) ) { |
|
584 | 584 | if ( EMPTY_TRASH_DAYS ) { |
585 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>'; |
|
585 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>'; |
|
586 | 586 | } else { |
587 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url .'&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>'; |
|
587 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>'; |
|
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | 'publish' => __( 'Published', 'formidable' ), |
599 | 599 | ); |
600 | 600 | |
601 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
601 | + if ( ! in_array( $status, array_keys( $nice_names ) ) ) { |
|
602 | 602 | $status = 'publish'; |
603 | 603 | } |
604 | 604 | |
605 | - $name = $nice_names[ $status ]; |
|
605 | + $name = $nice_names[$status]; |
|
606 | 606 | |
607 | 607 | return $name; |
608 | 608 | } |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | protected $modes = array(); |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @var array |
|
72 | - */ |
|
73 | - protected $params; |
|
70 | + * |
|
71 | + * @var array |
|
72 | + */ |
|
73 | + protected $params; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | 'single_row_columns' ); |
88 | 88 | |
89 | 89 | /** |
90 | - * Construct the table object |
|
91 | - */ |
|
90 | + * Construct the table object |
|
91 | + */ |
|
92 | 92 | public function __construct( $args ) { |
93 | - $args = wp_parse_args( $args, array( |
|
93 | + $args = wp_parse_args( $args, array( |
|
94 | 94 | 'params' => array(), |
95 | 95 | 'plural' => '', |
96 | 96 | 'singular' => '', |
@@ -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 | |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | return $this->get_pagenum(); |
276 | 276 | } |
277 | 277 | |
278 | - if ( isset( $this->_pagination_args[ $key ] ) ) { |
|
279 | - return $this->_pagination_args[ $key ]; |
|
278 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
279 | + return $this->_pagination_args[$key]; |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | } |
332 | 332 | |
333 | 333 | private function hidden_search_inputs( $param_name ) { |
334 | - if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
|
335 | - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
|
334 | + if ( ! empty( $_REQUEST[$param_name] ) ) { |
|
335 | + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />'; |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | |
376 | 376 | echo "<ul class='subsubsub'>\n"; |
377 | 377 | foreach ( $views as $class => $view ) { |
378 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
378 | + $views[$class] = "\t<li class='$class'>$view"; |
|
379 | 379 | } |
380 | 380 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
381 | 381 | echo '</ul>'; |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | foreach ( $this->_actions as $name => $title ) { |
437 | 437 | $class = 'edit' == $name ? ' class="hide-if-no-js"' : ''; |
438 | 438 | |
439 | - echo "\t<option value='". esc_attr( $name ) ."'$class>$title</option>\n"; |
|
439 | + echo "\t<option value='" . esc_attr( $name ) . "'$class>$title</option>\n"; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | echo "</select>\n"; |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | |
469 | 469 | private static function get_bulk_action( $action_name ) { |
470 | 470 | $action = false; |
471 | - if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
|
472 | - $action = sanitize_text_field( $_REQUEST[ $action_name ] ); |
|
471 | + if ( isset( $_REQUEST[$action_name] ) && -1 != sanitize_text_field( $_REQUEST[$action_name] ) ) { |
|
472 | + $action = sanitize_text_field( $_REQUEST[$action_name] ); |
|
473 | 473 | } |
474 | 474 | return $action; |
475 | 475 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
496 | 496 | foreach ( $actions as $action => $link ) { |
497 | - ++$i; |
|
497 | + ++ $i; |
|
498 | 498 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
499 | 499 | $out .= "<span class='$action'>$link$sep</span>"; |
500 | 500 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | // If the primary column doesn't exist fall back to the |
762 | 762 | // first non-checkbox column. |
763 | - if ( ! isset( $columns[ $default ] ) ) { |
|
763 | + if ( ! isset( $columns[$default] ) ) { |
|
764 | 764 | $default = FrmListHelper::get_default_primary_column_name(); |
765 | 765 | } |
766 | 766 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | */ |
775 | 775 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
776 | 776 | |
777 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
777 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
778 | 778 | $column = $default; |
779 | 779 | } |
780 | 780 | |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | // In 4.3, we added a fourth argument for primary column. |
797 | 797 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
798 | 798 | foreach ( $this->_column_headers as $key => $value ) { |
799 | - $column_headers[ $key ] = $value; |
|
799 | + $column_headers[$key] = $value; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | return $column_headers; |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | $data[1] = false; |
830 | 830 | } |
831 | 831 | |
832 | - $sortable[ $id ] = $data; |
|
832 | + $sortable[$id] = $data; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | $primary = $this->get_primary_column_name(); |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | static $cb_counter = 1; |
885 | 885 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
886 | 886 | . '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; |
887 | - $cb_counter++; |
|
887 | + $cb_counter ++; |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -904,8 +904,8 @@ discard block |
||
904 | 904 | $class[] = 'column-primary'; |
905 | 905 | } |
906 | 906 | |
907 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
908 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
907 | + if ( isset( $sortable[$column_key] ) ) { |
|
908 | + list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
909 | 909 | |
910 | 910 | if ( $current_orderby == $orderby ) { |
911 | 911 | $order = 'asc' == $current_order ? 'desc' : 'asc'; |
@@ -253,6 +253,9 @@ discard block |
||
253 | 253 | <?php |
254 | 254 | } |
255 | 255 | |
256 | + /** |
|
257 | + * @param string $param_name |
|
258 | + */ |
|
256 | 259 | private function hidden_search_inputs( $param_name ) { |
257 | 260 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
258 | 261 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -389,6 +392,9 @@ discard block |
||
389 | 392 | return $action; |
390 | 393 | } |
391 | 394 | |
395 | + /** |
|
396 | + * @param string $action_name |
|
397 | + */ |
|
392 | 398 | private static function get_bulk_action( $action_name ) { |
393 | 399 | $action = false; |
394 | 400 | if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
@@ -1,26 +1,26 @@ 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 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
21 | - } |
|
19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
21 | + } |
|
22 | 22 | |
23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | 24 | // Don't get subfields |
25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,46 +28,46 @@ discard block |
||
28 | 28 | $where['fi.type not'] = $exclude; |
29 | 29 | } |
30 | 30 | |
31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
32 | 32 | |
33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
34 | - $args = array( 'exclude' => $exclude ); |
|
33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
34 | + $args = array( 'exclude' => $exclude ); |
|
35 | 35 | |
36 | - foreach ( $posted_fields as $posted_field ) { |
|
37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
38 | - unset($posted_field); |
|
39 | - } |
|
36 | + foreach ( $posted_fields as $posted_field ) { |
|
37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
38 | + unset($posted_field); |
|
39 | + } |
|
40 | 40 | |
41 | - // check for spam |
|
42 | - self::spam_check( $exclude, $values, $errors ); |
|
41 | + // check for spam |
|
42 | + self::spam_check( $exclude, $values, $errors ); |
|
43 | 43 | |
44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
45 | 45 | |
46 | - return $errors; |
|
47 | - } |
|
46 | + return $errors; |
|
47 | + } |
|
48 | 48 | |
49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
50 | - $defaults = array( |
|
51 | - 'id' => $posted_field->id, |
|
52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
53 | - 'key_pointer' => '', // the pointer in the posted array |
|
54 | - 'exclude' => array(), // exclude these field types from validation |
|
55 | - ); |
|
56 | - $args = wp_parse_args( $args, $defaults ); |
|
49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
50 | + $defaults = array( |
|
51 | + 'id' => $posted_field->id, |
|
52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
53 | + 'key_pointer' => '', // the pointer in the posted array |
|
54 | + 'exclude' => array(), // exclude these field types from validation |
|
55 | + ); |
|
56 | + $args = wp_parse_args( $args, $defaults ); |
|
57 | 57 | |
58 | - if ( empty($args['parent_field_id']) ) { |
|
58 | + if ( empty($args['parent_field_id']) ) { |
|
59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
60 | - } else { |
|
61 | - // value is from a nested form |
|
62 | - $value = $values; |
|
63 | - } |
|
60 | + } else { |
|
61 | + // value is from a nested form |
|
62 | + $value = $values; |
|
63 | + } |
|
64 | 64 | |
65 | - // Check for values in "Other" fields |
|
66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
65 | + // Check for values in "Other" fields |
|
66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
67 | 67 | |
68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
69 | - $value = ''; |
|
70 | - } |
|
68 | + if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
69 | + $value = ''; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | // Check for an array with only one value |
73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | $value = reset($value); |
76 | 76 | } |
77 | 77 | |
78 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
78 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
79 | 79 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
80 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
81 | - $_POST['item_name'] = $value; |
|
82 | - } |
|
80 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
81 | + $_POST['item_name'] = $value; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | if ( $value != '' ) { |
85 | 85 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -88,41 +88,41 @@ discard block |
||
88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
89 | 89 | } |
90 | 90 | |
91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
91 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
92 | 92 | |
93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
93 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
94 | 94 | |
95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
96 | - } |
|
95 | + $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
99 | 99 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
100 | - return; |
|
101 | - } |
|
102 | - |
|
103 | - if ( trim($value) == 'http://' ) { |
|
104 | - $value = ''; |
|
105 | - } else { |
|
106 | - $value = esc_url_raw( $value ); |
|
107 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
108 | - } |
|
109 | - |
|
110 | - //validate the url format |
|
111 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
100 | + return; |
|
101 | + } |
|
102 | + |
|
103 | + if ( trim($value) == 'http://' ) { |
|
104 | + $value = ''; |
|
105 | + } else { |
|
106 | + $value = esc_url_raw( $value ); |
|
107 | + $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
108 | + } |
|
109 | + |
|
110 | + //validate the url format |
|
111 | + if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
112 | 112 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
113 | - } |
|
114 | - } |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
117 | - if ( $value == '' || $field->type != 'email' ) { |
|
118 | - return; |
|
119 | - } |
|
117 | + if ( $value == '' || $field->type != 'email' ) { |
|
118 | + return; |
|
119 | + } |
|
120 | 120 | |
121 | - //validate the email format |
|
122 | - if ( ! is_email($value) ) { |
|
121 | + //validate the email format |
|
122 | + if ( ! is_email($value) ) { |
|
123 | 123 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
124 | - } |
|
125 | - } |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | 127 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
128 | 128 | //validate the number format |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | public static function validate_recaptcha( &$errors, $field, $args ) { |
202 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
203 | - return; |
|
204 | - } |
|
202 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
203 | + return; |
|
204 | + } |
|
205 | 205 | |
206 | 206 | $frm_settings = FrmAppHelper::get_settings(); |
207 | 207 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -209,53 +209,53 @@ discard block |
||
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
213 | - // If captcha is missing, check if it was already verified |
|
212 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
213 | + // If captcha is missing, check if it was already verified |
|
214 | 214 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
215 | - // There was no captcha submitted |
|
215 | + // There was no captcha submitted |
|
216 | 216 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
217 | - } |
|
218 | - return; |
|
219 | - } |
|
217 | + } |
|
218 | + return; |
|
219 | + } |
|
220 | 220 | |
221 | - $arg_array = array( |
|
222 | - 'body' => array( |
|
221 | + $arg_array = array( |
|
222 | + 'body' => array( |
|
223 | 223 | 'secret' => $frm_settings->privkey, |
224 | 224 | 'response' => $_POST['g-recaptcha-response'], |
225 | 225 | 'remoteip' => FrmAppHelper::get_ip_address(), |
226 | 226 | ), |
227 | 227 | ); |
228 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
229 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
228 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
229 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
230 | 230 | |
231 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
232 | - // What happens when the CAPTCHA was entered incorrectly |
|
231 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
232 | + // What happens when the CAPTCHA was entered incorrectly |
|
233 | 233 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * check for spam |
|
239 | - * @param boolean $exclude |
|
240 | - * @param array $values |
|
241 | - * @param array $errors by reference |
|
242 | - */ |
|
243 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
244 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
245 | - // only check spam if there are no other errors |
|
246 | - return; |
|
247 | - } |
|
248 | - |
|
249 | - if ( self::is_akismet_spam( $values ) ) { |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * check for spam |
|
239 | + * @param boolean $exclude |
|
240 | + * @param array $values |
|
241 | + * @param array $errors by reference |
|
242 | + */ |
|
243 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
244 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
245 | + // only check spam if there are no other errors |
|
246 | + return; |
|
247 | + } |
|
248 | + |
|
249 | + if ( self::is_akismet_spam( $values ) ) { |
|
250 | 250 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
251 | 251 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
252 | 252 | } |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - if ( self::blacklist_check( $values ) ) { |
|
256 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
257 | - } |
|
258 | - } |
|
255 | + if ( self::blacklist_check( $values ) ) { |
|
256 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | 260 | private static function is_akismet_spam( $values ) { |
261 | 261 | global $wpcom_api_key; |
@@ -267,54 +267,54 @@ discard block |
||
267 | 267 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
268 | 268 | } |
269 | 269 | |
270 | - public static function blacklist_check( $values ) { |
|
271 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
272 | - return false; |
|
273 | - } |
|
270 | + public static function blacklist_check( $values ) { |
|
271 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
272 | + return false; |
|
273 | + } |
|
274 | 274 | |
275 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
275 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
276 | 276 | |
277 | - if ( empty( $mod_keys ) ) { |
|
278 | - return false; |
|
279 | - } |
|
277 | + if ( empty( $mod_keys ) ) { |
|
278 | + return false; |
|
279 | + } |
|
280 | 280 | |
281 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
281 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
282 | 282 | |
283 | 283 | if ( empty($content) ) { |
284 | - return false; |
|
284 | + return false; |
|
285 | 285 | } |
286 | 286 | |
287 | - $words = explode( "\n", $mod_keys ); |
|
287 | + $words = explode( "\n", $mod_keys ); |
|
288 | 288 | |
289 | - foreach ( (array) $words as $word ) { |
|
290 | - $word = trim( $word ); |
|
289 | + foreach ( (array) $words as $word ) { |
|
290 | + $word = trim( $word ); |
|
291 | 291 | |
292 | - if ( empty($word) ) { |
|
293 | - continue; |
|
294 | - } |
|
292 | + if ( empty($word) ) { |
|
293 | + continue; |
|
294 | + } |
|
295 | 295 | |
296 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
297 | - return true; |
|
298 | - } |
|
299 | - } |
|
296 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
297 | + return true; |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - return false; |
|
302 | - } |
|
301 | + return false; |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * Check entries for spam |
|
306 | - * |
|
307 | - * @return boolean true if is spam |
|
308 | - */ |
|
309 | - public static function akismet( $values ) { |
|
310 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
304 | + /** |
|
305 | + * Check entries for spam |
|
306 | + * |
|
307 | + * @return boolean true if is spam |
|
308 | + */ |
|
309 | + public static function akismet( $values ) { |
|
310 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
311 | 311 | |
312 | 312 | if ( empty( $content ) ) { |
313 | - return false; |
|
313 | + return false; |
|
314 | 314 | } |
315 | 315 | |
316 | - $datas = array(); |
|
317 | - self::parse_akismet_array( $datas, $content ); |
|
316 | + $datas = array(); |
|
317 | + self::parse_akismet_array( $datas, $content ); |
|
318 | 318 | |
319 | 319 | $query_string = ''; |
320 | 320 | foreach ( $datas as $key => $data ) { |
@@ -322,35 +322,35 @@ discard block |
||
322 | 322 | unset( $key, $data ); |
323 | 323 | } |
324 | 324 | |
325 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
325 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
326 | 326 | |
327 | 327 | return ( is_array( $response ) && $response[1] == 'true' ); |
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * @since 2.0 |
|
332 | - * @param string $content |
|
333 | - */ |
|
334 | - private static function parse_akismet_array( &$datas, $content ) { |
|
335 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
336 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * @since 2.0 |
|
332 | + * @param string $content |
|
333 | + */ |
|
334 | + private static function parse_akismet_array( &$datas, $content ) { |
|
335 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
336 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
337 | 337 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
338 | 338 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
339 | - $datas['comment_type'] = 'formidable'; |
|
340 | - $datas['comment_content'] = $content; |
|
339 | + $datas['comment_type'] = 'formidable'; |
|
340 | + $datas['comment_content'] = $content; |
|
341 | 341 | |
342 | - if ( $permalink = get_permalink() ) { |
|
343 | - $datas['permalink'] = $permalink; |
|
344 | - } |
|
342 | + if ( $permalink = get_permalink() ) { |
|
343 | + $datas['permalink'] = $permalink; |
|
344 | + } |
|
345 | 345 | |
346 | - foreach ( $_SERVER as $key => $value ) { |
|
346 | + foreach ( $_SERVER as $key => $value ) { |
|
347 | 347 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
348 | 348 | $datas[ $key ] = wp_strip_all_tags( $value ); |
349 | - } else { |
|
349 | + } else { |
|
350 | 350 | $datas[ $key ] = ''; |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | - unset($key, $value); |
|
354 | - } |
|
355 | - } |
|
353 | + unset($key, $value); |
|
354 | + } |
|
355 | + } |
|
356 | 356 | } |
@@ -7,20 +7,20 @@ 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 | |
19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
19 | + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
|
20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
|
21 | 21 | } |
22 | 22 | |
23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
23 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | 24 | // Don't get subfields |
25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $where['fi.type not'] = $exclude; |
29 | 29 | } |
30 | 30 | |
31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
31 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
32 | 32 | |
33 | 33 | // Pass exclude value to validate_field function so it can be used for repeating sections |
34 | 34 | $args = array( 'exclude' => $exclude ); |
35 | 35 | |
36 | 36 | foreach ( $posted_fields as $posted_field ) { |
37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
38 | - unset($posted_field); |
|
37 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
38 | + unset( $posted_field ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // check for spam |
42 | 42 | self::spam_check( $exclude, $values, $errors ); |
43 | 43 | |
44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
45 | 45 | |
46 | 46 | return $errors; |
47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | ); |
56 | 56 | $args = wp_parse_args( $args, $defaults ); |
57 | 57 | |
58 | - if ( empty($args['parent_field_id']) ) { |
|
59 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
58 | + if ( empty( $args['parent_field_id'] ) ) { |
|
59 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
60 | 60 | } else { |
61 | 61 | // value is from a nested form |
62 | 62 | $value = $values; |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | // Check for values in "Other" fields |
66 | 66 | FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
67 | 67 | |
68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
68 | + if ( isset( $posted_field->field_options['default_blank'] ) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
69 | 69 | $value = ''; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Check for an array with only one value |
73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
74 | - if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) { |
|
75 | - $value = reset($value); |
|
74 | + if ( is_array( $value ) && count( $value ) == 1 && $args['other'] !== true ) { |
|
75 | + $value = reset( $value ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
79 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
79 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
80 | 80 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
81 | 81 | $_POST['item_name'] = $value; |
82 | 82 | } |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
89 | 89 | } |
90 | 90 | |
91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
91 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
92 | 92 | |
93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
93 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
94 | 94 | |
95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
95 | + $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - if ( trim($value) == 'http://' ) { |
|
103 | + if ( trim( $value ) == 'http://' ) { |
|
104 | 104 | $value = ''; |
105 | 105 | } else { |
106 | 106 | $value = esc_url_raw( $value ); |
107 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
107 | + $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | //validate the url format |
111 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
112 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
111 | + if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) { |
|
112 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | //validate the email format |
122 | - if ( ! is_email($value) ) { |
|
123 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
122 | + if ( ! is_email( $value ) ) { |
|
123 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - if ( ! is_numeric( $value) ) { |
|
134 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
133 | + if ( ! is_numeric( $value ) ) { |
|
134 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // validate number settings |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
142 | 142 | //minnum maxnum |
143 | 143 | if ( (float) $value < $field->field_options['minnum'] ) { |
144 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
144 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
145 | 145 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
146 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
146 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $pattern = self::phone_format( $field ); |
158 | 158 | |
159 | 159 | if ( ! preg_match( $pattern, $value ) ) { |
160 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
160 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
212 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
213 | 213 | // If captcha is missing, check if it was already verified |
214 | 214 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
215 | 215 | // There was no captcha submitted |
216 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
216 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
217 | 217 | } |
218 | 218 | return; |
219 | 219 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | ), |
227 | 227 | ); |
228 | 228 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
229 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
229 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
230 | 230 | |
231 | 231 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
232 | 232 | // What happens when the CAPTCHA was entered incorrectly |
233 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
233 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | private static function is_akismet_spam( $values ) { |
261 | 261 | global $wpcom_api_key; |
262 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
262 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | public static function blacklist_check( $values ) { |
271 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
271 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
272 | 272 | return false; |
273 | 273 | } |
274 | 274 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | |
281 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
281 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
282 | 282 | |
283 | - if ( empty($content) ) { |
|
283 | + if ( empty( $content ) ) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | foreach ( (array) $words as $word ) { |
290 | 290 | $word = trim( $word ); |
291 | 291 | |
292 | - if ( empty($word) ) { |
|
292 | + if ( empty( $word ) ) { |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | |
296 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
296 | + if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) { |
|
297 | 297 | return true; |
298 | 298 | } |
299 | 299 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | unset( $key, $data ); |
323 | 323 | } |
324 | 324 | |
325 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
325 | + $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
326 | 326 | |
327 | 327 | return ( is_array( $response ) && $response[1] == 'true' ); |
328 | 328 | } |
@@ -345,12 +345,12 @@ discard block |
||
345 | 345 | |
346 | 346 | foreach ( $_SERVER as $key => $value ) { |
347 | 347 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
348 | - $datas[ $key ] = wp_strip_all_tags( $value ); |
|
348 | + $datas[$key] = wp_strip_all_tags( $value ); |
|
349 | 349 | } else { |
350 | - $datas[ $key ] = ''; |
|
350 | + $datas[$key] = ''; |
|
351 | 351 | } |
352 | 352 | |
353 | - unset($key, $value); |
|
353 | + unset( $key, $value ); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | * @uses api_request() |
70 | 70 | * |
71 | 71 | * @param array $_transient_data Update array build by WordPress. |
72 | - * @return array Modified update array with custom plugin data. |
|
72 | + * @return stdClass Modified update array with custom plugin data. |
|
73 | 73 | */ |
74 | 74 | public function check_update( $_transient_data ) { |
75 | 75 |
@@ -15,23 +15,23 @@ discard block |
||
15 | 15 | * @version 1.6.3 |
16 | 16 | */ |
17 | 17 | class FrmEDD_SL_Plugin_Updater { |
18 | - private $api_url = ''; |
|
19 | - private $api_data = array(); |
|
20 | - private $name = ''; |
|
21 | - private $slug = ''; |
|
22 | - private $version = ''; |
|
23 | - |
|
24 | - /** |
|
25 | - * Class constructor. |
|
26 | - * |
|
27 | - * @uses plugin_basename() |
|
28 | - * @uses hook() |
|
29 | - * |
|
30 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
31 | - * @param string $_plugin_file Path to the plugin file. |
|
32 | - * @param array $_api_data Optional data to send with API calls. |
|
33 | - */ |
|
34 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
18 | + private $api_url = ''; |
|
19 | + private $api_data = array(); |
|
20 | + private $name = ''; |
|
21 | + private $slug = ''; |
|
22 | + private $version = ''; |
|
23 | + |
|
24 | + /** |
|
25 | + * Class constructor. |
|
26 | + * |
|
27 | + * @uses plugin_basename() |
|
28 | + * @uses hook() |
|
29 | + * |
|
30 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
31 | + * @param string $_plugin_file Path to the plugin file. |
|
32 | + * @param array $_api_data Optional data to send with API calls. |
|
33 | + */ |
|
34 | + public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
35 | 35 | global $frm_edd_plugin_data; |
36 | 36 | |
37 | 37 | $this->api_url = trailingslashit( $_api_url ); |
@@ -44,159 +44,159 @@ discard block |
||
44 | 44 | |
45 | 45 | // Set up hooks. |
46 | 46 | $this->init(); |
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Set up WordPress filters to hook into WP's update process. |
|
51 | - * |
|
52 | - * @uses add_filter() |
|
53 | - * |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function init() { |
|
57 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
58 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Set up WordPress filters to hook into WP's update process. |
|
51 | + * |
|
52 | + * @uses add_filter() |
|
53 | + * |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function init() { |
|
57 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
58 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
59 | 59 | add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
64 | - * |
|
65 | - * This function dives into the update API just when WordPress creates its update array, |
|
66 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
67 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
68 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
69 | - * |
|
70 | - * @uses api_request() |
|
71 | - * |
|
72 | - * @param array $_transient_data Update array build by WordPress. |
|
73 | - * @return array Modified update array with custom plugin data. |
|
74 | - */ |
|
75 | - public function check_update( $_transient_data ) { |
|
76 | - |
|
77 | - global $pagenow; |
|
78 | - |
|
79 | - if ( ! is_object( $_transient_data ) ) { |
|
80 | - $_transient_data = new stdClass; |
|
81 | - } |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
64 | + * |
|
65 | + * This function dives into the update API just when WordPress creates its update array, |
|
66 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
67 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
68 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
69 | + * |
|
70 | + * @uses api_request() |
|
71 | + * |
|
72 | + * @param array $_transient_data Update array build by WordPress. |
|
73 | + * @return array Modified update array with custom plugin data. |
|
74 | + */ |
|
75 | + public function check_update( $_transient_data ) { |
|
76 | + |
|
77 | + global $pagenow; |
|
78 | + |
|
79 | + if ( ! is_object( $_transient_data ) ) { |
|
80 | + $_transient_data = new stdClass; |
|
81 | + } |
|
82 | 82 | |
83 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
83 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | 84 | |
85 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
85 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | 86 | |
87 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
87 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | 88 | |
89 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
89 | + if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
90 | 90 | |
91 | 91 | if ( empty( $version_info->plugin ) ) { |
92 | 92 | $version_info->plugin = $this->name; |
93 | 93 | } |
94 | 94 | |
95 | - $_transient_data->response[ $this->name ] = $version_info; |
|
96 | - |
|
97 | - } |
|
98 | - |
|
99 | - $_transient_data->last_checked = time(); |
|
100 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
101 | - |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - return $_transient_data; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Updates information on the "View version x.x details" page with custom data. |
|
110 | - * |
|
111 | - * @uses api_request() |
|
112 | - * |
|
113 | - * @param mixed $_data |
|
114 | - * @param string $_action |
|
115 | - * @param object $_args |
|
116 | - * @return object $_data |
|
117 | - */ |
|
118 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
119 | - |
|
120 | - if ( $_action != 'plugin_information' ) { |
|
95 | + $_transient_data->response[ $this->name ] = $version_info; |
|
121 | 96 | |
122 | - return $_data; |
|
97 | + } |
|
123 | 98 | |
124 | - } |
|
99 | + $_transient_data->last_checked = time(); |
|
100 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
125 | 101 | |
126 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
102 | + } |
|
103 | + } |
|
127 | 104 | |
128 | - return $_data; |
|
105 | + return $_transient_data; |
|
106 | + } |
|
129 | 107 | |
130 | - } |
|
108 | + /** |
|
109 | + * Updates information on the "View version x.x details" page with custom data. |
|
110 | + * |
|
111 | + * @uses api_request() |
|
112 | + * |
|
113 | + * @param mixed $_data |
|
114 | + * @param string $_action |
|
115 | + * @param object $_args |
|
116 | + * @return object $_data |
|
117 | + */ |
|
118 | + public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
131 | 119 | |
132 | - $to_send = array( |
|
133 | - 'slug' => $this->slug, |
|
134 | - 'is_ssl' => is_ssl(), |
|
135 | - 'fields' => array( |
|
136 | - 'banners' => false, // These will be supported soon hopefully |
|
137 | - 'reviews' => false, |
|
138 | - ), |
|
139 | - ); |
|
120 | + if ( $_action != 'plugin_information' ) { |
|
140 | 121 | |
141 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
122 | + return $_data; |
|
142 | 123 | |
143 | - if ( false !== $api_response ) { |
|
144 | - $_data = $api_response; |
|
145 | - } |
|
124 | + } |
|
146 | 125 | |
147 | - return $_data; |
|
148 | - } |
|
126 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
149 | 127 | |
128 | + return $_data; |
|
150 | 129 | |
151 | - /** |
|
152 | - * Disable SSL verification in order to prevent download update failures |
|
153 | - * |
|
154 | - * @param array $args |
|
155 | - * @param string $url |
|
156 | - * @return object $array |
|
157 | - */ |
|
158 | - public function http_request_args( $args, $url ) { |
|
159 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
160 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
161 | - $args['sslverify'] = false; |
|
162 | - } |
|
163 | - return $args; |
|
164 | - } |
|
130 | + } |
|
165 | 131 | |
166 | - /** |
|
167 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
168 | - * |
|
169 | - * @uses get_bloginfo() |
|
170 | - * @uses wp_remote_post() |
|
171 | - * @uses is_wp_error() |
|
172 | - * |
|
173 | - * @param string $_action The requested action. |
|
174 | - * @param array $_data Parameters for the API action. |
|
175 | - * @return false|object |
|
176 | - */ |
|
177 | - private function api_request( $_action, $_data ) { |
|
132 | + $to_send = array( |
|
133 | + 'slug' => $this->slug, |
|
134 | + 'is_ssl' => is_ssl(), |
|
135 | + 'fields' => array( |
|
136 | + 'banners' => false, // These will be supported soon hopefully |
|
137 | + 'reviews' => false, |
|
138 | + ), |
|
139 | + ); |
|
178 | 140 | |
179 | - global $wp_version; |
|
141 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
180 | 142 | |
181 | - $data = array_merge( $this->api_data, $_data ); |
|
143 | + if ( false !== $api_response ) { |
|
144 | + $_data = $api_response; |
|
145 | + } |
|
182 | 146 | |
183 | - if ( $data['slug'] != $this->slug ) { |
|
184 | - return; |
|
147 | + return $_data; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Disable SSL verification in order to prevent download update failures |
|
153 | + * |
|
154 | + * @param array $args |
|
155 | + * @param string $url |
|
156 | + * @return object $array |
|
157 | + */ |
|
158 | + public function http_request_args( $args, $url ) { |
|
159 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
160 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
161 | + $args['sslverify'] = false; |
|
162 | + } |
|
163 | + return $args; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
168 | + * |
|
169 | + * @uses get_bloginfo() |
|
170 | + * @uses wp_remote_post() |
|
171 | + * @uses is_wp_error() |
|
172 | + * |
|
173 | + * @param string $_action The requested action. |
|
174 | + * @param array $_data Parameters for the API action. |
|
175 | + * @return false|object |
|
176 | + */ |
|
177 | + private function api_request( $_action, $_data ) { |
|
178 | + |
|
179 | + global $wp_version; |
|
180 | + |
|
181 | + $data = array_merge( $this->api_data, $_data ); |
|
182 | + |
|
183 | + if ( $data['slug'] != $this->slug ) { |
|
184 | + return; |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $this->api_url == home_url() ) { |
|
188 | - return false; // Don't allow a plugin to ping itself |
|
189 | - } |
|
187 | + if ( $this->api_url == home_url() ) { |
|
188 | + return false; // Don't allow a plugin to ping itself |
|
189 | + } |
|
190 | 190 | |
191 | - $api_params = array( |
|
192 | - 'edd_action' => 'get_version', |
|
193 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
194 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
195 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
196 | - 'slug' => $data['slug'], |
|
197 | - 'author' => $data['author'], |
|
198 | - 'url' => home_url(), |
|
199 | - ); |
|
191 | + $api_params = array( |
|
192 | + 'edd_action' => 'get_version', |
|
193 | + 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
194 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
195 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
196 | + 'slug' => $data['slug'], |
|
197 | + 'author' => $data['author'], |
|
198 | + 'url' => home_url(), |
|
199 | + ); |
|
200 | 200 | |
201 | 201 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $api_params['license'] . $this->version ) . '_' . $api_params['edd_action'] ); |
202 | 202 | $cached_response = get_transient( $cache_key ); |
@@ -205,24 +205,24 @@ discard block |
||
205 | 205 | return $cached_response; |
206 | 206 | } |
207 | 207 | |
208 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
208 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
209 | 209 | |
210 | - if ( ! is_wp_error( $request ) ) { |
|
211 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
212 | - } |
|
210 | + if ( ! is_wp_error( $request ) ) { |
|
211 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
212 | + } |
|
213 | 213 | |
214 | - if ( $request && isset( $request->sections ) ) { |
|
215 | - $request->sections = maybe_unserialize( $request->sections ); |
|
214 | + if ( $request && isset( $request->sections ) ) { |
|
215 | + $request->sections = maybe_unserialize( $request->sections ); |
|
216 | 216 | set_transient( $cache_key, $request, DAY_IN_SECONDS ); |
217 | - } else { |
|
218 | - $request = false; |
|
217 | + } else { |
|
218 | + $request = false; |
|
219 | 219 | set_transient( $cache_key, 0, DAY_IN_SECONDS ); |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - return $request; |
|
223 | - } |
|
222 | + return $request; |
|
223 | + } |
|
224 | 224 | |
225 | - public function show_changelog() { |
|
225 | + public function show_changelog() { |
|
226 | 226 | |
227 | 227 | global $frm_edd_plugin_data; |
228 | 228 | |
@@ -278,5 +278,5 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | exit; |
281 | - } |
|
281 | + } |
|
282 | 282 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->slug = basename( $_plugin_file, '.php' ); |
41 | 41 | $this->version = $_api_data['version']; |
42 | 42 | |
43 | - $frm_edd_plugin_data[ $this->slug ] = $this->api_data; |
|
43 | + $frm_edd_plugin_data[$this->slug] = $this->api_data; |
|
44 | 44 | |
45 | 45 | // Set up hooks. |
46 | 46 | $this->init(); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $_transient_data = new stdClass; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
83 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[$this->name] ) ) { |
|
84 | 84 | |
85 | 85 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
86 | 86 | |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $version_info->plugin = $this->name; |
93 | 93 | } |
94 | 94 | |
95 | - $_transient_data->response[ $this->name ] = $version_info; |
|
95 | + $_transient_data->response[$this->name] = $version_info; |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | 99 | $_transient_data->last_checked = time(); |
100 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
100 | + $_transient_data->checked[$this->name] = $this->version; |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | wp_die( __( 'You do not have permission to install plugin updates', 'formidable' ), __( 'Error', 'formidable' ), array( 'response' => 403 ) ); |
243 | 243 | } |
244 | 244 | |
245 | - $data = $frm_edd_plugin_data[ $_REQUEST['slug'] ]; |
|
245 | + $data = $frm_edd_plugin_data[$_REQUEST['slug']]; |
|
246 | 246 | $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' ); |
247 | 247 | $version_info = get_transient( $cache_key ); |
248 | 248 |
@@ -17,6 +17,6 @@ |
||
17 | 17 | </ul> |
18 | 18 | |
19 | 19 | <?php if ( $form && $title == 'show' ) { ?> |
20 | - <input id="title" type="text" value="<?php echo esc_attr( $form->name == '' ? __( '(no title)') : $form->name ) ?>" readonly="readonly" disabled="disabled" /> |
|
20 | + <input id="title" type="text" value="<?php echo esc_attr( $form->name == '' ? __( '(no title)' ) : $form->name ) ?>" readonly="readonly" disabled="disabled" /> |
|
21 | 21 | <?php } ?> |
22 | 22 | </div> |
@@ -42,51 +42,51 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $f->type == 'data' ) { |
44 | 44 | //get all fields from linked form |
45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
46 | - $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
47 | - if ( ! in_array( $linked_form, $linked_forms ) ) { |
|
48 | - $linked_forms[] = $linked_form; |
|
45 | + if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
46 | + $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
47 | + if ( ! in_array( $linked_form, $linked_forms ) ) { |
|
48 | + $linked_forms[] = $linked_form; |
|
49 | 49 | $linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) ); |
50 | - $ldfe = ''; |
|
50 | + $ldfe = ''; |
|
51 | 51 | if ( $linked_fields ) { |
52 | 52 | foreach ( $linked_fields as $linked_field ) { |
53 | - FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
|
54 | - |
|
55 | - $ldfe = $linked_field->id; |
|
56 | - unset($linked_field); |
|
57 | - } |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
61 | - $dfe = $f->id; |
|
62 | - } |
|
63 | - unset($f); |
|
64 | - } |
|
65 | - } ?> |
|
53 | + FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
|
54 | + |
|
55 | + $ldfe = $linked_field->id; |
|
56 | + unset($linked_field); |
|
57 | + } |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | + $dfe = $f->id; |
|
62 | + } |
|
63 | + unset($f); |
|
64 | + } |
|
65 | + } ?> |
|
66 | 66 | </ul> |
67 | 67 | |
68 | 68 | <?php _e( 'Helpers', 'formidable' ) ?>: |
69 | 69 | <ul class="frm_code_list"> |
70 | 70 | <?php |
71 | - $col = 'one'; |
|
71 | + $col = 'one'; |
|
72 | 72 | foreach ( $entry_shortcodes as $skey => $sname ) { |
73 | 73 | if ( empty( $skey ) ) { |
74 | - $col = 'one'; |
|
75 | - echo '<li class="clear frm_block"></li>'; |
|
76 | - continue; |
|
77 | - } |
|
78 | - ?> |
|
74 | + $col = 'one'; |
|
75 | + echo '<li class="clear frm_block"></li>'; |
|
76 | + continue; |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
80 | 80 | <a href="javascript:void(0)" class="frmbutton button <?php |
81 | 81 | echo ( in_array( $skey, array( 'siteurl', 'sitename', 'entry_count' ) ) ) ? 'show_before_content show_after_content' : ''; |
82 | - echo ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : ''; |
|
83 | - ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ) ?></a> |
|
82 | + echo ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : ''; |
|
83 | + ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ) ?></a> |
|
84 | 84 | </li> |
85 | 85 | <?php |
86 | - $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
87 | - unset($skey, $sname); |
|
88 | - } |
|
89 | - ?> |
|
86 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
87 | + unset($skey, $sname); |
|
88 | + } |
|
89 | + ?> |
|
90 | 90 | </ul> |
91 | 91 | </div> |
92 | 92 | |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | <ul class="alignleft"><li><?php _e( 'Fields from your form', 'formidable' ) ?>:</li></ul> |
100 | 100 | <ul class="frm_code_list frm_full_width"> |
101 | 101 | <?php if ( ! empty( $fields ) ) { |
102 | - foreach ( $fields as $f ) { |
|
102 | + foreach ( $fields as $f ) { |
|
103 | 103 | if ( FrmField::is_no_save_field( $f->type ) || ( $f->type == 'data' && ( ! isset( $f->field_options['data_type'] ) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '' ) ) ) { |
104 | - continue; |
|
105 | - } |
|
106 | - ?> |
|
104 | + continue; |
|
105 | + } |
|
106 | + ?> |
|
107 | 107 | <li> |
108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
109 | 109 | <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | </li> |
112 | 112 | <?php |
113 | 113 | |
114 | - if ( $f->type == 'user_id' ) { |
|
115 | - $uid = $f; |
|
116 | - } else if ( $f->type == 'file' ) { |
|
117 | - $file = $f; |
|
118 | - } |
|
119 | - unset($f); |
|
120 | - } |
|
121 | - } ?> |
|
114 | + if ( $f->type == 'user_id' ) { |
|
115 | + $uid = $f; |
|
116 | + } else if ( $f->type == 'file' ) { |
|
117 | + $file = $f; |
|
118 | + } |
|
119 | + unset($f); |
|
120 | + } |
|
121 | + } ?> |
|
122 | 122 | </ul> |
123 | 123 | |
124 | 124 | <p class="howto"><?php _e( 'Click a button below to insert sample logic into your view', 'formidable' ) ?></p> |
125 | 125 | <ul class="frm_code_list"> |
126 | 126 | <?php |
127 | - $col = 'one'; |
|
127 | + $col = 'one'; |
|
128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
129 | - ?> |
|
129 | + ?> |
|
130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
131 | 131 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr($skey) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
132 | 132 | </li> |
133 | 133 | <?php |
134 | - $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
135 | - unset($skey, $sname); |
|
136 | - } |
|
137 | - ?> |
|
134 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
135 | + unset($skey, $sname); |
|
136 | + } |
|
137 | + ?> |
|
138 | 138 | </ul> |
139 | 139 | </div> |
140 | 140 | <?php } ?> |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | <div id="frm-adv-info-tab" class="tabs-panel"> |
143 | 143 | <ul class="frm_code_list"> |
144 | 144 | <?php |
145 | - $col = 'one'; |
|
145 | + $col = 'one'; |
|
146 | 146 | foreach ( $adv_shortcodes as $skey => $sname ) { |
147 | - ?> |
|
147 | + ?> |
|
148 | 148 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
149 | 149 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="'. esc_attr( $sname['title'] ) .'"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
150 | 150 | </li> |
151 | 151 | <?php |
152 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
153 | - unset($skey, $sname); |
|
154 | - } |
|
155 | - ?> |
|
152 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
153 | + unset($skey, $sname); |
|
154 | + } |
|
155 | + ?> |
|
156 | 156 | <?php if ( isset($file) ) { ?> |
157 | 157 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
158 | 158 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | <div class="clear"></div> |
170 | 170 | <?php |
171 | 171 | |
172 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
173 | - $col = 'one'; ?> |
|
172 | + if ( isset($uid) && ! empty($user_fields) ) { |
|
173 | + $col = 'one'; ?> |
|
174 | 174 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
175 | 175 | <ul class="frm_code_list"> |
176 | 176 | <?php foreach ( $user_fields as $uk => $uf ) { ?> |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
179 | 179 | </li> |
180 | 180 | <?php |
181 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
182 | - unset($uf, $uk); |
|
183 | - } |
|
184 | - unset($uid); ?> |
|
181 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
182 | + unset($uf, $uk); |
|
183 | + } |
|
184 | + unset($uid); ?> |
|
185 | 185 | </ul> |
186 | 186 | <?php } |
187 | 187 | |
188 | - if ( isset($repeat_field) ) { ?> |
|
188 | + if ( isset($repeat_field) ) { ?> |
|
189 | 189 | <div class="clear"></div> |
190 | 190 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
191 | 191 | <ul class="frm_code_list"> |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | </li> |
195 | 195 | </ul> |
196 | 196 | <?php |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - if ( isset($dfe) ) { ?> |
|
199 | + if ( isset($dfe) ) { ?> |
|
200 | 200 | |
201 | 201 | <div class="clear"></div> |
202 | 202 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | </div> |
216 | 216 | |
217 | 217 | <?php |
218 | - if ( $settings_tab ) { |
|
219 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
220 | - } |
|
221 | - ?> |
|
218 | + if ( $settings_tab ) { |
|
219 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
220 | + } |
|
221 | + ?> |
|
222 | 222 | </div> |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $f->type == 'data' ) { |
44 | 44 | //get all fields from linked form |
45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
46 | - $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
45 | + if ( isset( $f->field_options['form_select'] ) && is_numeric( $f->field_options['form_select'] ) ) { |
|
46 | + $linked_form = FrmDb::get_var( $wpdb->prefix . 'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
47 | 47 | if ( ! in_array( $linked_form, $linked_forms ) ) { |
48 | 48 | $linked_forms[] = $linked_form; |
49 | 49 | $linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) ); |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
54 | 54 | |
55 | 55 | $ldfe = $linked_field->id; |
56 | - unset($linked_field); |
|
56 | + unset( $linked_field ); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | $dfe = $f->id; |
62 | 62 | } |
63 | - unset($f); |
|
63 | + unset( $f ); |
|
64 | 64 | } |
65 | 65 | } ?> |
66 | 66 | </ul> |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | </li> |
85 | 85 | <?php |
86 | 86 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
87 | - unset($skey, $sname); |
|
87 | + unset( $skey, $sname ); |
|
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | </ul> |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | ?> |
107 | 107 | <li> |
108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
109 | - <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
|
110 | - <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr($f->id) ?>"><?php echo FrmAppHelper::truncate($f->name, 60) ?></a> |
|
109 | + <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate( $f->field_key, 10 ) ?>]</a> |
|
110 | + <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr( $f->id ) ?>"><?php echo FrmAppHelper::truncate( $f->name, 60 ) ?></a> |
|
111 | 111 | </li> |
112 | 112 | <?php |
113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } else if ( $f->type == 'file' ) { |
117 | 117 | $file = $f; |
118 | 118 | } |
119 | - unset($f); |
|
119 | + unset( $f ); |
|
120 | 120 | } |
121 | 121 | } ?> |
122 | 122 | </ul> |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
129 | 129 | ?> |
130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
131 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr($skey) ?>][/if x"><?php echo esc_html( $sname ) ?></a> |
|
131 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr( $skey ) ?>][/if x"><?php echo esc_html( $sname ) ?></a> |
|
132 | 132 | </li> |
133 | 133 | <?php |
134 | 134 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
135 | - unset($skey, $sname); |
|
135 | + unset( $skey, $sname ); |
|
136 | 136 | } |
137 | 137 | ?> |
138 | 138 | </ul> |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | foreach ( $adv_shortcodes as $skey => $sname ) { |
147 | 147 | ?> |
148 | 148 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
149 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="'. esc_attr( $sname['title'] ) .'"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
|
149 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="' . esc_attr( $sname['title'] ) . '"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
|
150 | 150 | </li> |
151 | 151 | <?php |
152 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
153 | - unset($skey, $sname); |
|
152 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
153 | + unset( $skey, $sname ); |
|
154 | 154 | } |
155 | 155 | ?> |
156 | - <?php if ( isset($file) ) { ?> |
|
156 | + <?php if ( isset( $file ) ) { ?> |
|
157 | 157 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
158 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
|
158 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
|
159 | 159 | </li> |
160 | - <li class="frm_col_<?php echo $col = (($col == 'one') ? 'two' : 'one') ?>"> |
|
161 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
160 | + <li class="frm_col_<?php echo $col = ( ( $col == 'one' ) ? 'two' : 'one' ) ?>"> |
|
161 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
162 | 162 | </li> |
163 | - <li class="frm_col_<?php echo $col = (($col == 'one') ? 'two' : 'one') ?>"> |
|
164 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=label"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
163 | + <li class="frm_col_<?php echo $col = ( ( $col == 'one' ) ? 'two' : 'one' ) ?>"> |
|
164 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=label"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
165 | 165 | </li> |
166 | 166 | <?php } ?> |
167 | 167 | </ul> |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | <div class="clear"></div> |
170 | 170 | <?php |
171 | 171 | |
172 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
172 | + if ( isset( $uid ) && ! empty( $user_fields ) ) { |
|
173 | 173 | $col = 'one'; ?> |
174 | 174 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
175 | 175 | <ul class="frm_code_list"> |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
179 | 179 | </li> |
180 | 180 | <?php |
181 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
182 | - unset($uf, $uk); |
|
181 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
182 | + unset( $uf, $uk ); |
|
183 | 183 | } |
184 | - unset($uid); ?> |
|
184 | + unset( $uid ); ?> |
|
185 | 185 | </ul> |
186 | 186 | <?php } |
187 | 187 | |
188 | - if ( isset($repeat_field) ) { ?> |
|
188 | + if ( isset( $repeat_field ) ) { ?> |
|
189 | 189 | <div class="clear"></div> |
190 | 190 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
191 | 191 | <ul class="frm_code_list"> |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | <?php |
197 | 197 | } |
198 | 198 | |
199 | - if ( isset($dfe) ) { ?> |
|
199 | + if ( isset( $dfe ) ) { ?> |
|
200 | 200 | |
201 | 201 | <div class="clear"></div> |
202 | 202 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | <li class="frm_col_one"> |
205 | 205 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="created-at"' ) ?>"><?php _e( 'Creation Date', 'formidable' ) ?></a> |
206 | 206 | </li> |
207 | - <?php if ( isset($ldfe) ) { ?> |
|
207 | + <?php if ( isset( $ldfe ) ) { ?> |
|
208 | 208 | <li class="frm_col_two"> |
209 | 209 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="' . $ldfe . '"' ) ?>"><?php _e( 'Field From Entry', 'formidable' ) ?></a> |
210 | 210 | </li> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | <?php |
218 | 218 | if ( $settings_tab ) { |
219 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
219 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/mb_html_tab.php' ); |
|
220 | 220 | } |
221 | 221 | ?> |
222 | 222 | </div> |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmCSVExportHelper{ |
|
3 | +class FrmCSVExportHelper { |
|
4 | 4 | protected static $separator = ', '; |
5 | 5 | protected static $column_separator = ','; |
6 | 6 | protected static $line_break = 'return'; |
@@ -235,50 +235,50 @@ discard block |
||
235 | 235 | return $line; |
236 | 236 | } |
237 | 237 | |
238 | - $convmap = false; |
|
238 | + $convmap = false; |
|
239 | 239 | |
240 | 240 | switch ( self::$to_encoding ) { |
241 | - case 'macintosh': |
|
241 | + case 'macintosh': |
|
242 | 242 | // this map was derived from the differences between the MacRoman and UTF-8 Charsets |
243 | 243 | // Reference: |
244 | 244 | // - http://www.alanwood.net/demos/macroman.html |
245 | - $convmap = array( |
|
246 | - 256, 304, 0, 0xffff, |
|
247 | - 306, 337, 0, 0xffff, |
|
248 | - 340, 375, 0, 0xffff, |
|
249 | - 377, 401, 0, 0xffff, |
|
250 | - 403, 709, 0, 0xffff, |
|
251 | - 712, 727, 0, 0xffff, |
|
252 | - 734, 936, 0, 0xffff, |
|
253 | - 938, 959, 0, 0xffff, |
|
254 | - 961, 8210, 0, 0xffff, |
|
255 | - 8213, 8215, 0, 0xffff, |
|
256 | - 8219, 8219, 0, 0xffff, |
|
257 | - 8227, 8229, 0, 0xffff, |
|
258 | - 8231, 8239, 0, 0xffff, |
|
259 | - 8241, 8248, 0, 0xffff, |
|
260 | - 8251, 8259, 0, 0xffff, |
|
261 | - 8261, 8363, 0, 0xffff, |
|
262 | - 8365, 8481, 0, 0xffff, |
|
263 | - 8483, 8705, 0, 0xffff, |
|
264 | - 8707, 8709, 0, 0xffff, |
|
265 | - 8711, 8718, 0, 0xffff, |
|
266 | - 8720, 8720, 0, 0xffff, |
|
267 | - 8722, 8729, 0, 0xffff, |
|
268 | - 8731, 8733, 0, 0xffff, |
|
269 | - 8735, 8746, 0, 0xffff, |
|
270 | - 8748, 8775, 0, 0xffff, |
|
271 | - 8777, 8799, 0, 0xffff, |
|
272 | - 8801, 8803, 0, 0xffff, |
|
273 | - 8806, 9673, 0, 0xffff, |
|
274 | - 9675, 63742, 0, 0xffff, |
|
275 | - 63744, 64256, 0, 0xffff, |
|
276 | - ); |
|
277 | - break; |
|
278 | - case 'ISO-8859-1': |
|
279 | - $convmap = array( 256, 10000, 0, 0xffff ); |
|
280 | - break; |
|
281 | - } |
|
245 | + $convmap = array( |
|
246 | + 256, 304, 0, 0xffff, |
|
247 | + 306, 337, 0, 0xffff, |
|
248 | + 340, 375, 0, 0xffff, |
|
249 | + 377, 401, 0, 0xffff, |
|
250 | + 403, 709, 0, 0xffff, |
|
251 | + 712, 727, 0, 0xffff, |
|
252 | + 734, 936, 0, 0xffff, |
|
253 | + 938, 959, 0, 0xffff, |
|
254 | + 961, 8210, 0, 0xffff, |
|
255 | + 8213, 8215, 0, 0xffff, |
|
256 | + 8219, 8219, 0, 0xffff, |
|
257 | + 8227, 8229, 0, 0xffff, |
|
258 | + 8231, 8239, 0, 0xffff, |
|
259 | + 8241, 8248, 0, 0xffff, |
|
260 | + 8251, 8259, 0, 0xffff, |
|
261 | + 8261, 8363, 0, 0xffff, |
|
262 | + 8365, 8481, 0, 0xffff, |
|
263 | + 8483, 8705, 0, 0xffff, |
|
264 | + 8707, 8709, 0, 0xffff, |
|
265 | + 8711, 8718, 0, 0xffff, |
|
266 | + 8720, 8720, 0, 0xffff, |
|
267 | + 8722, 8729, 0, 0xffff, |
|
268 | + 8731, 8733, 0, 0xffff, |
|
269 | + 8735, 8746, 0, 0xffff, |
|
270 | + 8748, 8775, 0, 0xffff, |
|
271 | + 8777, 8799, 0, 0xffff, |
|
272 | + 8801, 8803, 0, 0xffff, |
|
273 | + 8806, 9673, 0, 0xffff, |
|
274 | + 9675, 63742, 0, 0xffff, |
|
275 | + 63744, 64256, 0, 0xffff, |
|
276 | + ); |
|
277 | + break; |
|
278 | + case 'ISO-8859-1': |
|
279 | + $convmap = array( 256, 10000, 0, 0xffff ); |
|
280 | + break; |
|
281 | + } |
|
282 | 282 | |
283 | 283 | if ( is_array( $convmap ) ) { |
284 | 284 | $line = mb_encode_numericentity( $line, $convmap, self::$charset ); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | return self::escape_csv( $line ); |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * Escape a " in a csv with another " |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmCSVExportHelper{ |
|
3 | +class FrmCSVExportHelper { |
|
4 | 4 | protected static $separator = ', '; |
5 | 5 | protected static $column_separator = ','; |
6 | 6 | protected static $line_break = 'return'; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | header( 'Content-Description: File Transfer' ); |
64 | 64 | header( 'Content-Disposition: attachment; filename="' . esc_attr( $filename ) . '"' ); |
65 | 65 | header( 'Content-Type: text/csv; charset=' . self::$charset, true ); |
66 | - header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date('Y' ) ) ) . ' GMT' ); |
|
66 | + header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) ) ) . ' GMT' ); |
|
67 | 67 | header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
68 | 68 | header( 'Cache-Control: no-cache, must-revalidate' ); |
69 | 69 | header( 'Pragma: no-cache' ); |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | private static function csv_headings( &$headings ) { |
88 | 88 | foreach ( self::$fields as $col ) { |
89 | 89 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] && ! in_array( $col->type, array( 'user_id', 'file', 'data', 'date' ) ) ) { |
90 | - $headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
90 | + $headings[$col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
91 | 91 | } |
92 | 92 | |
93 | - $headings[ $col->id ] = strip_tags( $col->name ); |
|
93 | + $headings[$col->id] = strip_tags( $col->name ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if ( self::$comment_count ) { |
97 | - for ( $i = 0; $i < self::$comment_count; $i++ ) { |
|
98 | - $headings[ 'comment' . $i ] = __( 'Comment', 'formidable' ); |
|
99 | - $headings[ 'comment_user_id' . $i ] = __( 'Comment User', 'formidable' ); |
|
100 | - $headings[ 'comment_created_at' . $i ] = __( 'Comment Date', 'formidable' ); |
|
97 | + for ( $i = 0; $i < self::$comment_count; $i ++ ) { |
|
98 | + $headings['comment' . $i] = __( 'Comment', 'formidable' ); |
|
99 | + $headings['comment_user_id' . $i] = __( 'Comment User', 'formidable' ); |
|
100 | + $headings['comment_created_at' . $i] = __( 'Comment Date', 'formidable' ); |
|
101 | 101 | } |
102 | - unset($i); |
|
102 | + unset( $i ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $headings['created_at'] = __( 'Timestamp', 'formidable' ); |
@@ -146,30 +146,30 @@ discard block |
||
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
150 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array(); |
|
151 | - } else if ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
149 | + if ( ! isset( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
150 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = array(); |
|
151 | + } else if ( ! is_array( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
152 | 152 | // if the data is here, it should be an array but if this field has collected data |
153 | 153 | // both while inside and outside of the repeating section, it's possible this is a string |
154 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ]; |
|
154 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = (array) $entries[self::$entry->parent_item_id]->metas[$meta_id]; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | //add the repeated values |
158 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ][] = $meta_value; |
|
158 | + $entries[self::$entry->parent_item_id]->metas[$meta_id][] = $meta_value; |
|
159 | 159 | } |
160 | - $entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas; |
|
160 | + $entries[self::$entry->parent_item_id]->metas += self::$entry->metas; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // add the embedded form id |
164 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) { |
|
165 | - $entries[ self::$entry->parent_item_id ]->embedded_fields = array(); |
|
164 | + if ( ! isset( $entries[self::$entry->parent_item_id]->embedded_fields ) ) { |
|
165 | + $entries[self::$entry->parent_item_id]->embedded_fields = array(); |
|
166 | 166 | } |
167 | - $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id; |
|
167 | + $entries[self::$entry->parent_item_id]->embedded_fields[self::$entry->id] = self::$entry->form_id; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | private static function add_field_values_to_csv( &$row ) { |
171 | 171 | foreach ( self::$fields as $col ) { |
172 | - $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false; |
|
172 | + $field_value = isset( self::$entry->metas[$col->id] ) ? self::$entry->metas[$col->id] : false; |
|
173 | 173 | |
174 | 174 | $field_value = maybe_unserialize( $field_value ); |
175 | 175 | $field_value = apply_filters( 'frm_csv_value', $field_value, array( 'field' => $col, 'entry' => self::$entry, 'separator' => self::$separator ) ); |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | $sep_value = FrmEntriesHelper::display_value( $field_value, $col, array( |
179 | 179 | 'type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false, |
180 | 180 | 'entry_id' => self::$entry->id, 'sep' => self::$separator, |
181 | - 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0, |
|
181 | + 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[self::$entry->id] ) ) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0, |
|
182 | 182 | ) ); |
183 | - $row[ $col->id . '_label' ] = $sep_value; |
|
183 | + $row[$col->id . '_label'] = $sep_value; |
|
184 | 184 | unset( $sep_value ); |
185 | 185 | } |
186 | 186 | |
187 | - $row[ $col->id ] = $field_value; |
|
187 | + $row[$col->id] = $field_value; |
|
188 | 188 | |
189 | 189 | unset( $col, $field_value ); |
190 | 190 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | $col_count = count( $rows ); |
206 | 206 | $this_col = 0; |
207 | 207 | foreach ( $rows as $k => $row ) { |
208 | - $this_col++; |
|
208 | + $this_col ++; |
|
209 | 209 | |
210 | - if ( ! isset( self::$headings[ $k ] ) ) { |
|
210 | + if ( ! isset( self::$headings[$k] ) ) { |
|
211 | 211 | // this column has been removed from the csv, so skip it |
212 | 212 | continue; |
213 | 213 | } |