Completed
Push — master ( fae5f1...b2850e )
by Stephanie
03:05
created
classes/models/FrmFormAction.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 
31 31
 	/**
32
-     * Echo the settings update form
32
+	 * Echo the settings update form
33 33
 	 *
34 34
 	 * @param array $instance Current settings
35 35
 	 */
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 	 * @return array of the default options
43 43
 	 */
44 44
 	public function get_defaults() {
45
-	    return array();
45
+		return array();
46 46
 	}
47 47
 
48 48
 	public function get_switch_fields() {
49
-	    return array();
49
+		return array();
50 50
 	}
51 51
 
52 52
 	public function migrate_values( $action, $form ) {
53
-	    return $action;
53
+		return $action;
54 54
 	}
55 55
 
56 56
 	// Functions you'll need to call.
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
 		$this->name = $name;
78 78
 		$this->option_name = 'frm_' . $this->id_base . '_action';
79 79
 
80
-        $default_options = array(
81
-            'classes'   => '',
82
-            'active'    => true,
80
+		$default_options = array(
81
+			'classes'   => '',
82
+			'active'    => true,
83 83
 			'event'     => array( 'create' ),
84
-            'limit'     => 1,
85
-            'force_event' => false,
86
-            'priority'  => 20,
87
-            'ajax_load' => true,
88
-            'tooltip'   => $name,
89
-        );
84
+			'limit'     => 1,
85
+			'force_event' => false,
86
+			'priority'  => 20,
87
+			'ajax_load' => true,
88
+			'tooltip'   => $name,
89
+		);
90 90
 
91 91
 		$action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
92 92
 		$this->action_options = wp_parse_args( $action_options, $default_options );
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	public function prepare_new( $form_id = false ) {
138
-        if ( $form_id ) {
139
-            $this->form_id = $form_id;
140
-        }
138
+		if ( $form_id ) {
139
+			$this->form_id = $form_id;
140
+		}
141 141
 
142
-        $post_content = array();
143
-        $default_values = $this->get_global_defaults();
142
+		$post_content = array();
143
+		$default_values = $this->get_global_defaults();
144 144
 
145 145
 		// fill default values
146 146
 		$post_content = wp_parse_args( $post_content, $default_values );
@@ -149,118 +149,118 @@  discard block
 block discarded – undo
149 149
 			$post_content['event'] = array( reset( $this->action_options['event'] ) );
150 150
 		}
151 151
 
152
-        $form_action = array(
153
-            'post_title'    => $this->name,
154
-            'post_content'  => $post_content,
155
-            'post_excerpt'  => $this->id_base,
156
-            'ID'            => '',
157
-            'post_status'   => 'publish',
158
-            'post_type'     => FrmFormActionsController::$action_post_type,
152
+		$form_action = array(
153
+			'post_title'    => $this->name,
154
+			'post_content'  => $post_content,
155
+			'post_excerpt'  => $this->id_base,
156
+			'ID'            => '',
157
+			'post_status'   => 'publish',
158
+			'post_type'     => FrmFormActionsController::$action_post_type,
159 159
 			'post_name'     => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160
-            'menu_order'    => $this->form_id,
161
-        );
160
+			'menu_order'    => $this->form_id,
161
+		);
162 162
 		unset( $post_content );
163 163
 
164
-        return (object) $form_action;
165
-    }
164
+		return (object) $form_action;
165
+	}
166 166
 
167 167
 	public function create( $form_id ) {
168
-        $this->form_id = $form_id;
168
+		$this->form_id = $form_id;
169 169
 
170
-        $action = $this->prepare_new();
170
+		$action = $this->prepare_new();
171 171
 
172 172
 		return $this->save_settings( $action );
173
-    }
173
+	}
174 174
 
175 175
 	public function duplicate_form_actions( $form_id, $old_id ) {
176
-        if ( $form_id == $old_id ) {
177
-            // don't duplicate the actions if this is a template getting updated
178
-            return;
179
-        }
176
+		if ( $form_id == $old_id ) {
177
+			// don't duplicate the actions if this is a template getting updated
178
+			return;
179
+		}
180 180
 
181
-        $this->form_id = $old_id;
182
-        $actions = $this->get_all( $old_id );
181
+		$this->form_id = $old_id;
182
+		$actions = $this->get_all( $old_id );
183 183
 
184
-        $this->form_id = $form_id;
185
-        foreach ( $actions as $action ) {
184
+		$this->form_id = $form_id;
185
+		foreach ( $actions as $action ) {
186 186
 			$this->duplicate_one( $action, $form_id );
187 187
 			unset( $action );
188
-        }
189
-    }
188
+		}
189
+	}
190 190
 
191
-    /* Check if imported action should be created or updated
191
+	/* Check if imported action should be created or updated
192 192
     *
193 193
     * Since 2.0
194 194
     *
195 195
     * @param array $action
196 196
     * @return integer $post_id
197 197
     */
198
-    public function maybe_create_action( $action, $forms ) {
198
+	public function maybe_create_action( $action, $forms ) {
199 199
 		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
200
-            // Update action only
201
-            $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
-            $post_id = $this->save_settings( $action );
203
-        } else {
200
+			// Update action only
201
+			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
+			$post_id = $this->save_settings( $action );
203
+		} else {
204 204
 			// Create action
205 205
 			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
206 206
 			$post_id = $this->duplicate_one( (object) $action, $action['menu_order'] );
207
-        }
208
-        return $post_id;
209
-    }
207
+		}
208
+		return $post_id;
209
+	}
210 210
 
211 211
 	public function duplicate_one( $action, $form_id ) {
212
-        global $frm_duplicate_ids;
212
+		global $frm_duplicate_ids;
213 213
 
214
-        $action->menu_order = $form_id;
215
-        $switch = $this->get_global_switch_fields();
216
-        foreach ( (array) $action->post_content as $key => $val ) {
214
+		$action->menu_order = $form_id;
215
+		$switch = $this->get_global_switch_fields();
216
+		foreach ( (array) $action->post_content as $key => $val ) {
217 217
 			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218 218
 				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
219
-            } else if ( ! is_array( $val ) ) {
219
+			} else if ( ! is_array( $val ) ) {
220 220
 				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221 221
 			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
222
-                // loop through each value if empty
222
+				// loop through each value if empty
223 223
 				if ( empty( $switch[ $key ] ) ) {
224 224
 					$switch[ $key ] = array_keys( $val );
225 225
 				}
226 226
 
227 227
 				foreach ( $switch[ $key ] as $subkey ) {
228 228
 					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
229
-                }
230
-            }
229
+				}
230
+			}
231 231
 
232 232
 			unset( $key, $val );
233 233
 		}
234 234
 		unset( $action->ID );
235 235
 
236 236
 		return $this->save_settings( $action );
237
-    }
237
+	}
238 238
 
239 239
 	private function duplicate_array_walk( $action, $subkey, $val ) {
240
-        global $frm_duplicate_ids;
240
+		global $frm_duplicate_ids;
241 241
 
242 242
 		if ( is_array( $subkey ) ) {
243
-            foreach ( $subkey as $subkey2 ) {
244
-                foreach ( (array) $val as $ck => $cv ) {
243
+			foreach ( $subkey as $subkey2 ) {
244
+				foreach ( (array) $val as $ck => $cv ) {
245 245
 					if ( is_array( $cv ) ) {
246 246
 						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247 247
 					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248 248
 						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
249
-                    }
250
-                }
251
-            }
252
-        } else {
253
-            foreach ( (array) $val as $ck => $cv ) {
249
+					}
250
+				}
251
+			}
252
+		} else {
253
+			foreach ( (array) $val as $ck => $cv ) {
254 254
 				if ( is_array( $cv ) ) {
255 255
 					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256 256
 				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257 257
 					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
258
-                }
259
-            }
260
-        }
258
+				}
259
+			}
260
+		}
261 261
 
262
-        return $action;
263
-    }
262
+		return $action;
263
+	}
264 264
 
265 265
 	/**
266 266
 	 * Deal with changed settings.
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 */
271 271
  	public function update_callback( $form_id ) {
272
-        $this->form_id = $form_id;
272
+		$this->form_id = $form_id;
273 273
 
274 274
  		$all_instances = $this->get_settings();
275 275
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
  			return;
285 285
  		}
286 286
 
287
-        $action_ids = array();
287
+		$action_ids = array();
288 288
 
289 289
  		foreach ( $settings as $number => $new_instance ) {
290 290
  			$this->_set( $number );
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 			// settings were never opened, so don't update
299 299
  			if ( ! isset( $new_instance['post_title'] ) ) {
300 300
 				$this->maybe_update_status( $new_instance, $old_instance );
301
- 			    $action_ids[] = $new_instance['ID'];
302
-         		$this->updated = true;
303
-         		continue;
301
+ 				$action_ids[] = $new_instance['ID'];
302
+		 		$this->updated = true;
303
+		 		continue;
304 304
  			}
305 305
 
306 306
 			$new_instance['post_type']  = FrmFormActionsController::$action_post_type;
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
 			$action_ids[] = $this->save_settings( $instance );
336 336
 
337
-     		$this->updated = true;
337
+	 		$this->updated = true;
338 338
  		}
339 339
 
340 340
  		return $action_ids;
@@ -368,59 +368,59 @@  discard block
 block discarded – undo
368 368
 			$action = $this->prepare_action( $action );
369 369
 			$this->_set( $id );
370 370
 		}
371
-	    return $action;
371
+		return $action;
372 372
 	}
373 373
 
374 374
 	public function get_one( $form_id ) {
375 375
 		return $this->get_all( $form_id, 1 );
376 376
 	}
377 377
 
378
-    public static function get_action_for_form( $form_id, $type = 'all', $atts = array() ) {
379
-        $action_controls = FrmFormActionsController::get_form_actions( $type );
378
+	public static function get_action_for_form( $form_id, $type = 'all', $atts = array() ) {
379
+		$action_controls = FrmFormActionsController::get_form_actions( $type );
380 380
 		if ( empty( $action_controls ) ) {
381
-            // don't continue if there are no available actions
382
-            return array();
383
-        }
381
+			// don't continue if there are no available actions
382
+			return array();
383
+		}
384 384
 
385 385
 		self::prepare_get_action( $atts );
386 386
 
387 387
 		$limit = apply_filters( 'frm_form_action_limit', $atts['limit'], compact( 'type', 'form_id' ) );
388 388
 
389
-        if ( 'all' != $type ) {
390
-            return $action_controls->get_all( $form_id, $limit );
391
-        }
389
+		if ( 'all' != $type ) {
390
+			return $action_controls->get_all( $form_id, $limit );
391
+		}
392 392
 
393 393
 		$args = self::action_args( $form_id, $limit );
394 394
 		$args['post_status'] = $atts['post_status'];
395 395
 		$actions = FrmDb::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
396 396
 
397
-        if ( ! $actions ) {
398
-            return array();
399
-        }
397
+		if ( ! $actions ) {
398
+			return array();
399
+		}
400 400
 
401
-        $settings = array();
402
-        foreach ( $actions as $action ) {
401
+		$settings = array();
402
+		foreach ( $actions as $action ) {
403 403
 			// some plugins/themes are formatting the post_excerpt
404 404
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
405 405
 
406 406
 			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
407
-                continue;
408
-            }
407
+				continue;
408
+			}
409 409
 
410
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
410
+			$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
411 411
 			$settings[ $action->ID ] = $action;
412 412
 
413 413
 			if ( count( $settings ) >= $limit ) {
414 414
 				break;
415 415
 			}
416
-        }
416
+		}
417 417
 
418
-        if ( 1 === $limit ) {
418
+		if ( 1 === $limit ) {
419 419
 			$settings = reset( $settings );
420
-        }
420
+		}
421 421
 
422
-        return $settings;
423
-    }
422
+		return $settings;
423
+	}
424 424
 
425 425
 	/**
426 426
 	 * @since 3.04
@@ -460,19 +460,19 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	public function get_all( $form_id = false, $limit = 99 ) {
463
-	    if ( $form_id ) {
464
-	        $this->form_id = $form_id;
465
-	    }
463
+		if ( $form_id ) {
464
+			$this->form_id = $form_id;
465
+		}
466 466
 
467
-	    $type = $this->id_base;
467
+		$type = $this->id_base;
468 468
 
469
-	    global $frm_vars;
470
-	    $frm_vars['action_type'] = $type;
469
+		global $frm_vars;
470
+		$frm_vars['action_type'] = $type;
471 471
 
472 472
 		add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
473 473
 		$query = self::action_args( $form_id, $limit );
474
-        $query['post_status']      = 'any';
475
-        $query['suppress_filters'] = false;
474
+		$query['post_status']      = 'any';
475
+		$query['suppress_filters'] = false;
476 476
 
477 477
 		$actions = FrmDb::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
478 478
 		unset( $query );
@@ -480,25 +480,25 @@  discard block
 block discarded – undo
480 480
 		remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
481 481
 
482 482
 		if ( empty( $actions ) ) {
483
-            return array();
484
-        }
483
+			return array();
484
+		}
485 485
 
486
-        $settings = array();
487
-        foreach ( $actions as $action ) {
486
+		$settings = array();
487
+		foreach ( $actions as $action ) {
488 488
 			if ( count( $settings ) >= $limit ) {
489
-                continue;
490
-            }
489
+				continue;
490
+			}
491 491
 
492 492
 			$action = $this->prepare_action( $action );
493 493
 
494 494
 			$settings[ $action->ID ] = $action;
495
-        }
495
+		}
496 496
 
497
-        if ( 1 === $limit ) {
497
+		if ( 1 === $limit ) {
498 498
 			$settings = reset( $settings );
499
-        }
499
+		}
500 500
 
501
-        return $settings;
501
+		return $settings;
502 502
 	}
503 503
 
504 504
 	public static function action_args( $form_id = 0, $limit = 99 ) {
@@ -521,45 +521,45 @@  discard block
 block discarded – undo
521 521
 		$action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
522 522
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
523 523
 
524
-        $default_values = $this->get_global_defaults();
524
+		$default_values = $this->get_global_defaults();
525 525
 
526
-        // fill default values
527
-        $action->post_content += $default_values;
526
+		// fill default values
527
+		$action->post_content += $default_values;
528 528
 
529
-        foreach ( $default_values as $k => $vals ) {
529
+		foreach ( $default_values as $k => $vals ) {
530 530
 			if ( is_array( $vals ) && ! empty( $vals ) ) {
531 531
 				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
532
-                    continue;
533
-                }
532
+					continue;
533
+				}
534 534
 				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
535
-            }
536
-        }
535
+			}
536
+		}
537 537
 
538 538
 		if ( ! is_array( $action->post_content['event'] ) ) {
539 539
 			$action->post_content['event'] = explode( ',', $action->post_content['event'] );
540 540
 		}
541 541
 
542
-        return $action;
542
+		return $action;
543 543
 	}
544 544
 
545 545
 	public function destroy( $form_id = false, $type = 'default' ) {
546
-	    global $wpdb;
546
+		global $wpdb;
547 547
 
548
-	    $this->form_id = $form_id;
548
+		$this->form_id = $form_id;
549 549
 
550
-	    $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
551
-	    if ( $form_id ) {
552
-	        $query['menu_order'] = $form_id;
553
-	    }
554
-	    if ( 'all' != $type ) {
555
-	        $query['post_excerpt'] = $this->id_base;
556
-	    }
550
+		$query = array( 'post_type' => FrmFormActionsController::$action_post_type );
551
+		if ( $form_id ) {
552
+			$query['menu_order'] = $form_id;
553
+		}
554
+		if ( 'all' != $type ) {
555
+			$query['post_excerpt'] = $this->id_base;
556
+		}
557 557
 
558
-        $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
558
+		$post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
559 559
 
560
-        foreach ( $post_ids as $id ) {
560
+		foreach ( $post_ids as $id ) {
561 561
 			wp_delete_post( $id );
562
-        }
562
+		}
563 563
 		self::clear_cache();
564 564
 	}
565 565
 
@@ -577,26 +577,26 @@  discard block
 block discarded – undo
577 577
 	}
578 578
 
579 579
 	public function get_global_defaults() {
580
-	    $defaults = $this->get_defaults();
580
+		$defaults = $this->get_defaults();
581 581
 
582 582
 		if ( ! isset( $defaults['event'] ) ) {
583 583
 			$defaults['event'] = array( 'create' );
584
-	    }
584
+		}
585 585
 
586 586
 		if ( ! isset( $defaults['conditions'] ) ) {
587
-	        $defaults['conditions'] = array(
588
-                'send_stop' => '',
589
-                'any_all'   => '',
590
-            );
591
-        }
587
+			$defaults['conditions'] = array(
588
+				'send_stop' => '',
589
+				'any_all'   => '',
590
+			);
591
+		}
592 592
 
593
-        return $defaults;
593
+		return $defaults;
594 594
 	}
595 595
 
596 596
 	public function get_global_switch_fields() {
597
-	    $switch = $this->get_switch_fields();
597
+		$switch = $this->get_switch_fields();
598 598
 		$switch['conditions'] = array( 'hide_field' );
599
-	    return $switch;
599
+		return $switch;
600 600
 	}
601 601
 
602 602
 	/**
@@ -606,17 +606,17 @@  discard block
 block discarded – undo
606 606
 		$action = $this->prepare_new( $form->id );
607 607
 		$form->options = maybe_unserialize( $form->options );
608 608
 
609
-        // fill with existing options
610
-        foreach ( $action->post_content as $name => $val ) {
609
+		// fill with existing options
610
+		foreach ( $action->post_content as $name => $val ) {
611 611
 			if ( isset( $form->options[ $name ] ) ) {
612 612
 				$action->post_content[ $name ] = $form->options[ $name ];
613 613
 				unset( $form->options[ $name ] );
614
-            }
615
-        }
614
+			}
615
+		}
616 616
 
617 617
 		$action = $this->migrate_values( $action, $form );
618 618
 
619
-        // check if action already exists
619
+		// check if action already exists
620 620
 		$post_id = get_posts(
621 621
 			array(
622 622
 				'name'          => $action->post_name,
@@ -631,17 +631,17 @@  discard block
 block discarded – undo
631 631
 			$post_id = $this->save_settings( $action );
632 632
 		}
633 633
 
634
-        if ( $post_id && 'update' == $update ) {
635
-            global $wpdb;
634
+		if ( $post_id && 'update' == $update ) {
635
+			global $wpdb;
636 636
 			$form->options = maybe_serialize( $form->options );
637 637
 
638
-            // update form options
638
+			// update form options
639 639
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
640
-	        FrmForm::clear_form_cache();
641
-        }
640
+			FrmForm::clear_form_cache();
641
+		}
642 642
 
643
-        return $post_id;
644
-    }
643
+		return $post_id;
644
+	}
645 645
 
646 646
 	public static function action_conditions_met( $action, $entry ) {
647 647
 		$notification = $action->post_content;
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormAction {
4 4
 
5
-	public $id_base;         // Root id for all actions of this type.
6
-	public $name;            // Name for this action type.
5
+	public $id_base; // Root id for all actions of this type.
6
+	public $name; // Name for this action type.
7 7
 	public $option_name;
8
-	public $action_options;  // Option array passed to wp_register_sidebar_widget()
8
+	public $action_options; // Option array passed to wp_register_sidebar_widget()
9 9
 	public $control_options; // Option array passed to wp_register_widget_control()
10 10
 
11
-	public $form_id;         // The ID of the form to evaluate
12
-	public $number = false;  // Unique ID number of the current instance.
13
-	public $id = '';         // Unique ID string of the current instance (id_base-number)
11
+	public $form_id; // The ID of the form to evaluate
12
+	public $number = false; // Unique ID number of the current instance.
13
+	public $id = ''; // Unique ID string of the current instance (id_base-number)
14 14
 	public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
15 15
 
16 16
 	// Member functions that you must over-ride.
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     * @return integer $post_id
197 197
     */
198 198
     public function maybe_create_action( $action, $forms ) {
199
-		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
199
+		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) {
200 200
             // Update action only
201 201
             $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202 202
             $post_id = $this->save_settings( $action );
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
         $action->menu_order = $form_id;
215 215
         $switch = $this->get_global_switch_fields();
216 216
         foreach ( (array) $action->post_content as $key => $val ) {
217
-			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218
-				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
217
+			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) {
218
+				$action->post_content[$key] = $frm_duplicate_ids[$val];
219 219
             } else if ( ! is_array( $val ) ) {
220
-				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221
-			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
220
+				$action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val );
221
+			} else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) {
222 222
                 // loop through each value if empty
223
-				if ( empty( $switch[ $key ] ) ) {
224
-					$switch[ $key ] = array_keys( $val );
223
+				if ( empty( $switch[$key] ) ) {
224
+					$switch[$key] = array_keys( $val );
225 225
 				}
226 226
 
227
-				foreach ( $switch[ $key ] as $subkey ) {
228
-					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
227
+				foreach ( $switch[$key] as $subkey ) {
228
+					$action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val );
229 229
                 }
230 230
             }
231 231
 
@@ -243,18 +243,18 @@  discard block
 block discarded – undo
243 243
             foreach ( $subkey as $subkey2 ) {
244 244
                 foreach ( (array) $val as $ck => $cv ) {
245 245
 					if ( is_array( $cv ) ) {
246
-						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247
-					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248
-						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
246
+						$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv );
247
+					} else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) {
248
+						$action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]];
249 249
                     }
250 250
                 }
251 251
             }
252 252
         } else {
253 253
             foreach ( (array) $val as $ck => $cv ) {
254 254
 				if ( is_array( $cv ) ) {
255
-					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256
-				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257
-					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
255
+					$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv );
256
+				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) {
257
+					$action[$ck] = $frm_duplicate_ids[$cv];
258 258
                 }
259 259
             }
260 260
         }
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
  			return;
279 279
  		}
280 280
 
281
-		if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
282
-			$settings = $_POST[ $this->option_name ];
281
+		if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) {
282
+			$settings = $_POST[$this->option_name];
283 283
  		} else {
284 284
  			return;
285 285
  		}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
  		foreach ( $settings as $number => $new_instance ) {
290 290
  			$this->_set( $number );
291 291
 
292
-			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
292
+			$old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array();
293 293
 
294 294
 			if ( ! isset( $new_instance['post_status'] ) ) {
295 295
 				$new_instance['post_status'] = 'draft';
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			$instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
330 330
 
331 331
 			if ( false !== $instance ) {
332
-				$all_instances[ $number ] = $instance;
332
+				$all_instances[$number] = $instance;
333 333
 			}
334 334
 
335 335
 			$action_ids[] = $this->save_settings( $instance );
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 			// some plugins/themes are formatting the post_excerpt
404 404
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
405 405
 
406
-			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
406
+			if ( ! isset( $action_controls[$action->post_excerpt] ) ) {
407 407
                 continue;
408 408
             }
409 409
 
410
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
411
-			$settings[ $action->ID ] = $action;
410
+            $action = $action_controls[$action->post_excerpt]->prepare_action( $action );
411
+			$settings[$action->ID] = $action;
412 412
 
413 413
 			if ( count( $settings ) >= $limit ) {
414 414
 				break;
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 
492 492
 			$action = $this->prepare_action( $action );
493 493
 
494
-			$settings[ $action->ID ] = $action;
494
+			$settings[$action->ID] = $action;
495 495
         }
496 496
 
497 497
         if ( 1 === $limit ) {
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
 
529 529
         foreach ( $default_values as $k => $vals ) {
530 530
 			if ( is_array( $vals ) && ! empty( $vals ) ) {
531
-				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
531
+				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) {
532 532
                     continue;
533 533
                 }
534
-				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
534
+				$action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals );
535 535
             }
536 536
         }
537 537
 
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
 
609 609
         // fill with existing options
610 610
         foreach ( $action->post_content as $name => $val ) {
611
-			if ( isset( $form->options[ $name ] ) ) {
612
-				$action->post_content[ $name ] = $form->options[ $name ];
613
-				unset( $form->options[ $name ] );
611
+			if ( isset( $form->options[$name] ) ) {
612
+				$action->post_content[$name] = $form->options[$name];
613
+				unset( $form->options[$name] );
614 614
             }
615 615
         }
616 616
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 				$stop = $stop ? false : true;
672 672
 			}
673 673
 
674
-			$met[ $stop ] = $stop;
674
+			$met[$stop] = $stop;
675 675
 		}
676 676
 
677 677
 		if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 	private static function get_value_from_entry( $entry, $field_id ) {
712 712
 		$observed_value = '';
713 713
 
714
-		if ( isset( $entry->metas[ $field_id ] ) ) {
715
-			$observed_value = $entry->metas[ $field_id ];
714
+		if ( isset( $entry->metas[$field_id] ) ) {
715
+			$observed_value = $entry->metas[$field_id];
716 716
 		} else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) {
717 717
 			$field = FrmField::getOne( $field_id );
718 718
 			$observed_value = FrmProEntryMetaHelper::get_post_or_meta_value(
Please login to merge, or discard this patch.
classes/controllers/FrmFormActionsController.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmFormActionsController {
4
-    public static $action_post_type = 'frm_form_actions';
5
-    public static $registered_actions;
4
+	public static $action_post_type = 'frm_form_actions';
5
+	public static $registered_actions;
6 6
 
7
-    public static function register_post_types() {
7
+	public static function register_post_types() {
8 8
 		register_post_type(
9 9
 			self::$action_post_type,
10 10
 			array(
@@ -21,90 +21,90 @@  discard block
 block discarded – undo
21 21
 			)
22 22
 		);
23 23
 
24
-        /**
25
-         * post_content: json settings
26
-         * menu_order: form id
27
-         * post_excerpt: action type
28
-         */
24
+		/**
25
+		 * post_content: json settings
26
+		 * menu_order: form id
27
+		 * post_excerpt: action type
28
+		 */
29 29
 
30
-        self::actions_init();
31
-    }
30
+		self::actions_init();
31
+	}
32 32
 
33
-    public static function actions_init() {
34
-        self::$registered_actions = new Frm_Form_Action_Factory();
35
-        self::register_actions();
36
-        do_action( 'frm_form_actions_init' );
37
-    }
33
+	public static function actions_init() {
34
+		self::$registered_actions = new Frm_Form_Action_Factory();
35
+		self::register_actions();
36
+		do_action( 'frm_form_actions_init' );
37
+	}
38 38
 
39
-    public static function register_actions() {
39
+	public static function register_actions() {
40 40
 		$action_classes = array(
41
-            'email'     => 'FrmEmailAction',
42
-            'wppost'    => 'FrmDefPostAction',
43
-            'register'  => 'FrmDefRegAction',
44
-            'paypal'    => 'FrmDefPayPalAction',
45
-            //'aweber'    => 'FrmDefAweberAction',
46
-            'mailchimp' => 'FrmDefMlcmpAction',
47
-            'twilio'    => 'FrmDefTwilioAction',
48
-            'highrise'  => 'FrmDefHrsAction',
49
-        );
41
+			'email'     => 'FrmEmailAction',
42
+			'wppost'    => 'FrmDefPostAction',
43
+			'register'  => 'FrmDefRegAction',
44
+			'paypal'    => 'FrmDefPayPalAction',
45
+			//'aweber'    => 'FrmDefAweberAction',
46
+			'mailchimp' => 'FrmDefMlcmpAction',
47
+			'twilio'    => 'FrmDefTwilioAction',
48
+			'highrise'  => 'FrmDefHrsAction',
49
+		);
50 50
 		$action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
51 51
 
52 52
 		include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
53 53
 		include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
54 54
 
55
-        foreach ( $action_classes as $action_class ) {
55
+		foreach ( $action_classes as $action_class ) {
56 56
 			self::$registered_actions->register( $action_class );
57
-        }
58
-    }
57
+		}
58
+	}
59 59
 
60 60
 	public static function get_form_actions( $action = 'all' ) {
61
-        $temp_actions = self::$registered_actions;
61
+		$temp_actions = self::$registered_actions;
62 62
 		if ( empty( $temp_actions ) ) {
63
-            self::actions_init();
64
-            $temp_actions = self::$registered_actions->actions;
65
-        } else {
66
-            $temp_actions = $temp_actions->actions;
67
-        }
63
+			self::actions_init();
64
+			$temp_actions = self::$registered_actions->actions;
65
+		} else {
66
+			$temp_actions = $temp_actions->actions;
67
+		}
68 68
 
69
-        $actions = array();
69
+		$actions = array();
70 70
 
71
-        foreach ( $temp_actions as $a ) {
72
-            if ( 'all' != $action && $a->id_base == $action ) {
73
-                return $a;
74
-            }
71
+		foreach ( $temp_actions as $a ) {
72
+			if ( 'all' != $action && $a->id_base == $action ) {
73
+				return $a;
74
+			}
75 75
 
76 76
 			$actions[ $a->id_base ] = $a;
77
-        }
78
-        unset( $temp_actions, $a );
79
-
80
-        $action_limit = 10;
81
-        if ( count( $actions ) <= $action_limit ) {
82
-            return $actions;
83
-        }
84
-
85
-        // remove the last few inactive icons if there are too many
86
-        $temp_actions = $actions;
87
-        arsort( $temp_actions );
88
-        foreach ( $temp_actions as $type => $a ) {
89
-            if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
77
+		}
78
+		unset( $temp_actions, $a );
79
+
80
+		$action_limit = 10;
81
+		if ( count( $actions ) <= $action_limit ) {
82
+			return $actions;
83
+		}
84
+
85
+		// remove the last few inactive icons if there are too many
86
+		$temp_actions = $actions;
87
+		arsort( $temp_actions );
88
+		foreach ( $temp_actions as $type => $a ) {
89
+			if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
90 90
 				unset( $actions[ $type ] );
91
-                if ( count( $actions ) <= $action_limit ) {
92
-                    break;
93
-                }
94
-            }
95
-            unset( $type, $a );
96
-        }
91
+				if ( count( $actions ) <= $action_limit ) {
92
+					break;
93
+				}
94
+			}
95
+			unset( $type, $a );
96
+		}
97 97
 
98
-        return $actions;
99
-    }
98
+		return $actions;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * @since 2.0
103 103
 	 */
104
-    public static function list_actions( $form, $values ) {
105
-        if ( empty( $form ) ) {
106
-            return;
107
-        }
104
+	public static function list_actions( $form, $values ) {
105
+		if ( empty( $form ) ) {
106
+			return;
107
+		}
108 108
 
109 109
 		/**
110 110
 		 * use this hook to migrate old settings into a new action
@@ -117,72 +117,72 @@  discard block
 block discarded – undo
117 117
 		);
118 118
 		$form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters );
119 119
 
120
-        $action_controls = self::get_form_actions();
120
+		$action_controls = self::get_form_actions();
121 121
 
122
-        $action_map = array();
122
+		$action_map = array();
123 123
 
124 124
 		foreach ( $action_controls as $key => $control ) {
125
-            $action_map[ $control->id_base ] = $key;
126
-        }
125
+			$action_map[ $control->id_base ] = $key;
126
+		}
127 127
 
128
-    	foreach ( $form_actions as $action ) {
129
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
130
-    	        // don't try and show settings if action no longer exists
131
-    	        continue;
132
-    	    }
128
+		foreach ( $form_actions as $action ) {
129
+			if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
130
+				// don't try and show settings if action no longer exists
131
+				continue;
132
+			}
133 133
 
134
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
135
-    	}
136
-    }
134
+			self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
135
+		}
136
+	}
137 137
 
138 138
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
139 139
 		$action_control->_set( $action_key );
140 140
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
141
-    }
141
+	}
142 142
 
143
-    public static function add_form_action() {
143
+	public static function add_form_action() {
144 144
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
145
-        check_ajax_referer( 'frm_ajax', 'nonce' );
145
+		check_ajax_referer( 'frm_ajax', 'nonce' );
146 146
 
147
-        global $frm_vars;
147
+		global $frm_vars;
148 148
 
149 149
 		$action_key = absint( $_POST['list_id'] );
150
-        $action_type = sanitize_text_field( $_POST['type'] );
150
+		$action_type = sanitize_text_field( $_POST['type'] );
151 151
 
152
-        $action_control = self::get_form_actions( $action_type );
152
+		$action_control = self::get_form_actions( $action_type );
153 153
 		$action_control->_set( $action_key );
154 154
 
155
-        $form_id = absint( $_POST['form_id'] );
155
+		$form_id = absint( $_POST['form_id'] );
156 156
 
157 157
 		$form_action = $action_control->prepare_new( $form_id );
158 158
 
159
-        $values = array();
159
+		$values = array();
160 160
 		$form = self::fields_to_values( $form_id, $values );
161 161
 
162 162
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
163
-        wp_die();
164
-    }
163
+		wp_die();
164
+	}
165 165
 
166
-    public static function fill_action() {
166
+	public static function fill_action() {
167 167
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
168
-        check_ajax_referer( 'frm_ajax', 'nonce' );
168
+		check_ajax_referer( 'frm_ajax', 'nonce' );
169 169
 
170
-        $action_key = absint( $_POST['action_id'] );
171
-        $action_type = sanitize_text_field( $_POST['action_type'] );
170
+		$action_key = absint( $_POST['action_id'] );
171
+		$action_type = sanitize_text_field( $_POST['action_type'] );
172 172
 
173
-        $action_control = self::get_form_actions( $action_type );
173
+		$action_control = self::get_form_actions( $action_type );
174 174
 		if ( empty( $action_control ) ) {
175
-            wp_die();
176
-        }
175
+			wp_die();
176
+		}
177 177
 
178
-        $form_action = $action_control->get_single_action( $action_key );
178
+		$form_action = $action_control->get_single_action( $action_key );
179 179
 
180
-        $values = array();
180
+		$values = array();
181 181
 		$form = self::fields_to_values( $form_action->menu_order, $values );
182 182
 
183 183
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
184
-        wp_die();
185
-    }
184
+		wp_die();
185
+	}
186 186
 
187 187
 	private static function fields_to_values( $form_id, array &$values ) {
188 188
 		$form = FrmForm::getOne( $form_id );
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
 		);
194 194
 
195 195
 		$fields = FrmField::get_all_for_form( $form->id );
196
-        foreach ( $fields as $k => $f ) {
197
-            $f = (array) $f;
198
-            $opts = (array) $f['field_options'];
196
+		foreach ( $fields as $k => $f ) {
197
+			$f = (array) $f;
198
+			$opts = (array) $f['field_options'];
199 199
 			$f = array_merge( $opts, $f );
200
-            if ( ! isset( $f['post_field'] ) ) {
201
-                $f['post_field'] = '';
202
-            }
203
-            $values['fields'][] = $f;
200
+			if ( ! isset( $f['post_field'] ) ) {
201
+				$f['post_field'] = '';
202
+			}
203
+			$values['fields'][] = $f;
204 204
 			unset( $k, $f );
205
-        }
205
+		}
206 206
 
207
-        return $form;
208
-    }
207
+		return $form;
208
+	}
209 209
 
210 210
 	public static function update_settings( $form_id ) {
211 211
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 			wp_die( esc_html__( 'You do not have permission to do that', 'formidable' ) );
214 214
 		}
215 215
 
216
-        global $wpdb;
216
+		global $wpdb;
217 217
 
218
-        $registered_actions = self::$registered_actions->actions;
218
+		$registered_actions = self::$registered_actions->actions;
219 219
 
220 220
 		$old_actions = FrmDb::get_col(
221 221
 			$wpdb->posts,
@@ -225,23 +225,23 @@  discard block
 block discarded – undo
225 225
 			),
226 226
 			'ID'
227 227
 		);
228
-        $new_actions = array();
228
+		$new_actions = array();
229 229
 
230
-        foreach ( $registered_actions as $registered_action ) {
230
+		foreach ( $registered_actions as $registered_action ) {
231 231
 			$action_ids = $registered_action->update_callback( $form_id );
232
-            if ( ! empty( $action_ids ) ) {
233
-                $new_actions[] = $action_ids;
234
-            }
235
-        }
232
+			if ( ! empty( $action_ids ) ) {
233
+				$new_actions[] = $action_ids;
234
+			}
235
+		}
236 236
 
237
-        //Only use array_merge if there are new actions
238
-        if ( ! empty( $new_actions ) ) {
239
-            $new_actions = call_user_func_array( 'array_merge', $new_actions );
240
-        }
241
-        $old_actions = array_diff( $old_actions, $new_actions );
237
+		//Only use array_merge if there are new actions
238
+		if ( ! empty( $new_actions ) ) {
239
+			$new_actions = call_user_func_array( 'array_merge', $new_actions );
240
+		}
241
+		$old_actions = array_diff( $old_actions, $new_actions );
242 242
 
243 243
 		self::delete_missing_actions( $old_actions );
244
-    }
244
+	}
245 245
 
246 246
 	public static function delete_missing_actions( $old_actions ) {
247 247
 		if ( ! empty( $old_actions ) ) {
@@ -261,22 +261,22 @@  discard block
 block discarded – undo
261 261
 		self::trigger_actions( $event, $form_id, $entry_id, 'all', $args );
262 262
 	}
263 263
 
264
-    /**
265
-     * @param string $event
266
-     */
264
+	/**
265
+	 * @param string $event
266
+	 */
267 267
 	public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
268 268
 		$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
269 269
 
270 270
 		if ( empty( $form_actions ) ) {
271
-            return;
272
-        }
271
+			return;
272
+		}
273 273
 
274 274
 		FrmForm::maybe_get_form( $form );
275 275
 
276
-        $link_settings = self::get_form_actions( $type );
277
-        if ( 'all' != $type ) {
278
-            $link_settings = array( $type => $link_settings );
279
-        }
276
+		$link_settings = self::get_form_actions( $type );
277
+		if ( 'all' != $type ) {
278
+			$link_settings = array( $type => $link_settings );
279
+		}
280 280
 
281 281
 		$stored_actions = array();
282 282
 		$action_priority = array();
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 			$this_event = $event;
288 288
 		}
289 289
 
290
-        foreach ( $form_actions as $action ) {
290
+		foreach ( $form_actions as $action ) {
291 291
 
292 292
 			$skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) );
293 293
 			$skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) );
294 294
 			if ( $skip_this_action ) {
295
-                continue;
296
-            }
295
+				continue;
296
+			}
297 297
 
298
-            if ( ! is_object( $entry ) ) {
299
-                $entry = FrmEntry::getOne( $entry, true );
300
-            }
298
+			if ( ! is_object( $entry ) ) {
299
+				$entry = FrmEntry::getOne( $entry, true );
300
+			}
301 301
 
302 302
 			if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) {
303 303
 				continue;
@@ -311,64 +311,64 @@  discard block
 block discarded – undo
311 311
 				if ( ! $trigger_children ) {
312 312
 					continue;
313 313
 				}
314
-            }
314
+			}
315 315
 
316
-            // check conditional logic
316
+			// check conditional logic
317 317
 			$stop = FrmFormAction::action_conditions_met( $action, $entry );
318
-            if ( $stop ) {
319
-                continue;
320
-            }
318
+			if ( $stop ) {
319
+				continue;
320
+			}
321 321
 
322
-            // store actions so they can be triggered with the correct priority
323
-            $stored_actions[ $action->ID ] = $action;
324
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
322
+			// store actions so they can be triggered with the correct priority
323
+			$stored_actions[ $action->ID ] = $action;
324
+			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
325 325
 
326 326
 			unset( $action );
327
-        }
327
+		}
328 328
 
329
-        if ( ! empty( $stored_actions ) ) {
329
+		if ( ! empty( $stored_actions ) ) {
330 330
 			asort( $action_priority );
331 331
 
332
-            // make sure hooks are loaded
333
-            new FrmNotification();
332
+			// make sure hooks are loaded
333
+			new FrmNotification();
334 334
 
335
-            foreach ( $action_priority as $action_id => $priority ) {
336
-                $action = $stored_actions[ $action_id ];
335
+			foreach ( $action_priority as $action_id => $priority ) {
336
+				$action = $stored_actions[ $action_id ];
337 337
 				do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
338 338
 				do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
339 339
 
340
-                // If post is created, get updated $entry object
341
-                if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
340
+				// If post is created, get updated $entry object
341
+				if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
342 342
 					$entry = FrmEntry::getOne( $entry->id, true );
343
-                }
344
-            }
345
-        }
346
-    }
343
+				}
344
+			}
345
+		}
346
+	}
347 347
 
348 348
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
349 349
 		if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
350
-            // continue if we know which actions to copy
351
-            return;
352
-        }
350
+			// continue if we know which actions to copy
351
+			return;
352
+		}
353 353
 
354 354
 		$action_controls = self::get_form_actions();
355 355
 
356
-        foreach ( $action_controls as $action_control ) {
357
-            $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
358
-            unset( $action_control );
359
-        }
360
-    }
356
+		foreach ( $action_controls as $action_control ) {
357
+			$action_control->duplicate_form_actions( $form_id, $args['old_id'] );
358
+			unset( $action_control );
359
+		}
360
+	}
361 361
 
362
-    public static function limit_by_type( $where ) {
363
-        global $frm_vars, $wpdb;
362
+	public static function limit_by_type( $where ) {
363
+		global $frm_vars, $wpdb;
364 364
 
365
-        if ( ! isset( $frm_vars['action_type'] ) ) {
366
-            return $where;
367
-        }
365
+		if ( ! isset( $frm_vars['action_type'] ) ) {
366
+			return $where;
367
+		}
368 368
 
369
-        $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
370
-        return $where;
371
-    }
369
+		$where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
370
+		return $where;
371
+	}
372 372
 }
373 373
 
374 374
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		foreach ( $keys as $key ) {
396 396
 			// don't register new action if old action with the same id is already registered
397 397
 			if ( ! isset( $this->actions[ $key ] ) ) {
398
-			    $this->actions[ $key ]->_register();
398
+				$this->actions[ $key ]->_register();
399 399
 			}
400 400
 		}
401 401
 	}
Please login to merge, or discard this patch.