@@ -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,21 +67,21 @@ 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 | } |
81 | 81 | |
82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
83 | 83 | foreach ( $terms as $t ) { |
84 | - if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) { |
|
84 | + if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
@@ -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 ); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | 'default_template' => (int) $item->default_template, |
139 | 139 | 'editable' => (int) $item->editable, |
140 | 140 | 'status' => (string) $item->status, |
141 | - 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, |
|
142 | - 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)), |
|
141 | + 'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0, |
|
142 | + 'created_at' => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ), |
|
143 | 143 | ); |
144 | 144 | |
145 | - $form['options'] = FrmAppHelper::maybe_json_decode($form['options']); |
|
145 | + $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] ); |
|
146 | 146 | |
147 | 147 | self::update_custom_style_setting_on_import( $form ); |
148 | 148 | |
@@ -152,35 +152,35 @@ discard block |
||
152 | 152 | $edit_query['created_at'] = $form['created_at']; |
153 | 153 | } |
154 | 154 | |
155 | - $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form); |
|
155 | + $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form ); |
|
156 | 156 | |
157 | - $this_form = FrmForm::getAll($edit_query, '', 1); |
|
158 | - unset($edit_query); |
|
157 | + $this_form = FrmForm::getAll( $edit_query, '', 1 ); |
|
158 | + unset( $edit_query ); |
|
159 | 159 | |
160 | 160 | if ( ! empty( $this_form ) ) { |
161 | 161 | $old_id = $form_id = $this_form->id; |
162 | - FrmForm::update($form_id, $form ); |
|
163 | - $imported['updated']['forms']++; |
|
162 | + FrmForm::update( $form_id, $form ); |
|
163 | + $imported['updated']['forms'] ++; |
|
164 | 164 | // Keep track of whether this specific form was updated or not |
165 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
165 | + $imported['form_status'][$form_id] = 'updated'; |
|
166 | 166 | |
167 | 167 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
168 | 168 | $old_fields = array(); |
169 | 169 | foreach ( $form_fields as $f ) { |
170 | - $old_fields[ $f->id ] = $f; |
|
171 | - $old_fields[ $f->field_key ] = $f->id; |
|
172 | - unset($f); |
|
170 | + $old_fields[$f->id] = $f; |
|
171 | + $old_fields[$f->field_key] = $f->id; |
|
172 | + unset( $f ); |
|
173 | 173 | } |
174 | 174 | $form_fields = $old_fields; |
175 | - unset($old_fields); |
|
175 | + unset( $old_fields ); |
|
176 | 176 | } else { |
177 | 177 | $old_id = false; |
178 | 178 | //form does not exist, so create it |
179 | 179 | $form_id = FrmForm::create( $form ); |
180 | 180 | if ( $form_id ) { |
181 | - $imported['imported']['forms']++; |
|
181 | + $imported['imported']['forms'] ++; |
|
182 | 182 | // Keep track of whether this specific form was updated or not |
183 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
183 | + $imported['form_status'][$form_id] = 'imported'; |
|
184 | 184 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
185 | 185 | } |
186 | 186 | } |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | // Delete any fields attached to this form that were not included in the template |
191 | 191 | if ( isset( $form_fields ) && ! empty( $form_fields ) ) { |
192 | 192 | foreach ( $form_fields as $field ) { |
193 | - if ( is_object($field) ) { |
|
194 | - FrmField::destroy($field->id); |
|
193 | + if ( is_object( $field ) ) { |
|
194 | + FrmField::destroy( $field->id ); |
|
195 | 195 | } |
196 | - unset($field); |
|
196 | + unset( $field ); |
|
197 | 197 | } |
198 | - unset($form_fields); |
|
198 | + unset( $form_fields ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | // Update field ids/keys to new ones |
202 | 202 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
203 | 203 | |
204 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
204 | + $imported['forms'][(int) $item->id] = $form_id; |
|
205 | 205 | |
206 | 206 | // Send pre 2.0 form options through function that creates actions |
207 | 207 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true ); |
208 | 208 | |
209 | - unset($form, $item); |
|
209 | + unset( $form, $item ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $regular_forms = array(); |
226 | 226 | |
227 | 227 | foreach ( $forms as $form ) { |
228 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
228 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
229 | 229 | |
230 | 230 | if ( $parent_form_id ) { |
231 | 231 | $child_forms[] = $form; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
249 | 249 | if ( $parent_form_id ) { |
250 | - $child_forms[ $form_id ] = $parent_form_id; |
|
250 | + $child_forms[$form_id] = $parent_form_id; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
263 | 263 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
264 | 264 | |
265 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
265 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
266 | 266 | // Update all children with this old parent_form_id |
267 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
267 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
268 | 268 | |
269 | 269 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
270 | 270 | } |
@@ -287,49 +287,49 @@ discard block |
||
287 | 287 | 'name' => (string) $field->name, |
288 | 288 | 'description' => (string) $field->description, |
289 | 289 | 'type' => (string) $field->type, |
290 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
290 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
291 | 291 | 'field_order' => (int) $field->field_order, |
292 | 292 | 'form_id' => (int) $form_id, |
293 | 293 | 'required' => (int) $field->required, |
294 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
294 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
295 | 295 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
296 | 296 | ); |
297 | 297 | |
298 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
298 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
299 | 299 | 'text', 'email', 'url', 'textarea', |
300 | - 'number','phone', 'date', 'time', |
|
300 | + 'number', 'phone', 'date', 'time', |
|
301 | 301 | 'hidden', 'password', 'tag', 'image', |
302 | - )) ) { |
|
303 | - if ( count($f['default_value']) === 1 ) { |
|
302 | + ) ) ) { |
|
303 | + if ( count( $f['default_value'] ) === 1 ) { |
|
304 | 304 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
305 | 305 | } else { |
306 | - $f['default_value'] = reset($f['default_value']); |
|
306 | + $f['default_value'] = reset( $f['default_value'] ); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | 310 | self::maybe_update_form_select( $f, $imported ); |
311 | 311 | |
312 | - if ( ! empty($this_form) ) { |
|
312 | + if ( ! empty( $this_form ) ) { |
|
313 | 313 | // check for field to edit by field id |
314 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
314 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
315 | 315 | FrmField::update( $f['id'], $f ); |
316 | - $imported['updated']['fields']++; |
|
316 | + $imported['updated']['fields'] ++; |
|
317 | 317 | |
318 | - unset( $form_fields[ $f['id'] ] ); |
|
318 | + unset( $form_fields[$f['id']] ); |
|
319 | 319 | |
320 | 320 | //unset old field key |
321 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
322 | - unset( $form_fields[ $f['field_key'] ] ); |
|
321 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
322 | + unset( $form_fields[$f['field_key']] ); |
|
323 | 323 | } |
324 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
324 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
325 | 325 | // check for field to edit by field key |
326 | - unset($f['id']); |
|
326 | + unset( $f['id'] ); |
|
327 | 327 | |
328 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
329 | - $imported['updated']['fields']++; |
|
328 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
329 | + $imported['updated']['fields'] ++; |
|
330 | 330 | |
331 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
332 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
331 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
332 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
333 | 333 | } else { |
334 | 334 | // if no matching field id or key in this form, create the field |
335 | 335 | self::maybe_update_in_section_variable( $in_section, $f ); |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
383 | 383 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
384 | 384 | $form_select = $f['field_options']['form_select']; |
385 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
386 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
385 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
386 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | private static function create_imported_field( $f, &$imported ) { |
400 | 400 | $new_id = FrmField::create( $f ); |
401 | 401 | if ( $new_id != false ) { |
402 | - $imported[ 'imported' ][ 'fields' ]++; |
|
402 | + $imported['imported']['fields'] ++; |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | 'post_id' => (int) $item->post_id, |
461 | 461 | 'post_parent' => (int) $item->post_parent, |
462 | 462 | 'menu_order' => (int) $item->menu_order, |
463 | - 'post_content' => FrmFieldsHelper::switch_field_ids((string) $item->content), |
|
464 | - 'post_excerpt' => FrmFieldsHelper::switch_field_ids((string) $item->excerpt), |
|
463 | + 'post_content' => FrmFieldsHelper::switch_field_ids( (string) $item->content ), |
|
464 | + 'post_excerpt' => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ), |
|
465 | 465 | 'is_sticky' => (string) $item->is_sticky, |
466 | 466 | 'comment_status' => (string) $item->comment_status, |
467 | 467 | 'post_date' => (string) $item->post_date, |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | ); |
473 | 473 | |
474 | 474 | $old_id = $post['post_id']; |
475 | - self::populate_post($post, $item, $imported); |
|
475 | + self::populate_post( $post, $item, $imported ); |
|
476 | 476 | |
477 | - unset($item); |
|
477 | + unset( $item ); |
|
478 | 478 | |
479 | 479 | $post_id = false; |
480 | 480 | if ( $post['post_type'] == $form_action_type ) { |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | if ( $action_control ) { |
483 | 483 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
484 | 484 | } |
485 | - unset($action_control); |
|
485 | + unset( $action_control ); |
|
486 | 486 | } else if ( $post['post_type'] == 'frm_styles' ) { |
487 | 487 | // Properly encode post content before inserting the post |
488 | 488 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -495,26 +495,26 @@ discard block |
||
495 | 495 | $post_id = wp_insert_post( $post ); |
496 | 496 | } |
497 | 497 | |
498 | - if ( ! is_numeric($post_id) ) { |
|
498 | + if ( ! is_numeric( $post_id ) ) { |
|
499 | 499 | continue; |
500 | 500 | } |
501 | 501 | |
502 | - self::update_postmeta($post, $post_id); |
|
502 | + self::update_postmeta( $post, $post_id ); |
|
503 | 503 | |
504 | 504 | $this_type = 'posts'; |
505 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
506 | - $this_type = $post_types[ $post['post_type'] ]; |
|
505 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
506 | + $this_type = $post_types[$post['post_type']]; |
|
507 | 507 | } |
508 | 508 | |
509 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
510 | - $imported['updated'][ $this_type ]++; |
|
509 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
510 | + $imported['updated'][$this_type] ++; |
|
511 | 511 | } else { |
512 | - $imported['imported'][ $this_type ]++; |
|
512 | + $imported['imported'][$this_type] ++; |
|
513 | 513 | } |
514 | 514 | |
515 | - unset($post); |
|
515 | + unset( $post ); |
|
516 | 516 | |
517 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
517 | + $imported['posts'][(int) $old_id] = $post_id; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | self::maybe_update_stylesheet( $imported ); |
@@ -523,23 +523,23 @@ discard block |
||
523 | 523 | } |
524 | 524 | |
525 | 525 | private static function populate_post( &$post, $item, $imported ) { |
526 | - if ( isset($item->attachment_url) ) { |
|
526 | + if ( isset( $item->attachment_url ) ) { |
|
527 | 527 | $post['attachment_url'] = (string) $item->attachment_url; |
528 | 528 | } |
529 | 529 | |
530 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
530 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
531 | 531 | // update to new form id |
532 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
532 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | foreach ( $item->postmeta as $meta ) { |
536 | - self::populate_postmeta($post, $meta, $imported); |
|
537 | - unset($meta); |
|
536 | + self::populate_postmeta( $post, $meta, $imported ); |
|
537 | + unset( $meta ); |
|
538 | 538 | } |
539 | 539 | |
540 | - self::populate_taxonomies($post, $item); |
|
540 | + self::populate_taxonomies( $post, $item ); |
|
541 | 541 | |
542 | - self::maybe_editing_post($post); |
|
542 | + self::maybe_editing_post( $post ); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -551,27 +551,27 @@ discard block |
||
551 | 551 | ); |
552 | 552 | |
553 | 553 | //switch old form and field ids to new ones |
554 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
555 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
554 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
555 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
556 | 556 | } else { |
557 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
557 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
558 | 558 | |
559 | - if ( ! empty($frm_duplicate_ids) ) { |
|
559 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
560 | 560 | |
561 | 561 | if ( $m['key'] == 'frm_dyncontent' ) { |
562 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
562 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
563 | 563 | } else if ( $m['key'] == 'frm_options' ) { |
564 | 564 | |
565 | 565 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
566 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
567 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
566 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
567 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | 571 | $check_dup_array = array(); |
572 | 572 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
573 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
574 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
573 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
574 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
575 | 575 | } else if ( is_array( $m['value']['order_by'] ) ) { |
576 | 576 | $check_dup_array[] = 'order_by'; |
577 | 577 | } |
@@ -582,22 +582,22 @@ discard block |
||
582 | 582 | } |
583 | 583 | |
584 | 584 | foreach ( $check_dup_array as $check_k ) { |
585 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
586 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
587 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
585 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
586 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
587 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
588 | 588 | } |
589 | - unset($mk, $mv); |
|
589 | + unset( $mk, $mv ); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | } |
593 | 593 | } |
594 | 594 | } |
595 | 595 | |
596 | - if ( ! is_array($m['value']) ) { |
|
597 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
596 | + if ( ! is_array( $m['value'] ) ) { |
|
597 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
598 | 598 | } |
599 | 599 | |
600 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
600 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -613,23 +613,23 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | $taxonomy = (string) $att['domain']; |
616 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
616 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
617 | 617 | $name = (string) $att['nicename']; |
618 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
618 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
619 | 619 | if ( $h_term ) { |
620 | 620 | $name = $h_term->term_id; |
621 | 621 | } |
622 | - unset($h_term); |
|
622 | + unset( $h_term ); |
|
623 | 623 | } else { |
624 | 624 | $name = (string) $c; |
625 | 625 | } |
626 | 626 | |
627 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
628 | - $post['tax_input'][ $taxonomy ] = array(); |
|
627 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
628 | + $post['tax_input'][$taxonomy] = array(); |
|
629 | 629 | } |
630 | 630 | |
631 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
632 | - unset($name); |
|
631 | + $post['tax_input'][$taxonomy][] = $name; |
|
632 | + unset( $name ); |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | |
@@ -646,29 +646,29 @@ discard block |
||
646 | 646 | |
647 | 647 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
648 | 648 | $match_by['include'] = $post['post_id']; |
649 | - unset($match_by['name']); |
|
649 | + unset( $match_by['name'] ); |
|
650 | 650 | } |
651 | 651 | |
652 | - $editing = get_posts($match_by); |
|
652 | + $editing = get_posts( $match_by ); |
|
653 | 653 | |
654 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
654 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
655 | 655 | // set the id of the post to edit |
656 | - $post['ID'] = current($editing)->ID; |
|
656 | + $post['ID'] = current( $editing )->ID; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | |
660 | 660 | private static function update_postmeta( &$post, $post_id ) { |
661 | 661 | foreach ( $post['postmeta'] as $k => $v ) { |
662 | 662 | if ( '_edit_last' == $k ) { |
663 | - $v = FrmAppHelper::get_user_id_param($v); |
|
663 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
664 | 664 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
665 | 665 | //change the attachment ID |
666 | - $v = FrmProXMLHelper::get_file_id($v); |
|
666 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
667 | 667 | } |
668 | 668 | |
669 | - update_post_meta($post_id, $k, $v); |
|
669 | + update_post_meta( $post_id, $k, $v ); |
|
670 | 670 | |
671 | - unset($k, $v); |
|
671 | + unset( $k, $v ); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | |
@@ -685,13 +685,13 @@ discard block |
||
685 | 685 | * @param string $message |
686 | 686 | */ |
687 | 687 | public static function parse_message( $result, &$message, &$errors ) { |
688 | - if ( is_wp_error($result) ) { |
|
688 | + if ( is_wp_error( $result ) ) { |
|
689 | 689 | $errors[] = $result->get_error_message(); |
690 | 690 | } else if ( ! $result ) { |
691 | 691 | return; |
692 | 692 | } |
693 | 693 | |
694 | - if ( ! is_array($result) ) { |
|
694 | + if ( ! is_array( $result ) ) { |
|
695 | 695 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
696 | 696 | return; |
697 | 697 | } |
@@ -703,20 +703,20 @@ discard block |
||
703 | 703 | |
704 | 704 | $message = '<ul>'; |
705 | 705 | foreach ( $result as $type => $results ) { |
706 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
706 | + if ( ! isset( $t_strings[$type] ) ) { |
|
707 | 707 | // only print imported and updated |
708 | 708 | continue; |
709 | 709 | } |
710 | 710 | |
711 | 711 | $s_message = array(); |
712 | 712 | foreach ( $results as $k => $m ) { |
713 | - self::item_count_message($m, $k, $s_message); |
|
714 | - unset($k, $m); |
|
713 | + self::item_count_message( $m, $k, $s_message ); |
|
714 | + unset( $k, $m ); |
|
715 | 715 | } |
716 | 716 | |
717 | - if ( ! empty($s_message) ) { |
|
718 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
719 | - $message .= implode(', ', $s_message); |
|
717 | + if ( ! empty( $s_message ) ) { |
|
718 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
719 | + $message .= implode( ', ', $s_message ); |
|
720 | 720 | $message .= '</li>'; |
721 | 721 | } |
722 | 722 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
746 | 746 | ); |
747 | 747 | |
748 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
748 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
@@ -777,14 +777,14 @@ discard block |
||
777 | 777 | } |
778 | 778 | |
779 | 779 | public static function cdata( $str ) { |
780 | - $str = maybe_unserialize($str); |
|
781 | - if ( is_array($str) ) { |
|
782 | - $str = json_encode($str); |
|
780 | + $str = maybe_unserialize( $str ); |
|
781 | + if ( is_array( $str ) ) { |
|
782 | + $str = json_encode( $str ); |
|
783 | 783 | } else if ( seems_utf8( $str ) == false ) { |
784 | 784 | $str = utf8_encode( $str ); |
785 | 785 | } |
786 | 786 | |
787 | - if ( is_numeric($str) ) { |
|
787 | + if ( is_numeric( $str ) ) { |
|
788 | 788 | return $str; |
789 | 789 | } |
790 | 790 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * @param string $post_type |
830 | 830 | */ |
831 | 831 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
832 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
832 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
833 | 833 | return; |
834 | 834 | } |
835 | 835 | |
@@ -850,10 +850,10 @@ discard block |
||
850 | 850 | ); |
851 | 851 | |
852 | 852 | foreach ( $post_settings as $post_setting ) { |
853 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
854 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
853 | + if ( isset( $form_options[$post_setting] ) ) { |
|
854 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
855 | 855 | } |
856 | - unset($post_setting); |
|
856 | + unset( $post_setting ); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | $new_action['event'] = array( 'create', 'update' ); |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | |
868 | 868 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
869 | 869 | } |
870 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
870 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
871 | 871 | |
872 | 872 | $exists = get_posts( array( |
873 | 873 | 'name' => $new_action['post_name'], |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | if ( ! $exists ) { |
880 | 880 | // this isn't an email, but we need to use a class that will always be included |
881 | 881 | FrmAppHelper::save_json_post( $new_action ); |
882 | - $imported['imported']['actions']++; |
|
882 | + $imported['imported']['actions'] ++; |
|
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
@@ -911,11 +911,11 @@ discard block |
||
911 | 911 | foreach ( $post_content as $key => $setting ) { |
912 | 912 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
913 | 913 | // Replace old IDs with new IDs |
914 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
914 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
915 | 915 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
916 | 916 | foreach ( $setting as $k => $val ) { |
917 | 917 | // Replace old IDs with new IDs |
918 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
918 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | unset( $key, $setting ); |
@@ -938,14 +938,14 @@ discard block |
||
938 | 938 | // Migrate autoresponders |
939 | 939 | self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
940 | 940 | |
941 | - if ( empty( $notifications ) ) { |
|
941 | + if ( empty( $notifications ) ) { |
|
942 | 942 | return; |
943 | 943 | } |
944 | 944 | |
945 | 945 | foreach ( $notifications as $new_notification ) { |
946 | 946 | $new_notification['post_type'] = $post_type; |
947 | 947 | $new_notification['post_excerpt'] = 'email'; |
948 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
948 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
949 | 949 | $new_notification['menu_order'] = $form_id; |
950 | 950 | $new_notification['post_status'] = 'publish'; |
951 | 951 | |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | // Switch all other field IDs in email |
959 | 959 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
960 | 960 | } |
961 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
961 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
962 | 962 | |
963 | 963 | $exists = get_posts( array( |
964 | 964 | 'name' => $new_notification['post_name'], |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | 'numberposts' => 1, |
968 | 968 | ) ); |
969 | 969 | |
970 | - if ( empty($exists) ) { |
|
970 | + if ( empty( $exists ) ) { |
|
971 | 971 | FrmAppHelper::save_json_post( $new_notification ); |
972 | - $imported['imported']['actions']++; |
|
972 | + $imported['imported']['actions'] ++; |
|
973 | 973 | } |
974 | - unset($new_notification); |
|
974 | + unset( $new_notification ); |
|
975 | 975 | } |
976 | 976 | } |
977 | 977 | |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
985 | 985 | } |
986 | 986 | |
987 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
987 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
988 | 988 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
989 | 989 | |
990 | 990 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -1012,12 +1012,12 @@ discard block |
||
1012 | 1012 | // Format the reply to email and name |
1013 | 1013 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
1014 | 1014 | foreach ( $reply_fields as $f => $val ) { |
1015 | - if ( isset( $notification[ $f ] ) ) { |
|
1016 | - $atts[ $f ] = $notification[ $f ]; |
|
1017 | - if ( 'custom' == $notification[ $f ] ) { |
|
1018 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
1019 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
1020 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
1015 | + if ( isset( $notification[$f] ) ) { |
|
1016 | + $atts[$f] = $notification[$f]; |
|
1017 | + if ( 'custom' == $notification[$f] ) { |
|
1018 | + $atts[$f] = $notification['cust_' . $f]; |
|
1019 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
1020 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | unset( $f, $val ); |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | $atts['event'] = array( 'create' ); |
1028 | 1028 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
1029 | 1029 | $atts['event'][] = 'update'; |
1030 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1030 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
1031 | 1031 | $atts['event'] = array( 'update' ); |
1032 | 1032 | } |
1033 | 1033 | } |
@@ -1048,18 +1048,18 @@ discard block |
||
1048 | 1048 | foreach ( $atts['email_to'] as $key => $email_field ) { |
1049 | 1049 | |
1050 | 1050 | if ( is_numeric( $email_field ) ) { |
1051 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
1051 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | - if ( strpos( $email_field, '|') ) { |
|
1054 | + if ( strpos( $email_field, '|' ) ) { |
|
1055 | 1055 | $email_opt = explode( '|', $email_field ); |
1056 | 1056 | if ( isset( $email_opt[0] ) ) { |
1057 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1057 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1058 | 1058 | } |
1059 | 1059 | unset( $email_opt ); |
1060 | 1060 | } |
1061 | 1061 | } |
1062 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1062 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -1075,12 +1075,12 @@ discard block |
||
1075 | 1075 | // Add more fields to the new notification |
1076 | 1076 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
1077 | 1077 | foreach ( $add_fields as $add_field ) { |
1078 | - if ( isset( $notification[ $add_field ] ) ) { |
|
1079 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
1078 | + if ( isset( $notification[$add_field] ) ) { |
|
1079 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
1080 | 1080 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
1081 | - $new_notification['post_content'][ $add_field ] = 0; |
|
1081 | + $new_notification['post_content'][$add_field] = 0; |
|
1082 | 1082 | } else { |
1083 | - $new_notification['post_content'][ $add_field ] = ''; |
|
1083 | + $new_notification['post_content'][$add_field] = ''; |
|
1084 | 1084 | } |
1085 | 1085 | unset( $add_field ); |
1086 | 1086 | } |
@@ -1104,26 +1104,26 @@ discard block |
||
1104 | 1104 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
1105 | 1105 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
1106 | 1106 | if ( is_numeric( $email_key ) ) { |
1107 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1107 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1108 | 1108 | } |
1109 | - unset( $email_key, $val); |
|
1109 | + unset( $email_key, $val ); |
|
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
1115 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1115 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
1116 | 1116 | // migrate autoresponder |
1117 | 1117 | |
1118 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1119 | - if ( strpos($email_field, '|') ) { |
|
1118 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
1119 | + if ( strpos( $email_field, '|' ) ) { |
|
1120 | 1120 | // data from entries field |
1121 | - $email_field = explode('|', $email_field); |
|
1122 | - if ( isset($email_field[1]) ) { |
|
1121 | + $email_field = explode( '|', $email_field ); |
|
1122 | + if ( isset( $email_field[1] ) ) { |
|
1123 | 1123 | $email_field = $email_field[1]; |
1124 | 1124 | } |
1125 | 1125 | } |
1126 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1126 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
1127 | 1127 | $email_field = '[' . $email_field . ']'; |
1128 | 1128 | } |
1129 | 1129 | |
@@ -1131,16 +1131,16 @@ discard block |
||
1131 | 1131 | $new_notification2 = array( |
1132 | 1132 | 'post_content' => array( |
1133 | 1133 | 'email_message' => $notification['ar_email_message'], |
1134 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1134 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
1135 | 1135 | 'email_to' => $email_field, |
1136 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1136 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
1137 | 1137 | 'inc_user_info' => 0, |
1138 | 1138 | ), |
1139 | 1139 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
1140 | 1140 | ); |
1141 | 1141 | |
1142 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1143 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1142 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
1143 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
1144 | 1144 | |
1145 | 1145 | if ( ! empty( $reply_to ) ) { |
1146 | 1146 | $new_notification2['post_content']['reply_to'] = $reply_to; |