@@ -954,6 +954,7 @@ discard block |
||
| 954 | 954 | * The line endings may prevent html from being equal when it should |
| 955 | 955 | * |
| 956 | 956 | * @since 3.05.01 |
| 957 | + * @param string $html_name |
|
| 957 | 958 | */ |
| 958 | 959 | private static function remove_default_html( $html_name, $defaults, &$options ) { |
| 959 | 960 | if ( ! isset( $options[ $html_name ] ) || ! isset( $defaults[ $html_name ] ) ) { |
@@ -1025,6 +1026,7 @@ discard block |
||
| 1025 | 1026 | * Migrate post settings to form action |
| 1026 | 1027 | * |
| 1027 | 1028 | * @param string $post_type |
| 1029 | + * @param boolean $switch |
|
| 1028 | 1030 | */ |
| 1029 | 1031 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
| 1030 | 1032 | if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
@@ -1084,8 +1086,8 @@ discard block |
||
| 1084 | 1086 | * |
| 1085 | 1087 | * @since 2.0 |
| 1086 | 1088 | * @param array $post_content - check for old field IDs |
| 1087 | - * @param array $basic_fields - fields with string or int saved |
|
| 1088 | - * @param array $array_fields - fields with arrays saved |
|
| 1089 | + * @param string[] $basic_fields - fields with string or int saved |
|
| 1090 | + * @param string[] $array_fields - fields with arrays saved |
|
| 1089 | 1091 | * |
| 1090 | 1092 | * @return string $post_content - new field IDs |
| 1091 | 1093 | */ |
@@ -1119,6 +1121,10 @@ discard block |
||
| 1119 | 1121 | return $post_content; |
| 1120 | 1122 | } |
| 1121 | 1123 | |
| 1124 | + /** |
|
| 1125 | + * @param string $post_type |
|
| 1126 | + * @param boolean $switch |
|
| 1127 | + */ |
|
| 1122 | 1128 | private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
| 1123 | 1129 | // No old notifications or autoresponders to carry over |
| 1124 | 1130 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
@@ -33,22 +33,22 @@ discard block |
||
| 33 | 33 | 'styles' => 0, |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - $imported = array( |
|
| 37 | - 'imported' => $defaults, |
|
| 36 | + $imported = array( |
|
| 37 | + 'imported' => $defaults, |
|
| 38 | 38 | 'updated' => $defaults, |
| 39 | 39 | 'forms' => array(), |
| 40 | 40 | 'terms' => array(), |
| 41 | - ); |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | 43 | unset( $defaults ); |
| 44 | 44 | |
| 45 | 45 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 46 | 46 | define( 'WP_IMPORTING', true ); |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | if ( ! class_exists( 'DOMDocument' ) ) { |
| 50 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 51 | - } |
|
| 50 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | $dom = new DOMDocument(); |
| 54 | 54 | $success = $dom->loadXML( file_get_contents( $file ) ); |
@@ -68,25 +68,25 @@ discard block |
||
| 68 | 68 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 71 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 72 | 72 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 73 | - // grab cats, tags, and terms, or forms or posts |
|
| 73 | + // grab cats, tags, and terms, or forms or posts |
|
| 74 | 74 | if ( isset( $xml->{$item_type} ) ) { |
| 75 | 75 | $function_name = 'import_xml_' . $item_type . 's'; |
| 76 | 76 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 77 | 77 | unset( $function_name, $xml->{$item_type} ); |
| 78 | - } |
|
| 79 | - } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
| 82 | 82 | |
| 83 | - return $return; |
|
| 84 | - } |
|
| 83 | + return $return; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | public static function import_xml_terms( $terms, $imported ) { |
| 87 | - foreach ( $terms as $t ) { |
|
| 87 | + foreach ( $terms as $t ) { |
|
| 88 | 88 | if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
| 89 | - continue; |
|
| 89 | + continue; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $parent = self::get_term_parent_id( $t ); |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | if ( $term && is_array( $term ) ) { |
| 105 | - $imported['imported']['terms']++; |
|
| 105 | + $imported['imported']['terms']++; |
|
| 106 | 106 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | unset( $term, $t ); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $imported; |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @since 2.0.8 |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | self::put_child_forms_first( $forms ); |
| 136 | 136 | |
| 137 | 137 | foreach ( $forms as $item ) { |
| 138 | - $form = self::fill_form( $item ); |
|
| 138 | + $form = self::fill_form( $item ); |
|
| 139 | 139 | |
| 140 | 140 | self::update_custom_style_setting_on_import( $form ); |
| 141 | 141 | |
| 142 | - $this_form = self::maybe_get_form( $form ); |
|
| 142 | + $this_form = self::maybe_get_form( $form ); |
|
| 143 | 143 | |
| 144 | 144 | $old_id = false; |
| 145 | 145 | $form_fields = false; |
@@ -151,25 +151,25 @@ discard block |
||
| 151 | 151 | $form_fields = self::get_form_fields( $form_id ); |
| 152 | 152 | } else { |
| 153 | 153 | $form_id = FrmForm::create( $form ); |
| 154 | - if ( $form_id ) { |
|
| 155 | - $imported['imported']['forms']++; |
|
| 156 | - // Keep track of whether this specific form was updated or not |
|
| 154 | + if ( $form_id ) { |
|
| 155 | + $imported['imported']['forms']++; |
|
| 156 | + // Keep track of whether this specific form was updated or not |
|
| 157 | 157 | $imported['form_status'][ $form_id ] = 'imported'; |
| 158 | 158 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
| 163 | 163 | |
| 164 | 164 | self::delete_removed_fields( $form_fields ); |
| 165 | 165 | |
| 166 | - // Update field ids/keys to new ones |
|
| 166 | + // Update field ids/keys to new ones |
|
| 167 | 167 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 168 | 168 | |
| 169 | 169 | $imported['forms'][ (int) $item->id ] = $form_id; |
| 170 | 170 | |
| 171 | - // Send pre 2.0 form options through function that creates actions |
|
| 172 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 171 | + // Send pre 2.0 form options through function that creates actions |
|
| 172 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 173 | 173 | |
| 174 | 174 | do_action( 'frm_after_import_form', $form_id, $form ); |
| 175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
| 180 | 180 | |
| 181 | 181 | return $imported; |
| 182 | - } |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | private static function fill_form( $item ) { |
| 185 | 185 | $form = array( |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Put child forms first so they will be imported before parents |
|
| 254 | - * |
|
| 255 | - * @since 2.0.16 |
|
| 256 | - * @param array $forms |
|
| 257 | - */ |
|
| 253 | + * Put child forms first so they will be imported before parents |
|
| 254 | + * |
|
| 255 | + * @since 2.0.16 |
|
| 256 | + * @param array $forms |
|
| 257 | + */ |
|
| 258 | 258 | private static function put_child_forms_first( &$forms ) { |
| 259 | 259 | $child_forms = array(); |
| 260 | 260 | $regular_forms = array(); |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Keep track of all imported child forms |
|
| 277 | - * |
|
| 278 | - * @since 2.0.16 |
|
| 279 | - * @param int $form_id |
|
| 280 | - * @param int $parent_form_id |
|
| 281 | - * @param array $child_forms |
|
| 282 | - */ |
|
| 276 | + * Keep track of all imported child forms |
|
| 277 | + * |
|
| 278 | + * @since 2.0.16 |
|
| 279 | + * @param int $form_id |
|
| 280 | + * @param int $parent_form_id |
|
| 281 | + * @param array $child_forms |
|
| 282 | + */ |
|
| 283 | 283 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 284 | 284 | if ( $parent_form_id ) { |
| 285 | 285 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | - * Update the parent_form_id on imported child forms |
|
| 291 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 292 | - * |
|
| 293 | - * @since 2.0.6 |
|
| 294 | - * @param array $imported_forms |
|
| 295 | - * @param array $child_forms |
|
| 296 | - */ |
|
| 290 | + * Update the parent_form_id on imported child forms |
|
| 291 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 292 | + * |
|
| 293 | + * @since 2.0.6 |
|
| 294 | + * @param array $imported_forms |
|
| 295 | + * @param array $child_forms |
|
| 296 | + */ |
|
| 297 | 297 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 298 | 298 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 299 | 299 | |
@@ -307,12 +307,12 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | - * Import all fields for a form |
|
| 310 | + * Import all fields for a form |
|
| 311 | 311 | * |
| 312 | - * @since 2.0.13 |
|
| 313 | - * |
|
| 314 | - * TODO: Cut down on params |
|
| 315 | - */ |
|
| 312 | + * @since 2.0.13 |
|
| 313 | + * |
|
| 314 | + * TODO: Cut down on params |
|
| 315 | + */ |
|
| 316 | 316 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
| 317 | 317 | $in_section = 0; |
| 318 | 318 | |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 409 | - * |
|
| 410 | - * @since 2.0.16 |
|
| 411 | - * @param array $f |
|
| 412 | - * @param array $imported |
|
| 413 | - */ |
|
| 408 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 409 | + * |
|
| 410 | + * @since 2.0.16 |
|
| 411 | + * @param array $f |
|
| 412 | + * @param array $imported |
|
| 413 | + */ |
|
| 414 | 414 | private static function maybe_update_form_select( &$f, $imported ) { |
| 415 | 415 | if ( ! isset( $imported['forms'] ) ) { |
| 416 | 416 | return; |
@@ -462,12 +462,12 @@ discard block |
||
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
| 465 | - * Updates the custom style setting on import |
|
| 466 | - * Convert the post slug to an ID |
|
| 467 | - * |
|
| 468 | - * @since 2.0.19 |
|
| 469 | - * @param array $form |
|
| 470 | - */ |
|
| 465 | + * Updates the custom style setting on import |
|
| 466 | + * Convert the post slug to an ID |
|
| 467 | + * |
|
| 468 | + * @since 2.0.19 |
|
| 469 | + * @param array $form |
|
| 470 | + */ |
|
| 471 | 471 | private static function update_custom_style_setting_on_import( &$form ) { |
| 472 | 472 | if ( ! isset( $form['options']['custom_style'] ) ) { |
| 473 | 473 | return; |
@@ -521,16 +521,16 @@ discard block |
||
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | public static function import_xml_views( $views, $imported ) { |
| 524 | - $imported['posts'] = array(); |
|
| 525 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 524 | + $imported['posts'] = array(); |
|
| 525 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 526 | 526 | |
| 527 | - $post_types = array( |
|
| 528 | - 'frm_display' => 'views', |
|
| 529 | - $form_action_type => 'actions', |
|
| 530 | - 'frm_styles' => 'styles', |
|
| 531 | - ); |
|
| 527 | + $post_types = array( |
|
| 528 | + 'frm_display' => 'views', |
|
| 529 | + $form_action_type => 'actions', |
|
| 530 | + 'frm_styles' => 'styles', |
|
| 531 | + ); |
|
| 532 | 532 | |
| 533 | - foreach ( $views as $item ) { |
|
| 533 | + foreach ( $views as $item ) { |
|
| 534 | 534 | $post = array( |
| 535 | 535 | 'post_title' => (string) $item->title, |
| 536 | 536 | 'post_name' => (string) $item->post_name, |
@@ -549,52 +549,52 @@ discard block |
||
| 549 | 549 | 'post_date' => (string) $item->post_date, |
| 550 | 550 | 'post_date_gmt' => (string) $item->post_date_gmt, |
| 551 | 551 | 'ping_status' => (string) $item->ping_status, |
| 552 | - 'postmeta' => array(), |
|
| 553 | - 'tax_input' => array(), |
|
| 552 | + 'postmeta' => array(), |
|
| 553 | + 'tax_input' => array(), |
|
| 554 | 554 | ); |
| 555 | 555 | |
| 556 | - $old_id = $post['post_id']; |
|
| 556 | + $old_id = $post['post_id']; |
|
| 557 | 557 | self::populate_post( $post, $item, $imported ); |
| 558 | 558 | |
| 559 | 559 | unset( $item ); |
| 560 | 560 | |
| 561 | 561 | $post_id = false; |
| 562 | - if ( $post['post_type'] == $form_action_type ) { |
|
| 563 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 562 | + if ( $post['post_type'] == $form_action_type ) { |
|
| 563 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 564 | 564 | if ( $action_control && is_object( $action_control ) ) { |
| 565 | 565 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 566 | 566 | } |
| 567 | 567 | unset( $action_control ); |
| 568 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 569 | - // Properly encode post content before inserting the post |
|
| 570 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 568 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 569 | + // Properly encode post content before inserting the post |
|
| 570 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 571 | 571 | $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : ''; |
| 572 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 572 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 573 | 573 | |
| 574 | - // Create/update post now |
|
| 575 | - $post_id = wp_insert_post( $post ); |
|
| 574 | + // Create/update post now |
|
| 575 | + $post_id = wp_insert_post( $post ); |
|
| 576 | 576 | self::maybe_update_custom_css( $custom_css ); |
| 577 | - } else { |
|
| 578 | - // Create/update post now |
|
| 579 | - $post_id = wp_insert_post( $post ); |
|
| 580 | - } |
|
| 577 | + } else { |
|
| 578 | + // Create/update post now |
|
| 579 | + $post_id = wp_insert_post( $post ); |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | if ( ! is_numeric( $post_id ) ) { |
| 583 | - continue; |
|
| 584 | - } |
|
| 583 | + continue; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | self::update_postmeta( $post, $post_id ); |
| 587 | 587 | |
| 588 | - $this_type = 'posts'; |
|
| 588 | + $this_type = 'posts'; |
|
| 589 | 589 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
| 590 | 590 | $this_type = $post_types[ $post['post_type'] ]; |
| 591 | - } |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | 593 | if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
| 594 | - $imported['updated'][ $this_type ]++; |
|
| 595 | - } else { |
|
| 596 | - $imported['imported'][ $this_type ]++; |
|
| 597 | - } |
|
| 594 | + $imported['updated'][ $this_type ]++; |
|
| 595 | + } else { |
|
| 596 | + $imported['imported'][ $this_type ]++; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | 599 | $imported['posts'][ (int) $old_id ] = $post_id; |
| 600 | 600 | |
@@ -606,16 +606,16 @@ discard block |
||
| 606 | 606 | self::maybe_update_stylesheet( $imported ); |
| 607 | 607 | |
| 608 | 608 | return $imported; |
| 609 | - } |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | - private static function populate_post( &$post, $item, $imported ) { |
|
| 611 | + private static function populate_post( &$post, $item, $imported ) { |
|
| 612 | 612 | if ( isset( $item->attachment_url ) ) { |
| 613 | 613 | $post['attachment_url'] = (string) $item->attachment_url; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
| 617 | - // update to new form id |
|
| 618 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 617 | + // update to new form id |
|
| 618 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // Don't allow default styles to take over a site's default style |
@@ -631,57 +631,57 @@ discard block |
||
| 631 | 631 | self::populate_taxonomies( $post, $item ); |
| 632 | 632 | |
| 633 | 633 | self::maybe_editing_post( $post ); |
| 634 | - } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 637 | - global $frm_duplicate_ids; |
|
| 636 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 637 | + global $frm_duplicate_ids; |
|
| 638 | 638 | |
| 639 | - $m = array( |
|
| 639 | + $m = array( |
|
| 640 | 640 | 'key' => (string) $meta->meta_key, |
| 641 | 641 | 'value' => (string) $meta->meta_value, |
| 642 | 642 | ); |
| 643 | 643 | |
| 644 | 644 | //switch old form and field ids to new ones |
| 645 | 645 | if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) { |
| 646 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 646 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 647 | 647 | } else { |
| 648 | - $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 648 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 649 | 649 | |
| 650 | 650 | if ( ! empty( $frm_duplicate_ids ) ) { |
| 651 | 651 | |
| 652 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 652 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 653 | 653 | $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
| 654 | - } else if ( $m['key'] == 'frm_options' ) { |
|
| 654 | + } else if ( $m['key'] == 'frm_options' ) { |
|
| 655 | 655 | |
| 656 | 656 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 657 | 657 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
| 658 | 658 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
| 659 | - } |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - $check_dup_array = array(); |
|
| 663 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 664 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 665 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 666 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 667 | - $check_dup_array[] = 'order_by'; |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 672 | - $check_dup_array[] = 'where'; |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - foreach ( $check_dup_array as $check_k ) { |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + $check_dup_array = array(); |
|
| 663 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 664 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 665 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 666 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 667 | + $check_dup_array[] = 'order_by'; |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 672 | + $check_dup_array[] = 'where'; |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + foreach ( $check_dup_array as $check_k ) { |
|
| 676 | 676 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
| 677 | 677 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
| 678 | 678 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
| 679 | - } |
|
| 679 | + } |
|
| 680 | 680 | unset( $mk, $mv ); |
| 681 | - } |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - } |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | if ( ! is_array( $m['value'] ) ) { |
@@ -689,32 +689,32 @@ discard block |
||
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
| 692 | - } |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | - /** |
|
| 695 | - * Add terms to post |
|
| 694 | + /** |
|
| 695 | + * Add terms to post |
|
| 696 | 696 | * |
| 697 | - * @param array $post by reference |
|
| 698 | - * @param object $item The XML object data |
|
| 699 | - */ |
|
| 700 | - private static function populate_taxonomies( &$post, $item ) { |
|
| 697 | + * @param array $post by reference |
|
| 698 | + * @param object $item The XML object data |
|
| 699 | + */ |
|
| 700 | + private static function populate_taxonomies( &$post, $item ) { |
|
| 701 | 701 | foreach ( $item->category as $c ) { |
| 702 | 702 | $att = $c->attributes(); |
| 703 | 703 | if ( ! isset( $att['nicename'] ) ) { |
| 704 | - continue; |
|
| 705 | - } |
|
| 704 | + continue; |
|
| 705 | + } |
|
| 706 | 706 | |
| 707 | - $taxonomy = (string) $att['domain']; |
|
| 707 | + $taxonomy = (string) $att['domain']; |
|
| 708 | 708 | if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
| 709 | - $name = (string) $att['nicename']; |
|
| 709 | + $name = (string) $att['nicename']; |
|
| 710 | 710 | $h_term = get_term_by( 'slug', $name, $taxonomy ); |
| 711 | - if ( $h_term ) { |
|
| 712 | - $name = $h_term->term_id; |
|
| 713 | - } |
|
| 711 | + if ( $h_term ) { |
|
| 712 | + $name = $h_term->term_id; |
|
| 713 | + } |
|
| 714 | 714 | unset( $h_term ); |
| 715 | - } else { |
|
| 716 | - $name = (string) $c; |
|
| 717 | - } |
|
| 715 | + } else { |
|
| 716 | + $name = (string) $c; |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | 719 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
| 720 | 720 | $post['tax_input'][ $taxonomy ] = array(); |
@@ -723,21 +723,21 @@ discard block |
||
| 723 | 723 | $post['tax_input'][ $taxonomy ][] = $name; |
| 724 | 724 | unset( $name ); |
| 725 | 725 | } |
| 726 | - } |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - /** |
|
| 729 | - * Edit post if the key and created time match |
|
| 730 | - */ |
|
| 731 | - private static function maybe_editing_post( &$post ) { |
|
| 728 | + /** |
|
| 729 | + * Edit post if the key and created time match |
|
| 730 | + */ |
|
| 731 | + private static function maybe_editing_post( &$post ) { |
|
| 732 | 732 | $match_by = array( |
| 733 | - 'post_type' => $post['post_type'], |
|
| 734 | - 'name' => $post['post_name'], |
|
| 735 | - 'post_status' => $post['post_status'], |
|
| 736 | - 'posts_per_page' => 1, |
|
| 733 | + 'post_type' => $post['post_type'], |
|
| 734 | + 'name' => $post['post_name'], |
|
| 735 | + 'post_status' => $post['post_status'], |
|
| 736 | + 'posts_per_page' => 1, |
|
| 737 | 737 | ); |
| 738 | 738 | |
| 739 | 739 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 740 | - $match_by['include'] = $post['post_id']; |
|
| 740 | + $match_by['include'] = $post['post_id']; |
|
| 741 | 741 | unset( $match_by['name'] ); |
| 742 | 742 | } |
| 743 | 743 | |
@@ -747,23 +747,23 @@ discard block |
||
| 747 | 747 | // set the id of the post to edit |
| 748 | 748 | $post['ID'] = current( $editing )->ID; |
| 749 | 749 | } |
| 750 | - } |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | - private static function update_postmeta( &$post, $post_id ) { |
|
| 753 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
| 754 | - if ( '_edit_last' == $k ) { |
|
| 752 | + private static function update_postmeta( &$post, $post_id ) { |
|
| 753 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
| 754 | + if ( '_edit_last' == $k ) { |
|
| 755 | 755 | $v = FrmAppHelper::get_user_id_param( $v ); |
| 756 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 757 | - //change the attachment ID |
|
| 756 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 757 | + //change the attachment ID |
|
| 758 | 758 | $field_obj = FrmFieldFactory::get_field_type( 'file' ); |
| 759 | 759 | $v = $field_obj->get_file_id( $v ); |
| 760 | - } |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | 762 | update_post_meta( $post_id, $k, $v ); |
| 763 | 763 | |
| 764 | 764 | unset( $k, $v ); |
| 765 | - } |
|
| 766 | - } |
|
| 765 | + } |
|
| 766 | + } |
|
| 767 | 767 | |
| 768 | 768 | /** |
| 769 | 769 | * If a template includes custom css, let's include it. |
@@ -796,32 +796,32 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - /** |
|
| 800 | - * @param string $message |
|
| 801 | - */ |
|
| 799 | + /** |
|
| 800 | + * @param string $message |
|
| 801 | + */ |
|
| 802 | 802 | public static function parse_message( $result, &$message, &$errors ) { |
| 803 | 803 | if ( is_wp_error( $result ) ) { |
| 804 | - $errors[] = $result->get_error_message(); |
|
| 805 | - } else if ( ! $result ) { |
|
| 806 | - return; |
|
| 807 | - } |
|
| 804 | + $errors[] = $result->get_error_message(); |
|
| 805 | + } else if ( ! $result ) { |
|
| 806 | + return; |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | 809 | if ( ! is_array( $result ) ) { |
| 810 | - $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
|
| 811 | - return; |
|
| 812 | - } |
|
| 810 | + $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) ); |
|
| 811 | + return; |
|
| 812 | + } |
|
| 813 | 813 | |
| 814 | - $t_strings = array( |
|
| 815 | - 'imported' => __( 'Imported', 'formidable' ), |
|
| 816 | - 'updated' => __( 'Updated', 'formidable' ), |
|
| 817 | - ); |
|
| 814 | + $t_strings = array( |
|
| 815 | + 'imported' => __( 'Imported', 'formidable' ), |
|
| 816 | + 'updated' => __( 'Updated', 'formidable' ), |
|
| 817 | + ); |
|
| 818 | 818 | |
| 819 | - $message = '<ul>'; |
|
| 820 | - foreach ( $result as $type => $results ) { |
|
| 819 | + $message = '<ul>'; |
|
| 820 | + foreach ( $result as $type => $results ) { |
|
| 821 | 821 | if ( ! isset( $t_strings[ $type ] ) ) { |
| 822 | - // only print imported and updated |
|
| 823 | - continue; |
|
| 824 | - } |
|
| 822 | + // only print imported and updated |
|
| 823 | + continue; |
|
| 824 | + } |
|
| 825 | 825 | |
| 826 | 826 | $s_message = array(); |
| 827 | 827 | foreach ( $results as $k => $m ) { |
@@ -834,34 +834,34 @@ discard block |
||
| 834 | 834 | $message .= implode( ', ', $s_message ); |
| 835 | 835 | $message .= '</li>'; |
| 836 | 836 | } |
| 837 | - } |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - if ( $message == '<ul>' ) { |
|
| 840 | - $message = ''; |
|
| 841 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 842 | - } else { |
|
| 843 | - $message .= '</ul>'; |
|
| 844 | - } |
|
| 845 | - } |
|
| 839 | + if ( $message == '<ul>' ) { |
|
| 840 | + $message = ''; |
|
| 841 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 842 | + } else { |
|
| 843 | + $message .= '</ul>'; |
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | 846 | |
| 847 | 847 | public static function item_count_message( $m, $type, &$s_message ) { |
| 848 | - if ( ! $m ) { |
|
| 849 | - return; |
|
| 850 | - } |
|
| 851 | - |
|
| 852 | - $strings = array( |
|
| 853 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 854 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 855 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 856 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 857 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 858 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 859 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 860 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 861 | - ); |
|
| 848 | + if ( ! $m ) { |
|
| 849 | + return; |
|
| 850 | + } |
|
| 851 | + |
|
| 852 | + $strings = array( |
|
| 853 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 854 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 855 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 856 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 857 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 858 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 859 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 860 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 861 | + ); |
|
| 862 | 862 | |
| 863 | 863 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
| 864 | - } |
|
| 864 | + } |
|
| 865 | 865 | |
| 866 | 866 | /** |
| 867 | 867 | * Prepare the form options for export |
@@ -933,11 +933,11 @@ discard block |
||
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | /** |
| 936 | - * Compare the default array to the saved values and |
|
| 937 | - * remove if they are the same |
|
| 938 | - * |
|
| 939 | - * @since 3.05.01 |
|
| 940 | - */ |
|
| 936 | + * Compare the default array to the saved values and |
|
| 937 | + * remove if they are the same |
|
| 938 | + * |
|
| 939 | + * @since 3.05.01 |
|
| 940 | + */ |
|
| 941 | 941 | private static function remove_defaults( $defaults, &$saved ) { |
| 942 | 942 | $array_defaults = array_filter( $defaults, 'is_array' ); |
| 943 | 943 | foreach ( $array_defaults as $d => $default ) { |
@@ -951,10 +951,10 @@ discard block |
||
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | /** |
| 954 | - * The line endings may prevent html from being equal when it should |
|
| 955 | - * |
|
| 956 | - * @since 3.05.01 |
|
| 957 | - */ |
|
| 954 | + * The line endings may prevent html from being equal when it should |
|
| 955 | + * |
|
| 956 | + * @since 3.05.01 |
|
| 957 | + */ |
|
| 958 | 958 | private static function remove_default_html( $html_name, $defaults, &$options ) { |
| 959 | 959 | if ( ! isset( $options[ $html_name ] ) || ! isset( $defaults[ $html_name ] ) ) { |
| 960 | 960 | return; |
@@ -983,8 +983,8 @@ discard block |
||
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | if ( is_numeric( $str ) ) { |
| 986 | - return $str; |
|
| 987 | - } |
|
| 986 | + return $str; |
|
| 987 | + } |
|
| 988 | 988 | |
| 989 | 989 | self::remove_invalid_characters_from_xml( $str ); |
| 990 | 990 | |
@@ -1005,54 +1005,54 @@ discard block |
||
| 1005 | 1005 | $str = str_replace( '\x1F', '', $str ); |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 1009 | - // Get post type |
|
| 1010 | - $post_type = FrmFormActionsController::$action_post_type; |
|
| 1008 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 1009 | + // Get post type |
|
| 1010 | + $post_type = FrmFormActionsController::$action_post_type; |
|
| 1011 | 1011 | |
| 1012 | - // Set up imported index, if not set up yet |
|
| 1013 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 1014 | - $imported['imported']['actions'] = 0; |
|
| 1015 | - } |
|
| 1012 | + // Set up imported index, if not set up yet |
|
| 1013 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 1014 | + $imported['imported']['actions'] = 0; |
|
| 1015 | + } |
|
| 1016 | 1016 | |
| 1017 | - // Migrate post settings to action |
|
| 1018 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 1017 | + // Migrate post settings to action |
|
| 1018 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 1019 | 1019 | |
| 1020 | - // Migrate email settings to action |
|
| 1021 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 1022 | - } |
|
| 1020 | + // Migrate email settings to action |
|
| 1021 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 1022 | + } |
|
| 1023 | 1023 | |
| 1024 | - /** |
|
| 1025 | - * Migrate post settings to form action |
|
| 1026 | - * |
|
| 1027 | - * @param string $post_type |
|
| 1028 | - */ |
|
| 1029 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1024 | + /** |
|
| 1025 | + * Migrate post settings to form action |
|
| 1026 | + * |
|
| 1027 | + * @param string $post_type |
|
| 1028 | + */ |
|
| 1029 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1030 | 1030 | if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
| 1031 | - return; |
|
| 1032 | - } |
|
| 1031 | + return; |
|
| 1032 | + } |
|
| 1033 | 1033 | |
| 1034 | - $new_action = array( |
|
| 1035 | - 'post_type' => $post_type, |
|
| 1036 | - 'post_excerpt' => 'wppost', |
|
| 1034 | + $new_action = array( |
|
| 1035 | + 'post_type' => $post_type, |
|
| 1036 | + 'post_excerpt' => 'wppost', |
|
| 1037 | 1037 | 'post_title' => __( 'Create Posts', 'formidable' ), |
| 1038 | - 'menu_order' => $form_id, |
|
| 1039 | - 'post_status' => 'publish', |
|
| 1040 | - 'post_content' => array(), |
|
| 1038 | + 'menu_order' => $form_id, |
|
| 1039 | + 'post_status' => 'publish', |
|
| 1040 | + 'post_content' => array(), |
|
| 1041 | 1041 | 'post_name' => $form_id . '_wppost_1', |
| 1042 | - ); |
|
| 1042 | + ); |
|
| 1043 | 1043 | |
| 1044 | 1044 | $post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' ); |
| 1045 | 1045 | |
| 1046 | - foreach ( $post_settings as $post_setting ) { |
|
| 1046 | + foreach ( $post_settings as $post_setting ) { |
|
| 1047 | 1047 | if ( isset( $form_options[ $post_setting ] ) ) { |
| 1048 | 1048 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
| 1049 | - } |
|
| 1049 | + } |
|
| 1050 | 1050 | unset( $post_setting ); |
| 1051 | - } |
|
| 1051 | + } |
|
| 1052 | 1052 | |
| 1053 | 1053 | $new_action['event'] = array( 'create', 'update' ); |
| 1054 | 1054 | |
| 1055 | - if ( $switch ) { |
|
| 1055 | + if ( $switch ) { |
|
| 1056 | 1056 | // Fields with string or int saved |
| 1057 | 1057 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
| 1058 | 1058 | |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
| 1061 | 1061 | |
| 1062 | 1062 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 1063 | - } |
|
| 1063 | + } |
|
| 1064 | 1064 | $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
| 1065 | 1065 | |
| 1066 | 1066 | $exists = get_posts( |
@@ -1072,12 +1072,12 @@ discard block |
||
| 1072 | 1072 | ) |
| 1073 | 1073 | ); |
| 1074 | 1074 | |
| 1075 | - if ( ! $exists ) { |
|
| 1075 | + if ( ! $exists ) { |
|
| 1076 | 1076 | // this isn't an email, but we need to use a class that will always be included |
| 1077 | 1077 | FrmDb::save_json_post( $new_action ); |
| 1078 | - $imported['imported']['actions']++; |
|
| 1079 | - } |
|
| 1080 | - } |
|
| 1078 | + $imported['imported']['actions']++; |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | 1082 | /** |
| 1083 | 1083 | * Switch old field IDs for new field IDs in emails and post |
@@ -1090,71 +1090,71 @@ discard block |
||
| 1090 | 1090 | * @return string $post_content - new field IDs |
| 1091 | 1091 | */ |
| 1092 | 1092 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
| 1093 | - global $frm_duplicate_ids; |
|
| 1093 | + global $frm_duplicate_ids; |
|
| 1094 | 1094 | |
| 1095 | - // If there aren't IDs that were switched, end now |
|
| 1096 | - if ( ! $frm_duplicate_ids ) { |
|
| 1097 | - return; |
|
| 1098 | - } |
|
| 1095 | + // If there aren't IDs that were switched, end now |
|
| 1096 | + if ( ! $frm_duplicate_ids ) { |
|
| 1097 | + return; |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | - // Get old IDs |
|
| 1101 | - $old = array_keys( $frm_duplicate_ids ); |
|
| 1100 | + // Get old IDs |
|
| 1101 | + $old = array_keys( $frm_duplicate_ids ); |
|
| 1102 | 1102 | |
| 1103 | - // Get new IDs |
|
| 1104 | - $new = array_values( $frm_duplicate_ids ); |
|
| 1103 | + // Get new IDs |
|
| 1104 | + $new = array_values( $frm_duplicate_ids ); |
|
| 1105 | 1105 | |
| 1106 | - // Do a str_replace with each item to set the new IDs |
|
| 1107 | - foreach ( $post_content as $key => $setting ) { |
|
| 1108 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1109 | - // Replace old IDs with new IDs |
|
| 1106 | + // Do a str_replace with each item to set the new IDs |
|
| 1107 | + foreach ( $post_content as $key => $setting ) { |
|
| 1108 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1109 | + // Replace old IDs with new IDs |
|
| 1110 | 1110 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
| 1111 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1112 | - foreach ( $setting as $k => $val ) { |
|
| 1113 | - // Replace old IDs with new IDs |
|
| 1111 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1112 | + foreach ( $setting as $k => $val ) { |
|
| 1113 | + // Replace old IDs with new IDs |
|
| 1114 | 1114 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
| 1115 | - } |
|
| 1116 | - } |
|
| 1117 | - unset( $key, $setting ); |
|
| 1118 | - } |
|
| 1119 | - return $post_content; |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1123 | - // No old notifications or autoresponders to carry over |
|
| 1115 | + } |
|
| 1116 | + } |
|
| 1117 | + unset( $key, $setting ); |
|
| 1118 | + } |
|
| 1119 | + return $post_content; |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1123 | + // No old notifications or autoresponders to carry over |
|
| 1124 | 1124 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
| 1125 | - return; |
|
| 1126 | - } |
|
| 1125 | + return; |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | - // Initialize notifications array |
|
| 1129 | - $notifications = array(); |
|
| 1128 | + // Initialize notifications array |
|
| 1129 | + $notifications = array(); |
|
| 1130 | 1130 | |
| 1131 | - // Migrate regular notifications |
|
| 1132 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1131 | + // Migrate regular notifications |
|
| 1132 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1133 | 1133 | |
| 1134 | - // Migrate autoresponders |
|
| 1135 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1134 | + // Migrate autoresponders |
|
| 1135 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1136 | 1136 | |
| 1137 | - if ( empty( $notifications ) ) { |
|
| 1138 | - return; |
|
| 1139 | - } |
|
| 1137 | + if ( empty( $notifications ) ) { |
|
| 1138 | + return; |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | - foreach ( $notifications as $new_notification ) { |
|
| 1142 | - $new_notification['post_type'] = $post_type; |
|
| 1143 | - $new_notification['post_excerpt'] = 'email'; |
|
| 1141 | + foreach ( $notifications as $new_notification ) { |
|
| 1142 | + $new_notification['post_type'] = $post_type; |
|
| 1143 | + $new_notification['post_excerpt'] = 'email'; |
|
| 1144 | 1144 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
| 1145 | - $new_notification['menu_order'] = $form_id; |
|
| 1146 | - $new_notification['post_status'] = 'publish'; |
|
| 1145 | + $new_notification['menu_order'] = $form_id; |
|
| 1146 | + $new_notification['post_status'] = 'publish'; |
|
| 1147 | 1147 | |
| 1148 | - // Switch field IDs and keys, if needed |
|
| 1149 | - if ( $switch ) { |
|
| 1148 | + // Switch field IDs and keys, if needed |
|
| 1149 | + if ( $switch ) { |
|
| 1150 | 1150 | |
| 1151 | 1151 | // Switch field IDs in email conditional logic |
| 1152 | 1152 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
| 1153 | 1153 | |
| 1154 | 1154 | // Switch all other field IDs in email |
| 1155 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1156 | - } |
|
| 1157 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1155 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1156 | + } |
|
| 1157 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1158 | 1158 | |
| 1159 | 1159 | $exists = get_posts( |
| 1160 | 1160 | array( |
@@ -1167,13 +1167,13 @@ discard block |
||
| 1167 | 1167 | |
| 1168 | 1168 | if ( empty( $exists ) ) { |
| 1169 | 1169 | FrmDb::save_json_post( $new_notification ); |
| 1170 | - $imported['imported']['actions']++; |
|
| 1171 | - } |
|
| 1170 | + $imported['imported']['actions']++; |
|
| 1171 | + } |
|
| 1172 | 1172 | unset( $new_notification ); |
| 1173 | - } |
|
| 1173 | + } |
|
| 1174 | 1174 | |
| 1175 | 1175 | self::remove_deprecated_notification_settings( $form_id, $form_options ); |
| 1176 | - } |
|
| 1176 | + } |
|
| 1177 | 1177 | |
| 1178 | 1178 | /** |
| 1179 | 1179 | * Remove deprecated notification settings after migration |
@@ -1193,17 +1193,17 @@ discard block |
||
| 1193 | 1193 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1197 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1198 | - // add old settings into notification array |
|
| 1196 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1197 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1198 | + // add old settings into notification array |
|
| 1199 | 1199 | $form_options['notification'] = array( 0 => $form_options ); |
| 1200 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1201 | - // make sure it's in the correct format |
|
| 1200 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1201 | + // make sure it's in the correct format |
|
| 1202 | 1202 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 1203 | - } |
|
| 1203 | + } |
|
| 1204 | 1204 | |
| 1205 | 1205 | if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
| 1206 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1206 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1207 | 1207 | |
| 1208 | 1208 | $atts = array( |
| 1209 | 1209 | 'email_to' => '', |
@@ -1214,119 +1214,119 @@ discard block |
||
| 1214 | 1214 | 'email_key' => $email_key, |
| 1215 | 1215 | ); |
| 1216 | 1216 | |
| 1217 | - // Format the email data |
|
| 1218 | - self::format_email_data( $atts, $notification ); |
|
| 1217 | + // Format the email data |
|
| 1218 | + self::format_email_data( $atts, $notification ); |
|
| 1219 | 1219 | |
| 1220 | 1220 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
| 1221 | 1221 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - // Setup the new notification |
|
| 1225 | - $new_notification = array(); |
|
| 1226 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1224 | + // Setup the new notification |
|
| 1225 | + $new_notification = array(); |
|
| 1226 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1227 | 1227 | |
| 1228 | - $notifications[] = $new_notification; |
|
| 1229 | - } |
|
| 1230 | - } |
|
| 1231 | - } |
|
| 1228 | + $notifications[] = $new_notification; |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | + } |
|
| 1232 | 1232 | |
| 1233 | - private static function format_email_data( &$atts, $notification ) { |
|
| 1234 | - // Format email_to |
|
| 1235 | - self::format_email_to_data( $atts, $notification ); |
|
| 1233 | + private static function format_email_data( &$atts, $notification ) { |
|
| 1234 | + // Format email_to |
|
| 1235 | + self::format_email_to_data( $atts, $notification ); |
|
| 1236 | 1236 | |
| 1237 | - // Format the reply to email and name |
|
| 1237 | + // Format the reply to email and name |
|
| 1238 | 1238 | $reply_fields = array( |
| 1239 | 1239 | 'reply_to' => '', |
| 1240 | 1240 | 'reply_to_name' => '', |
| 1241 | 1241 | ); |
| 1242 | - foreach ( $reply_fields as $f => $val ) { |
|
| 1242 | + foreach ( $reply_fields as $f => $val ) { |
|
| 1243 | 1243 | if ( isset( $notification[ $f ] ) ) { |
| 1244 | 1244 | $atts[ $f ] = $notification[ $f ]; |
| 1245 | 1245 | if ( 'custom' == $notification[ $f ] ) { |
| 1246 | 1246 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
| 1247 | 1247 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
| 1248 | 1248 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
| 1249 | - } |
|
| 1250 | - } |
|
| 1251 | - unset( $f, $val ); |
|
| 1252 | - } |
|
| 1249 | + } |
|
| 1250 | + } |
|
| 1251 | + unset( $f, $val ); |
|
| 1252 | + } |
|
| 1253 | 1253 | |
| 1254 | - // Format event |
|
| 1254 | + // Format event |
|
| 1255 | 1255 | $atts['event'] = array( 'create' ); |
| 1256 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1257 | - $atts['event'][] = 'update'; |
|
| 1256 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1257 | + $atts['event'][] = 'update'; |
|
| 1258 | 1258 | } elseif ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
| 1259 | 1259 | $atts['event'] = array( 'update' ); |
| 1260 | - } |
|
| 1261 | - } |
|
| 1260 | + } |
|
| 1261 | + } |
|
| 1262 | 1262 | |
| 1263 | - private static function format_email_to_data( &$atts, $notification ) { |
|
| 1264 | - if ( isset( $notification['email_to'] ) ) { |
|
| 1263 | + private static function format_email_to_data( &$atts, $notification ) { |
|
| 1264 | + if ( isset( $notification['email_to'] ) ) { |
|
| 1265 | 1265 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
| 1266 | - } else { |
|
| 1267 | - $atts['email_to'] = array(); |
|
| 1268 | - } |
|
| 1266 | + } else { |
|
| 1267 | + $atts['email_to'] = array(); |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | - if ( isset( $notification['also_email_to'] ) ) { |
|
| 1271 | - $email_fields = (array) $notification['also_email_to']; |
|
| 1272 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1273 | - unset( $email_fields ); |
|
| 1274 | - } |
|
| 1270 | + if ( isset( $notification['also_email_to'] ) ) { |
|
| 1271 | + $email_fields = (array) $notification['also_email_to']; |
|
| 1272 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1273 | + unset( $email_fields ); |
|
| 1274 | + } |
|
| 1275 | 1275 | |
| 1276 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1276 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1277 | 1277 | |
| 1278 | - if ( is_numeric( $email_field ) ) { |
|
| 1278 | + if ( is_numeric( $email_field ) ) { |
|
| 1279 | 1279 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
| 1280 | - } |
|
| 1280 | + } |
|
| 1281 | 1281 | |
| 1282 | 1282 | if ( strpos( $email_field, '|' ) ) { |
| 1283 | - $email_opt = explode( '|', $email_field ); |
|
| 1284 | - if ( isset( $email_opt[0] ) ) { |
|
| 1283 | + $email_opt = explode( '|', $email_field ); |
|
| 1284 | + if ( isset( $email_opt[0] ) ) { |
|
| 1285 | 1285 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
| 1286 | - } |
|
| 1287 | - unset( $email_opt ); |
|
| 1288 | - } |
|
| 1289 | - } |
|
| 1286 | + } |
|
| 1287 | + unset( $email_opt ); |
|
| 1288 | + } |
|
| 1289 | + } |
|
| 1290 | 1290 | $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
| 1291 | - } |
|
| 1292 | - |
|
| 1293 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1294 | - // Set up new notification |
|
| 1295 | - $new_notification = array( |
|
| 1296 | - 'post_content' => array( |
|
| 1297 | - 'email_to' => $atts['email_to'], |
|
| 1298 | - 'event' => $atts['event'], |
|
| 1299 | - ), |
|
| 1291 | + } |
|
| 1292 | + |
|
| 1293 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1294 | + // Set up new notification |
|
| 1295 | + $new_notification = array( |
|
| 1296 | + 'post_content' => array( |
|
| 1297 | + 'email_to' => $atts['email_to'], |
|
| 1298 | + 'event' => $atts['event'], |
|
| 1299 | + ), |
|
| 1300 | 1300 | 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
| 1301 | - ); |
|
| 1301 | + ); |
|
| 1302 | 1302 | |
| 1303 | - // Add more fields to the new notification |
|
| 1304 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1305 | - foreach ( $add_fields as $add_field ) { |
|
| 1303 | + // Add more fields to the new notification |
|
| 1304 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1305 | + foreach ( $add_fields as $add_field ) { |
|
| 1306 | 1306 | if ( isset( $notification[ $add_field ] ) ) { |
| 1307 | 1307 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
| 1308 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1308 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1309 | 1309 | $new_notification['post_content'][ $add_field ] = 0; |
| 1310 | - } else { |
|
| 1310 | + } else { |
|
| 1311 | 1311 | $new_notification['post_content'][ $add_field ] = ''; |
| 1312 | - } |
|
| 1313 | - unset( $add_field ); |
|
| 1314 | - } |
|
| 1312 | + } |
|
| 1313 | + unset( $add_field ); |
|
| 1314 | + } |
|
| 1315 | 1315 | |
| 1316 | 1316 | // Set reply to |
| 1317 | 1317 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
| 1318 | 1318 | |
| 1319 | - // Set from |
|
| 1319 | + // Set from |
|
| 1320 | 1320 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
| 1321 | 1321 | $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
| 1322 | - } |
|
| 1323 | - } |
|
| 1322 | + } |
|
| 1323 | + } |
|
| 1324 | 1324 | |
| 1325 | 1325 | /** |
| 1326 | - * Switch field IDs in pre-2.0 email conditional logic |
|
| 1327 | - * |
|
| 1328 | - * @param $post_content array, pass by reference |
|
| 1329 | - */ |
|
| 1326 | + * Switch field IDs in pre-2.0 email conditional logic |
|
| 1327 | + * |
|
| 1328 | + * @param $post_content array, pass by reference |
|
| 1329 | + */ |
|
| 1330 | 1330 | private static function switch_email_contition_field_ids( &$post_content ) { |
| 1331 | 1331 | // Switch field IDs in conditional logic |
| 1332 | 1332 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | } |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1342 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1343 | 1343 | if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
| 1344 | 1344 | // migrate autoresponder |
| 1345 | 1345 | |
@@ -1355,8 +1355,8 @@ discard block |
||
| 1355 | 1355 | $email_field = '[' . $email_field . ']'; |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | - $notification = $form_options; |
|
| 1359 | - $new_notification2 = array( |
|
| 1358 | + $notification = $form_options; |
|
| 1359 | + $new_notification2 = array( |
|
| 1360 | 1360 | 'post_content' => array( |
| 1361 | 1361 | 'email_message' => $notification['ar_email_message'], |
| 1362 | 1362 | 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | 'inc_user_info' => 0, |
| 1366 | 1366 | ), |
| 1367 | 1367 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
| 1368 | - ); |
|
| 1368 | + ); |
|
| 1369 | 1369 | |
| 1370 | 1370 | $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
| 1371 | 1371 | $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
@@ -1378,9 +1378,9 @@ discard block |
||
| 1378 | 1378 | $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | - $notifications[] = $new_notification2; |
|
| 1382 | - unset( $new_notification2 ); |
|
| 1383 | - } |
|
| 1384 | - } |
|
| 1381 | + $notifications[] = $new_notification2; |
|
| 1382 | + unset( $new_notification2 ); |
|
| 1383 | + } |
|
| 1384 | + } |
|
| 1385 | 1385 | } |
| 1386 | 1386 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | if ( $term && is_array( $term ) ) { |
| 105 | - $imported['imported']['terms']++; |
|
| 106 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
| 105 | + $imported['imported']['terms'] ++; |
|
| 106 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | unset( $term, $t ); |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | } else { |
| 153 | 153 | $form_id = FrmForm::create( $form ); |
| 154 | 154 | if ( $form_id ) { |
| 155 | - $imported['imported']['forms']++; |
|
| 155 | + $imported['imported']['forms'] ++; |
|
| 156 | 156 | // Keep track of whether this specific form was updated or not |
| 157 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
| 157 | + $imported['form_status'][$form_id] = 'imported'; |
|
| 158 | 158 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | // Update field ids/keys to new ones |
| 167 | 167 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 168 | 168 | |
| 169 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
| 169 | + $imported['forms'][(int) $item->id] = $form_id; |
|
| 170 | 170 | |
| 171 | 171 | // Send pre 2.0 form options through function that creates actions |
| 172 | 172 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
@@ -218,17 +218,17 @@ discard block |
||
| 218 | 218 | private static function update_form( $this_form, $form, &$imported ) { |
| 219 | 219 | $form_id = $this_form->id; |
| 220 | 220 | FrmForm::update( $form_id, $form ); |
| 221 | - $imported['updated']['forms']++; |
|
| 221 | + $imported['updated']['forms'] ++; |
|
| 222 | 222 | // Keep track of whether this specific form was updated or not |
| 223 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
| 223 | + $imported['form_status'][$form_id] = 'updated'; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | private static function get_form_fields( $form_id ) { |
| 227 | 227 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
| 228 | 228 | $old_fields = array(); |
| 229 | 229 | foreach ( $form_fields as $f ) { |
| 230 | - $old_fields[ $f->id ] = $f; |
|
| 231 | - $old_fields[ $f->field_key ] = $f->id; |
|
| 230 | + $old_fields[$f->id] = $f; |
|
| 231 | + $old_fields[$f->field_key] = $f->id; |
|
| 232 | 232 | unset( $f ); |
| 233 | 233 | } |
| 234 | 234 | $form_fields = $old_fields; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 284 | 284 | if ( $parent_form_id ) { |
| 285 | - $child_forms[ $form_id ] = $parent_form_id; |
|
| 285 | + $child_forms[$form_id] = $parent_form_id; |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 298 | 298 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 299 | 299 | |
| 300 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
| 300 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
| 301 | 301 | // Update all children with this old parent_form_id |
| 302 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
| 302 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
| 303 | 303 | |
| 304 | 304 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
| 305 | 305 | } |
@@ -334,25 +334,25 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | if ( ! empty( $this_form ) ) { |
| 336 | 336 | // check for field to edit by field id |
| 337 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
| 337 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
| 338 | 338 | FrmField::update( $f['id'], $f ); |
| 339 | - $imported['updated']['fields']++; |
|
| 339 | + $imported['updated']['fields'] ++; |
|
| 340 | 340 | |
| 341 | - unset( $form_fields[ $f['id'] ] ); |
|
| 341 | + unset( $form_fields[$f['id']] ); |
|
| 342 | 342 | |
| 343 | 343 | //unset old field key |
| 344 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 345 | - unset( $form_fields[ $f['field_key'] ] ); |
|
| 344 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 345 | + unset( $form_fields[$f['field_key']] ); |
|
| 346 | 346 | } |
| 347 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 347 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 348 | 348 | // check for field to edit by field key |
| 349 | 349 | unset( $f['id'] ); |
| 350 | 350 | |
| 351 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
| 352 | - $imported['updated']['fields']++; |
|
| 351 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
| 352 | + $imported['updated']['fields'] ++; |
|
| 353 | 353 | |
| 354 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
| 355 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
| 354 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
| 355 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
| 356 | 356 | } else { |
| 357 | 357 | // if no matching field id or key in this form, create the field |
| 358 | 358 | self::create_imported_field( $f, $imported ); |
@@ -419,8 +419,8 @@ discard block |
||
| 419 | 419 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
| 420 | 420 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
| 421 | 421 | $form_select = (int) $f['field_options']['form_select']; |
| 422 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
| 423 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
| 422 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
| 423 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -440,8 +440,8 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) { |
| 442 | 442 | $old_form = $f['field_options']['get_values_form']; |
| 443 | - if ( isset( $imported['forms'][ $old_form ] ) ) { |
|
| 444 | - $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ]; |
|
| 443 | + if ( isset( $imported['forms'][$old_form] ) ) { |
|
| 444 | + $f['field_options']['get_values_form'] = $imported['forms'][$old_form]; |
|
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | private static function create_imported_field( $f, &$imported ) { |
| 457 | 457 | $new_id = FrmField::create( $f ); |
| 458 | 458 | if ( $new_id != false ) { |
| 459 | - $imported['imported']['fields']++; |
|
| 459 | + $imported['imported']['fields'] ++; |
|
| 460 | 460 | do_action( 'frm_after_field_is_imported', $f, $new_id ); |
| 461 | 461 | } |
| 462 | 462 | } |
@@ -586,17 +586,17 @@ discard block |
||
| 586 | 586 | self::update_postmeta( $post, $post_id ); |
| 587 | 587 | |
| 588 | 588 | $this_type = 'posts'; |
| 589 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
| 590 | - $this_type = $post_types[ $post['post_type'] ]; |
|
| 589 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
| 590 | + $this_type = $post_types[$post['post_type']]; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
| 594 | - $imported['updated'][ $this_type ]++; |
|
| 594 | + $imported['updated'][$this_type] ++; |
|
| 595 | 595 | } else { |
| 596 | - $imported['imported'][ $this_type ]++; |
|
| 596 | + $imported['imported'][$this_type] ++; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
| 599 | + $imported['posts'][(int) $old_id] = $post_id; |
|
| 600 | 600 | |
| 601 | 601 | do_action( 'frm_after_import_view', $post_id, $post ); |
| 602 | 602 | |
@@ -613,9 +613,9 @@ discard block |
||
| 613 | 613 | $post['attachment_url'] = (string) $item->attachment_url; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
| 616 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
| 617 | 617 | // update to new form id |
| 618 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 618 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // Don't allow default styles to take over a site's default style |
@@ -642,8 +642,8 @@ discard block |
||
| 642 | 642 | ); |
| 643 | 643 | |
| 644 | 644 | //switch old form and field ids to new ones |
| 645 | - if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][ (int) $m['value'] ] ) ) { |
|
| 646 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 645 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
| 646 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
| 647 | 647 | } else { |
| 648 | 648 | $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
| 649 | 649 | |
@@ -654,15 +654,15 @@ discard block |
||
| 654 | 654 | } else if ( $m['key'] == 'frm_options' ) { |
| 655 | 655 | |
| 656 | 656 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 657 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
| 658 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
| 657 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
| 658 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | $check_dup_array = array(); |
| 663 | 663 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
| 664 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 665 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 664 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
| 665 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
| 666 | 666 | } else if ( is_array( $m['value']['order_by'] ) ) { |
| 667 | 667 | $check_dup_array[] = 'order_by'; |
| 668 | 668 | } |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | foreach ( $check_dup_array as $check_k ) { |
| 676 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
| 677 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
| 678 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
| 676 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
| 677 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
| 678 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
| 679 | 679 | } |
| 680 | 680 | unset( $mk, $mv ); |
| 681 | 681 | } |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
| 691 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
@@ -716,11 +716,11 @@ discard block |
||
| 716 | 716 | $name = (string) $c; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
| 720 | - $post['tax_input'][ $taxonomy ] = array(); |
|
| 719 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
| 720 | + $post['tax_input'][$taxonomy] = array(); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
| 723 | + $post['tax_input'][$taxonomy][] = $name; |
|
| 724 | 724 | unset( $name ); |
| 725 | 725 | } |
| 726 | 726 | } |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | $message = '<ul>'; |
| 820 | 820 | foreach ( $result as $type => $results ) { |
| 821 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
| 821 | + if ( ! isset( $t_strings[$type] ) ) { |
|
| 822 | 822 | // only print imported and updated |
| 823 | 823 | continue; |
| 824 | 824 | } |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | if ( ! empty( $s_message ) ) { |
| 833 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
| 833 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
| 834 | 834 | $message .= implode( ', ', $s_message ); |
| 835 | 835 | $message .= '</li>'; |
| 836 | 836 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
| 861 | 861 | ); |
| 862 | 862 | |
| 863 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 863 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -942,10 +942,10 @@ discard block |
||
| 942 | 942 | $array_defaults = array_filter( $defaults, 'is_array' ); |
| 943 | 943 | foreach ( $array_defaults as $d => $default ) { |
| 944 | 944 | // compare array defaults |
| 945 | - if ( $default == $saved[ $d ] ) { |
|
| 946 | - unset( $saved[ $d ] ); |
|
| 945 | + if ( $default == $saved[$d] ) { |
|
| 946 | + unset( $saved[$d] ); |
|
| 947 | 947 | } |
| 948 | - unset( $defaults[ $d ] ); |
|
| 948 | + unset( $defaults[$d] ); |
|
| 949 | 949 | } |
| 950 | 950 | $saved = array_diff_assoc( (array) $saved, $defaults ); |
| 951 | 951 | } |
@@ -956,21 +956,21 @@ discard block |
||
| 956 | 956 | * @since 3.05.01 |
| 957 | 957 | */ |
| 958 | 958 | private static function remove_default_html( $html_name, $defaults, &$options ) { |
| 959 | - if ( ! isset( $options[ $html_name ] ) || ! isset( $defaults[ $html_name ] ) ) { |
|
| 959 | + if ( ! isset( $options[$html_name] ) || ! isset( $defaults[$html_name] ) ) { |
|
| 960 | 960 | return; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - $old_html = str_replace( "\r\n", "\n", $options[ $html_name ] ); |
|
| 964 | - $default_html = $defaults[ $html_name ]; |
|
| 963 | + $old_html = str_replace( "\r\n", "\n", $options[$html_name] ); |
|
| 964 | + $default_html = $defaults[$html_name]; |
|
| 965 | 965 | if ( $old_html == $default_html ) { |
| 966 | - unset( $options[ $html_name ] ); |
|
| 966 | + unset( $options[$html_name] ); |
|
| 967 | 967 | return; |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | // Account for some of the older field default HTML. |
| 971 | 971 | $default_html = str_replace( ' id="frm_desc_field_[key]"', '', $default_html ); |
| 972 | 972 | if ( $old_html == $default_html ) { |
| 973 | - unset( $options[ $html_name ] ); |
|
| 973 | + unset( $options[$html_name] ); |
|
| 974 | 974 | } |
| 975 | 975 | } |
| 976 | 976 | |
@@ -1044,8 +1044,8 @@ discard block |
||
| 1044 | 1044 | $post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' ); |
| 1045 | 1045 | |
| 1046 | 1046 | foreach ( $post_settings as $post_setting ) { |
| 1047 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
| 1048 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
| 1047 | + if ( isset( $form_options[$post_setting] ) ) { |
|
| 1048 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | unset( $post_setting ); |
| 1051 | 1051 | } |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | if ( ! $exists ) { |
| 1076 | 1076 | // this isn't an email, but we need to use a class that will always be included |
| 1077 | 1077 | FrmDb::save_json_post( $new_action ); |
| 1078 | - $imported['imported']['actions']++; |
|
| 1078 | + $imported['imported']['actions'] ++; |
|
| 1079 | 1079 | } |
| 1080 | 1080 | } |
| 1081 | 1081 | |
@@ -1107,11 +1107,11 @@ discard block |
||
| 1107 | 1107 | foreach ( $post_content as $key => $setting ) { |
| 1108 | 1108 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
| 1109 | 1109 | // Replace old IDs with new IDs |
| 1110 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
| 1110 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
| 1111 | 1111 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
| 1112 | 1112 | foreach ( $setting as $k => $val ) { |
| 1113 | 1113 | // Replace old IDs with new IDs |
| 1114 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
| 1114 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | } |
| 1117 | 1117 | unset( $key, $setting ); |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | foreach ( $notifications as $new_notification ) { |
| 1142 | 1142 | $new_notification['post_type'] = $post_type; |
| 1143 | 1143 | $new_notification['post_excerpt'] = 'email'; |
| 1144 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1144 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1145 | 1145 | $new_notification['menu_order'] = $form_id; |
| 1146 | 1146 | $new_notification['post_status'] = 'publish'; |
| 1147 | 1147 | |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | // Switch all other field IDs in email |
| 1155 | 1155 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
| 1156 | 1156 | } |
| 1157 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1157 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1158 | 1158 | |
| 1159 | 1159 | $exists = get_posts( |
| 1160 | 1160 | array( |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | |
| 1168 | 1168 | if ( empty( $exists ) ) { |
| 1169 | 1169 | FrmDb::save_json_post( $new_notification ); |
| 1170 | - $imported['imported']['actions']++; |
|
| 1170 | + $imported['imported']['actions'] ++; |
|
| 1171 | 1171 | } |
| 1172 | 1172 | unset( $new_notification ); |
| 1173 | 1173 | } |
@@ -1186,8 +1186,8 @@ discard block |
||
| 1186 | 1186 | private static function remove_deprecated_notification_settings( $form_id, $form_options ) { |
| 1187 | 1187 | $delete_settings = array( 'notification', 'autoresponder', 'email_to' ); |
| 1188 | 1188 | foreach ( $delete_settings as $index ) { |
| 1189 | - if ( isset( $form_options[ $index ] ) ) { |
|
| 1190 | - unset( $form_options[ $index ] ); |
|
| 1189 | + if ( isset( $form_options[$index] ) ) { |
|
| 1190 | + unset( $form_options[$index] ); |
|
| 1191 | 1191 | } |
| 1192 | 1192 | } |
| 1193 | 1193 | FrmForm::update( $form_id, array( 'options' => $form_options ) ); |
@@ -1240,12 +1240,12 @@ discard block |
||
| 1240 | 1240 | 'reply_to_name' => '', |
| 1241 | 1241 | ); |
| 1242 | 1242 | foreach ( $reply_fields as $f => $val ) { |
| 1243 | - if ( isset( $notification[ $f ] ) ) { |
|
| 1244 | - $atts[ $f ] = $notification[ $f ]; |
|
| 1245 | - if ( 'custom' == $notification[ $f ] ) { |
|
| 1246 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
| 1247 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
| 1248 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
| 1243 | + if ( isset( $notification[$f] ) ) { |
|
| 1244 | + $atts[$f] = $notification[$f]; |
|
| 1245 | + if ( 'custom' == $notification[$f] ) { |
|
| 1246 | + $atts[$f] = $notification['cust_' . $f]; |
|
| 1247 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
| 1248 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
| 1249 | 1249 | } |
| 1250 | 1250 | } |
| 1251 | 1251 | unset( $f, $val ); |
@@ -1276,13 +1276,13 @@ discard block |
||
| 1276 | 1276 | foreach ( $atts['email_to'] as $key => $email_field ) { |
| 1277 | 1277 | |
| 1278 | 1278 | if ( is_numeric( $email_field ) ) { |
| 1279 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
| 1279 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | if ( strpos( $email_field, '|' ) ) { |
| 1283 | 1283 | $email_opt = explode( '|', $email_field ); |
| 1284 | 1284 | if ( isset( $email_opt[0] ) ) { |
| 1285 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1285 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1286 | 1286 | } |
| 1287 | 1287 | unset( $email_opt ); |
| 1288 | 1288 | } |
@@ -1303,12 +1303,12 @@ discard block |
||
| 1303 | 1303 | // Add more fields to the new notification |
| 1304 | 1304 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
| 1305 | 1305 | foreach ( $add_fields as $add_field ) { |
| 1306 | - if ( isset( $notification[ $add_field ] ) ) { |
|
| 1307 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
| 1306 | + if ( isset( $notification[$add_field] ) ) { |
|
| 1307 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
| 1308 | 1308 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
| 1309 | - $new_notification['post_content'][ $add_field ] = 0; |
|
| 1309 | + $new_notification['post_content'][$add_field] = 0; |
|
| 1310 | 1310 | } else { |
| 1311 | - $new_notification['post_content'][ $add_field ] = ''; |
|
| 1311 | + $new_notification['post_content'][$add_field] = ''; |
|
| 1312 | 1312 | } |
| 1313 | 1313 | unset( $add_field ); |
| 1314 | 1314 | } |
@@ -1332,7 +1332,7 @@ discard block |
||
| 1332 | 1332 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
| 1333 | 1333 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
| 1334 | 1334 | if ( is_numeric( $email_key ) ) { |
| 1335 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1335 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | unset( $email_key, $val ); |
| 1338 | 1338 | } |