@@ -1,10 +1,10 @@ discard block |
||
1 | -<?php wp_nonce_field('frm_save_form_nonce', 'frm_save_form'); ?> |
|
1 | +<?php wp_nonce_field( 'frm_save_form_nonce', 'frm_save_form' ); ?> |
|
2 | 2 | <input type="hidden" name="status" value="<?php echo esc_attr( $values['status'] ); ?>" /> |
3 | 3 | <input type="hidden" name="new_status" value="" /> |
4 | 4 | |
5 | 5 | <div id="frm_form_editor_container"> |
6 | 6 | <div id="titlediv"> |
7 | - <input type="text" name="name" value="<?php echo esc_attr($form->name); ?>" id="title" placeholder="<?php esc_attr_e( 'Enter title here') ?>" /> |
|
7 | + <input type="text" name="name" value="<?php echo esc_attr( $form->name ); ?>" id="title" placeholder="<?php esc_attr_e( 'Enter title here' ) ?>" /> |
|
8 | 8 | <div id="edit-slug-box" class="hide-if-no-js"> |
9 | 9 | <div id="frm_form_key_box" class="alignright"> |
10 | 10 | <strong><?php _e( 'Form Key:', 'formidable' ) ?></strong> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | </div> |
17 | 17 | |
18 | 18 | <div class="postbox"> |
19 | - <div class="frm_no_fields <?php echo ( isset($values['fields']) && ! empty($values['fields']) ) ? 'frm_hidden' : ''; ?>"> |
|
19 | + <div class="frm_no_fields <?php echo ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) ? 'frm_hidden' : ''; ?>"> |
|
20 | 20 | <div class="alignleft sketch1"> |
21 | 21 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/sketch_arrow1.png' ); ?>" alt="" /> |
22 | 22 | </div> |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if ( isset( $values['fields'] ) && ! empty( $values['fields'] ) ) { |
54 | 54 | $values['count'] = 0; |
55 | 55 | foreach ( $values['fields'] as $field ) { |
56 | - $values['count']++; |
|
56 | + $values['count'] ++; |
|
57 | 57 | FrmFieldsController::load_single_field( $field, $values ); |
58 | 58 | unset( $field ); |
59 | 59 | } |
@@ -5,70 +5,70 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmEntriesHelper { |
7 | 7 | |
8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | - $values = array(); |
|
8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | + $values = array(); |
|
10 | 10 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
11 | 11 | $values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' ); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - $values['fields'] = array(); |
|
15 | - if ( empty($fields) ) { |
|
16 | - return apply_filters('frm_setup_new_entry', $values); |
|
17 | - } |
|
14 | + $values['fields'] = array(); |
|
15 | + if ( empty($fields) ) { |
|
16 | + return apply_filters('frm_setup_new_entry', $values); |
|
17 | + } |
|
18 | 18 | |
19 | - foreach ( (array) $fields as $field ) { |
|
19 | + foreach ( (array) $fields as $field ) { |
|
20 | 20 | self::prepare_field_default_value( $field ); |
21 | - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
22 | - |
|
23 | - $field_array = array( |
|
24 | - 'id' => $field->id, |
|
25 | - 'value' => $new_value, |
|
26 | - 'default_value' => $field->default_value, |
|
27 | - 'name' => $field->name, |
|
28 | - 'description' => $field->description, |
|
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
30 | - 'options' => $field->options, |
|
31 | - 'required' => $field->required, |
|
32 | - 'field_key' => $field->field_key, |
|
33 | - 'field_order' => $field->field_order, |
|
34 | - 'form_id' => $field->form_id, |
|
21 | + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
22 | + |
|
23 | + $field_array = array( |
|
24 | + 'id' => $field->id, |
|
25 | + 'value' => $new_value, |
|
26 | + 'default_value' => $field->default_value, |
|
27 | + 'name' => $field->name, |
|
28 | + 'description' => $field->description, |
|
29 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
30 | + 'options' => $field->options, |
|
31 | + 'required' => $field->required, |
|
32 | + 'field_key' => $field->field_key, |
|
33 | + 'field_order' => $field->field_order, |
|
34 | + 'form_id' => $field->form_id, |
|
35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
36 | - 'reset_value' => $reset, |
|
36 | + 'reset_value' => $reset, |
|
37 | 37 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
38 | - ); |
|
38 | + ); |
|
39 | 39 | |
40 | 40 | $opt_defaults = FrmFieldsHelper::get_default_field_options_from_field( $field ); |
41 | - $opt_defaults['required_indicator'] = ''; |
|
41 | + $opt_defaults['required_indicator'] = ''; |
|
42 | 42 | $opt_defaults['original_type'] = $field->type; |
43 | 43 | |
44 | 44 | foreach ( $opt_defaults as $opt => $default_opt ) { |
45 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
46 | - unset($opt, $default_opt); |
|
47 | - } |
|
45 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
46 | + unset($opt, $default_opt); |
|
47 | + } |
|
48 | 48 | |
49 | - unset($opt_defaults); |
|
49 | + unset($opt_defaults); |
|
50 | 50 | |
51 | - if ( $field_array['custom_html'] == '' ) { |
|
52 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
53 | - } |
|
51 | + if ( $field_array['custom_html'] == '' ) { |
|
52 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
53 | + } |
|
54 | 54 | |
55 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
56 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
55 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
56 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
57 | 57 | |
58 | - $values['fields'][] = $field_array; |
|
58 | + $values['fields'][] = $field_array; |
|
59 | 59 | |
60 | - if ( ! $form || ! isset($form->id) ) { |
|
61 | - $form = FrmForm::getOne($field->form_id); |
|
62 | - } |
|
63 | - } |
|
60 | + if ( ! $form || ! isset($form->id) ) { |
|
61 | + $form = FrmForm::getOne($field->form_id); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - $form->options = maybe_unserialize($form->options); |
|
66 | - if ( is_array($form->options) ) { |
|
67 | - foreach ( $form->options as $opt => $value ) { |
|
68 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
69 | - unset($opt, $value); |
|
70 | - } |
|
71 | - } |
|
65 | + $form->options = maybe_unserialize($form->options); |
|
66 | + if ( is_array($form->options) ) { |
|
67 | + foreach ( $form->options as $opt => $value ) { |
|
68 | + $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
69 | + unset($opt, $value); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | $form_defaults = FrmFormsHelper::get_default_opts(); |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $values = array_merge( $form_defaults, $values ); |
79 | 79 | |
80 | 80 | return apply_filters( 'frm_setup_new_entry', $values ); |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @since 2.05 |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | - * Set the value for each field |
|
97 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
98 | - * |
|
99 | - * @since 2.0.13 |
|
100 | - * |
|
101 | - * @param object $field - this is passed by reference since it is an object |
|
102 | - * @param boolean $reset |
|
103 | - * @param array $args |
|
104 | - * @return string|array $new_value |
|
105 | - */ |
|
96 | + * Set the value for each field |
|
97 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
98 | + * |
|
99 | + * @since 2.0.13 |
|
100 | + * |
|
101 | + * @param object $field - this is passed by reference since it is an object |
|
102 | + * @param boolean $reset |
|
103 | + * @param array $args |
|
104 | + * @return string|array $new_value |
|
105 | + */ |
|
106 | 106 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
107 | 107 | $new_value = $field->default_value; |
108 | 108 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | - * Check if a field has a posted value |
|
131 | - * |
|
132 | - * @since 2.01.0 |
|
133 | - * @param object $field |
|
134 | - * @param array $args |
|
135 | - * @return boolean $value_is_posted |
|
136 | - */ |
|
130 | + * Check if a field has a posted value |
|
131 | + * |
|
132 | + * @since 2.01.0 |
|
133 | + * @param object $field |
|
134 | + * @param array $args |
|
135 | + * @return boolean $value_is_posted |
|
136 | + */ |
|
137 | 137 | public static function value_is_posted( $field, $args ) { |
138 | 138 | $value_is_posted = false; |
139 | 139 | if ( $_POST ) { |
@@ -151,130 +151,130 @@ discard block |
||
151 | 151 | |
152 | 152 | public static function setup_edit_vars( $values, $record ) { |
153 | 153 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
154 | - $values['form_id'] = $record->form_id; |
|
155 | - $values['is_draft'] = $record->is_draft; |
|
156 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
157 | - } |
|
154 | + $values['form_id'] = $record->form_id; |
|
155 | + $values['is_draft'] = $record->is_draft; |
|
156 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | public static function replace_default_message( $message, $atts ) { |
160 | - if ( strpos($message, '[default-message') === false && |
|
161 | - strpos($message, '[default_message') === false && |
|
162 | - ! empty( $message ) ) { |
|
163 | - return $message; |
|
164 | - } |
|
160 | + if ( strpos($message, '[default-message') === false && |
|
161 | + strpos($message, '[default_message') === false && |
|
162 | + ! empty( $message ) ) { |
|
163 | + return $message; |
|
164 | + } |
|
165 | 165 | |
166 | - if ( empty($message) ) { |
|
167 | - $message = '[default-message]'; |
|
168 | - } |
|
166 | + if ( empty($message) ) { |
|
167 | + $message = '[default-message]'; |
|
168 | + } |
|
169 | 169 | |
170 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
170 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
171 | 171 | |
172 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
172 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
173 | 173 | $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
174 | 174 | if ( ! empty( $add_atts ) ) { |
175 | - $this_atts = array_merge($atts, $add_atts); |
|
176 | - } else { |
|
177 | - $this_atts = $atts; |
|
178 | - } |
|
175 | + $this_atts = array_merge($atts, $add_atts); |
|
176 | + } else { |
|
177 | + $this_atts = $atts; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
181 | 181 | |
182 | - // Add the default message |
|
183 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
184 | - } |
|
182 | + // Add the default message |
|
183 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
184 | + } |
|
185 | 185 | |
186 | - return $message; |
|
187 | - } |
|
186 | + return $message; |
|
187 | + } |
|
188 | 188 | |
189 | 189 | public static function prepare_display_value( $entry, $field, $atts ) { |
190 | 190 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
191 | 191 | |
192 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
192 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
193 | 193 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
194 | - } |
|
194 | + } |
|
195 | 195 | |
196 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
197 | - return self::display_value($field_value, $field, $atts); |
|
198 | - } |
|
196 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
197 | + return self::display_value($field_value, $field, $atts); |
|
198 | + } |
|
199 | 199 | |
200 | - // this is an embeded form |
|
201 | - $val = ''; |
|
200 | + // this is an embeded form |
|
201 | + $val = ''; |
|
202 | 202 | |
203 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
204 | - //this is a repeating section |
|
203 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
204 | + //this is a repeating section |
|
205 | 205 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
206 | - } else { |
|
207 | - // get all values for this field |
|
208 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
206 | + } else { |
|
207 | + // get all values for this field |
|
208 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
209 | 209 | |
210 | - if ( $child_values ) { |
|
211 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
212 | - } |
|
213 | - } |
|
210 | + if ( $child_values ) { |
|
211 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | - $field_value = array(); |
|
215 | + $field_value = array(); |
|
216 | 216 | |
217 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
218 | - return $val; |
|
219 | - } |
|
217 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
218 | + return $val; |
|
219 | + } |
|
220 | 220 | |
221 | - foreach ( $child_entries as $child_entry ) { |
|
222 | - $atts['item_id'] = $child_entry->id; |
|
223 | - $atts['post_id'] = $child_entry->post_id; |
|
221 | + foreach ( $child_entries as $child_entry ) { |
|
222 | + $atts['item_id'] = $child_entry->id; |
|
223 | + $atts['post_id'] = $child_entry->post_id; |
|
224 | 224 | |
225 | - // get the value for this field -- check for post values as well |
|
226 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
225 | + // get the value for this field -- check for post values as well |
|
226 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
227 | 227 | |
228 | - if ( $entry_val ) { |
|
229 | - // foreach entry get display_value |
|
230 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
231 | - } |
|
228 | + if ( $entry_val ) { |
|
229 | + // foreach entry get display_value |
|
230 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
231 | + } |
|
232 | 232 | |
233 | - unset($child_entry); |
|
234 | - } |
|
233 | + unset($child_entry); |
|
234 | + } |
|
235 | 235 | |
236 | - $val = implode(', ', (array) $field_value ); |
|
236 | + $val = implode(', ', (array) $field_value ); |
|
237 | 237 | $val = wp_kses_post( $val ); |
238 | 238 | |
239 | - return $val; |
|
240 | - } |
|
239 | + return $val; |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * Prepare the saved value for display |
|
244 | - * @return string |
|
245 | - */ |
|
242 | + /** |
|
243 | + * Prepare the saved value for display |
|
244 | + * @return string |
|
245 | + */ |
|
246 | 246 | public static function display_value( $value, $field, $atts = array() ) { |
247 | 247 | |
248 | - $defaults = array( |
|
249 | - 'type' => '', 'html' => false, 'show_filename' => true, |
|
250 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
251 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
248 | + $defaults = array( |
|
249 | + 'type' => '', 'html' => false, 'show_filename' => true, |
|
250 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
251 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
252 | 252 | 'return_array' => false, |
253 | - ); |
|
253 | + ); |
|
254 | 254 | |
255 | - $atts = wp_parse_args( $atts, $defaults ); |
|
256 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
255 | + $atts = wp_parse_args( $atts, $defaults ); |
|
256 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
257 | 257 | |
258 | - if ( ! isset($field->field_options['post_field']) ) { |
|
259 | - $field->field_options['post_field'] = ''; |
|
260 | - } |
|
258 | + if ( ! isset($field->field_options['post_field']) ) { |
|
259 | + $field->field_options['post_field'] = ''; |
|
260 | + } |
|
261 | 261 | |
262 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
263 | - $field->field_options['custom_field'] = ''; |
|
264 | - } |
|
262 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
263 | + $field->field_options['custom_field'] = ''; |
|
264 | + } |
|
265 | 265 | |
266 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
267 | - $atts['pre_truncate'] = $atts['truncate']; |
|
268 | - $atts['truncate'] = true; |
|
269 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
266 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
267 | + $atts['pre_truncate'] = $atts['truncate']; |
|
268 | + $atts['truncate'] = true; |
|
269 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
270 | 270 | |
271 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
272 | - $atts['truncate'] = $atts['pre_truncate']; |
|
273 | - } |
|
271 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
272 | + $atts['truncate'] = $atts['pre_truncate']; |
|
273 | + } |
|
274 | 274 | |
275 | - if ( $value == '' ) { |
|
276 | - return $value; |
|
277 | - } |
|
275 | + if ( $value == '' ) { |
|
276 | + return $value; |
|
277 | + } |
|
278 | 278 | |
279 | 279 | $unfiltered_value = maybe_unserialize( $value ); |
280 | 280 | $value = apply_filters('frm_display_value_custom', $unfiltered_value, $field, $atts); |
@@ -284,130 +284,130 @@ discard block |
||
284 | 284 | $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) ); |
285 | 285 | } |
286 | 286 | |
287 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
288 | - $value = FrmAppHelper::truncate($value, 50); |
|
289 | - } |
|
287 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
288 | + $value = FrmAppHelper::truncate($value, 50); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
292 | 292 | $value = wp_kses_post( $value ); |
293 | 293 | } |
294 | 294 | |
295 | 295 | return apply_filters( 'frm_display_value', $value, $field, $atts ); |
296 | - } |
|
296 | + } |
|
297 | 297 | |
298 | 298 | public static function set_posted_value( $field, $value, $args ) { |
299 | - // If validating a field with "other" opt, set back to prev value now |
|
300 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
301 | - $value = $args['temp_value']; |
|
302 | - } |
|
303 | - if ( empty($args['parent_field_id']) ) { |
|
304 | - $_POST['item_meta'][ $field->id ] = $value; |
|
305 | - } else { |
|
306 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
307 | - } |
|
308 | - } |
|
299 | + // If validating a field with "other" opt, set back to prev value now |
|
300 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
301 | + $value = $args['temp_value']; |
|
302 | + } |
|
303 | + if ( empty($args['parent_field_id']) ) { |
|
304 | + $_POST['item_meta'][ $field->id ] = $value; |
|
305 | + } else { |
|
306 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
307 | + } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | public static function get_posted_value( $field, &$value, $args ) { |
311 | 311 | $field_id = is_object( $field ) ? $field->id : $field; |
312 | 312 | |
313 | - if ( empty($args['parent_field_id']) ) { |
|
314 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
315 | - } else { |
|
316 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
317 | - } |
|
313 | + if ( empty($args['parent_field_id']) ) { |
|
314 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
315 | + } else { |
|
316 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
317 | + } |
|
318 | 318 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
319 | 319 | $value = stripslashes_deep( $value ); |
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * Check if field has an "Other" option and if any other values are posted |
|
324 | - * |
|
325 | - * @since 2.0 |
|
326 | - * |
|
327 | - * @param object $field |
|
328 | - * @param string|array $value |
|
329 | - * @param array $args |
|
330 | - */ |
|
331 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
332 | - $args['other'] = false; |
|
333 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
334 | - return; |
|
335 | - } |
|
336 | - |
|
337 | - // Get other value for fields in repeating section |
|
338 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
339 | - |
|
340 | - // Check if there are any posted "Other" values |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Check if field has an "Other" option and if any other values are posted |
|
324 | + * |
|
325 | + * @since 2.0 |
|
326 | + * |
|
327 | + * @param object $field |
|
328 | + * @param string|array $value |
|
329 | + * @param array $args |
|
330 | + */ |
|
331 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
332 | + $args['other'] = false; |
|
333 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
334 | + return; |
|
335 | + } |
|
336 | + |
|
337 | + // Get other value for fields in repeating section |
|
338 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
339 | + |
|
340 | + // Check if there are any posted "Other" values |
|
341 | 341 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
342 | 342 | |
343 | - // Save original value |
|
344 | - $args['temp_value'] = $value; |
|
345 | - $args['other'] = true; |
|
346 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
347 | - |
|
348 | - // Set the validation value now |
|
349 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
355 | - * |
|
356 | - * @since 2.0 |
|
357 | - * |
|
358 | - * @param object $field |
|
359 | - * @param string|array $value |
|
360 | - * @param array $args |
|
361 | - */ |
|
362 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
363 | - if ( ! $args['parent_field_id'] ) { |
|
364 | - return; |
|
365 | - } |
|
366 | - |
|
367 | - // Check if there are any other posted "other" values for this field |
|
343 | + // Save original value |
|
344 | + $args['temp_value'] = $value; |
|
345 | + $args['other'] = true; |
|
346 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
347 | + |
|
348 | + // Set the validation value now |
|
349 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
355 | + * |
|
356 | + * @since 2.0 |
|
357 | + * |
|
358 | + * @param object $field |
|
359 | + * @param string|array $value |
|
360 | + * @param array $args |
|
361 | + */ |
|
362 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
363 | + if ( ! $args['parent_field_id'] ) { |
|
364 | + return; |
|
365 | + } |
|
366 | + |
|
367 | + // Check if there are any other posted "other" values for this field |
|
368 | 368 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
369 | - // Save original value |
|
370 | - $args['temp_value'] = $value; |
|
371 | - $args['other'] = true; |
|
372 | - |
|
373 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
374 | - |
|
375 | - // Set the validation value now |
|
376 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
377 | - } |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Modify value used for validation |
|
382 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
383 | - * It also adds any text from the free text fields to the value |
|
384 | - * |
|
385 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
386 | - * |
|
387 | - * @since 2.0 |
|
388 | - * |
|
389 | - * @param string|array $value |
|
390 | - * @param string|array $other_vals (usually of posted values) |
|
391 | - * @param object $field |
|
392 | - * @param array $args |
|
393 | - */ |
|
394 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
395 | - // Checkboxes and multi-select dropdowns |
|
396 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
397 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
398 | - $value = array_merge( $value, $other_vals ); |
|
399 | - $value = array_filter( $value ); |
|
400 | - if ( count( $value ) == 0 ) { |
|
401 | - $value = ''; |
|
402 | - } |
|
403 | - } else { |
|
369 | + // Save original value |
|
370 | + $args['temp_value'] = $value; |
|
371 | + $args['other'] = true; |
|
372 | + |
|
373 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
374 | + |
|
375 | + // Set the validation value now |
|
376 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
377 | + } |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Modify value used for validation |
|
382 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
383 | + * It also adds any text from the free text fields to the value |
|
384 | + * |
|
385 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
386 | + * |
|
387 | + * @since 2.0 |
|
388 | + * |
|
389 | + * @param string|array $value |
|
390 | + * @param string|array $other_vals (usually of posted values) |
|
391 | + * @param object $field |
|
392 | + * @param array $args |
|
393 | + */ |
|
394 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
395 | + // Checkboxes and multi-select dropdowns |
|
396 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
397 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
398 | + $value = array_merge( $value, $other_vals ); |
|
399 | + $value = array_filter( $value ); |
|
400 | + if ( count( $value ) == 0 ) { |
|
401 | + $value = ''; |
|
402 | + } |
|
403 | + } else { |
|
404 | 404 | // Radio and dropdowns |
405 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
406 | - $other_key = reset( $other_key ); |
|
405 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
406 | + $other_key = reset( $other_key ); |
|
407 | 407 | |
408 | - // Multi-select dropdown |
|
409 | - if ( is_array( $value ) ) { |
|
410 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
408 | + // Multi-select dropdown |
|
409 | + if ( is_array( $value ) ) { |
|
410 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
411 | 411 | |
412 | 412 | if ( $o_key !== false ) { |
413 | 413 | // Modify the original value so other key will be preserved |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | $args['temp_value'] = $value; |
423 | 423 | $value[ $other_key ] = reset( $other_vals ); |
424 | 424 | } |
425 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
426 | - $value = $other_vals; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
425 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
426 | + $value = $other_vals; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | 430 | |
431 | - // Add submitted values to a string for spam checking |
|
431 | + // Add submitted values to a string for spam checking |
|
432 | 432 | public static function entry_array_to_string( $values ) { |
433 | - $content = ''; |
|
433 | + $content = ''; |
|
434 | 434 | foreach ( $values['item_meta'] as $val ) { |
435 | 435 | if ( $content != '' ) { |
436 | 436 | $content .= "\n\n"; |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | return $content; |
448 | - } |
|
448 | + } |
|
449 | 449 | |
450 | 450 | /** |
451 | 451 | * Get the browser from the user agent |
@@ -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 | |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
9 | 9 | $values = array(); |
10 | 10 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
11 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' ); |
|
11 | + $values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' ); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | $values['fields'] = array(); |
15 | - if ( empty($fields) ) { |
|
16 | - return apply_filters('frm_setup_new_entry', $values); |
|
15 | + if ( empty( $fields ) ) { |
|
16 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | foreach ( (array) $fields as $field ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'default_value' => $field->default_value, |
27 | 27 | 'name' => $field->name, |
28 | 28 | 'description' => $field->description, |
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
29 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
30 | 30 | 'options' => $field->options, |
31 | 31 | 'required' => $field->required, |
32 | 32 | 'field_key' => $field->field_key, |
@@ -42,38 +42,38 @@ discard block |
||
42 | 42 | $opt_defaults['original_type'] = $field->type; |
43 | 43 | |
44 | 44 | foreach ( $opt_defaults as $opt => $default_opt ) { |
45 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
46 | - unset($opt, $default_opt); |
|
45 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
46 | + unset( $opt, $default_opt ); |
|
47 | 47 | } |
48 | 48 | |
49 | - unset($opt_defaults); |
|
49 | + unset( $opt_defaults ); |
|
50 | 50 | |
51 | 51 | if ( $field_array['custom_html'] == '' ) { |
52 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
52 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
53 | 53 | } |
54 | 54 | |
55 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
55 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
56 | 56 | $field_array = array_merge( $field->field_options, $field_array ); |
57 | 57 | |
58 | 58 | $values['fields'][] = $field_array; |
59 | 59 | |
60 | - if ( ! $form || ! isset($form->id) ) { |
|
61 | - $form = FrmForm::getOne($field->form_id); |
|
60 | + if ( ! $form || ! isset( $form->id ) ) { |
|
61 | + $form = FrmForm::getOne( $field->form_id ); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - $form->options = maybe_unserialize($form->options); |
|
66 | - if ( is_array($form->options) ) { |
|
65 | + $form->options = maybe_unserialize( $form->options ); |
|
66 | + if ( is_array( $form->options ) ) { |
|
67 | 67 | foreach ( $form->options as $opt => $value ) { |
68 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
69 | - unset($opt, $value); |
|
68 | + $values[$opt] = FrmAppHelper::get_post_param( $opt, $value ); |
|
69 | + unset( $opt, $value ); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | 73 | $form_defaults = FrmFormsHelper::get_default_opts(); |
74 | 74 | |
75 | 75 | $frm_settings = FrmAppHelper::get_settings(); |
76 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
76 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
77 | 77 | |
78 | 78 | $values = array_merge( $form_defaults, $values ); |
79 | 79 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if ( ! is_array( $new_value ) ) { |
123 | - $new_value = str_replace('"', '"', $new_value); |
|
123 | + $new_value = str_replace( '"', '"', $new_value ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | return $new_value; |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | if ( $_POST ) { |
140 | 140 | $repeating = isset( $args['repeating'] ) && $args['repeating']; |
141 | 141 | if ( $repeating ) { |
142 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { |
|
142 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) { |
|
143 | 143 | $value_is_posted = true; |
144 | 144 | } |
145 | - } else if ( isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
145 | + } else if ( isset( $_POST['item_meta'][$field->id] ) ) { |
|
146 | 146 | $value_is_posted = true; |
147 | 147 | } |
148 | 148 | } |
@@ -153,26 +153,26 @@ discard block |
||
153 | 153 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
154 | 154 | $values['form_id'] = $record->form_id; |
155 | 155 | $values['is_draft'] = $record->is_draft; |
156 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
156 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public static function replace_default_message( $message, $atts ) { |
160 | - if ( strpos($message, '[default-message') === false && |
|
161 | - strpos($message, '[default_message') === false && |
|
160 | + if ( strpos( $message, '[default-message' ) === false && |
|
161 | + strpos( $message, '[default_message' ) === false && |
|
162 | 162 | ! empty( $message ) ) { |
163 | 163 | return $message; |
164 | 164 | } |
165 | 165 | |
166 | - if ( empty($message) ) { |
|
166 | + if ( empty( $message ) ) { |
|
167 | 167 | $message = '[default-message]'; |
168 | 168 | } |
169 | 169 | |
170 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
170 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
171 | 171 | |
172 | 172 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
173 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
173 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
174 | 174 | if ( ! empty( $add_atts ) ) { |
175 | - $this_atts = array_merge($atts, $add_atts); |
|
175 | + $this_atts = array_merge( $atts, $add_atts ); |
|
176 | 176 | } else { |
177 | 177 | $this_atts = $atts; |
178 | 178 | } |
@@ -180,32 +180,32 @@ discard block |
||
180 | 180 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
181 | 181 | |
182 | 182 | // Add the default message |
183 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
183 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return $message; |
187 | 187 | } |
188 | 188 | |
189 | 189 | public static function prepare_display_value( $entry, $field, $atts ) { |
190 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
190 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
191 | 191 | |
192 | 192 | if ( FrmAppHelper::pro_is_installed() ) { |
193 | 193 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
194 | 194 | } |
195 | 195 | |
196 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
197 | - return self::display_value($field_value, $field, $atts); |
|
196 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
197 | + return self::display_value( $field_value, $field, $atts ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // this is an embeded form |
201 | 201 | $val = ''; |
202 | 202 | |
203 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
203 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
204 | 204 | //this is a repeating section |
205 | 205 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
206 | 206 | } else { |
207 | 207 | // get all values for this field |
208 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
208 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
209 | 209 | |
210 | 210 | if ( $child_values ) { |
211 | 211 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $field_value = array(); |
216 | 216 | |
217 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
217 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
218 | 218 | return $val; |
219 | 219 | } |
220 | 220 | |
@@ -223,17 +223,17 @@ discard block |
||
223 | 223 | $atts['post_id'] = $child_entry->post_id; |
224 | 224 | |
225 | 225 | // get the value for this field -- check for post values as well |
226 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
226 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
227 | 227 | |
228 | 228 | if ( $entry_val ) { |
229 | 229 | // foreach entry get display_value |
230 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
230 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
231 | 231 | } |
232 | 232 | |
233 | - unset($child_entry); |
|
233 | + unset( $child_entry ); |
|
234 | 234 | } |
235 | 235 | |
236 | - $val = implode(', ', (array) $field_value ); |
|
236 | + $val = implode( ', ', (array) $field_value ); |
|
237 | 237 | $val = wp_kses_post( $val ); |
238 | 238 | |
239 | 239 | return $val; |
@@ -253,22 +253,22 @@ discard block |
||
253 | 253 | ); |
254 | 254 | |
255 | 255 | $atts = wp_parse_args( $atts, $defaults ); |
256 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
256 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
257 | 257 | |
258 | - if ( ! isset($field->field_options['post_field']) ) { |
|
258 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
259 | 259 | $field->field_options['post_field'] = ''; |
260 | 260 | } |
261 | 261 | |
262 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
262 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
263 | 263 | $field->field_options['custom_field'] = ''; |
264 | 264 | } |
265 | 265 | |
266 | 266 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
267 | 267 | $atts['pre_truncate'] = $atts['truncate']; |
268 | 268 | $atts['truncate'] = true; |
269 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
269 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
270 | 270 | |
271 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
271 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
272 | 272 | $atts['truncate'] = $atts['pre_truncate']; |
273 | 273 | } |
274 | 274 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | $unfiltered_value = maybe_unserialize( $value ); |
280 | - $value = apply_filters('frm_display_value_custom', $unfiltered_value, $field, $atts); |
|
280 | + $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts ); |
|
281 | 281 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
282 | 282 | |
283 | 283 | if ( $value == $unfiltered_value ) { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
288 | - $value = FrmAppHelper::truncate($value, 50); |
|
288 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
@@ -300,20 +300,20 @@ discard block |
||
300 | 300 | if ( isset( $args['other'] ) && $args['other'] ) { |
301 | 301 | $value = $args['temp_value']; |
302 | 302 | } |
303 | - if ( empty($args['parent_field_id']) ) { |
|
304 | - $_POST['item_meta'][ $field->id ] = $value; |
|
303 | + if ( empty( $args['parent_field_id'] ) ) { |
|
304 | + $_POST['item_meta'][$field->id] = $value; |
|
305 | 305 | } else { |
306 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
306 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | 310 | public static function get_posted_value( $field, &$value, $args ) { |
311 | 311 | $field_id = is_object( $field ) ? $field->id : $field; |
312 | 312 | |
313 | - if ( empty($args['parent_field_id']) ) { |
|
314 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
313 | + if ( empty( $args['parent_field_id'] ) ) { |
|
314 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
315 | 315 | } else { |
316 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
316 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
317 | 317 | } |
318 | 318 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
319 | 319 | $value = stripslashes_deep( $value ); |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | self::set_other_repeating_vals( $field, $value, $args ); |
339 | 339 | |
340 | 340 | // Check if there are any posted "Other" values |
341 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
341 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
342 | 342 | |
343 | 343 | // Save original value |
344 | 344 | $args['temp_value'] = $value; |
345 | 345 | $args['other'] = true; |
346 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
346 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
347 | 347 | |
348 | 348 | // Set the validation value now |
349 | 349 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | // Check if there are any other posted "other" values for this field |
368 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
368 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
369 | 369 | // Save original value |
370 | 370 | $args['temp_value'] = $value; |
371 | 371 | $args['other'] = true; |
372 | 372 | |
373 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
373 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
374 | 374 | |
375 | 375 | // Set the validation value now |
376 | 376 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -402,27 +402,27 @@ discard block |
||
402 | 402 | } |
403 | 403 | } else { |
404 | 404 | // Radio and dropdowns |
405 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
405 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
406 | 406 | $other_key = reset( $other_key ); |
407 | 407 | |
408 | 408 | // Multi-select dropdown |
409 | 409 | if ( is_array( $value ) ) { |
410 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
410 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
411 | 411 | |
412 | 412 | if ( $o_key !== false ) { |
413 | 413 | // Modify the original value so other key will be preserved |
414 | - $value[ $other_key ] = $value[ $o_key ]; |
|
414 | + $value[$other_key] = $value[$o_key]; |
|
415 | 415 | |
416 | 416 | // By default, the array keys will be numeric for multi-select dropdowns |
417 | 417 | // If going backwards and forwards between pages, the array key will match the other key |
418 | 418 | if ( $o_key != $other_key ) { |
419 | - unset( $value[ $o_key ] ); |
|
419 | + unset( $value[$o_key] ); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $args['temp_value'] = $value; |
423 | - $value[ $other_key ] = reset( $other_vals ); |
|
423 | + $value[$other_key] = reset( $other_vals ); |
|
424 | 424 | } |
425 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
425 | + } else if ( $field->options[$other_key] == $value ) { |
|
426 | 426 | $value = $other_vals; |
427 | 427 | } |
428 | 428 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $content .= "\n\n"; |
437 | 437 | } |
438 | 438 | |
439 | - if ( is_array($val) ) { |
|
439 | + if ( is_array( $val ) ) { |
|
440 | 440 | $val = FrmAppHelper::array_flatten( $val ); |
441 | 441 | $val = implode( ', ', $val ); |
442 | 442 | } |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
501 | 501 | |
502 | 502 | // see how many we have |
503 | - $i = count($matches['browser']); |
|
503 | + $i = count( $matches['browser'] ); |
|
504 | 504 | |
505 | 505 | if ( $i > 1 ) { |
506 | 506 | //we will have two since we are not using 'other' argument yet |
@@ -52,15 +52,15 @@ |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | $with_tags = $args['conditional_check'] ? 3 : 2; |
55 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
56 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
57 | - $tag = str_replace(']', '', $tag); |
|
58 | - $tags = explode(' ', $tag); |
|
59 | - if ( is_array($tags) ) { |
|
55 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
56 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
57 | + $tag = str_replace( ']', '', $tag ); |
|
58 | + $tags = explode( ' ', $tag ); |
|
59 | + if ( is_array( $tags ) ) { |
|
60 | 60 | $tag = $tags[0]; |
61 | 61 | } |
62 | 62 | } else { |
63 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
63 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $tag; |
@@ -23,30 +23,30 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function import_xml( $file ) { |
26 | - $defaults = array( |
|
27 | - 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
28 | - 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
29 | - 'styles' => 0, |
|
30 | - ); |
|
31 | - |
|
32 | - $imported = array( |
|
33 | - 'imported' => $defaults, |
|
26 | + $defaults = array( |
|
27 | + 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
28 | + 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
29 | + 'styles' => 0, |
|
30 | + ); |
|
31 | + |
|
32 | + $imported = array( |
|
33 | + 'imported' => $defaults, |
|
34 | 34 | 'updated' => $defaults, |
35 | 35 | 'forms' => array(), |
36 | 36 | 'terms' => array(), |
37 | - ); |
|
37 | + ); |
|
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset($defaults); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
43 | - } |
|
42 | + define('WP_IMPORTING', true); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
46 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
47 | - } |
|
46 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
47 | + } |
|
48 | 48 | |
49 | - $dom = new DOMDocument; |
|
49 | + $dom = new DOMDocument; |
|
50 | 50 | $success = $dom->loadXML( file_get_contents( $file ) ); |
51 | 51 | if ( ! $success ) { |
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
@@ -64,45 +64,45 @@ discard block |
||
64 | 64 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
65 | 65 | } |
66 | 66 | |
67 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
67 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | - // grab cats, tags, and terms, or forms or posts |
|
70 | - if ( isset($xml->{$item_type} ) ) { |
|
69 | + // grab cats, tags, and terms, or forms or posts |
|
70 | + if ( isset($xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | - } |
|
75 | - } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | - return $return; |
|
80 | - } |
|
79 | + return $return; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
83 | - foreach ( $terms as $t ) { |
|
83 | + foreach ( $terms as $t ) { |
|
84 | 84 | if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
85 | - continue; |
|
85 | + continue; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $parent = self::get_term_parent_id( $t ); |
89 | 89 | |
90 | 90 | $term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array( |
91 | - 'slug' => (string) $t->term_slug, |
|
92 | - 'description' => (string) $t->term_description, |
|
91 | + 'slug' => (string) $t->term_slug, |
|
92 | + 'description' => (string) $t->term_description, |
|
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | - )); |
|
94 | + )); |
|
95 | 95 | |
96 | 96 | if ( $term && is_array( $term ) ) { |
97 | - $imported['imported']['terms']++; |
|
97 | + $imported['imported']['terms']++; |
|
98 | 98 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | unset( $term, $t ); |
102 | 102 | } |
103 | 103 | |
104 | 104 | return $imported; |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * @since 2.0.8 |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | self::put_child_forms_first( $forms ); |
128 | 128 | |
129 | 129 | foreach ( $forms as $item ) { |
130 | - $form = self::fill_form( $item ); |
|
130 | + $form = self::fill_form( $item ); |
|
131 | 131 | |
132 | 132 | self::update_custom_style_setting_on_import( $form ); |
133 | 133 | |
134 | - $this_form = self::maybe_get_form( $form ); |
|
134 | + $this_form = self::maybe_get_form( $form ); |
|
135 | 135 | |
136 | 136 | $old_id = false; |
137 | 137 | $form_fields = false; |
@@ -143,35 +143,35 @@ discard block |
||
143 | 143 | $form_fields = self::get_form_fields( $form_id ); |
144 | 144 | } else { |
145 | 145 | $form_id = FrmForm::create( $form ); |
146 | - if ( $form_id ) { |
|
147 | - $imported['imported']['forms']++; |
|
148 | - // Keep track of whether this specific form was updated or not |
|
146 | + if ( $form_id ) { |
|
147 | + $imported['imported']['forms']++; |
|
148 | + // Keep track of whether this specific form was updated or not |
|
149 | 149 | $imported['form_status'][ $form_id ] = 'imported'; |
150 | 150 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
151 | - } |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
155 | 155 | |
156 | 156 | self::delete_removed_fields( $form_fields ); |
157 | 157 | |
158 | - // Update field ids/keys to new ones |
|
158 | + // Update field ids/keys to new ones |
|
159 | 159 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
160 | 160 | |
161 | 161 | $imported['forms'][ (int) $item->id ] = $form_id; |
162 | 162 | |
163 | - // Send pre 2.0 form options through function that creates actions |
|
164 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
163 | + // Send pre 2.0 form options through function that creates actions |
|
164 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
165 | 165 | |
166 | 166 | do_action( 'frm_after_import_form', $form_id, $form ); |
167 | 167 | |
168 | - unset($form, $item); |
|
168 | + unset($form, $item); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
172 | 172 | |
173 | 173 | return $imported; |
174 | - } |
|
174 | + } |
|
175 | 175 | |
176 | 176 | private static function fill_form( $item ) { |
177 | 177 | $form = array( |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | - * Put child forms first so they will be imported before parents |
|
243 | - * |
|
244 | - * @since 2.0.16 |
|
245 | - * @param array $forms |
|
246 | - */ |
|
242 | + * Put child forms first so they will be imported before parents |
|
243 | + * |
|
244 | + * @since 2.0.16 |
|
245 | + * @param array $forms |
|
246 | + */ |
|
247 | 247 | private static function put_child_forms_first( &$forms ) { |
248 | 248 | $child_forms = array(); |
249 | 249 | $regular_forms = array(); |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Keep track of all imported child forms |
|
266 | - * |
|
267 | - * @since 2.0.16 |
|
268 | - * @param int $form_id |
|
269 | - * @param int $parent_form_id |
|
270 | - * @param array $child_forms |
|
271 | - */ |
|
265 | + * Keep track of all imported child forms |
|
266 | + * |
|
267 | + * @since 2.0.16 |
|
268 | + * @param int $form_id |
|
269 | + * @param int $parent_form_id |
|
270 | + * @param array $child_forms |
|
271 | + */ |
|
272 | 272 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
273 | 273 | if ( $parent_form_id ) { |
274 | 274 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
279 | - * Update the parent_form_id on imported child forms |
|
280 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
281 | - * |
|
282 | - * @since 2.0.6 |
|
283 | - * @param array $imported_forms |
|
284 | - * @param array $child_forms |
|
285 | - */ |
|
279 | + * Update the parent_form_id on imported child forms |
|
280 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
281 | + * |
|
282 | + * @since 2.0.6 |
|
283 | + * @param array $imported_forms |
|
284 | + * @param array $child_forms |
|
285 | + */ |
|
286 | 286 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
287 | 287 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
288 | 288 | |
@@ -296,28 +296,28 @@ discard block |
||
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
299 | - * Import all fields for a form |
|
300 | - * @since 2.0.13 |
|
301 | - * |
|
302 | - * TODO: Cut down on params |
|
303 | - */ |
|
299 | + * Import all fields for a form |
|
300 | + * @since 2.0.13 |
|
301 | + * |
|
302 | + * TODO: Cut down on params |
|
303 | + */ |
|
304 | 304 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
305 | 305 | $in_section = 0; |
306 | 306 | |
307 | 307 | foreach ( $xml_fields as $field ) { |
308 | 308 | $f = self::fill_field( $field, $form_id ); |
309 | 309 | |
310 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
311 | - 'text', 'email', 'url', 'textarea', |
|
312 | - 'number','phone', 'date', |
|
313 | - 'hidden', 'password', 'tag', 'image', |
|
314 | - )) ) { |
|
315 | - if ( count($f['default_value']) === 1 ) { |
|
310 | + if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
311 | + 'text', 'email', 'url', 'textarea', |
|
312 | + 'number','phone', 'date', |
|
313 | + 'hidden', 'password', 'tag', 'image', |
|
314 | + )) ) { |
|
315 | + if ( count($f['default_value']) === 1 ) { |
|
316 | 316 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
317 | - } else { |
|
318 | - $f['default_value'] = reset($f['default_value']); |
|
319 | - } |
|
320 | - } |
|
317 | + } else { |
|
318 | + $f['default_value'] = reset($f['default_value']); |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | 322 | self::maybe_update_in_section_variable( $in_section, $f ); |
323 | 323 | self::maybe_update_form_select( $f, $imported ); |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
400 | - * |
|
401 | - * @since 2.0.16 |
|
402 | - * @param array $f |
|
403 | - * @param array $imported |
|
404 | - */ |
|
399 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
400 | + * |
|
401 | + * @since 2.0.16 |
|
402 | + * @param array $f |
|
403 | + * @param array $imported |
|
404 | + */ |
|
405 | 405 | private static function maybe_update_form_select( &$f, $imported ) { |
406 | 406 | if ( ! isset( $imported['forms'] ) ) { |
407 | 407 | return; |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
456 | - * Updates the custom style setting on import |
|
457 | - * Convert the post slug to an ID |
|
458 | - * |
|
459 | - * @since 2.0.19 |
|
460 | - * @param array $form |
|
461 | - * |
|
462 | - */ |
|
456 | + * Updates the custom style setting on import |
|
457 | + * Convert the post slug to an ID |
|
458 | + * |
|
459 | + * @since 2.0.19 |
|
460 | + * @param array $form |
|
461 | + * |
|
462 | + */ |
|
463 | 463 | private static function update_custom_style_setting_on_import( &$form ) { |
464 | 464 | if ( ! isset( $form['options']['custom_style'] ) ) { |
465 | 465 | return; |
@@ -513,16 +513,16 @@ discard block |
||
513 | 513 | } |
514 | 514 | |
515 | 515 | public static function import_xml_views( $views, $imported ) { |
516 | - $imported['posts'] = array(); |
|
517 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
516 | + $imported['posts'] = array(); |
|
517 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
518 | 518 | |
519 | - $post_types = array( |
|
520 | - 'frm_display' => 'views', |
|
521 | - $form_action_type => 'actions', |
|
522 | - 'frm_styles' => 'styles', |
|
523 | - ); |
|
519 | + $post_types = array( |
|
520 | + 'frm_display' => 'views', |
|
521 | + $form_action_type => 'actions', |
|
522 | + 'frm_styles' => 'styles', |
|
523 | + ); |
|
524 | 524 | |
525 | - foreach ( $views as $item ) { |
|
525 | + foreach ( $views as $item ) { |
|
526 | 526 | $post = array( |
527 | 527 | 'post_title' => (string) $item->title, |
528 | 528 | 'post_name' => (string) $item->post_name, |
@@ -541,52 +541,52 @@ discard block |
||
541 | 541 | 'post_date' => (string) $item->post_date, |
542 | 542 | 'post_date_gmt' => (string) $item->post_date_gmt, |
543 | 543 | 'ping_status' => (string) $item->ping_status, |
544 | - 'postmeta' => array(), |
|
545 | - 'tax_input' => array(), |
|
544 | + 'postmeta' => array(), |
|
545 | + 'tax_input' => array(), |
|
546 | 546 | ); |
547 | 547 | |
548 | - $old_id = $post['post_id']; |
|
549 | - self::populate_post($post, $item, $imported); |
|
548 | + $old_id = $post['post_id']; |
|
549 | + self::populate_post($post, $item, $imported); |
|
550 | 550 | |
551 | 551 | unset($item); |
552 | 552 | |
553 | 553 | $post_id = false; |
554 | - if ( $post['post_type'] == $form_action_type ) { |
|
555 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
554 | + if ( $post['post_type'] == $form_action_type ) { |
|
555 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
556 | 556 | if ( $action_control && is_object( $action_control ) ) { |
557 | 557 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
558 | 558 | } |
559 | - unset($action_control); |
|
560 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
561 | - // Properly encode post content before inserting the post |
|
562 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
559 | + unset($action_control); |
|
560 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
561 | + // Properly encode post content before inserting the post |
|
562 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
563 | 563 | $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : ''; |
564 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
564 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
565 | 565 | |
566 | - // Create/update post now |
|
567 | - $post_id = wp_insert_post( $post ); |
|
566 | + // Create/update post now |
|
567 | + $post_id = wp_insert_post( $post ); |
|
568 | 568 | self::maybe_update_custom_css( $custom_css ); |
569 | - } else { |
|
570 | - // Create/update post now |
|
571 | - $post_id = wp_insert_post( $post ); |
|
572 | - } |
|
569 | + } else { |
|
570 | + // Create/update post now |
|
571 | + $post_id = wp_insert_post( $post ); |
|
572 | + } |
|
573 | 573 | |
574 | - if ( ! is_numeric($post_id) ) { |
|
575 | - continue; |
|
576 | - } |
|
574 | + if ( ! is_numeric($post_id) ) { |
|
575 | + continue; |
|
576 | + } |
|
577 | 577 | |
578 | - self::update_postmeta($post, $post_id); |
|
578 | + self::update_postmeta($post, $post_id); |
|
579 | 579 | |
580 | - $this_type = 'posts'; |
|
580 | + $this_type = 'posts'; |
|
581 | 581 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
582 | 582 | $this_type = $post_types[ $post['post_type'] ]; |
583 | - } |
|
583 | + } |
|
584 | 584 | |
585 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
586 | - $imported['updated'][ $this_type ]++; |
|
587 | - } else { |
|
588 | - $imported['imported'][ $this_type ]++; |
|
589 | - } |
|
585 | + if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
586 | + $imported['updated'][ $this_type ]++; |
|
587 | + } else { |
|
588 | + $imported['imported'][ $this_type ]++; |
|
589 | + } |
|
590 | 590 | |
591 | 591 | $imported['posts'][ (int) $old_id ] = $post_id; |
592 | 592 | |
@@ -598,16 +598,16 @@ discard block |
||
598 | 598 | self::maybe_update_stylesheet( $imported ); |
599 | 599 | |
600 | 600 | return $imported; |
601 | - } |
|
601 | + } |
|
602 | 602 | |
603 | - private static function populate_post( &$post, $item, $imported ) { |
|
603 | + private static function populate_post( &$post, $item, $imported ) { |
|
604 | 604 | if ( isset($item->attachment_url) ) { |
605 | 605 | $post['attachment_url'] = (string) $item->attachment_url; |
606 | 606 | } |
607 | 607 | |
608 | 608 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
609 | - // update to new form id |
|
610 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
609 | + // update to new form id |
|
610 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | // Don't allow default styles to take over a site's default style |
@@ -616,145 +616,145 @@ discard block |
||
616 | 616 | } |
617 | 617 | |
618 | 618 | foreach ( $item->postmeta as $meta ) { |
619 | - self::populate_postmeta($post, $meta, $imported); |
|
619 | + self::populate_postmeta($post, $meta, $imported); |
|
620 | 620 | unset($meta); |
621 | 621 | } |
622 | 622 | |
623 | - self::populate_taxonomies($post, $item); |
|
623 | + self::populate_taxonomies($post, $item); |
|
624 | 624 | |
625 | - self::maybe_editing_post($post); |
|
626 | - } |
|
625 | + self::maybe_editing_post($post); |
|
626 | + } |
|
627 | 627 | |
628 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
629 | - global $frm_duplicate_ids; |
|
628 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
629 | + global $frm_duplicate_ids; |
|
630 | 630 | |
631 | - $m = array( |
|
631 | + $m = array( |
|
632 | 632 | 'key' => (string) $meta->meta_key, |
633 | 633 | 'value' => (string) $meta->meta_value, |
634 | 634 | ); |
635 | 635 | |
636 | 636 | //switch old form and field ids to new ones |
637 | 637 | if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
638 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
638 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
639 | 639 | } else { |
640 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
640 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
641 | 641 | |
642 | - if ( ! empty($frm_duplicate_ids) ) { |
|
642 | + if ( ! empty($frm_duplicate_ids) ) { |
|
643 | 643 | |
644 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
645 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
646 | - } else if ( $m['key'] == 'frm_options' ) { |
|
644 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
645 | + $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
646 | + } else if ( $m['key'] == 'frm_options' ) { |
|
647 | 647 | |
648 | 648 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
649 | 649 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
650 | 650 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
651 | - } |
|
652 | - } |
|
653 | - |
|
654 | - $check_dup_array = array(); |
|
655 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
656 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
657 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
658 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
659 | - $check_dup_array[] = 'order_by'; |
|
660 | - } |
|
661 | - } |
|
662 | - |
|
663 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
664 | - $check_dup_array[] = 'where'; |
|
665 | - } |
|
666 | - |
|
667 | - foreach ( $check_dup_array as $check_k ) { |
|
651 | + } |
|
652 | + } |
|
653 | + |
|
654 | + $check_dup_array = array(); |
|
655 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
656 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
657 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
658 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
659 | + $check_dup_array[] = 'order_by'; |
|
660 | + } |
|
661 | + } |
|
662 | + |
|
663 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
664 | + $check_dup_array[] = 'where'; |
|
665 | + } |
|
666 | + |
|
667 | + foreach ( $check_dup_array as $check_k ) { |
|
668 | 668 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
669 | 669 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
670 | 670 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
671 | - } |
|
672 | - unset($mk, $mv); |
|
673 | - } |
|
674 | - } |
|
675 | - } |
|
676 | - } |
|
671 | + } |
|
672 | + unset($mk, $mv); |
|
673 | + } |
|
674 | + } |
|
675 | + } |
|
676 | + } |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | if ( ! is_array($m['value']) ) { |
680 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
680 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
684 | - } |
|
685 | - |
|
686 | - /** |
|
687 | - * Add terms to post |
|
688 | - * @param array $post by reference |
|
689 | - * @param object $item The XML object data |
|
690 | - */ |
|
691 | - private static function populate_taxonomies( &$post, $item ) { |
|
684 | + } |
|
685 | + |
|
686 | + /** |
|
687 | + * Add terms to post |
|
688 | + * @param array $post by reference |
|
689 | + * @param object $item The XML object data |
|
690 | + */ |
|
691 | + private static function populate_taxonomies( &$post, $item ) { |
|
692 | 692 | foreach ( $item->category as $c ) { |
693 | 693 | $att = $c->attributes(); |
694 | 694 | if ( ! isset( $att['nicename'] ) ) { |
695 | - continue; |
|
696 | - } |
|
697 | - |
|
698 | - $taxonomy = (string) $att['domain']; |
|
699 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
700 | - $name = (string) $att['nicename']; |
|
701 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
702 | - if ( $h_term ) { |
|
703 | - $name = $h_term->term_id; |
|
704 | - } |
|
705 | - unset($h_term); |
|
706 | - } else { |
|
707 | - $name = (string) $c; |
|
708 | - } |
|
695 | + continue; |
|
696 | + } |
|
697 | + |
|
698 | + $taxonomy = (string) $att['domain']; |
|
699 | + if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
700 | + $name = (string) $att['nicename']; |
|
701 | + $h_term = get_term_by('slug', $name, $taxonomy); |
|
702 | + if ( $h_term ) { |
|
703 | + $name = $h_term->term_id; |
|
704 | + } |
|
705 | + unset($h_term); |
|
706 | + } else { |
|
707 | + $name = (string) $c; |
|
708 | + } |
|
709 | 709 | |
710 | 710 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
711 | 711 | $post['tax_input'][ $taxonomy ] = array(); |
712 | 712 | } |
713 | 713 | |
714 | 714 | $post['tax_input'][ $taxonomy ][] = $name; |
715 | - unset($name); |
|
715 | + unset($name); |
|
716 | 716 | } |
717 | - } |
|
717 | + } |
|
718 | 718 | |
719 | - /** |
|
720 | - * Edit post if the key and created time match |
|
721 | - */ |
|
722 | - private static function maybe_editing_post( &$post ) { |
|
719 | + /** |
|
720 | + * Edit post if the key and created time match |
|
721 | + */ |
|
722 | + private static function maybe_editing_post( &$post ) { |
|
723 | 723 | $match_by = array( |
724 | - 'post_type' => $post['post_type'], |
|
725 | - 'name' => $post['post_name'], |
|
726 | - 'post_status' => $post['post_status'], |
|
727 | - 'posts_per_page' => 1, |
|
724 | + 'post_type' => $post['post_type'], |
|
725 | + 'name' => $post['post_name'], |
|
726 | + 'post_status' => $post['post_status'], |
|
727 | + 'posts_per_page' => 1, |
|
728 | 728 | ); |
729 | 729 | |
730 | 730 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
731 | - $match_by['include'] = $post['post_id']; |
|
732 | - unset($match_by['name']); |
|
731 | + $match_by['include'] = $post['post_id']; |
|
732 | + unset($match_by['name']); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | $editing = get_posts($match_by); |
736 | 736 | |
737 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
738 | - // set the id of the post to edit |
|
739 | - $post['ID'] = current($editing)->ID; |
|
740 | - } |
|
741 | - } |
|
742 | - |
|
743 | - private static function update_postmeta( &$post, $post_id ) { |
|
744 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
745 | - if ( '_edit_last' == $k ) { |
|
746 | - $v = FrmAppHelper::get_user_id_param($v); |
|
747 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
748 | - //change the attachment ID |
|
737 | + if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
738 | + // set the id of the post to edit |
|
739 | + $post['ID'] = current($editing)->ID; |
|
740 | + } |
|
741 | + } |
|
742 | + |
|
743 | + private static function update_postmeta( &$post, $post_id ) { |
|
744 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
745 | + if ( '_edit_last' == $k ) { |
|
746 | + $v = FrmAppHelper::get_user_id_param($v); |
|
747 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
748 | + //change the attachment ID |
|
749 | 749 | $field_obj = FrmFieldFactory::get_field_type( 'file' ); |
750 | 750 | $v = $field_obj->get_file_id( $v ); |
751 | - } |
|
751 | + } |
|
752 | 752 | |
753 | - update_post_meta($post_id, $k, $v); |
|
753 | + update_post_meta($post_id, $k, $v); |
|
754 | 754 | |
755 | - unset($k, $v); |
|
756 | - } |
|
757 | - } |
|
755 | + unset($k, $v); |
|
756 | + } |
|
757 | + } |
|
758 | 758 | |
759 | 759 | /** |
760 | 760 | * If a template includes custom css, let's include it. |
@@ -787,72 +787,72 @@ discard block |
||
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
790 | - /** |
|
791 | - * @param string $message |
|
792 | - */ |
|
790 | + /** |
|
791 | + * @param string $message |
|
792 | + */ |
|
793 | 793 | public static function parse_message( $result, &$message, &$errors ) { |
794 | - if ( is_wp_error($result) ) { |
|
795 | - $errors[] = $result->get_error_message(); |
|
796 | - } else if ( ! $result ) { |
|
797 | - return; |
|
798 | - } |
|
799 | - |
|
800 | - if ( ! is_array($result) ) { |
|
801 | - $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
802 | - return; |
|
803 | - } |
|
804 | - |
|
805 | - $t_strings = array( |
|
806 | - 'imported' => __( 'Imported', 'formidable' ), |
|
807 | - 'updated' => __( 'Updated', 'formidable' ), |
|
808 | - ); |
|
809 | - |
|
810 | - $message = '<ul>'; |
|
811 | - foreach ( $result as $type => $results ) { |
|
794 | + if ( is_wp_error($result) ) { |
|
795 | + $errors[] = $result->get_error_message(); |
|
796 | + } else if ( ! $result ) { |
|
797 | + return; |
|
798 | + } |
|
799 | + |
|
800 | + if ( ! is_array($result) ) { |
|
801 | + $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
802 | + return; |
|
803 | + } |
|
804 | + |
|
805 | + $t_strings = array( |
|
806 | + 'imported' => __( 'Imported', 'formidable' ), |
|
807 | + 'updated' => __( 'Updated', 'formidable' ), |
|
808 | + ); |
|
809 | + |
|
810 | + $message = '<ul>'; |
|
811 | + foreach ( $result as $type => $results ) { |
|
812 | 812 | if ( ! isset( $t_strings[ $type ] ) ) { |
813 | - // only print imported and updated |
|
814 | - continue; |
|
815 | - } |
|
813 | + // only print imported and updated |
|
814 | + continue; |
|
815 | + } |
|
816 | 816 | |
817 | - $s_message = array(); |
|
818 | - foreach ( $results as $k => $m ) { |
|
819 | - self::item_count_message($m, $k, $s_message); |
|
820 | - unset($k, $m); |
|
821 | - } |
|
817 | + $s_message = array(); |
|
818 | + foreach ( $results as $k => $m ) { |
|
819 | + self::item_count_message($m, $k, $s_message); |
|
820 | + unset($k, $m); |
|
821 | + } |
|
822 | 822 | |
823 | - if ( ! empty($s_message) ) { |
|
823 | + if ( ! empty($s_message) ) { |
|
824 | 824 | $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
825 | - $message .= implode(', ', $s_message); |
|
826 | - $message .= '</li>'; |
|
827 | - } |
|
828 | - } |
|
829 | - |
|
830 | - if ( $message == '<ul>' ) { |
|
831 | - $message = ''; |
|
832 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
833 | - } else { |
|
834 | - $message .= '</ul>'; |
|
835 | - } |
|
836 | - } |
|
825 | + $message .= implode(', ', $s_message); |
|
826 | + $message .= '</li>'; |
|
827 | + } |
|
828 | + } |
|
829 | + |
|
830 | + if ( $message == '<ul>' ) { |
|
831 | + $message = ''; |
|
832 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
833 | + } else { |
|
834 | + $message .= '</ul>'; |
|
835 | + } |
|
836 | + } |
|
837 | 837 | |
838 | 838 | public static function item_count_message( $m, $type, &$s_message ) { |
839 | - if ( ! $m ) { |
|
840 | - return; |
|
841 | - } |
|
842 | - |
|
843 | - $strings = array( |
|
844 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
845 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
846 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
847 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
848 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
849 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
850 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
851 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
852 | - ); |
|
839 | + if ( ! $m ) { |
|
840 | + return; |
|
841 | + } |
|
842 | + |
|
843 | + $strings = array( |
|
844 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
845 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
846 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
847 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
848 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
849 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
850 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
851 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
852 | + ); |
|
853 | 853 | |
854 | 854 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
855 | - } |
|
855 | + } |
|
856 | 856 | |
857 | 857 | /** |
858 | 858 | * Prepare the form options for export |
@@ -883,16 +883,16 @@ discard block |
||
883 | 883 | } |
884 | 884 | |
885 | 885 | public static function cdata( $str ) { |
886 | - $str = maybe_unserialize($str); |
|
887 | - if ( is_array($str) ) { |
|
888 | - $str = json_encode($str); |
|
886 | + $str = maybe_unserialize($str); |
|
887 | + if ( is_array($str) ) { |
|
888 | + $str = json_encode($str); |
|
889 | 889 | } else if ( seems_utf8( $str ) == false ) { |
890 | 890 | $str = utf8_encode( $str ); |
891 | 891 | } |
892 | 892 | |
893 | - if ( is_numeric($str) ) { |
|
894 | - return $str; |
|
895 | - } |
|
893 | + if ( is_numeric($str) ) { |
|
894 | + return $str; |
|
895 | + } |
|
896 | 896 | |
897 | 897 | self::remove_invalid_characters_from_xml( $str ); |
898 | 898 | |
@@ -913,58 +913,58 @@ discard block |
||
913 | 913 | $str = str_replace( '\x1F', '', $str ); |
914 | 914 | } |
915 | 915 | |
916 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
917 | - // Get post type |
|
918 | - $post_type = FrmFormActionsController::$action_post_type; |
|
919 | - |
|
920 | - // Set up imported index, if not set up yet |
|
921 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
922 | - $imported['imported']['actions'] = 0; |
|
923 | - } |
|
924 | - |
|
925 | - // Migrate post settings to action |
|
926 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
927 | - |
|
928 | - // Migrate email settings to action |
|
929 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
930 | - } |
|
931 | - |
|
932 | - /** |
|
933 | - * Migrate post settings to form action |
|
934 | - * |
|
935 | - * @param string $post_type |
|
936 | - */ |
|
937 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
938 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
939 | - return; |
|
940 | - } |
|
941 | - |
|
942 | - $new_action = array( |
|
943 | - 'post_type' => $post_type, |
|
944 | - 'post_excerpt' => 'wppost', |
|
916 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
917 | + // Get post type |
|
918 | + $post_type = FrmFormActionsController::$action_post_type; |
|
919 | + |
|
920 | + // Set up imported index, if not set up yet |
|
921 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
922 | + $imported['imported']['actions'] = 0; |
|
923 | + } |
|
924 | + |
|
925 | + // Migrate post settings to action |
|
926 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
927 | + |
|
928 | + // Migrate email settings to action |
|
929 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
930 | + } |
|
931 | + |
|
932 | + /** |
|
933 | + * Migrate post settings to form action |
|
934 | + * |
|
935 | + * @param string $post_type |
|
936 | + */ |
|
937 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
938 | + if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
939 | + return; |
|
940 | + } |
|
941 | + |
|
942 | + $new_action = array( |
|
943 | + 'post_type' => $post_type, |
|
944 | + 'post_excerpt' => 'wppost', |
|
945 | 945 | 'post_title' => __( 'Create Posts', 'formidable' ), |
946 | - 'menu_order' => $form_id, |
|
947 | - 'post_status' => 'publish', |
|
948 | - 'post_content' => array(), |
|
946 | + 'menu_order' => $form_id, |
|
947 | + 'post_status' => 'publish', |
|
948 | + 'post_content' => array(), |
|
949 | 949 | 'post_name' => $form_id . '_wppost_1', |
950 | - ); |
|
950 | + ); |
|
951 | 951 | |
952 | - $post_settings = array( |
|
953 | - 'post_type', 'post_category', 'post_content', |
|
954 | - 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
952 | + $post_settings = array( |
|
953 | + 'post_type', 'post_category', 'post_content', |
|
954 | + 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
955 | 955 | 'post_status', 'post_custom_fields', 'post_password', |
956 | - ); |
|
956 | + ); |
|
957 | 957 | |
958 | - foreach ( $post_settings as $post_setting ) { |
|
958 | + foreach ( $post_settings as $post_setting ) { |
|
959 | 959 | if ( isset( $form_options[ $post_setting ] ) ) { |
960 | 960 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
961 | - } |
|
962 | - unset($post_setting); |
|
963 | - } |
|
961 | + } |
|
962 | + unset($post_setting); |
|
963 | + } |
|
964 | 964 | |
965 | 965 | $new_action['event'] = array( 'create', 'update' ); |
966 | 966 | |
967 | - if ( $switch ) { |
|
967 | + if ( $switch ) { |
|
968 | 968 | // Fields with string or int saved |
969 | 969 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
970 | 970 | |
@@ -972,22 +972,22 @@ discard block |
||
972 | 972 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
973 | 973 | |
974 | 974 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
975 | - } |
|
976 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
975 | + } |
|
976 | + $new_action['post_content'] = json_encode($new_action['post_content']); |
|
977 | 977 | |
978 | - $exists = get_posts( array( |
|
979 | - 'name' => $new_action['post_name'], |
|
980 | - 'post_type' => $new_action['post_type'], |
|
981 | - 'post_status' => $new_action['post_status'], |
|
982 | - 'numberposts' => 1, |
|
983 | - ) ); |
|
978 | + $exists = get_posts( array( |
|
979 | + 'name' => $new_action['post_name'], |
|
980 | + 'post_type' => $new_action['post_type'], |
|
981 | + 'post_status' => $new_action['post_status'], |
|
982 | + 'numberposts' => 1, |
|
983 | + ) ); |
|
984 | 984 | |
985 | - if ( ! $exists ) { |
|
985 | + if ( ! $exists ) { |
|
986 | 986 | // this isn't an email, but we need to use a class that will always be included |
987 | 987 | FrmAppHelper::save_json_post( $new_action ); |
988 | - $imported['imported']['actions']++; |
|
989 | - } |
|
990 | - } |
|
988 | + $imported['imported']['actions']++; |
|
989 | + } |
|
990 | + } |
|
991 | 991 | |
992 | 992 | /** |
993 | 993 | * Switch old field IDs for new field IDs in emails and post |
@@ -1000,88 +1000,88 @@ discard block |
||
1000 | 1000 | * @return string $post_content - new field IDs |
1001 | 1001 | */ |
1002 | 1002 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
1003 | - global $frm_duplicate_ids; |
|
1003 | + global $frm_duplicate_ids; |
|
1004 | 1004 | |
1005 | - // If there aren't IDs that were switched, end now |
|
1006 | - if ( ! $frm_duplicate_ids ) { |
|
1007 | - return; |
|
1008 | - } |
|
1005 | + // If there aren't IDs that were switched, end now |
|
1006 | + if ( ! $frm_duplicate_ids ) { |
|
1007 | + return; |
|
1008 | + } |
|
1009 | 1009 | |
1010 | - // Get old IDs |
|
1011 | - $old = array_keys( $frm_duplicate_ids ); |
|
1010 | + // Get old IDs |
|
1011 | + $old = array_keys( $frm_duplicate_ids ); |
|
1012 | 1012 | |
1013 | - // Get new IDs |
|
1014 | - $new = array_values( $frm_duplicate_ids ); |
|
1013 | + // Get new IDs |
|
1014 | + $new = array_values( $frm_duplicate_ids ); |
|
1015 | 1015 | |
1016 | - // Do a str_replace with each item to set the new IDs |
|
1017 | - foreach ( $post_content as $key => $setting ) { |
|
1018 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
1019 | - // Replace old IDs with new IDs |
|
1016 | + // Do a str_replace with each item to set the new IDs |
|
1017 | + foreach ( $post_content as $key => $setting ) { |
|
1018 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
1019 | + // Replace old IDs with new IDs |
|
1020 | 1020 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
1021 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
1022 | - foreach ( $setting as $k => $val ) { |
|
1023 | - // Replace old IDs with new IDs |
|
1021 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
1022 | + foreach ( $setting as $k => $val ) { |
|
1023 | + // Replace old IDs with new IDs |
|
1024 | 1024 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
1025 | - } |
|
1026 | - } |
|
1027 | - unset( $key, $setting ); |
|
1028 | - } |
|
1029 | - return $post_content; |
|
1030 | - } |
|
1031 | - |
|
1032 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
1033 | - // No old notifications or autoresponders to carry over |
|
1025 | + } |
|
1026 | + } |
|
1027 | + unset( $key, $setting ); |
|
1028 | + } |
|
1029 | + return $post_content; |
|
1030 | + } |
|
1031 | + |
|
1032 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
1033 | + // No old notifications or autoresponders to carry over |
|
1034 | 1034 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
1035 | - return; |
|
1036 | - } |
|
1035 | + return; |
|
1036 | + } |
|
1037 | 1037 | |
1038 | - // Initialize notifications array |
|
1039 | - $notifications = array(); |
|
1038 | + // Initialize notifications array |
|
1039 | + $notifications = array(); |
|
1040 | 1040 | |
1041 | - // Migrate regular notifications |
|
1042 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
1041 | + // Migrate regular notifications |
|
1042 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
1043 | 1043 | |
1044 | - // Migrate autoresponders |
|
1045 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
1044 | + // Migrate autoresponders |
|
1045 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
1046 | 1046 | |
1047 | - if ( empty( $notifications ) ) { |
|
1048 | - return; |
|
1049 | - } |
|
1047 | + if ( empty( $notifications ) ) { |
|
1048 | + return; |
|
1049 | + } |
|
1050 | 1050 | |
1051 | - foreach ( $notifications as $new_notification ) { |
|
1052 | - $new_notification['post_type'] = $post_type; |
|
1053 | - $new_notification['post_excerpt'] = 'email'; |
|
1051 | + foreach ( $notifications as $new_notification ) { |
|
1052 | + $new_notification['post_type'] = $post_type; |
|
1053 | + $new_notification['post_excerpt'] = 'email'; |
|
1054 | 1054 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
1055 | - $new_notification['menu_order'] = $form_id; |
|
1056 | - $new_notification['post_status'] = 'publish'; |
|
1055 | + $new_notification['menu_order'] = $form_id; |
|
1056 | + $new_notification['post_status'] = 'publish'; |
|
1057 | 1057 | |
1058 | - // Switch field IDs and keys, if needed |
|
1059 | - if ( $switch ) { |
|
1058 | + // Switch field IDs and keys, if needed |
|
1059 | + if ( $switch ) { |
|
1060 | 1060 | |
1061 | 1061 | // Switch field IDs in email conditional logic |
1062 | 1062 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
1063 | 1063 | |
1064 | 1064 | // Switch all other field IDs in email |
1065 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
1066 | - } |
|
1067 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1068 | - |
|
1069 | - $exists = get_posts( array( |
|
1070 | - 'name' => $new_notification['post_name'], |
|
1071 | - 'post_type' => $new_notification['post_type'], |
|
1072 | - 'post_status' => $new_notification['post_status'], |
|
1073 | - 'numberposts' => 1, |
|
1074 | - ) ); |
|
1075 | - |
|
1076 | - if ( empty($exists) ) { |
|
1065 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
1066 | + } |
|
1067 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1068 | + |
|
1069 | + $exists = get_posts( array( |
|
1070 | + 'name' => $new_notification['post_name'], |
|
1071 | + 'post_type' => $new_notification['post_type'], |
|
1072 | + 'post_status' => $new_notification['post_status'], |
|
1073 | + 'numberposts' => 1, |
|
1074 | + ) ); |
|
1075 | + |
|
1076 | + if ( empty($exists) ) { |
|
1077 | 1077 | FrmAppHelper::save_json_post( $new_notification ); |
1078 | - $imported['imported']['actions']++; |
|
1079 | - } |
|
1080 | - unset($new_notification); |
|
1081 | - } |
|
1078 | + $imported['imported']['actions']++; |
|
1079 | + } |
|
1080 | + unset($new_notification); |
|
1081 | + } |
|
1082 | 1082 | |
1083 | 1083 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
1084 | - } |
|
1084 | + } |
|
1085 | 1085 | |
1086 | 1086 | /** |
1087 | 1087 | * Remove deprecated notification settings after migration |
@@ -1101,130 +1101,130 @@ discard block |
||
1101 | 1101 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
1105 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
1106 | - // add old settings into notification array |
|
1104 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
1105 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
1106 | + // add old settings into notification array |
|
1107 | 1107 | $form_options['notification'] = array( 0 => $form_options ); |
1108 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
1109 | - // make sure it's in the correct format |
|
1108 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
1109 | + // make sure it's in the correct format |
|
1110 | 1110 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
1111 | - } |
|
1111 | + } |
|
1112 | 1112 | |
1113 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1114 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
1113 | + if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1114 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
1115 | 1115 | |
1116 | - $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
1116 | + $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
1117 | 1117 | |
1118 | - // Format the email data |
|
1119 | - self::format_email_data( $atts, $notification ); |
|
1118 | + // Format the email data |
|
1119 | + self::format_email_data( $atts, $notification ); |
|
1120 | 1120 | |
1121 | 1121 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
1122 | 1122 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - // Setup the new notification |
|
1126 | - $new_notification = array(); |
|
1127 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
1125 | + // Setup the new notification |
|
1126 | + $new_notification = array(); |
|
1127 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
1128 | 1128 | |
1129 | - $notifications[] = $new_notification; |
|
1130 | - } |
|
1131 | - } |
|
1132 | - } |
|
1129 | + $notifications[] = $new_notification; |
|
1130 | + } |
|
1131 | + } |
|
1132 | + } |
|
1133 | 1133 | |
1134 | - private static function format_email_data( &$atts, $notification ) { |
|
1135 | - // Format email_to |
|
1136 | - self::format_email_to_data( $atts, $notification ); |
|
1134 | + private static function format_email_data( &$atts, $notification ) { |
|
1135 | + // Format email_to |
|
1136 | + self::format_email_to_data( $atts, $notification ); |
|
1137 | 1137 | |
1138 | - // Format the reply to email and name |
|
1139 | - $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
1140 | - foreach ( $reply_fields as $f => $val ) { |
|
1138 | + // Format the reply to email and name |
|
1139 | + $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
1140 | + foreach ( $reply_fields as $f => $val ) { |
|
1141 | 1141 | if ( isset( $notification[ $f ] ) ) { |
1142 | 1142 | $atts[ $f ] = $notification[ $f ]; |
1143 | 1143 | if ( 'custom' == $notification[ $f ] ) { |
1144 | 1144 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
1145 | 1145 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
1146 | 1146 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
1147 | - } |
|
1148 | - } |
|
1149 | - unset( $f, $val ); |
|
1150 | - } |
|
1147 | + } |
|
1148 | + } |
|
1149 | + unset( $f, $val ); |
|
1150 | + } |
|
1151 | 1151 | |
1152 | - // Format event |
|
1152 | + // Format event |
|
1153 | 1153 | $atts['event'] = array( 'create' ); |
1154 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
1155 | - $atts['event'][] = 'update'; |
|
1156 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1154 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
1155 | + $atts['event'][] = 'update'; |
|
1156 | + } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1157 | 1157 | $atts['event'] = array( 'update' ); |
1158 | - } |
|
1159 | - } |
|
1158 | + } |
|
1159 | + } |
|
1160 | 1160 | |
1161 | - private static function format_email_to_data( &$atts, $notification ) { |
|
1162 | - if ( isset( $notification['email_to'] ) ) { |
|
1161 | + private static function format_email_to_data( &$atts, $notification ) { |
|
1162 | + if ( isset( $notification['email_to'] ) ) { |
|
1163 | 1163 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
1164 | - } else { |
|
1165 | - $atts['email_to'] = array(); |
|
1166 | - } |
|
1164 | + } else { |
|
1165 | + $atts['email_to'] = array(); |
|
1166 | + } |
|
1167 | 1167 | |
1168 | - if ( isset( $notification['also_email_to'] ) ) { |
|
1169 | - $email_fields = (array) $notification['also_email_to']; |
|
1170 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
1171 | - unset( $email_fields ); |
|
1172 | - } |
|
1168 | + if ( isset( $notification['also_email_to'] ) ) { |
|
1169 | + $email_fields = (array) $notification['also_email_to']; |
|
1170 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
1171 | + unset( $email_fields ); |
|
1172 | + } |
|
1173 | 1173 | |
1174 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
1174 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
1175 | 1175 | |
1176 | - if ( is_numeric( $email_field ) ) { |
|
1176 | + if ( is_numeric( $email_field ) ) { |
|
1177 | 1177 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
1178 | - } |
|
1178 | + } |
|
1179 | 1179 | |
1180 | - if ( strpos( $email_field, '|') ) { |
|
1181 | - $email_opt = explode( '|', $email_field ); |
|
1182 | - if ( isset( $email_opt[0] ) ) { |
|
1180 | + if ( strpos( $email_field, '|') ) { |
|
1181 | + $email_opt = explode( '|', $email_field ); |
|
1182 | + if ( isset( $email_opt[0] ) ) { |
|
1183 | 1183 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
1184 | - } |
|
1185 | - unset( $email_opt ); |
|
1186 | - } |
|
1187 | - } |
|
1188 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1189 | - } |
|
1190 | - |
|
1191 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
1192 | - // Set up new notification |
|
1193 | - $new_notification = array( |
|
1194 | - 'post_content' => array( |
|
1195 | - 'email_to' => $atts['email_to'], |
|
1196 | - 'event' => $atts['event'], |
|
1197 | - ), |
|
1184 | + } |
|
1185 | + unset( $email_opt ); |
|
1186 | + } |
|
1187 | + } |
|
1188 | + $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1189 | + } |
|
1190 | + |
|
1191 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
1192 | + // Set up new notification |
|
1193 | + $new_notification = array( |
|
1194 | + 'post_content' => array( |
|
1195 | + 'email_to' => $atts['email_to'], |
|
1196 | + 'event' => $atts['event'], |
|
1197 | + ), |
|
1198 | 1198 | 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
1199 | - ); |
|
1199 | + ); |
|
1200 | 1200 | |
1201 | - // Add more fields to the new notification |
|
1202 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
1203 | - foreach ( $add_fields as $add_field ) { |
|
1201 | + // Add more fields to the new notification |
|
1202 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
1203 | + foreach ( $add_fields as $add_field ) { |
|
1204 | 1204 | if ( isset( $notification[ $add_field ] ) ) { |
1205 | 1205 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
1206 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
1206 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
1207 | 1207 | $new_notification['post_content'][ $add_field ] = 0; |
1208 | - } else { |
|
1208 | + } else { |
|
1209 | 1209 | $new_notification['post_content'][ $add_field ] = ''; |
1210 | - } |
|
1211 | - unset( $add_field ); |
|
1212 | - } |
|
1210 | + } |
|
1211 | + unset( $add_field ); |
|
1212 | + } |
|
1213 | 1213 | |
1214 | 1214 | // Set reply to |
1215 | 1215 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
1216 | 1216 | |
1217 | - // Set from |
|
1217 | + // Set from |
|
1218 | 1218 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
1219 | 1219 | $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
1220 | - } |
|
1221 | - } |
|
1220 | + } |
|
1221 | + } |
|
1222 | 1222 | |
1223 | 1223 | /** |
1224 | - * Switch field IDs in pre-2.0 email conditional logic |
|
1225 | - * |
|
1226 | - * @param $post_content array, pass by reference |
|
1227 | - */ |
|
1224 | + * Switch field IDs in pre-2.0 email conditional logic |
|
1225 | + * |
|
1226 | + * @param $post_content array, pass by reference |
|
1227 | + */ |
|
1228 | 1228 | private static function switch_email_contition_field_ids( &$post_content ) { |
1229 | 1229 | // Switch field IDs in conditional logic |
1230 | 1230 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1237,36 +1237,36 @@ discard block |
||
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
1240 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
1241 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1242 | - // migrate autoresponder |
|
1243 | - |
|
1244 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1245 | - if ( strpos($email_field, '|') ) { |
|
1246 | - // data from entries field |
|
1247 | - $email_field = explode('|', $email_field); |
|
1248 | - if ( isset($email_field[1]) ) { |
|
1249 | - $email_field = $email_field[1]; |
|
1250 | - } |
|
1251 | - } |
|
1252 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1240 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
1241 | + if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1242 | + // migrate autoresponder |
|
1243 | + |
|
1244 | + $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1245 | + if ( strpos($email_field, '|') ) { |
|
1246 | + // data from entries field |
|
1247 | + $email_field = explode('|', $email_field); |
|
1248 | + if ( isset($email_field[1]) ) { |
|
1249 | + $email_field = $email_field[1]; |
|
1250 | + } |
|
1251 | + } |
|
1252 | + if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1253 | 1253 | $email_field = '[' . $email_field . ']'; |
1254 | - } |
|
1255 | - |
|
1256 | - $notification = $form_options; |
|
1257 | - $new_notification2 = array( |
|
1258 | - 'post_content' => array( |
|
1259 | - 'email_message' => $notification['ar_email_message'], |
|
1260 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1261 | - 'email_to' => $email_field, |
|
1262 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1263 | - 'inc_user_info' => 0, |
|
1264 | - ), |
|
1254 | + } |
|
1255 | + |
|
1256 | + $notification = $form_options; |
|
1257 | + $new_notification2 = array( |
|
1258 | + 'post_content' => array( |
|
1259 | + 'email_message' => $notification['ar_email_message'], |
|
1260 | + 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1261 | + 'email_to' => $email_field, |
|
1262 | + 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1263 | + 'inc_user_info' => 0, |
|
1264 | + ), |
|
1265 | 1265 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
1266 | - ); |
|
1266 | + ); |
|
1267 | 1267 | |
1268 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1269 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1268 | + $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1269 | + $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1270 | 1270 | |
1271 | 1271 | if ( ! empty( $reply_to ) ) { |
1272 | 1272 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -1276,9 +1276,9 @@ discard block |
||
1276 | 1276 | $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
1277 | 1277 | } |
1278 | 1278 | |
1279 | - $notifications[] = $new_notification2; |
|
1280 | - unset( $new_notification2 ); |
|
1281 | - } |
|
1282 | - } |
|
1279 | + $notifications[] = $new_notification2; |
|
1280 | + unset( $new_notification2 ); |
|
1281 | + } |
|
1282 | + } |
|
1283 | 1283 | } |
1284 | 1284 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | 'terms' => array(), |
37 | 37 | ); |
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset( $defaults ); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
42 | + define( 'WP_IMPORTING', true ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
55 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
57 | 57 | } |
58 | 58 | |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | 69 | // grab cats, tags, and terms, or forms or posts |
70 | - if ( isset($xml->{$item_type} ) ) { |
|
70 | + if ( isset( $xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | 79 | return $return; |
80 | 80 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | 'slug' => (string) $t->term_slug, |
92 | 92 | 'description' => (string) $t->term_description, |
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | - )); |
|
94 | + ) ); |
|
95 | 95 | |
96 | 96 | if ( $term && is_array( $term ) ) { |
97 | - $imported['imported']['terms']++; |
|
98 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
97 | + $imported['imported']['terms'] ++; |
|
98 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | unset( $term, $t ); |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | } else { |
145 | 145 | $form_id = FrmForm::create( $form ); |
146 | 146 | if ( $form_id ) { |
147 | - $imported['imported']['forms']++; |
|
147 | + $imported['imported']['forms'] ++; |
|
148 | 148 | // Keep track of whether this specific form was updated or not |
149 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
149 | + $imported['form_status'][$form_id] = 'imported'; |
|
150 | 150 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
151 | 151 | } |
152 | 152 | } |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | // Update field ids/keys to new ones |
159 | 159 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
160 | 160 | |
161 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
161 | + $imported['forms'][(int) $item->id] = $form_id; |
|
162 | 162 | |
163 | 163 | // Send pre 2.0 form options through function that creates actions |
164 | 164 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
165 | 165 | |
166 | 166 | do_action( 'frm_after_import_form', $form_id, $form ); |
167 | 167 | |
168 | - unset($form, $item); |
|
168 | + unset( $form, $item ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | private static function update_form( $this_form, $form, &$imported ) { |
208 | 208 | $form_id = $this_form->id; |
209 | 209 | FrmForm::update( $form_id, $form ); |
210 | - $imported['updated']['forms']++; |
|
210 | + $imported['updated']['forms'] ++; |
|
211 | 211 | // Keep track of whether this specific form was updated or not |
212 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
212 | + $imported['form_status'][$form_id] = 'updated'; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | private static function get_form_fields( $form_id ) { |
216 | 216 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
217 | 217 | $old_fields = array(); |
218 | 218 | foreach ( $form_fields as $f ) { |
219 | - $old_fields[ $f->id ] = $f; |
|
220 | - $old_fields[ $f->field_key ] = $f->id; |
|
221 | - unset($f); |
|
219 | + $old_fields[$f->id] = $f; |
|
220 | + $old_fields[$f->field_key] = $f->id; |
|
221 | + unset( $f ); |
|
222 | 222 | } |
223 | 223 | $form_fields = $old_fields; |
224 | 224 | return $form_fields; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $regular_forms = array(); |
250 | 250 | |
251 | 251 | foreach ( $forms as $form ) { |
252 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
252 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
253 | 253 | |
254 | 254 | if ( $parent_form_id ) { |
255 | 255 | $child_forms[] = $form; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
273 | 273 | if ( $parent_form_id ) { |
274 | - $child_forms[ $form_id ] = $parent_form_id; |
|
274 | + $child_forms[$form_id] = $parent_form_id; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
287 | 287 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
288 | 288 | |
289 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
289 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
290 | 290 | // Update all children with this old parent_form_id |
291 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
291 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
292 | 292 | |
293 | 293 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
294 | 294 | } |
@@ -307,15 +307,15 @@ discard block |
||
307 | 307 | foreach ( $xml_fields as $field ) { |
308 | 308 | $f = self::fill_field( $field, $form_id ); |
309 | 309 | |
310 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
310 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
311 | 311 | 'text', 'email', 'url', 'textarea', |
312 | - 'number','phone', 'date', |
|
312 | + 'number', 'phone', 'date', |
|
313 | 313 | 'hidden', 'password', 'tag', 'image', |
314 | - )) ) { |
|
315 | - if ( count($f['default_value']) === 1 ) { |
|
314 | + ) ) ) { |
|
315 | + if ( count( $f['default_value'] ) === 1 ) { |
|
316 | 316 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
317 | 317 | } else { |
318 | - $f['default_value'] = reset($f['default_value']); |
|
318 | + $f['default_value'] = reset( $f['default_value'] ); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,27 +323,27 @@ discard block |
||
323 | 323 | self::maybe_update_form_select( $f, $imported ); |
324 | 324 | self::maybe_update_get_values_form_setting( $imported, $f ); |
325 | 325 | |
326 | - if ( ! empty($this_form) ) { |
|
326 | + if ( ! empty( $this_form ) ) { |
|
327 | 327 | // check for field to edit by field id |
328 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
328 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
329 | 329 | FrmField::update( $f['id'], $f ); |
330 | - $imported['updated']['fields']++; |
|
330 | + $imported['updated']['fields'] ++; |
|
331 | 331 | |
332 | - unset( $form_fields[ $f['id'] ] ); |
|
332 | + unset( $form_fields[$f['id']] ); |
|
333 | 333 | |
334 | 334 | //unset old field key |
335 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
336 | - unset( $form_fields[ $f['field_key'] ] ); |
|
335 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
336 | + unset( $form_fields[$f['field_key']] ); |
|
337 | 337 | } |
338 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
338 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
339 | 339 | // check for field to edit by field key |
340 | - unset($f['id']); |
|
340 | + unset( $f['id'] ); |
|
341 | 341 | |
342 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
343 | - $imported['updated']['fields']++; |
|
342 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
343 | + $imported['updated']['fields'] ++; |
|
344 | 344 | |
345 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
346 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
345 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
346 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
347 | 347 | } else { |
348 | 348 | // if no matching field id or key in this form, create the field |
349 | 349 | self::create_imported_field( $f, $imported ); |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | 'name' => (string) $field->name, |
363 | 363 | 'description' => (string) $field->description, |
364 | 364 | 'type' => (string) $field->type, |
365 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
365 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
366 | 366 | 'field_order' => (int) $field->field_order, |
367 | 367 | 'form_id' => (int) $form_id, |
368 | 368 | 'required' => (int) $field->required, |
369 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
369 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
370 | 370 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
371 | 371 | ); |
372 | 372 | } |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
411 | 411 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
412 | 412 | $form_select = (int) $f['field_options']['form_select']; |
413 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
414 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
413 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
414 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | } |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | |
432 | 432 | if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) { |
433 | 433 | $old_form = $f['field_options']['get_values_form']; |
434 | - if ( isset( $imported['forms'][ $old_form ] ) ) { |
|
435 | - $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ]; |
|
434 | + if ( isset( $imported['forms'][$old_form] ) ) { |
|
435 | + $f['field_options']['get_values_form'] = $imported['forms'][$old_form]; |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | private static function create_imported_field( $f, &$imported ) { |
448 | 448 | $new_id = FrmField::create( $f ); |
449 | 449 | if ( $new_id != false ) { |
450 | - $imported['imported']['fields']++; |
|
450 | + $imported['imported']['fields'] ++; |
|
451 | 451 | do_action( 'frm_after_field_is_imported', $f, $new_id ); |
452 | 452 | } |
453 | 453 | } |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | ); |
547 | 547 | |
548 | 548 | $old_id = $post['post_id']; |
549 | - self::populate_post($post, $item, $imported); |
|
549 | + self::populate_post( $post, $item, $imported ); |
|
550 | 550 | |
551 | - unset($item); |
|
551 | + unset( $item ); |
|
552 | 552 | |
553 | 553 | $post_id = false; |
554 | 554 | if ( $post['post_type'] == $form_action_type ) { |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | if ( $action_control && is_object( $action_control ) ) { |
557 | 557 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
558 | 558 | } |
559 | - unset($action_control); |
|
559 | + unset( $action_control ); |
|
560 | 560 | } else if ( $post['post_type'] == 'frm_styles' ) { |
561 | 561 | // Properly encode post content before inserting the post |
562 | 562 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -571,24 +571,24 @@ discard block |
||
571 | 571 | $post_id = wp_insert_post( $post ); |
572 | 572 | } |
573 | 573 | |
574 | - if ( ! is_numeric($post_id) ) { |
|
574 | + if ( ! is_numeric( $post_id ) ) { |
|
575 | 575 | continue; |
576 | 576 | } |
577 | 577 | |
578 | - self::update_postmeta($post, $post_id); |
|
578 | + self::update_postmeta( $post, $post_id ); |
|
579 | 579 | |
580 | 580 | $this_type = 'posts'; |
581 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
582 | - $this_type = $post_types[ $post['post_type'] ]; |
|
581 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
582 | + $this_type = $post_types[$post['post_type']]; |
|
583 | 583 | } |
584 | 584 | |
585 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
586 | - $imported['updated'][ $this_type ]++; |
|
585 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
586 | + $imported['updated'][$this_type] ++; |
|
587 | 587 | } else { |
588 | - $imported['imported'][ $this_type ]++; |
|
588 | + $imported['imported'][$this_type] ++; |
|
589 | 589 | } |
590 | 590 | |
591 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
591 | + $imported['posts'][(int) $old_id] = $post_id; |
|
592 | 592 | |
593 | 593 | do_action( 'frm_after_import_view', $post_id, $post ); |
594 | 594 | |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | private static function populate_post( &$post, $item, $imported ) { |
604 | - if ( isset($item->attachment_url) ) { |
|
604 | + if ( isset( $item->attachment_url ) ) { |
|
605 | 605 | $post['attachment_url'] = (string) $item->attachment_url; |
606 | 606 | } |
607 | 607 | |
608 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
608 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
609 | 609 | // update to new form id |
610 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
610 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | // Don't allow default styles to take over a site's default style |
@@ -616,13 +616,13 @@ discard block |
||
616 | 616 | } |
617 | 617 | |
618 | 618 | foreach ( $item->postmeta as $meta ) { |
619 | - self::populate_postmeta($post, $meta, $imported); |
|
620 | - unset($meta); |
|
619 | + self::populate_postmeta( $post, $meta, $imported ); |
|
620 | + unset( $meta ); |
|
621 | 621 | } |
622 | 622 | |
623 | - self::populate_taxonomies($post, $item); |
|
623 | + self::populate_taxonomies( $post, $item ); |
|
624 | 624 | |
625 | - self::maybe_editing_post($post); |
|
625 | + self::maybe_editing_post( $post ); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -634,27 +634,27 @@ discard block |
||
634 | 634 | ); |
635 | 635 | |
636 | 636 | //switch old form and field ids to new ones |
637 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
638 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
637 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
638 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
639 | 639 | } else { |
640 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
640 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
641 | 641 | |
642 | - if ( ! empty($frm_duplicate_ids) ) { |
|
642 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
643 | 643 | |
644 | 644 | if ( $m['key'] == 'frm_dyncontent' ) { |
645 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
645 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
646 | 646 | } else if ( $m['key'] == 'frm_options' ) { |
647 | 647 | |
648 | 648 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
649 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
650 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
649 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
650 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
654 | 654 | $check_dup_array = array(); |
655 | 655 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
656 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
657 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
656 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
657 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
658 | 658 | } else if ( is_array( $m['value']['order_by'] ) ) { |
659 | 659 | $check_dup_array[] = 'order_by'; |
660 | 660 | } |
@@ -665,22 +665,22 @@ discard block |
||
665 | 665 | } |
666 | 666 | |
667 | 667 | foreach ( $check_dup_array as $check_k ) { |
668 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
669 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
670 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
668 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
669 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
670 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
671 | 671 | } |
672 | - unset($mk, $mv); |
|
672 | + unset( $mk, $mv ); |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | } |
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | - if ( ! is_array($m['value']) ) { |
|
680 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
679 | + if ( ! is_array( $m['value'] ) ) { |
|
680 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
681 | 681 | } |
682 | 682 | |
683 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
683 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -696,23 +696,23 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | $taxonomy = (string) $att['domain']; |
699 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
699 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
700 | 700 | $name = (string) $att['nicename']; |
701 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
701 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
702 | 702 | if ( $h_term ) { |
703 | 703 | $name = $h_term->term_id; |
704 | 704 | } |
705 | - unset($h_term); |
|
705 | + unset( $h_term ); |
|
706 | 706 | } else { |
707 | 707 | $name = (string) $c; |
708 | 708 | } |
709 | 709 | |
710 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
711 | - $post['tax_input'][ $taxonomy ] = array(); |
|
710 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
711 | + $post['tax_input'][$taxonomy] = array(); |
|
712 | 712 | } |
713 | 713 | |
714 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
715 | - unset($name); |
|
714 | + $post['tax_input'][$taxonomy][] = $name; |
|
715 | + unset( $name ); |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
@@ -729,30 +729,30 @@ discard block |
||
729 | 729 | |
730 | 730 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
731 | 731 | $match_by['include'] = $post['post_id']; |
732 | - unset($match_by['name']); |
|
732 | + unset( $match_by['name'] ); |
|
733 | 733 | } |
734 | 734 | |
735 | - $editing = get_posts($match_by); |
|
735 | + $editing = get_posts( $match_by ); |
|
736 | 736 | |
737 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
737 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
738 | 738 | // set the id of the post to edit |
739 | - $post['ID'] = current($editing)->ID; |
|
739 | + $post['ID'] = current( $editing )->ID; |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
743 | 743 | private static function update_postmeta( &$post, $post_id ) { |
744 | 744 | foreach ( $post['postmeta'] as $k => $v ) { |
745 | 745 | if ( '_edit_last' == $k ) { |
746 | - $v = FrmAppHelper::get_user_id_param($v); |
|
746 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
747 | 747 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
748 | 748 | //change the attachment ID |
749 | 749 | $field_obj = FrmFieldFactory::get_field_type( 'file' ); |
750 | 750 | $v = $field_obj->get_file_id( $v ); |
751 | 751 | } |
752 | 752 | |
753 | - update_post_meta($post_id, $k, $v); |
|
753 | + update_post_meta( $post_id, $k, $v ); |
|
754 | 754 | |
755 | - unset($k, $v); |
|
755 | + unset( $k, $v ); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | * @param string $message |
792 | 792 | */ |
793 | 793 | public static function parse_message( $result, &$message, &$errors ) { |
794 | - if ( is_wp_error($result) ) { |
|
794 | + if ( is_wp_error( $result ) ) { |
|
795 | 795 | $errors[] = $result->get_error_message(); |
796 | 796 | } else if ( ! $result ) { |
797 | 797 | return; |
798 | 798 | } |
799 | 799 | |
800 | - if ( ! is_array($result) ) { |
|
800 | + if ( ! is_array( $result ) ) { |
|
801 | 801 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
802 | 802 | return; |
803 | 803 | } |
@@ -809,20 +809,20 @@ discard block |
||
809 | 809 | |
810 | 810 | $message = '<ul>'; |
811 | 811 | foreach ( $result as $type => $results ) { |
812 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
812 | + if ( ! isset( $t_strings[$type] ) ) { |
|
813 | 813 | // only print imported and updated |
814 | 814 | continue; |
815 | 815 | } |
816 | 816 | |
817 | 817 | $s_message = array(); |
818 | 818 | foreach ( $results as $k => $m ) { |
819 | - self::item_count_message($m, $k, $s_message); |
|
820 | - unset($k, $m); |
|
819 | + self::item_count_message( $m, $k, $s_message ); |
|
820 | + unset( $k, $m ); |
|
821 | 821 | } |
822 | 822 | |
823 | - if ( ! empty($s_message) ) { |
|
824 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
825 | - $message .= implode(', ', $s_message); |
|
823 | + if ( ! empty( $s_message ) ) { |
|
824 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
825 | + $message .= implode( ', ', $s_message ); |
|
826 | 826 | $message .= '</li>'; |
827 | 827 | } |
828 | 828 | } |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
852 | 852 | ); |
853 | 853 | |
854 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
854 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | } |
884 | 884 | |
885 | 885 | public static function cdata( $str ) { |
886 | - $str = maybe_unserialize($str); |
|
887 | - if ( is_array($str) ) { |
|
888 | - $str = json_encode($str); |
|
886 | + $str = maybe_unserialize( $str ); |
|
887 | + if ( is_array( $str ) ) { |
|
888 | + $str = json_encode( $str ); |
|
889 | 889 | } else if ( seems_utf8( $str ) == false ) { |
890 | 890 | $str = utf8_encode( $str ); |
891 | 891 | } |
892 | 892 | |
893 | - if ( is_numeric($str) ) { |
|
893 | + if ( is_numeric( $str ) ) { |
|
894 | 894 | return $str; |
895 | 895 | } |
896 | 896 | |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | * @param string $post_type |
936 | 936 | */ |
937 | 937 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
938 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
938 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
939 | 939 | return; |
940 | 940 | } |
941 | 941 | |
@@ -956,10 +956,10 @@ discard block |
||
956 | 956 | ); |
957 | 957 | |
958 | 958 | foreach ( $post_settings as $post_setting ) { |
959 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
960 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
959 | + if ( isset( $form_options[$post_setting] ) ) { |
|
960 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
961 | 961 | } |
962 | - unset($post_setting); |
|
962 | + unset( $post_setting ); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | $new_action['event'] = array( 'create', 'update' ); |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | |
974 | 974 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
975 | 975 | } |
976 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
976 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
977 | 977 | |
978 | 978 | $exists = get_posts( array( |
979 | 979 | 'name' => $new_action['post_name'], |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | if ( ! $exists ) { |
986 | 986 | // this isn't an email, but we need to use a class that will always be included |
987 | 987 | FrmAppHelper::save_json_post( $new_action ); |
988 | - $imported['imported']['actions']++; |
|
988 | + $imported['imported']['actions'] ++; |
|
989 | 989 | } |
990 | 990 | } |
991 | 991 | |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | foreach ( $post_content as $key => $setting ) { |
1018 | 1018 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
1019 | 1019 | // Replace old IDs with new IDs |
1020 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
1020 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
1021 | 1021 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
1022 | 1022 | foreach ( $setting as $k => $val ) { |
1023 | 1023 | // Replace old IDs with new IDs |
1024 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
1024 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | unset( $key, $setting ); |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | foreach ( $notifications as $new_notification ) { |
1052 | 1052 | $new_notification['post_type'] = $post_type; |
1053 | 1053 | $new_notification['post_excerpt'] = 'email'; |
1054 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
1054 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
1055 | 1055 | $new_notification['menu_order'] = $form_id; |
1056 | 1056 | $new_notification['post_status'] = 'publish'; |
1057 | 1057 | |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | // Switch all other field IDs in email |
1065 | 1065 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
1066 | 1066 | } |
1067 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1067 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1068 | 1068 | |
1069 | 1069 | $exists = get_posts( array( |
1070 | 1070 | 'name' => $new_notification['post_name'], |
@@ -1073,11 +1073,11 @@ discard block |
||
1073 | 1073 | 'numberposts' => 1, |
1074 | 1074 | ) ); |
1075 | 1075 | |
1076 | - if ( empty($exists) ) { |
|
1076 | + if ( empty( $exists ) ) { |
|
1077 | 1077 | FrmAppHelper::save_json_post( $new_notification ); |
1078 | - $imported['imported']['actions']++; |
|
1078 | + $imported['imported']['actions'] ++; |
|
1079 | 1079 | } |
1080 | - unset($new_notification); |
|
1080 | + unset( $new_notification ); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
@@ -1094,8 +1094,8 @@ discard block |
||
1094 | 1094 | private static function remove_deprecated_notification_settings( $form_id, $form_options ) { |
1095 | 1095 | $delete_settings = array( 'notification', 'autoresponder', 'email_to' ); |
1096 | 1096 | foreach ( $delete_settings as $index ) { |
1097 | - if ( isset( $form_options[ $index ] ) ) { |
|
1098 | - unset( $form_options[ $index ] ); |
|
1097 | + if ( isset( $form_options[$index] ) ) { |
|
1098 | + unset( $form_options[$index] ); |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1113 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
1114 | 1114 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
1115 | 1115 | |
1116 | 1116 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -1138,12 +1138,12 @@ discard block |
||
1138 | 1138 | // Format the reply to email and name |
1139 | 1139 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
1140 | 1140 | foreach ( $reply_fields as $f => $val ) { |
1141 | - if ( isset( $notification[ $f ] ) ) { |
|
1142 | - $atts[ $f ] = $notification[ $f ]; |
|
1143 | - if ( 'custom' == $notification[ $f ] ) { |
|
1144 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
1145 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
1146 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
1141 | + if ( isset( $notification[$f] ) ) { |
|
1142 | + $atts[$f] = $notification[$f]; |
|
1143 | + if ( 'custom' == $notification[$f] ) { |
|
1144 | + $atts[$f] = $notification['cust_' . $f]; |
|
1145 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
1146 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
1147 | 1147 | } |
1148 | 1148 | } |
1149 | 1149 | unset( $f, $val ); |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | $atts['event'] = array( 'create' ); |
1154 | 1154 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
1155 | 1155 | $atts['event'][] = 'update'; |
1156 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1156 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
1157 | 1157 | $atts['event'] = array( 'update' ); |
1158 | 1158 | } |
1159 | 1159 | } |
@@ -1174,18 +1174,18 @@ discard block |
||
1174 | 1174 | foreach ( $atts['email_to'] as $key => $email_field ) { |
1175 | 1175 | |
1176 | 1176 | if ( is_numeric( $email_field ) ) { |
1177 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
1177 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | - if ( strpos( $email_field, '|') ) { |
|
1180 | + if ( strpos( $email_field, '|' ) ) { |
|
1181 | 1181 | $email_opt = explode( '|', $email_field ); |
1182 | 1182 | if ( isset( $email_opt[0] ) ) { |
1183 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1183 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1184 | 1184 | } |
1185 | 1185 | unset( $email_opt ); |
1186 | 1186 | } |
1187 | 1187 | } |
1188 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1188 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -1201,12 +1201,12 @@ discard block |
||
1201 | 1201 | // Add more fields to the new notification |
1202 | 1202 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
1203 | 1203 | foreach ( $add_fields as $add_field ) { |
1204 | - if ( isset( $notification[ $add_field ] ) ) { |
|
1205 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
1204 | + if ( isset( $notification[$add_field] ) ) { |
|
1205 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
1206 | 1206 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
1207 | - $new_notification['post_content'][ $add_field ] = 0; |
|
1207 | + $new_notification['post_content'][$add_field] = 0; |
|
1208 | 1208 | } else { |
1209 | - $new_notification['post_content'][ $add_field ] = ''; |
|
1209 | + $new_notification['post_content'][$add_field] = ''; |
|
1210 | 1210 | } |
1211 | 1211 | unset( $add_field ); |
1212 | 1212 | } |
@@ -1230,26 +1230,26 @@ discard block |
||
1230 | 1230 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
1231 | 1231 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
1232 | 1232 | if ( is_numeric( $email_key ) ) { |
1233 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1233 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1234 | 1234 | } |
1235 | - unset( $email_key, $val); |
|
1235 | + unset( $email_key, $val ); |
|
1236 | 1236 | } |
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
1241 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1241 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
1242 | 1242 | // migrate autoresponder |
1243 | 1243 | |
1244 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1245 | - if ( strpos($email_field, '|') ) { |
|
1244 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
1245 | + if ( strpos( $email_field, '|' ) ) { |
|
1246 | 1246 | // data from entries field |
1247 | - $email_field = explode('|', $email_field); |
|
1248 | - if ( isset($email_field[1]) ) { |
|
1247 | + $email_field = explode( '|', $email_field ); |
|
1248 | + if ( isset( $email_field[1] ) ) { |
|
1249 | 1249 | $email_field = $email_field[1]; |
1250 | 1250 | } |
1251 | 1251 | } |
1252 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1252 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
1253 | 1253 | $email_field = '[' . $email_field . ']'; |
1254 | 1254 | } |
1255 | 1255 | |
@@ -1257,16 +1257,16 @@ discard block |
||
1257 | 1257 | $new_notification2 = array( |
1258 | 1258 | 'post_content' => array( |
1259 | 1259 | 'email_message' => $notification['ar_email_message'], |
1260 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1260 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
1261 | 1261 | 'email_to' => $email_field, |
1262 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1262 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
1263 | 1263 | 'inc_user_info' => 0, |
1264 | 1264 | ), |
1265 | 1265 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
1266 | 1266 | ); |
1267 | 1267 | |
1268 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1269 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1268 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
1269 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
1270 | 1270 | |
1271 | 1271 | if ( ! empty( $reply_to ) ) { |
1272 | 1272 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -2,25 +2,25 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | - public static function load_field() { |
|
5 | + public static function load_field() { |
|
6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
8 | 8 | |
9 | - $fields = $_POST['field']; |
|
10 | - if ( empty( $fields ) ) { |
|
11 | - wp_die(); |
|
12 | - } |
|
9 | + $fields = $_POST['field']; |
|
10 | + if ( empty( $fields ) ) { |
|
11 | + wp_die(); |
|
12 | + } |
|
13 | 13 | |
14 | - $_GET['page'] = 'formidable'; |
|
15 | - $fields = stripslashes_deep( $fields ); |
|
14 | + $_GET['page'] = 'formidable'; |
|
15 | + $fields = stripslashes_deep( $fields ); |
|
16 | 16 | |
17 | 17 | $values = array( |
18 | 18 | 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
19 | 19 | 'doing_ajax' => true, |
20 | 20 | ); |
21 | - $field_html = array(); |
|
21 | + $field_html = array(); |
|
22 | 22 | |
23 | - foreach ( $fields as $field ) { |
|
23 | + foreach ( $fields as $field ) { |
|
24 | 24 | $field = htmlspecialchars_decode( nl2br( $field ) ); |
25 | 25 | $field = json_decode( $field ); |
26 | 26 | if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) { |
@@ -38,90 +38,90 @@ discard block |
||
38 | 38 | self::load_single_field( $field, $values ); |
39 | 39 | $field_html[ absint( $field->id ) ] = ob_get_contents(); |
40 | 40 | ob_end_clean(); |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - echo json_encode( $field_html ); |
|
43 | + echo json_encode( $field_html ); |
|
44 | 44 | |
45 | - wp_die(); |
|
46 | - } |
|
45 | + wp_die(); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Create a new field with ajax |
50 | 50 | */ |
51 | - public static function create() { |
|
51 | + public static function create() { |
|
52 | 52 | FrmAppHelper::permission_check('frm_edit_forms'); |
53 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
53 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
54 | 54 | |
55 | 55 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
56 | 56 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
57 | 57 | |
58 | 58 | $field = self::include_new_field( $field_type, $form_id ); |
59 | 59 | |
60 | - // this hook will allow for multiple fields to be added at once |
|
61 | - do_action('frm_after_field_created', $field, $form_id); |
|
60 | + // this hook will allow for multiple fields to be added at once |
|
61 | + do_action('frm_after_field_created', $field, $form_id); |
|
62 | 62 | |
63 | - wp_die(); |
|
64 | - } |
|
63 | + wp_die(); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Set up and create a new field |
|
68 | - * |
|
69 | - * @param string $field_type |
|
70 | - * @param integer $form_id |
|
71 | - * @return array|bool |
|
72 | - */ |
|
66 | + /** |
|
67 | + * Set up and create a new field |
|
68 | + * |
|
69 | + * @param string $field_type |
|
70 | + * @param integer $form_id |
|
71 | + * @return array|bool |
|
72 | + */ |
|
73 | 73 | public static function include_new_field( $field_type, $form_id ) { |
74 | - $values = array(); |
|
75 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
76 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
77 | - } |
|
74 | + $values = array(); |
|
75 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
76 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
80 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
80 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
81 | 81 | |
82 | - $field_id = FrmField::create( $field_values ); |
|
82 | + $field_id = FrmField::create( $field_values ); |
|
83 | 83 | |
84 | - if ( ! $field_id ) { |
|
85 | - return false; |
|
86 | - } |
|
84 | + if ( ! $field_id ) { |
|
85 | + return false; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $field = self::get_field_array_from_id( $field_id ); |
89 | 89 | self::load_single_field( $field, $values, $form_id ); |
90 | 90 | |
91 | - return $field; |
|
92 | - } |
|
91 | + return $field; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | public static function edit_name( $field = 'name', $id = '' ) { |
95 | 95 | FrmAppHelper::permission_check('frm_edit_forms'); |
96 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
96 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
97 | 97 | |
98 | - if ( empty($field) ) { |
|
99 | - $field = 'name'; |
|
100 | - } |
|
98 | + if ( empty($field) ) { |
|
99 | + $field = 'name'; |
|
100 | + } |
|
101 | 101 | |
102 | - if ( empty($id) ) { |
|
102 | + if ( empty($id) ) { |
|
103 | 103 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
104 | 104 | $id = str_replace( 'field_label_', '', $id ); |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
108 | 108 | $value = trim( $value ); |
109 | - if ( trim(strip_tags($value)) == '' ) { |
|
110 | - // set blank value if there is no content |
|
111 | - $value = ''; |
|
112 | - } |
|
109 | + if ( trim(strip_tags($value)) == '' ) { |
|
110 | + // set blank value if there is no content |
|
111 | + $value = ''; |
|
112 | + } |
|
113 | 113 | |
114 | 114 | FrmField::update( $id, array( $field => $value ) ); |
115 | 115 | |
116 | 116 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
117 | 117 | |
118 | 118 | echo stripslashes( wp_kses_post( $value ) ); |
119 | - wp_die(); |
|
120 | - } |
|
119 | + wp_die(); |
|
120 | + } |
|
121 | 121 | |
122 | - public static function update_ajax_option() { |
|
122 | + public static function update_ajax_option() { |
|
123 | 123 | FrmAppHelper::permission_check('frm_edit_forms'); |
124 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
124 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
125 | 125 | |
126 | 126 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
127 | 127 | if ( ! $field_id ) { |
@@ -136,24 +136,24 @@ discard block |
||
136 | 136 | unset($new_val); |
137 | 137 | } |
138 | 138 | |
139 | - FrmField::update( $field_id, array( |
|
140 | - 'field_options' => $field->field_options, |
|
139 | + FrmField::update( $field_id, array( |
|
140 | + 'field_options' => $field->field_options, |
|
141 | 141 | 'form_id' => $field->form_id, |
142 | - ) ); |
|
143 | - wp_die(); |
|
144 | - } |
|
142 | + ) ); |
|
143 | + wp_die(); |
|
144 | + } |
|
145 | 145 | |
146 | - public static function duplicate() { |
|
146 | + public static function duplicate() { |
|
147 | 147 | FrmAppHelper::permission_check('frm_edit_forms'); |
148 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
148 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
149 | 149 | |
150 | 150 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
151 | 151 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
152 | 152 | |
153 | 153 | $copy_field = FrmField::getOne( $field_id ); |
154 | - if ( ! $copy_field ) { |
|
155 | - wp_die(); |
|
156 | - } |
|
154 | + if ( ! $copy_field ) { |
|
155 | + wp_die(); |
|
156 | + } |
|
157 | 157 | |
158 | 158 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
159 | 159 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | self::load_single_field( $field_id, $values ); |
168 | 168 | } |
169 | 169 | |
170 | - wp_die(); |
|
171 | - } |
|
170 | + wp_die(); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Load a single field in the form builder along with all needed variables |
@@ -247,27 +247,27 @@ discard block |
||
247 | 247 | return apply_filters( 'frm_build_field_class', $li_classes, $field ); |
248 | 248 | } |
249 | 249 | |
250 | - public static function destroy() { |
|
250 | + public static function destroy() { |
|
251 | 251 | FrmAppHelper::permission_check('frm_edit_forms'); |
252 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
252 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
253 | 253 | |
254 | 254 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
255 | 255 | FrmField::destroy( $field_id ); |
256 | - wp_die(); |
|
257 | - } |
|
256 | + wp_die(); |
|
257 | + } |
|
258 | 258 | |
259 | - /* Field Options */ |
|
259 | + /* Field Options */ |
|
260 | 260 | |
261 | - //Add Single Option or Other Option |
|
262 | - public static function add_option() { |
|
261 | + //Add Single Option or Other Option |
|
262 | + public static function add_option() { |
|
263 | 263 | FrmAppHelper::permission_check('frm_edit_forms'); |
264 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
264 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
265 | 265 | |
266 | 266 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
267 | 267 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
268 | 268 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' ); |
269 | 269 | |
270 | - $field = FrmField::getOne($id); |
|
270 | + $field = FrmField::getOne($id); |
|
271 | 271 | |
272 | 272 | if ( 'other' == $opt_type ) { |
273 | 273 | $opt = __( 'Other', 'formidable' ); |
@@ -285,137 +285,137 @@ discard block |
||
285 | 285 | FrmFieldsHelper::show_single_option( $field ); |
286 | 286 | |
287 | 287 | wp_die(); |
288 | - } |
|
288 | + } |
|
289 | 289 | |
290 | - public static function edit_option() { |
|
290 | + public static function edit_option() { |
|
291 | 291 | _deprecated_function( __FUNCTION__, '2.3' ); |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | - public static function delete_option() { |
|
294 | + public static function delete_option() { |
|
295 | 295 | _deprecated_function( __FUNCTION__, '2.3' ); |
296 | - } |
|
296 | + } |
|
297 | 297 | |
298 | - public static function import_choices() { |
|
299 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
298 | + public static function import_choices() { |
|
299 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
300 | 300 | |
301 | 301 | $field_id = absint( $_REQUEST['field_id'] ); |
302 | 302 | |
303 | - global $current_screen, $hook_suffix; |
|
303 | + global $current_screen, $hook_suffix; |
|
304 | 304 | |
305 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
306 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
307 | - $hook_suffix = ''; |
|
308 | - set_current_screen(); |
|
309 | - } |
|
305 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
306 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
307 | + $hook_suffix = ''; |
|
308 | + set_current_screen(); |
|
309 | + } |
|
310 | 310 | |
311 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
312 | - register_admin_color_schemes(); |
|
313 | - } |
|
311 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
312 | + register_admin_color_schemes(); |
|
313 | + } |
|
314 | 314 | |
315 | 315 | $hook_suffix = ''; |
316 | 316 | $admin_body_class = ''; |
317 | 317 | |
318 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
319 | - $admin_body_class .= ' folded'; |
|
320 | - } |
|
318 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
319 | + $admin_body_class .= ' folded'; |
|
320 | + } |
|
321 | 321 | |
322 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
323 | - $admin_body_class .= ' admin-bar'; |
|
324 | - } |
|
322 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
323 | + $admin_body_class .= ' admin-bar'; |
|
324 | + } |
|
325 | 325 | |
326 | - if ( is_rtl() ) { |
|
327 | - $admin_body_class .= ' rtl'; |
|
328 | - } |
|
326 | + if ( is_rtl() ) { |
|
327 | + $admin_body_class .= ' rtl'; |
|
328 | + } |
|
329 | 329 | |
330 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
331 | - $prepop = array(); |
|
332 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
330 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
331 | + $prepop = array(); |
|
332 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
333 | 333 | |
334 | - $field = FrmField::getOne($field_id); |
|
334 | + $field = FrmField::getOne($field_id); |
|
335 | 335 | |
336 | - wp_enqueue_script( 'utils' ); |
|
336 | + wp_enqueue_script( 'utils' ); |
|
337 | 337 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
338 | - FrmAppHelper::load_admin_wide_js(); |
|
338 | + FrmAppHelper::load_admin_wide_js(); |
|
339 | 339 | |
340 | 340 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
341 | - wp_die(); |
|
342 | - } |
|
341 | + wp_die(); |
|
342 | + } |
|
343 | 343 | |
344 | - public static function import_options() { |
|
344 | + public static function import_options() { |
|
345 | 345 | FrmAppHelper::permission_check('frm_edit_forms'); |
346 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
346 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
347 | 347 | |
348 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
349 | - return; |
|
350 | - } |
|
348 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
349 | + return; |
|
350 | + } |
|
351 | 351 | |
352 | 352 | $field_id = absint( $_POST['field_id'] ); |
353 | - $field = FrmField::getOne($field_id); |
|
353 | + $field = FrmField::getOne($field_id); |
|
354 | 354 | |
355 | 355 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
356 | - return; |
|
357 | - } |
|
356 | + return; |
|
357 | + } |
|
358 | 358 | |
359 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
359 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
360 | 360 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
361 | 361 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
362 | 362 | $opts = array_map( 'trim', $opts ); |
363 | 363 | |
364 | - if ( $field['separate_value'] ) { |
|
365 | - foreach ( $opts as $opt_key => $opt ) { |
|
366 | - if ( strpos($opt, '|') !== false ) { |
|
367 | - $vals = explode('|', $opt); |
|
368 | - if ( $vals[0] != $vals[1] ) { |
|
369 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
370 | - } |
|
371 | - unset($vals); |
|
372 | - } |
|
373 | - unset($opt_key, $opt); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - //Keep other options after bulk update |
|
378 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
379 | - $other_array = array(); |
|
380 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
364 | + if ( $field['separate_value'] ) { |
|
365 | + foreach ( $opts as $opt_key => $opt ) { |
|
366 | + if ( strpos($opt, '|') !== false ) { |
|
367 | + $vals = explode('|', $opt); |
|
368 | + if ( $vals[0] != $vals[1] ) { |
|
369 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
370 | + } |
|
371 | + unset($vals); |
|
372 | + } |
|
373 | + unset($opt_key, $opt); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + //Keep other options after bulk update |
|
378 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
379 | + $other_array = array(); |
|
380 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
381 | 381 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
382 | 382 | $other_array[ $opt_key ] = $opt; |
383 | 383 | } |
384 | - unset($opt_key, $opt); |
|
385 | - } |
|
386 | - if ( ! empty($other_array) ) { |
|
387 | - $opts = array_merge( $opts, $other_array); |
|
388 | - } |
|
389 | - } |
|
384 | + unset($opt_key, $opt); |
|
385 | + } |
|
386 | + if ( ! empty($other_array) ) { |
|
387 | + $opts = array_merge( $opts, $other_array); |
|
388 | + } |
|
389 | + } |
|
390 | 390 | |
391 | - $field['options'] = $opts; |
|
391 | + $field['options'] = $opts; |
|
392 | 392 | |
393 | 393 | FrmFieldsHelper::show_single_option( $field ); |
394 | 394 | |
395 | - wp_die(); |
|
396 | - } |
|
395 | + wp_die(); |
|
396 | + } |
|
397 | 397 | |
398 | - public static function update_order() { |
|
398 | + public static function update_order() { |
|
399 | 399 | FrmAppHelper::permission_check('frm_edit_forms'); |
400 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
400 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
401 | 401 | |
402 | 402 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
403 | 403 | foreach ( (array) $fields as $position => $item ) { |
404 | 404 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
405 | 405 | } |
406 | - wp_die(); |
|
407 | - } |
|
406 | + wp_die(); |
|
407 | + } |
|
408 | 408 | |
409 | 409 | public static function change_type( $type ) { |
410 | - $type_switch = array( |
|
411 | - 'scale' => 'radio', |
|
412 | - '10radio' => 'radio', |
|
413 | - 'rte' => 'textarea', |
|
414 | - 'website' => 'url', |
|
415 | - ); |
|
416 | - if ( isset( $type_switch[ $type ] ) ) { |
|
417 | - $type = $type_switch[ $type ]; |
|
418 | - } |
|
410 | + $type_switch = array( |
|
411 | + 'scale' => 'radio', |
|
412 | + '10radio' => 'radio', |
|
413 | + 'rte' => 'textarea', |
|
414 | + 'website' => 'url', |
|
415 | + ); |
|
416 | + if ( isset( $type_switch[ $type ] ) ) { |
|
417 | + $type = $type_switch[ $type ]; |
|
418 | + } |
|
419 | 419 | |
420 | 420 | $pro_fields = FrmField::pro_field_selection(); |
421 | 421 | $types = array_keys( $pro_fields ); |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | $type = 'text'; |
424 | 424 | } |
425 | 425 | |
426 | - return $type; |
|
427 | - } |
|
426 | + return $type; |
|
427 | + } |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * @param array $settings |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | return apply_filters( 'frm_display_field_options', $settings ); |
442 | - } |
|
442 | + } |
|
443 | 443 | |
444 | 444 | /** |
445 | 445 | * Display the format option |
@@ -451,105 +451,105 @@ discard block |
||
451 | 451 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' ); |
452 | 452 | } |
453 | 453 | |
454 | - public static function input_html( $field, $echo = true ) { |
|
455 | - $class = array(); //$field['type']; |
|
456 | - self::add_input_classes($field, $class); |
|
454 | + public static function input_html( $field, $echo = true ) { |
|
455 | + $class = array(); //$field['type']; |
|
456 | + self::add_input_classes($field, $class); |
|
457 | 457 | |
458 | - $add_html = array(); |
|
459 | - self::add_html_size($field, $add_html); |
|
460 | - self::add_html_length($field, $add_html); |
|
461 | - self::add_html_placeholder($field, $add_html, $class); |
|
458 | + $add_html = array(); |
|
459 | + self::add_html_size($field, $add_html); |
|
460 | + self::add_html_length($field, $add_html); |
|
461 | + self::add_html_placeholder($field, $add_html, $class); |
|
462 | 462 | self::add_validation_messages( $field, $add_html ); |
463 | 463 | |
464 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
464 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
465 | 465 | |
466 | 466 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
467 | 467 | |
468 | - self::add_shortcodes_to_html($field, $add_html); |
|
468 | + self::add_shortcodes_to_html($field, $add_html); |
|
469 | 469 | self::add_pattern_attribute( $field, $add_html ); |
470 | 470 | |
471 | 471 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
472 | 472 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
473 | 473 | |
474 | - if ( $echo ) { |
|
475 | - echo $add_html; |
|
476 | - } |
|
474 | + if ( $echo ) { |
|
475 | + echo $add_html; |
|
476 | + } |
|
477 | 477 | |
478 | - return $add_html; |
|
479 | - } |
|
478 | + return $add_html; |
|
479 | + } |
|
480 | 480 | |
481 | 481 | private static function add_input_classes( $field, array &$class ) { |
482 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
483 | - $class[] = $field['input_class']; |
|
484 | - } |
|
482 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
483 | + $class[] = $field['input_class']; |
|
484 | + } |
|
485 | 485 | |
486 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
487 | - return; |
|
488 | - } |
|
486 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
487 | + return; |
|
488 | + } |
|
489 | 489 | |
490 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
491 | - $class[] = 'auto_width'; |
|
492 | - } |
|
493 | - } |
|
490 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
491 | + $class[] = 'auto_width'; |
|
492 | + } |
|
493 | + } |
|
494 | 494 | |
495 | 495 | private static function add_html_size( $field, array &$add_html ) { |
496 | 496 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
497 | - return; |
|
498 | - } |
|
497 | + return; |
|
498 | + } |
|
499 | 499 | |
500 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
501 | - return; |
|
502 | - } |
|
500 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
501 | + return; |
|
502 | + } |
|
503 | 503 | |
504 | - if ( is_numeric($field['size']) ) { |
|
505 | - $field['size'] .= 'px'; |
|
506 | - } |
|
504 | + if ( is_numeric($field['size']) ) { |
|
505 | + $field['size'] .= 'px'; |
|
506 | + } |
|
507 | 507 | |
508 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
509 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
508 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
509 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
510 | 510 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
511 | 511 | |
512 | - self::add_html_cols($field, $add_html); |
|
513 | - } |
|
512 | + self::add_html_cols($field, $add_html); |
|
513 | + } |
|
514 | 514 | |
515 | 515 | private static function add_html_cols( $field, array &$add_html ) { |
516 | 516 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
517 | - return; |
|
518 | - } |
|
517 | + return; |
|
518 | + } |
|
519 | 519 | |
520 | - // convert to cols for textareas |
|
521 | - $calc = array( |
|
522 | - '' => 9, |
|
523 | - 'px' => 9, |
|
524 | - 'rem' => 0.444, |
|
525 | - 'em' => 0.544, |
|
526 | - ); |
|
520 | + // convert to cols for textareas |
|
521 | + $calc = array( |
|
522 | + '' => 9, |
|
523 | + 'px' => 9, |
|
524 | + 'rem' => 0.444, |
|
525 | + 'em' => 0.544, |
|
526 | + ); |
|
527 | 527 | |
528 | - // include "col" for valid html |
|
529 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
528 | + // include "col" for valid html |
|
529 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
530 | 530 | |
531 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
532 | - return; |
|
533 | - } |
|
531 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
532 | + return; |
|
533 | + } |
|
534 | 534 | |
535 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
535 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
536 | 536 | |
537 | 537 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | private static function add_html_length( $field, array &$add_html ) { |
541 | - // check for max setting and if this field accepts maxlength |
|
541 | + // check for max setting and if this field accepts maxlength |
|
542 | 542 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
543 | - return; |
|
544 | - } |
|
543 | + return; |
|
544 | + } |
|
545 | 545 | |
546 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
547 | - // don't load on form builder page |
|
548 | - return; |
|
549 | - } |
|
546 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
547 | + // don't load on form builder page |
|
548 | + return; |
|
549 | + } |
|
550 | 550 | |
551 | 551 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
552 | - } |
|
552 | + } |
|
553 | 553 | |
554 | 554 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
555 | 555 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -653,27 +653,27 @@ discard block |
||
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
656 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
657 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
658 | - return; |
|
659 | - } |
|
656 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
657 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
658 | + return; |
|
659 | + } |
|
660 | 660 | |
661 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
662 | - if ( 'opt' === $k ) { |
|
663 | - continue; |
|
664 | - } |
|
661 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
662 | + if ( 'opt' === $k ) { |
|
663 | + continue; |
|
664 | + } |
|
665 | 665 | |
666 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
667 | - $add_html[] = $v; |
|
668 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
666 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
667 | + $add_html[] = $v; |
|
668 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
669 | 669 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
670 | - } else { |
|
670 | + } else { |
|
671 | 671 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
672 | - } |
|
672 | + } |
|
673 | 673 | |
674 | - unset($k, $v); |
|
675 | - } |
|
676 | - } |
|
674 | + unset($k, $v); |
|
675 | + } |
|
676 | + } |
|
677 | 677 | |
678 | 678 | /** |
679 | 679 | * Add pattern attribute |
@@ -692,22 +692,22 @@ discard block |
||
692 | 692 | } |
693 | 693 | } |
694 | 694 | |
695 | - public static function check_value( $opt, $opt_key, $field ) { |
|
696 | - if ( is_array( $opt ) ) { |
|
697 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
698 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
699 | - } else { |
|
700 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
701 | - } |
|
702 | - } |
|
703 | - return $opt; |
|
704 | - } |
|
695 | + public static function check_value( $opt, $opt_key, $field ) { |
|
696 | + if ( is_array( $opt ) ) { |
|
697 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
698 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
699 | + } else { |
|
700 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
701 | + } |
|
702 | + } |
|
703 | + return $opt; |
|
704 | + } |
|
705 | 705 | |
706 | 706 | public static function check_label( $opt ) { |
707 | - if ( is_array( $opt ) ) { |
|
708 | - $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
709 | - } |
|
707 | + if ( is_array( $opt ) ) { |
|
708 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
709 | + } |
|
710 | 710 | |
711 | - return $opt; |
|
712 | - } |
|
711 | + return $opt; |
|
712 | + } |
|
713 | 713 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | 5 | public static function load_field() { |
6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
8 | 8 | |
9 | 9 | $fields = $_POST['field']; |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | if ( ! isset( $field->value ) ) { |
32 | 32 | $field->value = ''; |
33 | 33 | } |
34 | - $field->field_options = json_decode( json_encode( $field->field_options), true ); |
|
34 | + $field->field_options = json_decode( json_encode( $field->field_options ), true ); |
|
35 | 35 | $field->options = json_decode( json_encode( $field->options ), true ); |
36 | 36 | |
37 | 37 | ob_start(); |
38 | 38 | self::load_single_field( $field, $values ); |
39 | - $field_html[ absint( $field->id ) ] = ob_get_contents(); |
|
39 | + $field_html[absint( $field->id )] = ob_get_contents(); |
|
40 | 40 | ob_end_clean(); |
41 | 41 | } |
42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * Create a new field with ajax |
50 | 50 | */ |
51 | 51 | public static function create() { |
52 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
52 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
53 | 53 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
54 | 54 | |
55 | 55 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $field = self::include_new_field( $field_type, $form_id ); |
59 | 59 | |
60 | 60 | // this hook will allow for multiple fields to be added at once |
61 | - do_action('frm_after_field_created', $field, $form_id); |
|
61 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
62 | 62 | |
63 | 63 | wp_die(); |
64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public static function include_new_field( $field_type, $form_id ) { |
74 | 74 | $values = array(); |
75 | 75 | if ( FrmAppHelper::pro_is_installed() ) { |
76 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
76 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -92,21 +92,21 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public static function edit_name( $field = 'name', $id = '' ) { |
95 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
95 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
96 | 96 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
97 | 97 | |
98 | - if ( empty($field) ) { |
|
98 | + if ( empty( $field ) ) { |
|
99 | 99 | $field = 'name'; |
100 | 100 | } |
101 | 101 | |
102 | - if ( empty($id) ) { |
|
102 | + if ( empty( $id ) ) { |
|
103 | 103 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
104 | 104 | $id = str_replace( 'field_label_', '', $id ); |
105 | 105 | } |
106 | 106 | |
107 | 107 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
108 | 108 | $value = trim( $value ); |
109 | - if ( trim(strip_tags($value)) == '' ) { |
|
109 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
110 | 110 | // set blank value if there is no content |
111 | 111 | $value = ''; |
112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | public static function update_ajax_option() { |
123 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
123 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
124 | 124 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
125 | 125 | |
126 | 126 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | if ( isset( $_POST['separate_value'] ) ) { |
134 | 134 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
135 | 135 | $field->field_options['separate_value'] = $new_val; |
136 | - unset($new_val); |
|
136 | + unset( $new_val ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | FrmField::update( $field_id, array( |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | public static function duplicate() { |
147 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
147 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
148 | 148 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
149 | 149 | |
150 | 150 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
183 | 183 | _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldsController::load_single_field' ); |
184 | 184 | |
185 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
185 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
186 | 186 | self::load_single_field( $field, $values, $form_id ); |
187 | 187 | |
188 | 188 | return $field; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | public static function destroy() { |
251 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
251 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
252 | 252 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
253 | 253 | |
254 | 254 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | |
261 | 261 | //Add Single Option or Other Option |
262 | 262 | public static function add_option() { |
263 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
263 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
264 | 264 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
265 | 265 | |
266 | 266 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
267 | 267 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
268 | 268 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' ); |
269 | 269 | |
270 | - $field = FrmField::getOne($id); |
|
270 | + $field = FrmField::getOne( $id ); |
|
271 | 271 | |
272 | 272 | if ( 'other' == $opt_type ) { |
273 | 273 | $opt = __( 'Other', 'formidable' ); |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | |
330 | 330 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
331 | 331 | $prepop = array(); |
332 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
332 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
333 | 333 | |
334 | - $field = FrmField::getOne($field_id); |
|
334 | + $field = FrmField::getOne( $field_id ); |
|
335 | 335 | |
336 | 336 | wp_enqueue_script( 'utils' ); |
337 | 337 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -342,35 +342,35 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | public static function import_options() { |
345 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
345 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
346 | 346 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
347 | 347 | |
348 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
348 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | 352 | $field_id = absint( $_POST['field_id'] ); |
353 | - $field = FrmField::getOne($field_id); |
|
353 | + $field = FrmField::getOne( $field_id ); |
|
354 | 354 | |
355 | 355 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
359 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
360 | 360 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
361 | 361 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
362 | 362 | $opts = array_map( 'trim', $opts ); |
363 | 363 | |
364 | 364 | if ( $field['separate_value'] ) { |
365 | 365 | foreach ( $opts as $opt_key => $opt ) { |
366 | - if ( strpos($opt, '|') !== false ) { |
|
367 | - $vals = explode('|', $opt); |
|
366 | + if ( strpos( $opt, '|' ) !== false ) { |
|
367 | + $vals = explode( '|', $opt ); |
|
368 | 368 | if ( $vals[0] != $vals[1] ) { |
369 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
369 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
370 | 370 | } |
371 | - unset($vals); |
|
371 | + unset( $vals ); |
|
372 | 372 | } |
373 | - unset($opt_key, $opt); |
|
373 | + unset( $opt_key, $opt ); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | $other_array = array(); |
380 | 380 | foreach ( $field['options'] as $opt_key => $opt ) { |
381 | 381 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
382 | - $other_array[ $opt_key ] = $opt; |
|
382 | + $other_array[$opt_key] = $opt; |
|
383 | 383 | } |
384 | - unset($opt_key, $opt); |
|
384 | + unset( $opt_key, $opt ); |
|
385 | 385 | } |
386 | - if ( ! empty($other_array) ) { |
|
387 | - $opts = array_merge( $opts, $other_array); |
|
386 | + if ( ! empty( $other_array ) ) { |
|
387 | + $opts = array_merge( $opts, $other_array ); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | public static function update_order() { |
399 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
399 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
400 | 400 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
401 | 401 | |
402 | 402 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | 'rte' => 'textarea', |
414 | 414 | 'website' => 'url', |
415 | 415 | ); |
416 | - if ( isset( $type_switch[ $type ] ) ) { |
|
417 | - $type = $type_switch[ $type ]; |
|
416 | + if ( isset( $type_switch[$type] ) ) { |
|
417 | + $type = $type_switch[$type]; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | $pro_fields = FrmField::pro_field_selection(); |
@@ -453,19 +453,19 @@ discard block |
||
453 | 453 | |
454 | 454 | public static function input_html( $field, $echo = true ) { |
455 | 455 | $class = array(); //$field['type']; |
456 | - self::add_input_classes($field, $class); |
|
456 | + self::add_input_classes( $field, $class ); |
|
457 | 457 | |
458 | 458 | $add_html = array(); |
459 | - self::add_html_size($field, $add_html); |
|
460 | - self::add_html_length($field, $add_html); |
|
461 | - self::add_html_placeholder($field, $add_html, $class); |
|
459 | + self::add_html_size( $field, $add_html ); |
|
460 | + self::add_html_length( $field, $add_html ); |
|
461 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
462 | 462 | self::add_validation_messages( $field, $add_html ); |
463 | 463 | |
464 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
464 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
465 | 465 | |
466 | 466 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
467 | 467 | |
468 | - self::add_shortcodes_to_html($field, $add_html); |
|
468 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
469 | 469 | self::add_pattern_attribute( $field, $add_html ); |
470 | 470 | |
471 | 471 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | private static function add_input_classes( $field, array &$class ) { |
482 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
482 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
483 | 483 | $class[] = $field['input_class']; |
484 | 484 | } |
485 | 485 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | return; |
488 | 488 | } |
489 | 489 | |
490 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
490 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
491 | 491 | $class[] = 'auto_width'; |
492 | 492 | } |
493 | 493 | } |
@@ -497,19 +497,19 @@ discard block |
||
497 | 497 | return; |
498 | 498 | } |
499 | 499 | |
500 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
500 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
504 | - if ( is_numeric($field['size']) ) { |
|
504 | + if ( is_numeric( $field['size'] ) ) { |
|
505 | 505 | $field['size'] .= 'px'; |
506 | 506 | } |
507 | 507 | |
508 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
508 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
509 | 509 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
510 | 510 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
511 | 511 | |
512 | - self::add_html_cols($field, $add_html); |
|
512 | + self::add_html_cols( $field, $add_html ); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | ); |
527 | 527 | |
528 | 528 | // include "col" for valid html |
529 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
529 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
530 | 530 | |
531 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
531 | + if ( ! isset( $calc[$unit] ) ) { |
|
532 | 532 | return; |
533 | 533 | } |
534 | 534 | |
535 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
535 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
536 | 536 | |
537 | 537 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
538 | 538 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | return; |
544 | 544 | } |
545 | 545 | |
546 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
546 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
547 | 547 | // don't load on form builder page |
548 | 548 | return; |
549 | 549 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | private static function add_placeholder_to_input( $field, &$add_html ) { |
631 | 631 | if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) { |
632 | 632 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
633 | - wp_enqueue_script('jquery-placeholder'); |
|
633 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
@@ -663,15 +663,15 @@ discard block |
||
663 | 663 | continue; |
664 | 664 | } |
665 | 665 | |
666 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
666 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
667 | 667 | $add_html[] = $v; |
668 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
669 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
668 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
669 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
670 | 670 | } else { |
671 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
671 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
672 | 672 | } |
673 | 673 | |
674 | - unset($k, $v); |
|
674 | + unset( $k, $v ); |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | protected function extra_field_opts() { |
41 | - $form_id = $this->get_field_column('form_id'); |
|
41 | + $form_id = $this->get_field_column( 'form_id' ); |
|
42 | 42 | return array( |
43 | 43 | 'align' => FrmStylesController::get_style_val( 'radio_align', ( empty( $form_id ) ? 'default' : $form_id ) ), |
44 | 44 | ); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | protected function extra_field_opts() { |
50 | - $form_id = $this->get_field_column('form_id'); |
|
50 | + $form_id = $this->get_field_column( 'form_id' ); |
|
51 | 51 | return array( |
52 | 52 | 'align' => FrmStylesController::get_style_val( 'check_align', ( empty( $form_id ) ? 'default' : $form_id ) ), |
53 | 53 | ); |
@@ -41,11 +41,11 @@ |
||
41 | 41 | |
42 | 42 | $user_ID = get_current_user_id(); |
43 | 43 | $user_ID = ( $user_ID ? $user_ID : '' ); |
44 | - $posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][ $this->field['id'] ] ) ); |
|
44 | + $posted_value = ( FrmAppHelper::is_admin() && $_POST && isset( $_POST['item_meta'][$this->field['id']] ) ); |
|
45 | 45 | $updating = ( isset( $args['action'] ) && $args['action'] == 'update' ); |
46 | 46 | $value = ( is_numeric( $this->field['value'] ) || $posted_value || $updating ) ? $this->field['value'] : $user_ID; |
47 | 47 | |
48 | - echo '<input type="hidden" name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" value="' . esc_attr( $value ) . '" data-frmval="' . esc_attr( $value ) . '"/>'."\n"; |
|
48 | + echo '<input type="hidden" name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" value="' . esc_attr( $value ) . '" data-frmval="' . esc_attr( $value ) . '"/>' . "\n"; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -32,10 +32,10 @@ |
||
32 | 32 | $size_html = $size ? ' style="width:' . esc_attr( $size . ( is_numeric( $size ) ? 'px' : '' ) ) . '";' : ''; |
33 | 33 | |
34 | 34 | $max = FrmField::get_option( $this->field, 'max' ); |
35 | - $default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column('default_value') ) ); |
|
35 | + $default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column( 'default_value' ) ) ); |
|
36 | 36 | |
37 | 37 | echo '<textarea name="' . esc_attr( $this->html_name( $name ) ) . '" ' . |
38 | - $size_html . ' rows="' . esc_attr( $max ) . '" '. |
|
38 | + $size_html . ' rows="' . esc_attr( $max ) . '" ' . |
|
39 | 39 | 'id="' . esc_attr( $this->html_id() ) . '" class="dyn_default_value">' . |
40 | 40 | $default_value . |
41 | 41 | '</textarea>'; |