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