| @@ -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,24 +78,8 @@ | ||
| 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 | */ |
| @@ -128,17 +98,11 @@ | ||
| 128 | 98 | /** |
| 129 | 99 | * Add unknown actions to a group. |
| 130 | 100 | * |
| 131 | 101 | * @since 4.0 |
| 132 | - * | |
| 133 | - * @param array $action_controls | |
| 134 | - * @param array $groups | |
| 135 | - * | |
| 136 | - * @return void | |
| 137 | 102 | */ |
| 138 | 103 | private static function maybe_add_action_to_group( $action_controls, &$groups ) { |
| 139 | 104 | $grouped = array(); |
| 140 | - | |
| 141 | 105 | foreach ( $groups as $group ) { |
| 142 | 106 | if ( isset( $group['actions'] ) ) { |
| 143 | 107 | $grouped = array_merge( $grouped, $group['actions'] ); |
| 144 | 108 | } |
| @@ -149,9 +113,8 @@ | ||
| 149 | 113 | continue; |
| 150 | 114 | } |
| 151 | 115 | |
| 152 | 116 | $this_group = $action->action_options['group']; |
| 153 | - | |
| 154 | 117 | if ( ! isset( $groups[ $this_group ] ) ) { |
| 155 | 118 | $this_group = 'misc'; |
| 156 | 119 | } |
| 157 | 120 | |
| @@ -200,15 +163,18 @@ | ||
| 200 | 163 | 'constantcontact', |
| 201 | 164 | 'getresponse', |
| 202 | 165 | 'aweber', |
| 203 | 166 | 'mailpoet', |
| 204 | - 'convertkit', | |
| 205 | 167 | ), |
| 206 | 168 | ), |
| 207 | 169 | 'crm' => array( |
| 208 | 170 | 'name' => __( 'CRM', 'formidable' ), |
| 209 | 171 | 'icon' => 'frm_icon_font frm_address_card_icon', |
| 210 | - 'actions' => self::get_crm_actions(), | |
| 172 | + 'actions' => array( | |
| 173 | + 'salesforce', | |
| 174 | + 'hubspot', | |
| 175 | + 'highrise', | |
| 176 | + ), | |
| 211 | 177 | ), |
| 212 | 178 | ); |
| 213 | 179 | |
| 214 | 180 | return apply_filters( 'frm_action_groups', $groups ); |
| @@ -214,41 +180,16 @@ | ||
| 214 | 180 | return apply_filters( 'frm_action_groups', $groups ); |
| 215 | 181 | } |
| 216 | 182 | |
| 217 | 183 | /** |
| 218 | - * Get the actions to include in the CRM section. | |
| 219 | - * | |
| 220 | - * @since 6.23 | |
| 221 | - * | |
| 222 | - * @return array | |
| 223 | - */ | |
| 224 | - private static function get_crm_actions() { | |
| 225 | - $crm_actions = array( | |
| 226 | - 'salesforce', | |
| 227 | - 'hubspot', | |
| 228 | - ); | |
| 229 | - | |
| 230 | - // Only include Highrise when the add-on is active. | |
| 231 | - // This is because Highrise is deprecated. We don't want to show it in Lite. | |
| 232 | - if ( class_exists( 'FrmHrsSettings' ) ) { | |
| 233 | - $crm_actions[] = 'highrise'; | |
| 234 | - } | |
| 235 | - | |
| 236 | - return $crm_actions; | |
| 237 | - } | |
| 238 | - | |
| 239 | - /** | |
| 240 | 184 | * Get the number of currently active form actions. |
| 241 | 185 | * |
| 242 | 186 | * @since 4.0 |
| 243 | 187 | * |
| 244 | - * @param array $action_controls | |
| 245 | - * | |
| 246 | 188 | * @return array |
| 247 | 189 | */ |
| 248 | 190 | private static function active_actions( $action_controls ) { |
| 249 | 191 | $allowed = array(); |
| 250 | - | |
| 251 | 192 | foreach ( $action_controls as $action_control ) { |
| 252 | 193 | if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) { |
| 253 | 194 | $allowed[] = $action_control->id_base; |
| 254 | 195 | } |
| @@ -259,9 +200,8 @@ | ||
| 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 ) { |
| @@ -281,9 +221,8 @@ | ||
| 281 | 221 | if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) { |
| 282 | 222 | $classes .= ' frm_active_action'; |
| 283 | 223 | } else { |
| 284 | 224 | $classes .= ' frm_inactive_action'; |
| 285 | - | |
| 286 | 225 | if ( $default_position !== false && ( $allowed_count + $default_position ) < 6 ) { |
| 287 | 226 | $group_class .= ' frm-default-show'; |
| 288 | 227 | } |
| 289 | 228 | |
| @@ -290,9 +229,8 @@ | ||
| 290 | 229 | $data['data-upgrade'] = $upgrade_label; |
| 291 | 230 | $data['data-medium'] = 'settings-' . $action_control->id_base; |
| 292 | 231 | |
| 293 | 232 | $upgrading = FrmAddonsController::install_link( $action_control->action_options['plugin'] ); |
| 294 | - | |
| 295 | 233 | if ( isset( $upgrading['url'] ) ) { |
| 296 | 234 | $data['data-oneclick'] = json_encode( $upgrading ); |
| 297 | 235 | } |
| 298 | 236 | |
| @@ -300,9 +238,8 @@ | ||
| 300 | 238 | $data['data-message'] = $action_control->action_options['message']; |
| 301 | 239 | } |
| 302 | 240 | |
| 303 | 241 | $requires = FrmFormsHelper::get_plan_required( $upgrading ); |
| 304 | - | |
| 305 | 242 | if ( $requires && 'free' !== $requires ) { |
| 306 | 243 | $data['data-requires'] = $requires; |
| 307 | 244 | } |
| 308 | 245 | }//end if |
| @@ -308,9 +245,8 @@ | ||
| 308 | 245 | }//end if |
| 309 | 246 | |
| 310 | 247 | // HTML to include on the icon. |
| 311 | 248 | $icon_atts = array(); |
| 312 | - | |
| 313 | 249 | if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) { |
| 314 | 250 | $icon_atts = array( |
| 315 | 251 | 'style' => '--primary-700:' . $action_control->action_options['color'], |
| 316 | 252 | ); |
| @@ -320,14 +256,11 @@ | ||
| 320 | 256 | } |
| 321 | 257 | |
| 322 | 258 | /** |
| 323 | 259 | * @param string $action |
| 324 | - * | |
| 325 | - * @return array|FrmFormAction A single form action is returned when a specific $action value is requested. | |
| 326 | 260 | */ |
| 327 | 261 | public static function get_form_actions( $action = 'all' ) { |
| 328 | 262 | $temp_actions = self::$registered_actions; |
| 329 | - | |
| 330 | 263 | if ( empty( $temp_actions ) ) { |
| 331 | 264 | self::actions_init(); |
| 332 | 265 | $temp_actions = self::$registered_actions->actions; |
| 333 | 266 | } else { |
| @@ -348,13 +281,8 @@ | ||
| 348 | 281 | } |
| 349 | 282 | |
| 350 | 283 | /** |
| 351 | 284 | * @since 2.0 |
| 352 | - * | |
| 353 | - * @param object $form | |
| 354 | - * @param array $values | |
| 355 | - * | |
| 356 | - * @return void | |
| 357 | 285 | */ |
| 358 | 286 | public static function list_actions( $form, $values ) { |
| 359 | 287 | if ( empty( $form ) ) { |
| 360 | 288 | return; |
| @@ -371,11 +299,8 @@ | ||
| 371 | 299 | 'post_status' => 'all', |
| 372 | 300 | ); |
| 373 | 301 | $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters ); |
| 374 | 302 | |
| 375 | - /** | |
| 376 | - * @var array | |
| 377 | - */ | |
| 378 | 303 | $action_controls = self::get_form_actions(); |
| 379 | 304 | |
| 380 | 305 | $action_map = array(); |
| 381 | 306 | |
| @@ -382,10 +307,8 @@ | ||
| 382 | 307 | foreach ( $action_controls as $key => $control ) { |
| 383 | 308 | $action_map[ $control->id_base ] = $key; |
| 384 | 309 | } |
| 385 | 310 | |
| 386 | - self::maybe_show_limit_warning( $form->id, $form_actions ); | |
| 387 | - | |
| 388 | 311 | foreach ( $form_actions as $action ) { |
| 389 | 312 | if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
| 390 | 313 | // don't try and show settings if action no longer exists |
| 391 | 314 | continue; |
| @@ -394,54 +317,8 @@ | ||
| 394 | 317 | self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
| 395 | 318 | } |
| 396 | 319 | } |
| 397 | 320 | |
| 398 | - /** | |
| 399 | - * Show a warning before the form actions list if there are 99 actions, and the limit is set to 99. | |
| 400 | - * If it is filtered, the warning is still shown when applicable, just using the new limit. | |
| 401 | - * | |
| 402 | - * @since 6.17 | |
| 403 | - * | |
| 404 | - * @param int|string $form_id | |
| 405 | - * @param array $form_actions | |
| 406 | - * | |
| 407 | - * @return void | |
| 408 | - */ | |
| 409 | - private static function maybe_show_limit_warning( $form_id, $form_actions ) { | |
| 410 | - $count = count( $form_actions ); | |
| 411 | - | |
| 412 | - if ( $count < 99 ) { | |
| 413 | - return; | |
| 414 | - } | |
| 415 | - | |
| 416 | - $limit = FrmFormAction::get_action_limit( $form_id ); | |
| 417 | - | |
| 418 | - if ( $limit < 99 || $count < $limit ) { | |
| 419 | - return; | |
| 420 | - } | |
| 421 | - | |
| 422 | - $documentation_url = 'https://formidableforms.com/knowledgebase/frm_form_action_limit/#kb-increase-limit-of-form-actions'; | |
| 423 | - | |
| 424 | - echo '<div class="frm_warning_style">'; | |
| 425 | - FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon' ); | |
| 426 | - echo ' '; | |
| 427 | - printf( | |
| 428 | - // translators: %s: URL to documentation | |
| 429 | - esc_html__( 'You have reached your form action limit. To increase this limit, you will require additional code. Visit our documentation at %s.', 'formidable' ), | |
| 430 | - '<a href="' . esc_url( $documentation_url ) . '" target="_blank">' . esc_html( $documentation_url ) . '</a>' | |
| 431 | - ); | |
| 432 | - echo '</div>'; | |
| 433 | - } | |
| 434 | - | |
| 435 | - /** | |
| 436 | - * @param WP_Post $form_action | |
| 437 | - * @param object $form | |
| 438 | - * @param int $action_key Action ID. | |
| 439 | - * @param FrmFormAction $action_control | |
| 440 | - * @param array $values | |
| 441 | - * | |
| 442 | - * @return void | |
| 443 | - */ | |
| 444 | 321 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 445 | 322 | $action_control->_set( $action_key ); |
| 446 | 323 | |
| 447 | 324 | $use_logging = self::should_show_log_message( $form_action->post_excerpt ); |
| @@ -457,11 +334,8 @@ | ||
| 457 | 334 | |
| 458 | 335 | $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' ); |
| 459 | 336 | $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' ); |
| 460 | 337 | |
| 461 | - /** | |
| 462 | - * @var FrmFormAction | |
| 463 | - */ | |
| 464 | 338 | $action_control = self::get_form_actions( $action_type ); |
| 465 | 339 | $action_control->_set( $action_key ); |
| 466 | 340 | |
| 467 | 341 | $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' ); |
| @@ -483,9 +357,8 @@ | ||
| 483 | 357 | $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' ); |
| 484 | 358 | $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' ); |
| 485 | 359 | |
| 486 | 360 | $action_control = self::get_form_actions( $action_type ); |
| 487 | - | |
| 488 | 361 | if ( empty( $action_control ) ) { |
| 489 | 362 | wp_die(); |
| 490 | 363 | } |
| 491 | 364 | |
| @@ -501,11 +374,8 @@ | ||
| 501 | 374 | } |
| 502 | 375 | |
| 503 | 376 | /** |
| 504 | 377 | * @since 3.06.04 |
| 505 | - * | |
| 506 | - * @param string $action_type | |
| 507 | - * | |
| 508 | 378 | * @return bool |
| 509 | 379 | */ |
| 510 | 380 | private static function should_show_log_message( $action_type ) { |
| 511 | 381 | $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' ); |
| @@ -511,14 +381,8 @@ | ||
| 511 | 381 | $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' ); |
| 512 | 382 | return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' ); |
| 513 | 383 | } |
| 514 | 384 | |
| 515 | - /** | |
| 516 | - * @param int|string $form_id | |
| 517 | - * @param array $values | |
| 518 | - * | |
| 519 | - * @return object | |
| 520 | - */ | |
| 521 | 385 | private static function fields_to_values( $form_id, array &$values ) { |
| 522 | 386 | $form = FrmForm::getOne( $form_id ); |
| 523 | 387 | |
| 524 | 388 | $values = array( |
| @@ -526,14 +390,12 @@ | ||
| 526 | 390 | 'id' => $form->id, |
| 527 | 391 | ); |
| 528 | 392 | |
| 529 | 393 | $fields = FrmField::get_all_for_form( $form->id ); |
| 530 | - | |
| 531 | 394 | foreach ( $fields as $k => $f ) { |
| 532 | 395 | $f = (array) $f; |
| 533 | 396 | $opts = (array) $f['field_options']; |
| 534 | 397 | $f = array_merge( $opts, $f ); |
| 535 | - | |
| 536 | 398 | if ( ! isset( $f['post_field'] ) ) { |
| 537 | 399 | $f['post_field'] = ''; |
| 538 | 400 | } |
| 539 | 401 | $values['fields'][] = $f; |
| @@ -544,15 +406,13 @@ | ||
| 544 | 406 | } |
| 545 | 407 | |
| 546 | 408 | /** |
| 547 | 409 | * @param int $form_id |
| 548 | - * | |
| 549 | 410 | * @return void |
| 550 | 411 | */ |
| 551 | 412 | public static function update_settings( $form_id ) { |
| 552 | 413 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 553 | 414 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 554 | - | |
| 555 | 415 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 556 | 416 | $frm_settings = FrmAppHelper::get_settings(); |
| 557 | 417 | $error_args = array( |
| 558 | 418 | 'title' => __( 'Verification failed', 'formidable' ), |
| @@ -585,9 +445,8 @@ | ||
| 585 | 445 | $new_actions = array(); |
| 586 | 446 | |
| 587 | 447 | foreach ( $registered_actions as $registered_action ) { |
| 588 | 448 | $action_ids = $registered_action->update_callback( $form_id ); |
| 589 | - | |
| 590 | 449 | if ( ! empty( $action_ids ) ) { |
| 591 | 450 | $new_actions[] = $action_ids; |
| 592 | 451 | } |
| 593 | 452 | } |
| @@ -595,9 +454,8 @@ | ||
| 595 | 454 | // Only use array_merge if there are new actions. |
| 596 | 455 | if ( ! empty( $new_actions ) ) { |
| 597 | 456 | $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
| 598 | 457 | } |
| 599 | - | |
| 600 | 458 | $old_actions = array_diff( $old_actions, $new_actions ); |
| 601 | 459 | |
| 602 | 460 | self::delete_missing_actions( $old_actions ); |
| 603 | 461 | |
| @@ -603,13 +461,8 @@ | ||
| 603 | 461 | |
| 604 | 462 | FrmOnSubmitHelper::save_on_submit_settings( $form_id ); |
| 605 | 463 | } |
| 606 | 464 | |
| 607 | - /** | |
| 608 | - * @param array $old_actions | |
| 609 | - * | |
| 610 | - * @return void | |
| 611 | - */ | |
| 612 | 465 | public static function delete_missing_actions( $old_actions ) { |
| 613 | 466 | if ( ! empty( $old_actions ) ) { |
| 614 | 467 | foreach ( $old_actions as $old_id ) { |
| 615 | 468 | wp_delete_post( $old_id ); |
| @@ -617,15 +470,8 @@ | ||
| 617 | 470 | FrmDb::cache_delete_group( 'frm_actions' ); |
| 618 | 471 | } |
| 619 | 472 | } |
| 620 | 473 | |
| 621 | - /** | |
| 622 | - * @param int|string $entry_id | |
| 623 | - * @param int|string $form_id | |
| 624 | - * @param array $args | |
| 625 | - * | |
| 626 | - * @return void | |
| 627 | - */ | |
| 628 | 474 | public static function trigger_create_actions( $entry_id, $form_id, $args = array() ) { |
| 629 | 475 | $filter_args = $args; |
| 630 | 476 | $filter_args['entry_id'] = $entry_id; |
| 631 | 477 | $filter_args['form_id'] = $form_id; |
| @@ -642,15 +488,9 @@ | ||
| 642 | 488 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 643 | 489 | } |
| 644 | 490 | |
| 645 | 491 | /** |
| 646 | - * @param string $event | |
| 647 | - * @param int|object|string $form | |
| 648 | - * @param int|string $entry | |
| 649 | - * @param string $type | |
| 650 | - * @param array $args | |
| 651 | - * | |
| 652 | - * @return void | |
| 492 | + * @param string $event | |
| 653 | 493 | */ |
| 654 | 494 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 655 | 495 | $action_status = array( |
| 656 | 496 | 'post_status' => 'publish', |
| @@ -662,15 +502,10 @@ | ||
| 662 | 502 | } |
| 663 | 503 | |
| 664 | 504 | FrmForm::maybe_get_form( $form ); |
| 665 | 505 | |
| 666 | - if ( ! is_object( $form ) ) { | |
| 667 | - return; | |
| 668 | - } | |
| 669 | - | |
| 670 | 506 | $link_settings = self::get_form_actions( $type ); |
| 671 | - | |
| 672 | - if ( 'all' !== $type ) { | |
| 507 | + if ( 'all' != $type ) { | |
| 673 | 508 | $link_settings = array( $type => $link_settings ); |
| 674 | 509 | } |
| 675 | 510 | |
| 676 | 511 | $stored_actions = array(); |
| @@ -685,9 +520,8 @@ | ||
| 685 | 520 | foreach ( $form_actions as $action ) { |
| 686 | 521 | |
| 687 | 522 | $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt; |
| 688 | 523 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
| 689 | - | |
| 690 | 524 | if ( $skip_this_action ) { |
| 691 | 525 | continue; |
| 692 | 526 | } |
| 693 | 527 | |
| @@ -698,14 +532,13 @@ | ||
| 698 | 532 | if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) { |
| 699 | 533 | continue; |
| 700 | 534 | } |
| 701 | 535 | |
| 702 | - $child_entry = ( is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ! empty( $args['is_child'] ); | |
| 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'] ) ); | |
| 703 | 537 | |
| 704 | 538 | if ( $child_entry ) { |
| 705 | 539 | // maybe trigger actions for sub forms |
| 706 | 540 | $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) ); |
| 707 | - | |
| 708 | 541 | if ( ! $trigger_children ) { |
| 709 | 542 | continue; |
| 710 | 543 | } |
| 711 | 544 | } |
| @@ -711,9 +544,8 @@ | ||
| 711 | 544 | } |
| 712 | 545 | |
| 713 | 546 | // Check conditional logic. |
| 714 | 547 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 715 | - | |
| 716 | 548 | if ( $stop ) { |
| 717 | 549 | continue; |
| 718 | 550 | } |
| 719 | 551 | |
| @@ -756,15 +588,8 @@ | ||
| 756 | 588 | }//end foreach |
| 757 | 589 | }//end if |
| 758 | 590 | } |
| 759 | 591 | |
| 760 | - /** | |
| 761 | - * @param int|string $form_id | |
| 762 | - * @param array $values | |
| 763 | - * @param array $args | |
| 764 | - * | |
| 765 | - * @return void | |
| 766 | - */ | |
| 767 | 592 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 768 | 593 | if ( empty( $args['old_id'] ) ) { |
| 769 | 594 | // Continue if we know which actions to copy. |
| 770 | 595 | return; |
| @@ -769,11 +594,8 @@ | ||
| 769 | 594 | // Continue if we know which actions to copy. |
| 770 | 595 | return; |
| 771 | 596 | } |
| 772 | 597 | |
| 773 | - /** | |
| 774 | - * @var array | |
| 775 | - */ | |
| 776 | 598 | $action_controls = self::get_form_actions(); |
| 777 | 599 | |
| 778 | 600 | foreach ( $action_controls as $action_control ) { |
| 779 | 601 | $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
| @@ -780,13 +602,8 @@ | ||
| 780 | 602 | unset( $action_control ); |
| 781 | 603 | } |
| 782 | 604 | } |
| 783 | 605 | |
| 784 | - /** | |
| 785 | - * @param string $where | |
| 786 | - * | |
| 787 | - * @return string | |
| 788 | - */ | |
| 789 | 606 | public static function limit_by_type( $where ) { |
| 790 | 607 | global $frm_vars, $wpdb; |
| 791 | 608 | |
| 792 | 609 | if ( ! isset( $frm_vars['action_type'] ) ) { |
| @@ -796,32 +613,11 @@ | ||
| 796 | 613 | $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
| 797 | 614 | |
| 798 | 615 | return $where; |
| 799 | 616 | } |
| 800 | - | |
| 801 | - /** | |
| 802 | - * Prevent WPML from filtering form actions based on the active language. | |
| 803 | - * | |
| 804 | - * @since 6.20 | |
| 805 | - * | |
| 806 | - * @param bool|null $null | |
| 807 | - * @param string $post_type | |
| 808 | - * | |
| 809 | - * @return bool|null | |
| 810 | - */ | |
| 811 | - public static function prevent_wpml_translations( $null, $post_type ) { | |
| 812 | - if ( self::$action_post_type === $post_type ) { | |
| 813 | - return false; | |
| 814 | - } | |
| 815 | - return $null; | |
| 816 | - } | |
| 817 | 617 | } |
| 818 | 618 | |
| 819 | 619 | class Frm_Form_Action_Factory { |
| 820 | - | |
| 821 | - /** | |
| 822 | - * @var array | |
| 823 | - */ | |
| 824 | 620 | public $actions = array(); |
| 825 | 621 | |
| 826 | 622 | public function __construct() { |
| 827 | 623 | add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 ); |
| @@ -826,22 +622,12 @@ | ||
| 826 | 622 | public function __construct() { |
| 827 | 623 | add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 ); |
| 828 | 624 | } |
| 829 | 625 | |
| 830 | - /** | |
| 831 | - * @param string $action_class | |
| 832 | - * | |
| 833 | - * @return void | |
| 834 | - */ | |
| 835 | 626 | public function register( $action_class ) { |
| 836 | 627 | $this->actions[ $action_class ] = new $action_class(); |
| 837 | 628 | } |
| 838 | 629 | |
| 839 | - /** | |
| 840 | - * @param string $action_class | |
| 841 | - * | |
| 842 | - * @return void | |
| 843 | - */ | |
| 844 | 630 | public function unregister( $action_class ) { |
| 845 | 631 | if ( isset( $this->actions[ $action_class ] ) ) { |
| 846 | 632 | unset( $this->actions[ $action_class ] ); |
| 847 | 633 | } |