@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | echo "\n" . $padding; |
| 12 | 12 | $tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok; |
| 13 | 13 | echo '<' . $tag . '>'; |
| 14 | - self::get_xml_values( $ov, $padding .' ' ); |
|
| 14 | + self::get_xml_values( $ov, $padding . ' ' ); |
|
| 15 | 15 | if ( is_array( $ov ) ) { |
| 16 | 16 | echo "\n" . $padding; |
| 17 | 17 | } |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | 'terms' => array(), |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - unset($defaults); |
|
| 39 | + unset( $defaults ); |
|
| 40 | 40 | |
| 41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 42 | - define('WP_IMPORTING', true); |
|
| 42 | + define( 'WP_IMPORTING', true ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
| 55 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
| 56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
| 68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 69 | 69 | // grab cats, tags, and terms, or forms or posts |
| 70 | - if ( isset($xml->{$item_type} ) ) { |
|
| 70 | + if ( isset( $xml->{$item_type} ) ) { |
|
| 71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
| 72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 73 | 73 | unset( $function_name, $xml->{$item_type} ); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 77 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
| 78 | 78 | |
| 79 | 79 | return $return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
| 83 | 83 | foreach ( $terms as $t ) { |
| 84 | - if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) { |
|
| 84 | + if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | 'description' => (string) $t->term_description, |
| 93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
| 94 | 94 | 'slug' => (string) $t->term_slug, |
| 95 | - )); |
|
| 95 | + ) ); |
|
| 96 | 96 | |
| 97 | 97 | if ( $term && is_array( $term ) ) { |
| 98 | - $imported['imported']['terms']++; |
|
| 99 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
| 98 | + $imported['imported']['terms'] ++; |
|
| 99 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | unset( $term, $t ); |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | 'default_template' => (int) $item->default_template, |
| 140 | 140 | 'editable' => (int) $item->editable, |
| 141 | 141 | 'status' => (string) $item->status, |
| 142 | - 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, |
|
| 143 | - 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)), |
|
| 142 | + 'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0, |
|
| 143 | + 'created_at' => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ), |
|
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - $form['options'] = FrmAppHelper::maybe_json_decode($form['options']); |
|
| 146 | + $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] ); |
|
| 147 | 147 | |
| 148 | 148 | // if template, allow to edit if form keys match, otherwise, creation date must also match |
| 149 | 149 | $edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] ); |
@@ -151,35 +151,35 @@ discard block |
||
| 151 | 151 | $edit_query['created_at'] = $form['created_at']; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form); |
|
| 154 | + $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form ); |
|
| 155 | 155 | |
| 156 | - $this_form = FrmForm::getAll($edit_query, '', 1); |
|
| 157 | - unset($edit_query); |
|
| 156 | + $this_form = FrmForm::getAll( $edit_query, '', 1 ); |
|
| 157 | + unset( $edit_query ); |
|
| 158 | 158 | |
| 159 | 159 | if ( ! empty( $this_form ) ) { |
| 160 | 160 | $old_id = $form_id = $this_form->id; |
| 161 | - FrmForm::update($form_id, $form ); |
|
| 162 | - $imported['updated']['forms']++; |
|
| 161 | + FrmForm::update( $form_id, $form ); |
|
| 162 | + $imported['updated']['forms'] ++; |
|
| 163 | 163 | // Keep track of whether this specific form was updated or not |
| 164 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
| 164 | + $imported['form_status'][$form_id] = 'updated'; |
|
| 165 | 165 | |
| 166 | 166 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
| 167 | 167 | $old_fields = array(); |
| 168 | 168 | foreach ( $form_fields as $f ) { |
| 169 | - $old_fields[ $f->id ] = $f; |
|
| 170 | - $old_fields[ $f->field_key ] = $f->id; |
|
| 171 | - unset($f); |
|
| 169 | + $old_fields[$f->id] = $f; |
|
| 170 | + $old_fields[$f->field_key] = $f->id; |
|
| 171 | + unset( $f ); |
|
| 172 | 172 | } |
| 173 | 173 | $form_fields = $old_fields; |
| 174 | - unset($old_fields); |
|
| 174 | + unset( $old_fields ); |
|
| 175 | 175 | } else { |
| 176 | 176 | $old_id = false; |
| 177 | 177 | //form does not exist, so create it |
| 178 | 178 | $form_id = FrmForm::create( $form ); |
| 179 | 179 | if ( $form_id ) { |
| 180 | - $imported['imported']['forms']++; |
|
| 180 | + $imported['imported']['forms'] ++; |
|
| 181 | 181 | // Keep track of whether this specific form was updated or not |
| 182 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
| 182 | + $imported['form_status'][$form_id] = 'imported'; |
|
| 183 | 183 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -189,23 +189,23 @@ discard block |
||
| 189 | 189 | // Delete any fields attached to this form that were not included in the template |
| 190 | 190 | if ( isset( $form_fields ) && ! empty( $form_fields ) ) { |
| 191 | 191 | foreach ( $form_fields as $field ) { |
| 192 | - if ( is_object($field) ) { |
|
| 193 | - FrmField::destroy($field->id); |
|
| 192 | + if ( is_object( $field ) ) { |
|
| 193 | + FrmField::destroy( $field->id ); |
|
| 194 | 194 | } |
| 195 | - unset($field); |
|
| 195 | + unset( $field ); |
|
| 196 | 196 | } |
| 197 | - unset($form_fields); |
|
| 197 | + unset( $form_fields ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Update field ids/keys to new ones |
| 201 | 201 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 202 | 202 | |
| 203 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
| 203 | + $imported['forms'][(int) $item->id] = $form_id; |
|
| 204 | 204 | |
| 205 | 205 | // Send pre 2.0 form options through function that creates actions |
| 206 | 206 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true ); |
| 207 | 207 | |
| 208 | - unset($form, $item); |
|
| 208 | + unset( $form, $item ); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $regular_forms = array(); |
| 225 | 225 | |
| 226 | 226 | foreach ( $forms as $form ) { |
| 227 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
| 227 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
| 228 | 228 | |
| 229 | 229 | if ( $parent_form_id ) { |
| 230 | 230 | $child_forms[] = $form; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 248 | 248 | if ( $parent_form_id ) { |
| 249 | - $child_forms[ $form_id ] = $parent_form_id; |
|
| 249 | + $child_forms[$form_id] = $parent_form_id; |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 262 | 262 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 263 | 263 | |
| 264 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
| 264 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
| 265 | 265 | // Update all children with this old parent_form_id |
| 266 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
| 266 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
| 267 | 267 | |
| 268 | 268 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
| 269 | 269 | } |
@@ -284,51 +284,51 @@ discard block |
||
| 284 | 284 | 'name' => (string) $field->name, |
| 285 | 285 | 'description' => (string) $field->description, |
| 286 | 286 | 'type' => (string) $field->type, |
| 287 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
| 287 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
| 288 | 288 | 'field_order' => (int) $field->field_order, |
| 289 | 289 | 'form_id' => (int) $form_id, |
| 290 | 290 | 'required' => (int) $field->required, |
| 291 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
| 291 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
| 292 | 292 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
| 293 | 293 | ); |
| 294 | 294 | |
| 295 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
| 295 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
| 296 | 296 | 'text', 'email', 'url', 'textarea', |
| 297 | - 'number','phone', 'date', 'time', |
|
| 297 | + 'number', 'phone', 'date', 'time', |
|
| 298 | 298 | 'hidden', 'password', 'tag', 'image', |
| 299 | - )) ) { |
|
| 300 | - if ( count($f['default_value']) === 1 ) { |
|
| 301 | - $f['default_value'] = '['. reset($f['default_value']) .']'; |
|
| 299 | + ) ) ) { |
|
| 300 | + if ( count( $f['default_value'] ) === 1 ) { |
|
| 301 | + $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
|
| 302 | 302 | } else { |
| 303 | - $f['default_value'] = reset($f['default_value']); |
|
| 303 | + $f['default_value'] = reset( $f['default_value'] ); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $f = apply_filters('frm_duplicated_field', $f); |
|
| 307 | + $f = apply_filters( 'frm_duplicated_field', $f ); |
|
| 308 | 308 | |
| 309 | 309 | self::maybe_update_form_select( $f, $imported ); |
| 310 | 310 | |
| 311 | - if ( ! empty($this_form) ) { |
|
| 311 | + if ( ! empty( $this_form ) ) { |
|
| 312 | 312 | // check for field to edit by field id |
| 313 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
| 313 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
| 314 | 314 | FrmField::update( $f['id'], $f ); |
| 315 | - $imported['updated']['fields']++; |
|
| 315 | + $imported['updated']['fields'] ++; |
|
| 316 | 316 | |
| 317 | - unset( $form_fields[ $f['id'] ] ); |
|
| 317 | + unset( $form_fields[$f['id']] ); |
|
| 318 | 318 | |
| 319 | 319 | //unset old field key |
| 320 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 321 | - unset( $form_fields[ $f['field_key'] ] ); |
|
| 320 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 321 | + unset( $form_fields[$f['field_key']] ); |
|
| 322 | 322 | } |
| 323 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 323 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 324 | 324 | // check for field to edit by field key |
| 325 | - unset($f['id']); |
|
| 325 | + unset( $f['id'] ); |
|
| 326 | 326 | |
| 327 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
| 328 | - $imported['updated']['fields']++; |
|
| 327 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
| 328 | + $imported['updated']['fields'] ++; |
|
| 329 | 329 | |
| 330 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
| 331 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
| 330 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
| 331 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
| 332 | 332 | } else { |
| 333 | 333 | $new_id = FrmField::create( $f ); |
| 334 | 334 | if ( $new_id == false ) { |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // if no matching field id or key in this form, create the field |
| 339 | - $imported['imported']['fields']++; |
|
| 339 | + $imported['imported']['fields'] ++; |
|
| 340 | 340 | } |
| 341 | 341 | } else { |
| 342 | 342 | $new_id = FrmField::create( $f ); |
@@ -344,10 +344,10 @@ discard block |
||
| 344 | 344 | continue; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $imported['imported']['fields']++; |
|
| 347 | + $imported['imported']['fields'] ++; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - unset($field, $new_id); |
|
| 350 | + unset( $field, $new_id ); |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
| 367 | 367 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
| 368 | 368 | $form_select = $f['field_options']['form_select']; |
| 369 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
| 370 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
| 369 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
| 370 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | } |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | 'post_id' => (int) $item->post_id, |
| 396 | 396 | 'post_parent' => (int) $item->post_parent, |
| 397 | 397 | 'menu_order' => (int) $item->menu_order, |
| 398 | - 'post_content' => FrmFieldsHelper::switch_field_ids((string) $item->content), |
|
| 399 | - 'post_excerpt' => FrmFieldsHelper::switch_field_ids((string) $item->excerpt), |
|
| 398 | + 'post_content' => FrmFieldsHelper::switch_field_ids( (string) $item->content ), |
|
| 399 | + 'post_excerpt' => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ), |
|
| 400 | 400 | 'is_sticky' => (string) $item->is_sticky, |
| 401 | 401 | 'comment_status' => (string) $item->comment_status, |
| 402 | 402 | 'post_date' => (string) $item->post_date, |
@@ -407,9 +407,9 @@ discard block |
||
| 407 | 407 | ); |
| 408 | 408 | |
| 409 | 409 | $old_id = $post['post_id']; |
| 410 | - self::populate_post($post, $item, $imported); |
|
| 410 | + self::populate_post( $post, $item, $imported ); |
|
| 411 | 411 | |
| 412 | - unset($item); |
|
| 412 | + unset( $item ); |
|
| 413 | 413 | |
| 414 | 414 | $post_id = false; |
| 415 | 415 | if ( $post['post_type'] == $form_action_type ) { |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if ( $action_control ) { |
| 418 | 418 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 419 | 419 | } |
| 420 | - unset($action_control); |
|
| 420 | + unset( $action_control ); |
|
| 421 | 421 | } else if ( $post['post_type'] == 'frm_styles' ) { |
| 422 | 422 | // Properly encode post content before inserting the post |
| 423 | 423 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -430,26 +430,26 @@ discard block |
||
| 430 | 430 | $post_id = wp_insert_post( $post ); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if ( ! is_numeric($post_id) ) { |
|
| 433 | + if ( ! is_numeric( $post_id ) ) { |
|
| 434 | 434 | continue; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - self::update_postmeta($post, $post_id); |
|
| 437 | + self::update_postmeta( $post, $post_id ); |
|
| 438 | 438 | |
| 439 | 439 | $this_type = 'posts'; |
| 440 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
| 441 | - $this_type = $post_types[ $post['post_type'] ]; |
|
| 440 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
| 441 | + $this_type = $post_types[$post['post_type']]; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 445 | - $imported['updated'][ $this_type ]++; |
|
| 444 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
| 445 | + $imported['updated'][$this_type] ++; |
|
| 446 | 446 | } else { |
| 447 | - $imported['imported'][ $this_type ]++; |
|
| 447 | + $imported['imported'][$this_type] ++; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - unset($post); |
|
| 450 | + unset( $post ); |
|
| 451 | 451 | |
| 452 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
| 452 | + $imported['posts'][(int) $old_id] = $post_id; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | self::maybe_update_stylesheet( $imported ); |
@@ -458,23 +458,23 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | private static function populate_post( &$post, $item, $imported ) { |
| 461 | - if ( isset($item->attachment_url) ) { |
|
| 461 | + if ( isset( $item->attachment_url ) ) { |
|
| 462 | 462 | $post['attachment_url'] = (string) $item->attachment_url; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
| 465 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
| 466 | 466 | // update to new form id |
| 467 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 467 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | foreach ( $item->postmeta as $meta ) { |
| 471 | - self::populate_postmeta($post, $meta, $imported); |
|
| 472 | - unset($meta); |
|
| 471 | + self::populate_postmeta( $post, $meta, $imported ); |
|
| 472 | + unset( $meta ); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - self::populate_taxonomies($post, $item); |
|
| 475 | + self::populate_taxonomies( $post, $item ); |
|
| 476 | 476 | |
| 477 | - self::maybe_editing_post($post); |
|
| 477 | + self::maybe_editing_post( $post ); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -486,27 +486,27 @@ discard block |
||
| 486 | 486 | ); |
| 487 | 487 | |
| 488 | 488 | //switch old form and field ids to new ones |
| 489 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
| 490 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 489 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
| 490 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
| 491 | 491 | } else { |
| 492 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 492 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 493 | 493 | |
| 494 | - if ( ! empty($frm_duplicate_ids) ) { |
|
| 494 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
| 495 | 495 | |
| 496 | 496 | if ( $m['key'] == 'frm_dyncontent' ) { |
| 497 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 497 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
| 498 | 498 | } else if ( $m['key'] == 'frm_options' ) { |
| 499 | 499 | |
| 500 | 500 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 501 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
| 502 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
| 501 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
| 502 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $check_dup_array = array(); |
| 507 | 507 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
| 508 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 509 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 508 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
| 509 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
| 510 | 510 | } else if ( is_array( $m['value']['order_by'] ) ) { |
| 511 | 511 | $check_dup_array[] = 'order_by'; |
| 512 | 512 | } |
@@ -517,22 +517,22 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | foreach ( $check_dup_array as $check_k ) { |
| 520 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
| 521 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
| 522 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
| 520 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
| 521 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
| 522 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
| 523 | 523 | } |
| 524 | - unset($mk, $mv); |
|
| 524 | + unset( $mk, $mv ); |
|
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if ( ! is_array($m['value']) ) { |
|
| 532 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 531 | + if ( ! is_array( $m['value'] ) ) { |
|
| 532 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
| 535 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -548,23 +548,23 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | $taxonomy = (string) $att['domain']; |
| 551 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 551 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 552 | 552 | $name = (string) $att['nicename']; |
| 553 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 553 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
| 554 | 554 | if ( $h_term ) { |
| 555 | 555 | $name = $h_term->term_id; |
| 556 | 556 | } |
| 557 | - unset($h_term); |
|
| 557 | + unset( $h_term ); |
|
| 558 | 558 | } else { |
| 559 | 559 | $name = (string) $c; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
| 563 | - $post['tax_input'][ $taxonomy ] = array(); |
|
| 562 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
| 563 | + $post['tax_input'][$taxonomy] = array(); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
| 567 | - unset($name); |
|
| 566 | + $post['tax_input'][$taxonomy][] = $name; |
|
| 567 | + unset( $name ); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
@@ -581,29 +581,29 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 583 | 583 | $match_by['include'] = $post['post_id']; |
| 584 | - unset($match_by['name']); |
|
| 584 | + unset( $match_by['name'] ); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $editing = get_posts($match_by); |
|
| 587 | + $editing = get_posts( $match_by ); |
|
| 588 | 588 | |
| 589 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 589 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
| 590 | 590 | // set the id of the post to edit |
| 591 | - $post['ID'] = current($editing)->ID; |
|
| 591 | + $post['ID'] = current( $editing )->ID; |
|
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | private static function update_postmeta( &$post, $post_id ) { |
| 596 | 596 | foreach ( $post['postmeta'] as $k => $v ) { |
| 597 | 597 | if ( '_edit_last' == $k ) { |
| 598 | - $v = FrmAppHelper::get_user_id_param($v); |
|
| 598 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
| 599 | 599 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
| 600 | 600 | //change the attachment ID |
| 601 | - $v = FrmProXMLHelper::get_file_id($v); |
|
| 601 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - update_post_meta($post_id, $k, $v); |
|
| 604 | + update_post_meta( $post_id, $k, $v ); |
|
| 605 | 605 | |
| 606 | - unset($k, $v); |
|
| 606 | + unset( $k, $v ); |
|
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | |
@@ -620,13 +620,13 @@ discard block |
||
| 620 | 620 | * @param string $message |
| 621 | 621 | */ |
| 622 | 622 | public static function parse_message( $result, &$message, &$errors ) { |
| 623 | - if ( is_wp_error($result) ) { |
|
| 623 | + if ( is_wp_error( $result ) ) { |
|
| 624 | 624 | $errors[] = $result->get_error_message(); |
| 625 | 625 | } else if ( ! $result ) { |
| 626 | 626 | return; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - if ( ! is_array($result) ) { |
|
| 629 | + if ( ! is_array( $result ) ) { |
|
| 630 | 630 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
| 631 | 631 | return; |
| 632 | 632 | } |
@@ -638,20 +638,20 @@ discard block |
||
| 638 | 638 | |
| 639 | 639 | $message = '<ul>'; |
| 640 | 640 | foreach ( $result as $type => $results ) { |
| 641 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
| 641 | + if ( ! isset( $t_strings[$type] ) ) { |
|
| 642 | 642 | // only print imported and updated |
| 643 | 643 | continue; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | $s_message = array(); |
| 647 | 647 | foreach ( $results as $k => $m ) { |
| 648 | - self::item_count_message($m, $k, $s_message); |
|
| 649 | - unset($k, $m); |
|
| 648 | + self::item_count_message( $m, $k, $s_message ); |
|
| 649 | + unset( $k, $m ); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if ( ! empty($s_message) ) { |
|
| 653 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
| 654 | - $message .= implode(', ', $s_message); |
|
| 652 | + if ( ! empty( $s_message ) ) { |
|
| 653 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
| 654 | + $message .= implode( ', ', $s_message ); |
|
| 655 | 655 | $message .= '</li>'; |
| 656 | 656 | } |
| 657 | 657 | } |
@@ -680,18 +680,18 @@ discard block |
||
| 680 | 680 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
| 681 | 681 | ); |
| 682 | 682 | |
| 683 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 683 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | public static function cdata( $str ) { |
| 687 | - $str = maybe_unserialize($str); |
|
| 688 | - if ( is_array($str) ) { |
|
| 689 | - $str = json_encode($str); |
|
| 687 | + $str = maybe_unserialize( $str ); |
|
| 688 | + if ( is_array( $str ) ) { |
|
| 689 | + $str = json_encode( $str ); |
|
| 690 | 690 | } else if ( seems_utf8( $str ) == false ) { |
| 691 | 691 | $str = utf8_encode( $str ); |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - if ( is_numeric($str) ) { |
|
| 694 | + if ( is_numeric( $str ) ) { |
|
| 695 | 695 | return $str; |
| 696 | 696 | } |
| 697 | 697 | |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | * @param string $post_type |
| 724 | 724 | */ |
| 725 | 725 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
| 726 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 726 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
| 727 | 727 | return; |
| 728 | 728 | } |
| 729 | 729 | |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | 'menu_order' => $form_id, |
| 735 | 735 | 'post_status' => 'publish', |
| 736 | 736 | 'post_content' => array(), |
| 737 | - 'post_name' => $form_id .'_wppost_1', |
|
| 737 | + 'post_name' => $form_id . '_wppost_1', |
|
| 738 | 738 | ); |
| 739 | 739 | |
| 740 | 740 | $post_settings = array( |
@@ -744,10 +744,10 @@ discard block |
||
| 744 | 744 | ); |
| 745 | 745 | |
| 746 | 746 | foreach ( $post_settings as $post_setting ) { |
| 747 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
| 748 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
| 747 | + if ( isset( $form_options[$post_setting] ) ) { |
|
| 748 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
| 749 | 749 | } |
| 750 | - unset($post_setting); |
|
| 750 | + unset( $post_setting ); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | $new_action['event'] = array( 'create', 'update' ); |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 763 | 763 | } |
| 764 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 764 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
| 765 | 765 | |
| 766 | 766 | $exists = get_posts( array( |
| 767 | 767 | 'name' => $new_action['post_name'], |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | if ( ! $exists ) { |
| 774 | 774 | // this isn't an email, but we need to use a class that will always be included |
| 775 | 775 | FrmAppHelper::save_json_post( $new_action ); |
| 776 | - $imported['imported']['actions']++; |
|
| 776 | + $imported['imported']['actions'] ++; |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | |
@@ -805,11 +805,11 @@ discard block |
||
| 805 | 805 | foreach ( $post_content as $key => $setting ) { |
| 806 | 806 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
| 807 | 807 | // Replace old IDs with new IDs |
| 808 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
| 808 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
| 809 | 809 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
| 810 | 810 | foreach ( $setting as $k => $val ) { |
| 811 | 811 | // Replace old IDs with new IDs |
| 812 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
| 812 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
| 813 | 813 | } |
| 814 | 814 | } |
| 815 | 815 | unset( $key, $setting ); |
@@ -832,14 +832,14 @@ discard block |
||
| 832 | 832 | // Migrate autoresponders |
| 833 | 833 | self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
| 834 | 834 | |
| 835 | - if ( empty( $notifications ) ) { |
|
| 835 | + if ( empty( $notifications ) ) { |
|
| 836 | 836 | return; |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | foreach ( $notifications as $new_notification ) { |
| 840 | 840 | $new_notification['post_type'] = $post_type; |
| 841 | 841 | $new_notification['post_excerpt'] = 'email'; |
| 842 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 842 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 843 | 843 | $new_notification['menu_order'] = $form_id; |
| 844 | 844 | $new_notification['post_status'] = 'publish'; |
| 845 | 845 | |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | // Switch all other field IDs in email |
| 853 | 853 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
| 854 | 854 | } |
| 855 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 855 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 856 | 856 | |
| 857 | 857 | $exists = get_posts( array( |
| 858 | 858 | 'name' => $new_notification['post_name'], |
@@ -861,11 +861,11 @@ discard block |
||
| 861 | 861 | 'numberposts' => 1, |
| 862 | 862 | ) ); |
| 863 | 863 | |
| 864 | - if ( empty($exists) ) { |
|
| 864 | + if ( empty( $exists ) ) { |
|
| 865 | 865 | FrmAppHelper::save_json_post( $new_notification ); |
| 866 | - $imported['imported']['actions']++; |
|
| 866 | + $imported['imported']['actions'] ++; |
|
| 867 | 867 | } |
| 868 | - unset($new_notification); |
|
| 868 | + unset( $new_notification ); |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 881 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
| 882 | 882 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
| 883 | 883 | |
| 884 | 884 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -906,12 +906,12 @@ discard block |
||
| 906 | 906 | // Format the reply to email and name |
| 907 | 907 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
| 908 | 908 | foreach ( $reply_fields as $f => $val ) { |
| 909 | - if ( isset( $notification[ $f ] ) ) { |
|
| 910 | - $atts[ $f ] = $notification[ $f ]; |
|
| 911 | - if ( 'custom' == $notification[ $f ] ) { |
|
| 912 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
| 913 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
| 914 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
| 909 | + if ( isset( $notification[$f] ) ) { |
|
| 910 | + $atts[$f] = $notification[$f]; |
|
| 911 | + if ( 'custom' == $notification[$f] ) { |
|
| 912 | + $atts[$f] = $notification['cust_' . $f]; |
|
| 913 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
| 914 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | unset( $f, $val ); |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | $atts['event'] = array( 'create' ); |
| 922 | 922 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
| 923 | 923 | $atts['event'][] = 'update'; |
| 924 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 924 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
| 925 | 925 | $atts['event'] = array( 'update' ); |
| 926 | 926 | } |
| 927 | 927 | } |
@@ -942,18 +942,18 @@ discard block |
||
| 942 | 942 | foreach ( $atts['email_to'] as $key => $email_field ) { |
| 943 | 943 | |
| 944 | 944 | if ( is_numeric( $email_field ) ) { |
| 945 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
| 945 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - if ( strpos( $email_field, '|') ) { |
|
| 948 | + if ( strpos( $email_field, '|' ) ) { |
|
| 949 | 949 | $email_opt = explode( '|', $email_field ); |
| 950 | 950 | if ( isset( $email_opt[0] ) ) { |
| 951 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 951 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 952 | 952 | } |
| 953 | 953 | unset( $email_opt ); |
| 954 | 954 | } |
| 955 | 955 | } |
| 956 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 956 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -963,18 +963,18 @@ discard block |
||
| 963 | 963 | 'email_to' => $atts['email_to'], |
| 964 | 964 | 'event' => $atts['event'], |
| 965 | 965 | ), |
| 966 | - 'post_name' => $atts['form_id'] .'_email_'. $atts['email_key'], |
|
| 966 | + 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
|
| 967 | 967 | ); |
| 968 | 968 | |
| 969 | 969 | // Add more fields to the new notification |
| 970 | 970 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
| 971 | 971 | foreach ( $add_fields as $add_field ) { |
| 972 | - if ( isset( $notification[ $add_field ] ) ) { |
|
| 973 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
| 972 | + if ( isset( $notification[$add_field] ) ) { |
|
| 973 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
| 974 | 974 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
| 975 | - $new_notification['post_content'][ $add_field ] = 0; |
|
| 975 | + $new_notification['post_content'][$add_field] = 0; |
|
| 976 | 976 | } else { |
| 977 | - $new_notification['post_content'][ $add_field ] = ''; |
|
| 977 | + $new_notification['post_content'][$add_field] = ''; |
|
| 978 | 978 | } |
| 979 | 979 | unset( $add_field ); |
| 980 | 980 | } |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | |
| 985 | 985 | // Set from |
| 986 | 986 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
| 987 | - $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>'; |
|
| 987 | + $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
|
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | |
@@ -998,50 +998,50 @@ discard block |
||
| 998 | 998 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
| 999 | 999 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
| 1000 | 1000 | if ( is_numeric( $email_key ) ) { |
| 1001 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1001 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1002 | 1002 | } |
| 1003 | - unset( $email_key, $val); |
|
| 1003 | + unset( $email_key, $val ); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
| 1009 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1009 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
| 1010 | 1010 | // migrate autoresponder |
| 1011 | 1011 | |
| 1012 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1013 | - if ( strpos($email_field, '|') ) { |
|
| 1012 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
| 1013 | + if ( strpos( $email_field, '|' ) ) { |
|
| 1014 | 1014 | // data from entries field |
| 1015 | - $email_field = explode('|', $email_field); |
|
| 1016 | - if ( isset($email_field[1]) ) { |
|
| 1015 | + $email_field = explode( '|', $email_field ); |
|
| 1016 | + if ( isset( $email_field[1] ) ) { |
|
| 1017 | 1017 | $email_field = $email_field[1]; |
| 1018 | 1018 | } |
| 1019 | 1019 | } |
| 1020 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1021 | - $email_field = '['. $email_field .']'; |
|
| 1020 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
| 1021 | + $email_field = '[' . $email_field . ']'; |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | $notification = $form_options; |
| 1025 | 1025 | $new_notification2 = array( |
| 1026 | 1026 | 'post_content' => array( |
| 1027 | 1027 | 'email_message' => $notification['ar_email_message'], |
| 1028 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1028 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
| 1029 | 1029 | 'email_to' => $email_field, |
| 1030 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1030 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
| 1031 | 1031 | 'inc_user_info' => 0, |
| 1032 | 1032 | ), |
| 1033 | - 'post_name' => $form_id .'_email_'. count( $notifications ), |
|
| 1033 | + 'post_name' => $form_id . '_email_' . count( $notifications ), |
|
| 1034 | 1034 | ); |
| 1035 | 1035 | |
| 1036 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1037 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1036 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
| 1037 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
| 1038 | 1038 | |
| 1039 | 1039 | if ( ! empty( $reply_to ) ) { |
| 1040 | 1040 | $new_notification2['post_content']['reply_to'] = $reply_to; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) { |
| 1044 | - $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>'; |
|
| 1044 | + $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | $notifications[] = $new_notification2; |