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