@@ -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,29 +729,29 @@ 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 | - $v = FrmProXMLHelper::get_file_id($v); |
|
749 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
750 | 750 | } |
751 | 751 | |
752 | - update_post_meta($post_id, $k, $v); |
|
752 | + update_post_meta( $post_id, $k, $v ); |
|
753 | 753 | |
754 | - unset($k, $v); |
|
754 | + unset( $k, $v ); |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
@@ -790,13 +790,13 @@ discard block |
||
790 | 790 | * @param string $message |
791 | 791 | */ |
792 | 792 | public static function parse_message( $result, &$message, &$errors ) { |
793 | - if ( is_wp_error($result) ) { |
|
793 | + if ( is_wp_error( $result ) ) { |
|
794 | 794 | $errors[] = $result->get_error_message(); |
795 | 795 | } else if ( ! $result ) { |
796 | 796 | return; |
797 | 797 | } |
798 | 798 | |
799 | - if ( ! is_array($result) ) { |
|
799 | + if ( ! is_array( $result ) ) { |
|
800 | 800 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
801 | 801 | return; |
802 | 802 | } |
@@ -808,20 +808,20 @@ discard block |
||
808 | 808 | |
809 | 809 | $message = '<ul>'; |
810 | 810 | foreach ( $result as $type => $results ) { |
811 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
811 | + if ( ! isset( $t_strings[$type] ) ) { |
|
812 | 812 | // only print imported and updated |
813 | 813 | continue; |
814 | 814 | } |
815 | 815 | |
816 | 816 | $s_message = array(); |
817 | 817 | foreach ( $results as $k => $m ) { |
818 | - self::item_count_message($m, $k, $s_message); |
|
819 | - unset($k, $m); |
|
818 | + self::item_count_message( $m, $k, $s_message ); |
|
819 | + unset( $k, $m ); |
|
820 | 820 | } |
821 | 821 | |
822 | - if ( ! empty($s_message) ) { |
|
823 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
824 | - $message .= implode(', ', $s_message); |
|
822 | + if ( ! empty( $s_message ) ) { |
|
823 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
824 | + $message .= implode( ', ', $s_message ); |
|
825 | 825 | $message .= '</li>'; |
826 | 826 | } |
827 | 827 | } |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
851 | 851 | ); |
852 | 852 | |
853 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
853 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -882,14 +882,14 @@ discard block |
||
882 | 882 | } |
883 | 883 | |
884 | 884 | public static function cdata( $str ) { |
885 | - $str = maybe_unserialize($str); |
|
886 | - if ( is_array($str) ) { |
|
887 | - $str = json_encode($str); |
|
885 | + $str = maybe_unserialize( $str ); |
|
886 | + if ( is_array( $str ) ) { |
|
887 | + $str = json_encode( $str ); |
|
888 | 888 | } else if ( seems_utf8( $str ) == false ) { |
889 | 889 | $str = utf8_encode( $str ); |
890 | 890 | } |
891 | 891 | |
892 | - if ( is_numeric($str) ) { |
|
892 | + if ( is_numeric( $str ) ) { |
|
893 | 893 | return $str; |
894 | 894 | } |
895 | 895 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | * @param string $post_type |
935 | 935 | */ |
936 | 936 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
937 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
937 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
938 | 938 | return; |
939 | 939 | } |
940 | 940 | |
@@ -955,10 +955,10 @@ discard block |
||
955 | 955 | ); |
956 | 956 | |
957 | 957 | foreach ( $post_settings as $post_setting ) { |
958 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
959 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
958 | + if ( isset( $form_options[$post_setting] ) ) { |
|
959 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
960 | 960 | } |
961 | - unset($post_setting); |
|
961 | + unset( $post_setting ); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | $new_action['event'] = array( 'create', 'update' ); |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | |
973 | 973 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
974 | 974 | } |
975 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
975 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
976 | 976 | |
977 | 977 | $exists = get_posts( array( |
978 | 978 | 'name' => $new_action['post_name'], |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | if ( ! $exists ) { |
985 | 985 | // this isn't an email, but we need to use a class that will always be included |
986 | 986 | FrmAppHelper::save_json_post( $new_action ); |
987 | - $imported['imported']['actions']++; |
|
987 | + $imported['imported']['actions'] ++; |
|
988 | 988 | } |
989 | 989 | } |
990 | 990 | |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | foreach ( $post_content as $key => $setting ) { |
1017 | 1017 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
1018 | 1018 | // Replace old IDs with new IDs |
1019 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
1019 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
1020 | 1020 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
1021 | 1021 | foreach ( $setting as $k => $val ) { |
1022 | 1022 | // Replace old IDs with new IDs |
1023 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
1023 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | unset( $key, $setting ); |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | foreach ( $notifications as $new_notification ) { |
1051 | 1051 | $new_notification['post_type'] = $post_type; |
1052 | 1052 | $new_notification['post_excerpt'] = 'email'; |
1053 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
1053 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
1054 | 1054 | $new_notification['menu_order'] = $form_id; |
1055 | 1055 | $new_notification['post_status'] = 'publish'; |
1056 | 1056 | |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | // Switch all other field IDs in email |
1064 | 1064 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
1065 | 1065 | } |
1066 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1066 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
1067 | 1067 | |
1068 | 1068 | $exists = get_posts( array( |
1069 | 1069 | 'name' => $new_notification['post_name'], |
@@ -1072,11 +1072,11 @@ discard block |
||
1072 | 1072 | 'numberposts' => 1, |
1073 | 1073 | ) ); |
1074 | 1074 | |
1075 | - if ( empty($exists) ) { |
|
1075 | + if ( empty( $exists ) ) { |
|
1076 | 1076 | FrmAppHelper::save_json_post( $new_notification ); |
1077 | - $imported['imported']['actions']++; |
|
1077 | + $imported['imported']['actions'] ++; |
|
1078 | 1078 | } |
1079 | - unset($new_notification); |
|
1079 | + unset( $new_notification ); |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
@@ -1093,8 +1093,8 @@ discard block |
||
1093 | 1093 | private static function remove_deprecated_notification_settings( $form_id, $form_options ) { |
1094 | 1094 | $delete_settings = array( 'notification', 'autoresponder', 'email_to' ); |
1095 | 1095 | foreach ( $delete_settings as $index ) { |
1096 | - if ( isset( $form_options[ $index ] ) ) { |
|
1097 | - unset( $form_options[ $index ] ); |
|
1096 | + if ( isset( $form_options[$index] ) ) { |
|
1097 | + unset( $form_options[$index] ); |
|
1098 | 1098 | } |
1099 | 1099 | } |
1100 | 1100 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
1112 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
1113 | 1113 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
1114 | 1114 | |
1115 | 1115 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -1137,12 +1137,12 @@ discard block |
||
1137 | 1137 | // Format the reply to email and name |
1138 | 1138 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
1139 | 1139 | foreach ( $reply_fields as $f => $val ) { |
1140 | - if ( isset( $notification[ $f ] ) ) { |
|
1141 | - $atts[ $f ] = $notification[ $f ]; |
|
1142 | - if ( 'custom' == $notification[ $f ] ) { |
|
1143 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
1144 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
1145 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
1140 | + if ( isset( $notification[$f] ) ) { |
|
1141 | + $atts[$f] = $notification[$f]; |
|
1142 | + if ( 'custom' == $notification[$f] ) { |
|
1143 | + $atts[$f] = $notification['cust_' . $f]; |
|
1144 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
1145 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
1146 | 1146 | } |
1147 | 1147 | } |
1148 | 1148 | unset( $f, $val ); |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | $atts['event'] = array( 'create' ); |
1153 | 1153 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
1154 | 1154 | $atts['event'][] = 'update'; |
1155 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
1155 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
1156 | 1156 | $atts['event'] = array( 'update' ); |
1157 | 1157 | } |
1158 | 1158 | } |
@@ -1173,18 +1173,18 @@ discard block |
||
1173 | 1173 | foreach ( $atts['email_to'] as $key => $email_field ) { |
1174 | 1174 | |
1175 | 1175 | if ( is_numeric( $email_field ) ) { |
1176 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
1176 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | - if ( strpos( $email_field, '|') ) { |
|
1179 | + if ( strpos( $email_field, '|' ) ) { |
|
1180 | 1180 | $email_opt = explode( '|', $email_field ); |
1181 | 1181 | if ( isset( $email_opt[0] ) ) { |
1182 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1182 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
1183 | 1183 | } |
1184 | 1184 | unset( $email_opt ); |
1185 | 1185 | } |
1186 | 1186 | } |
1187 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1187 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -1200,12 +1200,12 @@ discard block |
||
1200 | 1200 | // Add more fields to the new notification |
1201 | 1201 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
1202 | 1202 | foreach ( $add_fields as $add_field ) { |
1203 | - if ( isset( $notification[ $add_field ] ) ) { |
|
1204 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
1203 | + if ( isset( $notification[$add_field] ) ) { |
|
1204 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
1205 | 1205 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
1206 | - $new_notification['post_content'][ $add_field ] = 0; |
|
1206 | + $new_notification['post_content'][$add_field] = 0; |
|
1207 | 1207 | } else { |
1208 | - $new_notification['post_content'][ $add_field ] = ''; |
|
1208 | + $new_notification['post_content'][$add_field] = ''; |
|
1209 | 1209 | } |
1210 | 1210 | unset( $add_field ); |
1211 | 1211 | } |
@@ -1229,26 +1229,26 @@ discard block |
||
1229 | 1229 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
1230 | 1230 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
1231 | 1231 | if ( is_numeric( $email_key ) ) { |
1232 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1232 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1233 | 1233 | } |
1234 | - unset( $email_key, $val); |
|
1234 | + unset( $email_key, $val ); |
|
1235 | 1235 | } |
1236 | 1236 | } |
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
1240 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1240 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
1241 | 1241 | // migrate autoresponder |
1242 | 1242 | |
1243 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1244 | - if ( strpos($email_field, '|') ) { |
|
1243 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
1244 | + if ( strpos( $email_field, '|' ) ) { |
|
1245 | 1245 | // data from entries field |
1246 | - $email_field = explode('|', $email_field); |
|
1247 | - if ( isset($email_field[1]) ) { |
|
1246 | + $email_field = explode( '|', $email_field ); |
|
1247 | + if ( isset( $email_field[1] ) ) { |
|
1248 | 1248 | $email_field = $email_field[1]; |
1249 | 1249 | } |
1250 | 1250 | } |
1251 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1251 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
1252 | 1252 | $email_field = '[' . $email_field . ']'; |
1253 | 1253 | } |
1254 | 1254 | |
@@ -1256,16 +1256,16 @@ discard block |
||
1256 | 1256 | $new_notification2 = array( |
1257 | 1257 | 'post_content' => array( |
1258 | 1258 | 'email_message' => $notification['ar_email_message'], |
1259 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1259 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
1260 | 1260 | 'email_to' => $email_field, |
1261 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1261 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
1262 | 1262 | 'inc_user_info' => 0, |
1263 | 1263 | ), |
1264 | 1264 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
1265 | 1265 | ); |
1266 | 1266 | |
1267 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1268 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1267 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
1268 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
1269 | 1269 | |
1270 | 1270 | if ( ! empty( $reply_to ) ) { |
1271 | 1271 | $new_notification2['post_content']['reply_to'] = $reply_to; |