PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFormActionsController.php +48 -250 6.276.13 View file →
@@ -3,17 +3,9 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmFormActionsController {
7 -
8 - /**
9 - * @var string
10 - */
11 7 public static $action_post_type = 'frm_form_actions';
12 -
13 - /**
14 - * @var array|null
15 - */
16 8 public static $registered_actions;
17 9
18 10 /**
19 11 * Variables saved in the post:
@@ -67,9 +59,8 @@
67 59 'constantcontact' => 'FrmDefConstContactAction',
68 60 'getresponse' => 'FrmDefGetResponseAction',
69 61 'hubspot' => 'FrmDefHubspotAction',
70 62 'zapier' => 'FrmDefZapierAction',
71 - 'n8n' => 'FrmDefN8NAction',
72 63 'twilio' => 'FrmDefTwilioAction',
73 64 'highrise' => 'FrmDefHighriseAction',
74 65 'mailpoet' => 'FrmDefMailpoetAction',
75 66 'aweber' => 'FrmDefAweberAction',
@@ -76,14 +67,9 @@
76 67 'convertkit' => 'FrmDefConvertKitAction',
77 68 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
78 69 );
79 70
80 - if ( ! FrmAppHelper::show_new_feature( 'n8n' ) ) {
81 - unset( $action_classes['n8n'] );
82 - }
83 -
84 71 $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
85 - $action_classes = self::maybe_unset_highrise( $action_classes );
86 72
87 73 include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php';
88 74 include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php';
89 75
@@ -92,31 +78,16 @@
92 78 }
93 79 }
94 80
95 81 /**
96 - * Remove the Highrise action if it is not registered.
97 - *
98 - * @since 6.23
99 - *
100 - * @param array $action_classes
101 - *
102 - * @return array
103 - */
104 - private static function maybe_unset_highrise( $action_classes ) {
105 - if ( 'FrmDefHighriseAction' === ( $action_classes['highrise'] ?? '' ) ) {
106 - unset( $action_classes['highrise'] );
107 - }
108 - return $action_classes;
109 - }
110 -
111 - /**
112 82 * @since 4.0
113 83 *
114 84 * @param array $values
115 85 */
116 86 public static function email_settings( $values ) {
117 - $form = FrmForm::getOne( $values['id'] );
118 - $groups = self::form_action_groups();
87 + $form = FrmForm::getOne( $values['id'] );
88 + $groups = self::form_action_groups();
89 +
119 90 $action_controls = self::get_form_actions();
120 91 self::maybe_add_action_to_group( $action_controls, $groups );
121 92
122 93 $allowed = self::active_actions( $action_controls );
@@ -127,17 +98,11 @@
127 98 /**
128 99 * Add unknown actions to a group.
129 100 *
130 101 * @since 4.0
131 - *
132 - * @param array $action_controls
133 - * @param array $groups
134 - *
135 - * @return void
136 102 */
137 103 private static function maybe_add_action_to_group( $action_controls, &$groups ) {
138 104 $grouped = array();
139 -
140 105 foreach ( $groups as $group ) {
141 106 if ( isset( $group['actions'] ) ) {
142 107 $grouped = array_merge( $grouped, $group['actions'] );
143 108 }
@@ -143,14 +108,13 @@
143 108 }
144 109 }
145 110
146 111 foreach ( $action_controls as $action ) {
147 - if ( isset( $groups[ $action->id_base ] ) || in_array( $action->id_base, $grouped, true ) ) {
112 + if ( isset( $groups[ $action->id_base ] ) || in_array( $action->id_base, $grouped ) ) {
148 113 continue;
149 114 }
150 115
151 116 $this_group = $action->action_options['group'];
152 -
153 117 if ( ! isset( $groups[ $this_group ] ) ) {
154 118 $this_group = 'misc';
155 119 }
156 120
@@ -171,9 +135,9 @@
171 135 public static function form_action_groups() {
172 136 $groups = array(
173 137 'misc' => array(
174 138 'name' => '',
175 - 'icon' => 'frmfont frm_shuffle_icon',
139 + 'icon' => 'frm_icon_font frm_shuffle_icon',
176 140 'actions' => array(
177 141 'email',
178 142 'wppost',
179 143 'register',
@@ -183,9 +147,9 @@
183 147 ),
184 148 ),
185 149 'payment' => array(
186 150 'name' => __( 'eCommerce', 'formidable' ),
187 - 'icon' => 'frmfont frm_credit_card_alt_icon',
151 + 'icon' => 'frm_icon_font frm_credit_card_alt_icon',
188 152 'actions' => array(
189 153 'paypal',
190 154 'payment',
191 155 ),
@@ -191,9 +155,9 @@
191 155 ),
192 156 ),
193 157 'marketing' => array(
194 158 'name' => __( 'Email Marketing', 'formidable' ),
195 - 'icon' => 'frmfont frm_mail_bulk_icon',
159 + 'icon' => 'frm_icon_font frm_mail_bulk_icon',
196 160 'actions' => array(
197 161 'mailchimp',
198 162 'activecampaign',
199 163 'constantcontact',
@@ -199,15 +163,18 @@
199 163 'constantcontact',
200 164 'getresponse',
201 165 'aweber',
202 166 'mailpoet',
203 - 'convertkit',
204 167 ),
205 168 ),
206 169 'crm' => array(
207 170 'name' => __( 'CRM', 'formidable' ),
208 - 'icon' => 'frmfont frm_address_card_icon',
209 - 'actions' => self::get_crm_actions(),
171 + 'icon' => 'frm_icon_font frm_address_card_icon',
172 + 'actions' => array(
173 + 'salesforce',
174 + 'hubspot',
175 + 'highrise',
176 + ),
210 177 ),
211 178 );
212 179
213 180 return apply_filters( 'frm_action_groups', $groups );
@@ -213,47 +180,21 @@
213 180 return apply_filters( 'frm_action_groups', $groups );
214 181 }
215 182
216 183 /**
217 - * Get the actions to include in the CRM section.
218 - *
219 - * @since 6.23
220 - *
221 - * @return array
222 - */
223 - private static function get_crm_actions() {
224 - $crm_actions = array(
225 - 'salesforce',
226 - 'hubspot',
227 - );
228 -
229 - // Only include Highrise when the add-on is active.
230 - // This is because Highrise is deprecated. We don't want to show it in Lite.
231 - if ( class_exists( 'FrmHrsSettings' ) ) {
232 - $crm_actions[] = 'highrise';
233 - }
234 -
235 - return $crm_actions;
236 - }
237 -
238 - /**
239 184 * Get the number of currently active form actions.
240 185 *
241 186 * @since 4.0
242 187 *
243 - * @param array $action_controls
244 - *
245 188 * @return array
246 189 */
247 190 private static function active_actions( $action_controls ) {
248 191 $allowed = array();
249 -
250 192 foreach ( $action_controls as $action_control ) {
251 - if ( ! empty( $action_control->action_options['active'] ) ) {
193 + if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
252 194 $allowed[] = $action_control->id_base;
253 195 }
254 196 }
255 -
256 197 return $allowed;
257 198 }
258 199
259 200 /**
@@ -259,15 +200,15 @@
259 200 /**
260 201 * For each add-on, add an li, class, and javascript function. If active, add an additional class.
261 202 *
262 203 * @since 4.0
263 - *
264 204 * @param object $action_control
265 205 * @param array $allowed
266 206 */
267 207 public static function show_action_icon_link( $action_control, $allowed ) {
268 - $data = array();
269 - $classes = ' frm_' . $action_control->id_base . '_action frm_single_action';
208 + $data = array();
209 + $classes = ' frm_' . $action_control->id_base . '_action frm_single_action';
210 +
270 211 $group_class = ' frm-group-' . $action_control->action_options['group'];
271 212
272 213 /* translators: %s: Name of form action */
273 214 $upgrade_label = sprintf( esc_html__( '%s form actions', 'formidable' ), $action_control->action_options['tooltip'] );
@@ -273,16 +214,15 @@
273 214 $upgrade_label = sprintf( esc_html__( '%s form actions', 'formidable' ), $action_control->action_options['tooltip'] );
274 215
275 216 $default_shown = array( 'wppost', 'register', 'payment', 'quiz', 'hubspot' );
276 217 $default_shown = array_values( array_diff( $default_shown, $allowed ) );
277 - $default_position = array_search( $action_control->id_base, $default_shown, true );
218 + $default_position = array_search( $action_control->id_base, $default_shown );
278 219 $allowed_count = count( $allowed );
279 220
280 - if ( ! empty( $action_control->action_options['active'] ) ) {
221 + if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
281 222 $classes .= ' frm_active_action';
282 223 } else {
283 224 $classes .= ' frm_inactive_action';
284 -
285 225 if ( $default_position !== false && ( $allowed_count + $default_position ) < 6 ) {
286 226 $group_class .= ' frm-default-show';
287 227 }
288 228
@@ -289,9 +229,8 @@
289 229 $data['data-upgrade'] = $upgrade_label;
290 230 $data['data-medium'] = 'settings-' . $action_control->id_base;
291 231
292 232 $upgrading = FrmAddonsController::install_link( $action_control->action_options['plugin'] );
293 -
294 233 if ( isset( $upgrading['url'] ) ) {
295 234 $data['data-oneclick'] = json_encode( $upgrading );
296 235 }
297 236
@@ -299,9 +238,8 @@
299 238 $data['data-message'] = $action_control->action_options['message'];
300 239 }
301 240
302 241 $requires = FrmFormsHelper::get_plan_required( $upgrading );
303 -
304 242 if ( $requires && 'free' !== $requires ) {
305 243 $data['data-requires'] = $requires;
306 244 }
307 245 }//end if
@@ -307,9 +245,8 @@
307 245 }//end if
308 246
309 247 // HTML to include on the icon.
310 248 $icon_atts = array();
311 -
312 249 if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) {
313 250 $icon_atts = array(
314 251 'style' => '--primary-700:' . $action_control->action_options['color'],
315 252 );
@@ -319,15 +256,12 @@
319 256 }
320 257
321 258 /**
322 259 * @param string $action
323 - *
324 - * @return array|FrmFormAction A single form action is returned when a specific $action value is requested.
325 260 */
326 261 public static function get_form_actions( $action = 'all' ) {
327 262 $temp_actions = self::$registered_actions;
328 -
329 - if ( ! $temp_actions ) {
263 + if ( empty( $temp_actions ) ) {
330 264 self::actions_init();
331 265 $temp_actions = self::$registered_actions->actions;
332 266 } else {
333 267 $temp_actions = $temp_actions->actions;
@@ -335,9 +269,9 @@
335 269
336 270 $actions = array();
337 271
338 272 foreach ( $temp_actions as $a ) {
339 - if ( 'all' !== $action && $a->id_base === $action ) {
273 + if ( 'all' !== $action && $a->id_base == $action ) {
340 274 return $a;
341 275 }
342 276
343 277 $actions[ $a->id_base ] = $a;
@@ -347,16 +281,11 @@
347 281 }
348 282
349 283 /**
350 284 * @since 2.0
351 - *
352 - * @param object $form
353 - * @param array $values
354 - *
355 - * @return void
356 285 */
357 286 public static function list_actions( $form, $values ) {
358 - if ( ! $form ) {
287 + if ( empty( $form ) ) {
359 288 return;
360 289 }
361 290
362 291 /**
@@ -370,11 +299,8 @@
370 299 'post_status' => 'all',
371 300 );
372 301 $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters );
373 302
374 - /**
375 - * @var array
376 - */
377 303 $action_controls = self::get_form_actions();
378 304
379 305 $action_map = array();
380 306
@@ -381,10 +307,8 @@
381 307 foreach ( $action_controls as $key => $control ) {
382 308 $action_map[ $control->id_base ] = $key;
383 309 }
384 310
385 - self::maybe_show_limit_warning( $form->id, $form_actions );
386 -
387 311 foreach ( $form_actions as $action ) {
388 312 if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
389 313 // don't try and show settings if action no longer exists
390 314 continue;
@@ -393,54 +317,8 @@
393 317 self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
394 318 }
395 319 }
396 320
397 - /**
398 - * Show a warning before the form actions list if there are 99 actions, and the limit is set to 99.
399 - * If it is filtered, the warning is still shown when applicable, just using the new limit.
400 - *
401 - * @since 6.17
402 - *
403 - * @param int|string $form_id
404 - * @param array $form_actions
405 - *
406 - * @return void
407 - */
408 - private static function maybe_show_limit_warning( $form_id, $form_actions ) {
409 - $count = count( $form_actions );
410 -
411 - if ( $count < 99 ) {
412 - return;
413 - }
414 -
415 - $limit = FrmFormAction::get_action_limit( $form_id );
416 -
417 - if ( $limit < 99 || $count < $limit ) {
418 - return;
419 - }
420 -
421 - $documentation_url = 'https://formidableforms.com/knowledgebase/frm_form_action_limit/#kb-increase-limit-of-form-actions';
422 -
423 - echo '<div class="frm_warning_style">';
424 - FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon' );
425 - echo '&nbsp;';
426 - printf(
427 - // translators: %s: URL to documentation
428 - esc_html__( 'You have reached your form action limit. To increase this limit, you will require additional code. Visit our documentation at %s.', 'formidable' ),
429 - '<a href="' . esc_url( $documentation_url ) . '" target="_blank">' . esc_html( $documentation_url ) . '</a>'
430 - );
431 - echo '</div>';
432 - }
433 -
434 - /**
435 - * @param WP_Post $form_action
436 - * @param object $form
437 - * @param int $action_key Action ID.
438 - * @param FrmFormAction $action_control
439 - * @param array $values
440 - *
441 - * @return void
442 - */
443 321 public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
444 322 $action_control->_set( $action_key );
445 323
446 324 $use_logging = self::should_show_log_message( $form_action->post_excerpt );
@@ -456,20 +334,19 @@
456 334
457 335 $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' );
458 336 $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' );
459 337
460 - /**
461 - * @var FrmFormAction
462 - */
463 338 $action_control = self::get_form_actions( $action_type );
464 339 $action_control->_set( $action_key );
465 340
466 - $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
341 + $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
342 +
467 343 $form_action = $action_control->prepare_new( $form_id );
468 344 $use_logging = self::should_show_log_message( $action_type );
469 - $values = array();
470 - $form = self::fields_to_values( $form_id, $values );
471 345
346 + $values = array();
347 + $form = self::fields_to_values( $form_id, $values );
348 +
472 349 include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php';
473 350 wp_die();
474 351 }
475 352
@@ -476,19 +353,21 @@
476 353 public static function fill_action() {
477 354 FrmAppHelper::permission_check( 'frm_edit_forms' );
478 355 check_ajax_referer( 'frm_ajax', 'nonce' );
479 356
480 - $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' );
481 - $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' );
357 + $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' );
358 + $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' );
359 +
482 360 $action_control = self::get_form_actions( $action_type );
483 -
484 - if ( ! $action_control ) {
361 + if ( empty( $action_control ) ) {
485 362 wp_die();
486 363 }
487 364
488 365 $form_action = $action_control->get_single_action( $action_key );
489 - $values = array();
490 - $form = self::fields_to_values( $form_action->menu_order, $values );
366 +
367 + $values = array();
368 + $form = self::fields_to_values( $form_action->menu_order, $values );
369 +
491 370 $use_logging = self::should_show_log_message( $action_type );
492 371
493 372 include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php';
494 373 wp_die();
@@ -495,11 +374,8 @@
495 374 }
496 375
497 376 /**
498 377 * @since 3.06.04
499 - *
500 - * @param string $action_type
501 - *
502 378 * @return bool
503 379 */
504 380 private static function should_show_log_message( $action_type ) {
505 381 $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
@@ -505,14 +381,8 @@
505 381 $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
506 382 return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' );
507 383 }
508 384
509 - /**
510 - * @param int|string $form_id
511 - * @param array $values
512 - *
513 - * @return object
514 - */
515 385 private static function fields_to_values( $form_id, array &$values ) {
516 386 $form = FrmForm::getOne( $form_id );
517 387
518 388 $values = array(
@@ -520,14 +390,12 @@
520 390 'id' => $form->id,
521 391 );
522 392
523 393 $fields = FrmField::get_all_for_form( $form->id );
524 -
525 394 foreach ( $fields as $k => $f ) {
526 395 $f = (array) $f;
527 396 $opts = (array) $f['field_options'];
528 397 $f = array_merge( $opts, $f );
529 -
530 398 if ( ! isset( $f['post_field'] ) ) {
531 399 $f['post_field'] = '';
532 400 }
533 401 $values['fields'][] = $f;
@@ -538,15 +406,13 @@
538 406 }
539 407
540 408 /**
541 409 * @param int $form_id
542 - *
543 410 * @return void
544 411 */
545 412 public static function update_settings( $form_id ) {
546 413 FrmAppHelper::permission_check( 'frm_edit_forms' );
547 414 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
548 -
549 415 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
550 416 $frm_settings = FrmAppHelper::get_settings();
551 417 $error_args = array(
552 418 'title' => __( 'Verification failed', 'formidable' ),
@@ -579,19 +445,17 @@
579 445 $new_actions = array();
580 446
581 447 foreach ( $registered_actions as $registered_action ) {
582 448 $action_ids = $registered_action->update_callback( $form_id );
583 -
584 - if ( $action_ids ) {
449 + if ( ! empty( $action_ids ) ) {
585 450 $new_actions[] = $action_ids;
586 451 }
587 452 }
588 453
589 454 // Only use array_merge if there are new actions.
590 - if ( $new_actions ) {
455 + if ( ! empty( $new_actions ) ) {
591 456 $new_actions = call_user_func_array( 'array_merge', $new_actions );
592 457 }
593 -
594 458 $old_actions = array_diff( $old_actions, $new_actions );
595 459
596 460 self::delete_missing_actions( $old_actions );
597 461
@@ -597,15 +461,10 @@
597 461
598 462 FrmOnSubmitHelper::save_on_submit_settings( $form_id );
599 463 }
600 464
601 - /**
602 - * @param array $old_actions
603 - *
604 - * @return void
605 - */
606 465 public static function delete_missing_actions( $old_actions ) {
607 - if ( $old_actions ) {
466 + if ( ! empty( $old_actions ) ) {
608 467 foreach ( $old_actions as $old_id ) {
609 468 wp_delete_post( $old_id );
610 469 }
611 470 FrmDb::cache_delete_group( 'frm_actions' );
@@ -611,15 +470,8 @@
611 470 FrmDb::cache_delete_group( 'frm_actions' );
612 471 }
613 472 }
614 473
615 - /**
616 - * @param int|string $entry_id
617 - * @param int|string $form_id
618 - * @param array $args
619 - *
620 - * @return void
621 - */
622 474 public static function trigger_create_actions( $entry_id, $form_id, $args = array() ) {
623 475 $filter_args = $args;
624 476 $filter_args['entry_id'] = $entry_id;
625 477 $filter_args['form_id'] = $form_id;
@@ -636,35 +488,24 @@
636 488 self::trigger_actions( $event, $form_id, $entry_id, 'all', $args );
637 489 }
638 490
639 491 /**
640 - * @param string $event
641 - * @param int|object|string $form
642 - * @param int|string $entry
643 - * @param string $type
644 - * @param array $args
645 - *
646 - * @return void
492 + * @param string $event
647 493 */
648 - public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
494 + public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
649 495 $action_status = array(
650 496 'post_status' => 'publish',
651 497 );
652 498 $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status );
653 499
654 - if ( ! $form_actions ) {
500 + if ( empty( $form_actions ) ) {
655 501 return;
656 502 }
657 503
658 504 FrmForm::maybe_get_form( $form );
659 505
660 - if ( ! is_object( $form ) ) {
661 - return;
662 - }
663 -
664 506 $link_settings = self::get_form_actions( $type );
665 -
666 - if ( 'all' !== $type ) {
507 + if ( 'all' != $type ) {
667 508 $link_settings = array( $type => $link_settings );
668 509 }
669 510
670 511 $stored_actions = array();
@@ -676,11 +517,11 @@
676 517 $this_event = $event;
677 518 }
678 519
679 520 foreach ( $form_actions as $action ) {
521 +
680 522 $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt;
681 523 $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) );
682 -
683 524 if ( $skip_this_action ) {
684 525 continue;
685 526 }
686 527
@@ -687,18 +528,17 @@
687 528 if ( ! is_object( $entry ) ) {
688 529 $entry = FrmEntry::getOne( $entry, true );
689 530 }
690 531
691 - if ( ! $entry || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) {
532 + if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) {
692 533 continue;
693 534 }
694 535
695 - $child_entry = ( is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( (int) $entry->form_id !== (int) $form->id || $entry->parent_item_id ) ) || ! empty( $args['is_child'] ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
536 + $child_entry = ( ( is_object( $form ) && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) );
696 537
697 538 if ( $child_entry ) {
698 539 // maybe trigger actions for sub forms
699 540 $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) );
700 -
701 541 if ( ! $trigger_children ) {
702 542 continue;
703 543 }
704 544 }
@@ -704,9 +544,8 @@
704 544 }
705 545
706 546 // Check conditional logic.
707 547 $stop = FrmFormAction::action_conditions_met( $action, $entry );
708 -
709 548 if ( $stop ) {
710 549 continue;
711 550 }
712 551
@@ -716,9 +555,9 @@
716 555
717 556 unset( $action );
718 557 }//end foreach
719 558
720 - if ( $stored_actions ) {
559 + if ( ! empty( $stored_actions ) ) {
721 560 asort( $action_priority );
722 561
723 562 // Make sure hooks are loaded.
724 563 new FrmNotification();
@@ -749,15 +588,8 @@
749 588 }//end foreach
750 589 }//end if
751 590 }
752 591
753 - /**
754 - * @param int|string $form_id
755 - * @param array $values
756 - * @param array $args
757 - *
758 - * @return void
759 - */
760 592 public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
761 593 if ( empty( $args['old_id'] ) ) {
762 594 // Continue if we know which actions to copy.
763 595 return;
@@ -762,11 +594,8 @@
762 594 // Continue if we know which actions to copy.
763 595 return;
764 596 }
765 597
766 - /**
767 - * @var array
768 - */
769 598 $action_controls = self::get_form_actions();
770 599
771 600 foreach ( $action_controls as $action_control ) {
772 601 $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
@@ -773,13 +602,8 @@
773 602 unset( $action_control );
774 603 }
775 604 }
776 605
777 - /**
778 - * @param string $where
779 - *
780 - * @return string
781 - */
782 606 public static function limit_by_type( $where ) {
783 607 global $frm_vars, $wpdb;
784 608
785 609 if ( ! isset( $frm_vars['action_type'] ) ) {
@@ -785,31 +609,15 @@
785 609 if ( ! isset( $frm_vars['action_type'] ) ) {
786 610 return $where;
787 611 }
788 612
789 - return $where . $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
790 - }
613 + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
791 614
792 - /**
793 - * Prevent WPML from filtering form actions based on the active language.
794 - *
795 - * @since 6.20
796 - *
797 - * @param bool|null $null
798 - * @param string $post_type
799 - *
800 - * @return bool|null
801 - */
802 - public static function prevent_wpml_translations( $null, $post_type ) {
803 - return self::$action_post_type === $post_type ? false : $null;
615 + return $where;
804 616 }
805 617 }
806 618
807 619 class Frm_Form_Action_Factory {
808 -
809 - /**
810 - * @var array
811 - */
812 620 public $actions = array();
813 621
814 622 public function __construct() {
815 623 add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
@@ -814,22 +622,12 @@
814 622 public function __construct() {
815 623 add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
816 624 }
817 625
818 - /**
819 - * @param string $action_class
820 - *
821 - * @return void
822 - */
823 626 public function register( $action_class ) {
824 627 $this->actions[ $action_class ] = new $action_class();
825 628 }
826 629
827 - /**
828 - * @param string $action_class
829 - *
830 - * @return void
831 - */
832 630 public function unregister( $action_class ) {
833 631 if ( isset( $this->actions[ $action_class ] ) ) {
834 632 unset( $this->actions[ $action_class ] );
835 633 }