| @@ -4,12 +4,8 @@ | ||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmFormActionsController { |
| 7 | 7 | public static $action_post_type = 'frm_form_actions'; |
| 8 | - | |
| 9 | - /** | |
| 10 | - * @var array|null | |
| 11 | - */ | |
| 12 | 8 | public static $registered_actions; |
| 13 | 9 | |
| 14 | 10 | /** |
| 15 | 11 | * Variables saved in the post: |
| @@ -47,37 +43,33 @@ | ||
| 47 | 43 | * @return void |
| 48 | 44 | */ |
| 49 | 45 | public static function register_actions() { |
| 50 | 46 | $action_classes = array( |
| 51 | - 'on_submit' => 'FrmOnSubmitAction', | |
| 52 | - 'email' => 'FrmEmailAction', | |
| 53 | - 'wppost' => 'FrmDefPostAction', | |
| 54 | - 'register' => 'FrmDefRegAction', | |
| 55 | - 'paypal' => 'FrmDefPayPalAction', | |
| 56 | - 'payment' => 'FrmTransLiteAction', | |
| 57 | - 'quiz' => 'FrmDefQuizAction', | |
| 58 | - 'quiz_outcome' => 'FrmDefQuizOutcomeAction', | |
| 59 | - 'mailchimp' => 'FrmDefMlcmpAction', | |
| 60 | - 'api' => 'FrmDefApiAction', | |
| 61 | - 'salesforce' => 'FrmDefSalesforceAction', | |
| 62 | - 'activecampaign' => 'FrmDefActiveCampaignAction', | |
| 63 | - 'constantcontact' => 'FrmDefConstContactAction', | |
| 64 | - 'getresponse' => 'FrmDefGetResponseAction', | |
| 65 | - 'hubspot' => 'FrmDefHubspotAction', | |
| 66 | - 'zapier' => 'FrmDefZapierAction', | |
| 67 | - 'twilio' => 'FrmDefTwilioAction', | |
| 68 | - 'highrise' => 'FrmDefHighriseAction', | |
| 69 | - 'mailpoet' => 'FrmDefMailpoetAction', | |
| 70 | - 'aweber' => 'FrmDefAweberAction', | |
| 71 | - 'convertkit' => 'FrmDefConvertKitAction', | |
| 72 | - 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction', | |
| 47 | + 'email' => 'FrmEmailAction', | |
| 48 | + 'wppost' => 'FrmDefPostAction', | |
| 49 | + 'register' => 'FrmDefRegAction', | |
| 50 | + 'paypal' => 'FrmDefPayPalAction', | |
| 51 | + 'payment' => 'FrmDefHrsAction', | |
| 52 | + 'quiz' => 'FrmDefQuizAction', | |
| 53 | + 'quiz_outcome' => 'FrmDefQuizOutcomeAction', | |
| 54 | + 'mailchimp' => 'FrmDefMlcmpAction', | |
| 55 | + 'api' => 'FrmDefApiAction', | |
| 56 | + 'salesforce' => 'FrmDefSalesforceAction', | |
| 57 | + 'activecampaign' => 'FrmDefActiveCampaignAction', | |
| 58 | + 'constantcontact' => 'FrmDefConstContactAction', | |
| 59 | + 'getresponse' => 'FrmDefGetResponseAction', | |
| 60 | + 'hubspot' => 'FrmDefHubspotAction', | |
| 61 | + 'zapier' => 'FrmDefZapierAction', | |
| 62 | + 'twilio' => 'FrmDefTwilioAction', | |
| 63 | + 'highrise' => 'FrmDefHighriseAction', | |
| 64 | + 'mailpoet' => 'FrmDefMailpoetAction', | |
| 65 | + 'aweber' => 'FrmDefAweberAction', | |
| 73 | 66 | ); |
| 74 | 67 | |
| 75 | 68 | $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes ); |
| 76 | - $action_classes = self::maybe_unset_highrise( $action_classes ); | |
| 77 | 69 | |
| 78 | - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'; | |
| 79 | - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'; | |
| 70 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); | |
| 71 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); | |
| 80 | 72 | |
| 81 | 73 | foreach ( $action_classes as $action_class ) { |
| 82 | 74 | self::$registered_actions->register( $action_class ); |
| 83 | 75 | } |
| @@ -83,23 +75,8 @@ | ||
| 83 | 75 | } |
| 84 | 76 | } |
| 85 | 77 | |
| 86 | 78 | /** |
| 87 | - * Remove the Highrise action if it is not registered. | |
| 88 | - * | |
| 89 | - * @since 6.23 | |
| 90 | - * | |
| 91 | - * @param array $action_classes | |
| 92 | - * @return array | |
| 93 | - */ | |
| 94 | - private static function maybe_unset_highrise( $action_classes ) { | |
| 95 | - if ( 'FrmDefHighriseAction' === ( $action_classes['highrise'] ?? '' ) ) { | |
| 96 | - unset( $action_classes['highrise'] ); | |
| 97 | - } | |
| 98 | - return $action_classes; | |
| 99 | - } | |
| 100 | - | |
| 101 | - /** | |
| 102 | 79 | * @since 4.0 |
| 103 | 80 | * |
| 104 | 81 | * @param array $values |
| 105 | 82 | */ |
| @@ -111,9 +88,9 @@ | ||
| 111 | 88 | self::maybe_add_action_to_group( $action_controls, $groups ); |
| 112 | 89 | |
| 113 | 90 | $allowed = self::active_actions( $action_controls ); |
| 114 | 91 | |
| 115 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php'; | |
| 92 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php' ); | |
| 116 | 93 | } |
| 117 | 94 | |
| 118 | 95 | /** |
| 119 | 96 | * Add unknown actions to a group. |
| @@ -153,9 +130,9 @@ | ||
| 153 | 130 | * @return array |
| 154 | 131 | */ |
| 155 | 132 | public static function form_action_groups() { |
| 156 | 133 | $groups = array( |
| 157 | - 'misc' => array( | |
| 134 | + 'misc' => array( | |
| 158 | 135 | 'name' => '', |
| 159 | 136 | 'icon' => 'frm_icon_font frm_shuffle_icon', |
| 160 | 137 | 'actions' => array( |
| 161 | 138 | 'email', |
| @@ -183,15 +160,18 @@ | ||
| 183 | 160 | 'constantcontact', |
| 184 | 161 | 'getresponse', |
| 185 | 162 | 'aweber', |
| 186 | 163 | 'mailpoet', |
| 187 | - 'convertkit', | |
| 188 | 164 | ), |
| 189 | 165 | ), |
| 190 | 166 | 'crm' => array( |
| 191 | 167 | 'name' => __( 'CRM', 'formidable' ), |
| 192 | 168 | 'icon' => 'frm_icon_font frm_address_card_icon', |
| 193 | - 'actions' => self::get_crm_actions(), | |
| 169 | + 'actions' => array( | |
| 170 | + 'salesforce', | |
| 171 | + 'hubspot', | |
| 172 | + 'highrise', | |
| 173 | + ), | |
| 194 | 174 | ), |
| 195 | 175 | ); |
| 196 | 176 | |
| 197 | 177 | return apply_filters( 'frm_action_groups', $groups ); |
| @@ -197,30 +177,8 @@ | ||
| 197 | 177 | return apply_filters( 'frm_action_groups', $groups ); |
| 198 | 178 | } |
| 199 | 179 | |
| 200 | 180 | /** |
| 201 | - * Get the actions to include in the CRM section. | |
| 202 | - * | |
| 203 | - * @since 6.23 | |
| 204 | - * | |
| 205 | - * @return array | |
| 206 | - */ | |
| 207 | - private static function get_crm_actions() { | |
| 208 | - $crm_actions = array( | |
| 209 | - 'salesforce', | |
| 210 | - 'hubspot', | |
| 211 | - ); | |
| 212 | - | |
| 213 | - // Only include Highrise when the add-on is active. | |
| 214 | - // This is because Highrise is deprecated. We don't want to show it in Lite. | |
| 215 | - if ( class_exists( 'FrmHrsSettings' ) ) { | |
| 216 | - $crm_actions[] = 'highrise'; | |
| 217 | - } | |
| 218 | - | |
| 219 | - return $crm_actions; | |
| 220 | - } | |
| 221 | - | |
| 222 | - /** | |
| 223 | 181 | * Get the number of currently active form actions. |
| 224 | 182 | * |
| 225 | 183 | * @since 4.0 |
| 226 | 184 | * |
| @@ -280,15 +238,15 @@ | ||
| 280 | 238 | $requires = FrmFormsHelper::get_plan_required( $upgrading ); |
| 281 | 239 | if ( $requires && 'free' !== $requires ) { |
| 282 | 240 | $data['data-requires'] = $requires; |
| 283 | 241 | } |
| 284 | - }//end if | |
| 242 | + } | |
| 285 | 243 | |
| 286 | 244 | // HTML to include on the icon. |
| 287 | 245 | $icon_atts = array(); |
| 288 | - if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) { | |
| 246 | + if ( $action_control->action_options['color'] !== 'var(--primary-hover)' ) { | |
| 289 | 247 | $icon_atts = array( |
| 290 | - 'style' => '--primary-700:' . $action_control->action_options['color'], | |
| 248 | + 'style' => '--primary-hover:' . $action_control->action_options['color'], | |
| 291 | 249 | ); |
| 292 | 250 | } |
| 293 | 251 | |
| 294 | 252 | include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php'; |
| @@ -293,12 +251,8 @@ | ||
| 293 | 251 | |
| 294 | 252 | include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php'; |
| 295 | 253 | } |
| 296 | 254 | |
| 297 | - /** | |
| 298 | - * @param string $action | |
| 299 | - * @return array|FrmFormAction A single form action is returned when a specific $action value is requested. | |
| 300 | - */ | |
| 301 | 255 | public static function get_form_actions( $action = 'all' ) { |
| 302 | 256 | $temp_actions = self::$registered_actions; |
| 303 | 257 | if ( empty( $temp_actions ) ) { |
| 304 | 258 | self::actions_init(); |
| @@ -309,9 +263,9 @@ | ||
| 309 | 263 | |
| 310 | 264 | $actions = array(); |
| 311 | 265 | |
| 312 | 266 | foreach ( $temp_actions as $a ) { |
| 313 | - if ( 'all' !== $action && $a->id_base == $action ) { | |
| 267 | + if ( 'all' != $action && $a->id_base == $action ) { | |
| 314 | 268 | return $a; |
| 315 | 269 | } |
| 316 | 270 | |
| 317 | 271 | $actions[ $a->id_base ] = $a; |
| @@ -339,11 +293,8 @@ | ||
| 339 | 293 | 'post_status' => 'all', |
| 340 | 294 | ); |
| 341 | 295 | $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters ); |
| 342 | 296 | |
| 343 | - /** | |
| 344 | - * @var array | |
| 345 | - */ | |
| 346 | 297 | $action_controls = self::get_form_actions(); |
| 347 | 298 | |
| 348 | 299 | $action_map = array(); |
| 349 | 300 | |
| @@ -350,10 +301,8 @@ | ||
| 350 | 301 | foreach ( $action_controls as $key => $control ) { |
| 351 | 302 | $action_map[ $control->id_base ] = $key; |
| 352 | 303 | } |
| 353 | 304 | |
| 354 | - self::maybe_show_limit_warning( $form->id, $form_actions ); | |
| 355 | - | |
| 356 | 305 | foreach ( $form_actions as $action ) { |
| 357 | 306 | if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
| 358 | 307 | // don't try and show settings if action no longer exists |
| 359 | 308 | continue; |
| @@ -362,48 +311,14 @@ | ||
| 362 | 311 | self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
| 363 | 312 | } |
| 364 | 313 | } |
| 365 | 314 | |
| 366 | - /** | |
| 367 | - * Show a warning before the form actions list if there are 99 actions, and the limit is set to 99. | |
| 368 | - * If it is filtered, the warning is still shown when applicable, just using the new limit. | |
| 369 | - * | |
| 370 | - * @since 6.17 | |
| 371 | - * | |
| 372 | - * @param int|string $form_id | |
| 373 | - * @param array $form_actions | |
| 374 | - * @return void | |
| 375 | - */ | |
| 376 | - private static function maybe_show_limit_warning( $form_id, $form_actions ) { | |
| 377 | - $count = count( $form_actions ); | |
| 378 | - if ( $count < 99 ) { | |
| 379 | - return; | |
| 380 | - } | |
| 381 | - | |
| 382 | - $limit = FrmFormAction::get_action_limit( $form_id ); | |
| 383 | - if ( $limit < 99 || $count < $limit ) { | |
| 384 | - return; | |
| 385 | - } | |
| 386 | - | |
| 387 | - $documentation_url = 'https://formidableforms.com/knowledgebase/frm_form_action_limit/#kb-increase-limit-of-form-actions'; | |
| 388 | - | |
| 389 | - echo '<div class="frm_warning_style">'; | |
| 390 | - FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon' ); | |
| 391 | - echo ' '; | |
| 392 | - printf( | |
| 393 | - // translators: %s: URL to documentation | |
| 394 | - esc_html__( 'You have reached your form action limit. To increase this limit, you will require additional code. Visit our documentation at %s.', 'formidable' ), | |
| 395 | - '<a href="' . esc_url( $documentation_url ) . '" target="_blank">' . esc_html( $documentation_url ) . '</a>' | |
| 396 | - ); | |
| 397 | - echo '</div>'; | |
| 398 | - } | |
| 399 | - | |
| 400 | 315 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 401 | 316 | $action_control->_set( $action_key ); |
| 402 | 317 | |
| 403 | 318 | $use_logging = self::should_show_log_message( $form_action->post_excerpt ); |
| 404 | 319 | |
| 405 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php'; | |
| 320 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); | |
| 406 | 321 | } |
| 407 | 322 | |
| 408 | 323 | public static function add_form_action() { |
| 409 | 324 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| @@ -413,11 +328,8 @@ | ||
| 413 | 328 | |
| 414 | 329 | $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' ); |
| 415 | 330 | $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' ); |
| 416 | 331 | |
| 417 | - /** | |
| 418 | - * @var FrmFormAction | |
| 419 | - */ | |
| 420 | 332 | $action_control = self::get_form_actions( $action_type ); |
| 421 | 333 | $action_control->_set( $action_key ); |
| 422 | 334 | |
| 423 | 335 | $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' ); |
| @@ -427,9 +339,9 @@ | ||
| 427 | 339 | |
| 428 | 340 | $values = array(); |
| 429 | 341 | $form = self::fields_to_values( $form_id, $values ); |
| 430 | 342 | |
| 431 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php'; | |
| 343 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); | |
| 432 | 344 | wp_die(); |
| 433 | 345 | } |
| 434 | 346 | |
| 435 | 347 | public static function fill_action() { |
| @@ -450,9 +362,9 @@ | ||
| 450 | 362 | $form = self::fields_to_values( $form_action->menu_order, $values ); |
| 451 | 363 | |
| 452 | 364 | $use_logging = self::should_show_log_message( $action_type ); |
| 453 | 365 | |
| 454 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php'; | |
| 366 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); | |
| 455 | 367 | wp_die(); |
| 456 | 368 | } |
| 457 | 369 | |
| 458 | 370 | /** |
| @@ -460,9 +372,9 @@ | ||
| 460 | 372 | * @return bool |
| 461 | 373 | */ |
| 462 | 374 | private static function should_show_log_message( $action_type ) { |
| 463 | 375 | $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' ); |
| 464 | - return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' ); | |
| 376 | + return in_array( $action_type, $logging ) && ! function_exists( 'frm_log_autoloader' ); | |
| 465 | 377 | } |
| 466 | 378 | |
| 467 | 379 | private static function fields_to_values( $form_id, array &$values ) { |
| 468 | 380 | $form = FrmForm::getOne( $form_id ); |
| @@ -495,22 +407,9 @@ | ||
| 495 | 407 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 496 | 408 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 497 | 409 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 498 | 410 | $frm_settings = FrmAppHelper::get_settings(); |
| 499 | - $error_args = array( | |
| 500 | - 'title' => __( 'Verification failed', 'formidable' ), | |
| 501 | - 'body' => $frm_settings->admin_permission, | |
| 502 | - 'cancel_url' => add_query_arg( | |
| 503 | - array( | |
| 504 | - 'page' => 'formidable', | |
| 505 | - 'frm_action' => 'settings', | |
| 506 | - 'id' => $form_id, | |
| 507 | - ), | |
| 508 | - admin_url( 'admin.php?' ) | |
| 509 | - ), | |
| 510 | - ); | |
| 511 | - FrmAppController::show_error_modal( $error_args ); | |
| 512 | - return; | |
| 411 | + wp_die( esc_html( $frm_settings->admin_permission ) ); | |
| 513 | 412 | } |
| 514 | 413 | |
| 515 | 414 | global $wpdb; |
| 516 | 415 | |
| @@ -539,10 +438,8 @@ | ||
| 539 | 438 | } |
| 540 | 439 | $old_actions = array_diff( $old_actions, $new_actions ); |
| 541 | 440 | |
| 542 | 441 | self::delete_missing_actions( $old_actions ); |
| 543 | - | |
| 544 | - FrmOnSubmitHelper::save_on_submit_settings( $form_id ); | |
| 545 | 442 | } |
| 546 | 443 | |
| 547 | 444 | public static function delete_missing_actions( $old_actions ) { |
| 548 | 445 | if ( ! empty( $old_actions ) ) { |
| @@ -557,16 +454,9 @@ | ||
| 557 | 454 | $filter_args = $args; |
| 558 | 455 | $filter_args['entry_id'] = $entry_id; |
| 559 | 456 | $filter_args['form_id'] = $form_id; |
| 560 | 457 | |
| 561 | - /** | |
| 562 | - * @since 2.0.23 | |
| 563 | - * @since 6.11.2 $filter_args is now passed instead of $args. It includes additional ID data. | |
| 564 | - * | |
| 565 | - * @param string $event 'create' by default. Pro may filter this value to 'draft' instead. | |
| 566 | - * @param array $filter_args | |
| 567 | - */ | |
| 568 | - $event = apply_filters( 'frm_trigger_create_action', 'create', $filter_args ); | |
| 458 | + $event = apply_filters( 'frm_trigger_create_action', 'create', $args ); | |
| 569 | 459 | |
| 570 | 460 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 571 | 461 | } |
| 572 | 462 | |
| @@ -576,9 +466,9 @@ | ||
| 576 | 466 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 577 | 467 | $action_status = array( |
| 578 | 468 | 'post_status' => 'publish', |
| 579 | 469 | ); |
| 580 | - $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status ); | |
| 470 | + $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status ); | |
| 581 | 471 | |
| 582 | 472 | if ( empty( $form_actions ) ) { |
| 583 | 473 | return; |
| 584 | 474 | } |
| @@ -583,14 +473,11 @@ | ||
| 583 | 473 | return; |
| 584 | 474 | } |
| 585 | 475 | |
| 586 | 476 | FrmForm::maybe_get_form( $form ); |
| 587 | - if ( ! is_object( $form ) ) { | |
| 588 | - return; | |
| 589 | - } | |
| 590 | 477 | |
| 591 | 478 | $link_settings = self::get_form_actions( $type ); |
| 592 | - if ( 'all' !== $type ) { | |
| 479 | + if ( 'all' != $type ) { | |
| 593 | 480 | $link_settings = array( $type => $link_settings ); |
| 594 | 481 | } |
| 595 | 482 | |
| 596 | 483 | $stored_actions = array(); |
| @@ -595,9 +482,9 @@ | ||
| 595 | 482 | |
| 596 | 483 | $stored_actions = array(); |
| 597 | 484 | $action_priority = array(); |
| 598 | 485 | |
| 599 | - if ( in_array( $event, array( 'create', 'update' ), true ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 486 | + if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 600 | 487 | $this_event = 'import'; |
| 601 | 488 | } else { |
| 602 | 489 | $this_event = $event; |
| 603 | 490 | } |
| @@ -603,9 +490,9 @@ | ||
| 603 | 490 | } |
| 604 | 491 | |
| 605 | 492 | foreach ( $form_actions as $action ) { |
| 606 | 493 | |
| 607 | - $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt; | |
| 494 | + $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) ); | |
| 608 | 495 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
| 609 | 496 | if ( $skip_this_action ) { |
| 610 | 497 | continue; |
| 611 | 498 | } |
| @@ -613,13 +500,13 @@ | ||
| 613 | 500 | if ( ! is_object( $entry ) ) { |
| 614 | 501 | $entry = FrmEntry::getOne( $entry, true ); |
| 615 | 502 | } |
| 616 | 503 | |
| 617 | - if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) { | |
| 504 | + if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { | |
| 618 | 505 | continue; |
| 619 | 506 | } |
| 620 | 507 | |
| 621 | - $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'] ); | |
| 508 | + $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'] ) ); | |
| 622 | 509 | |
| 623 | 510 | if ( $child_entry ) { |
| 624 | 511 | // maybe trigger actions for sub forms |
| 625 | 512 | $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) ); |
| @@ -638,9 +525,9 @@ | ||
| 638 | 525 | $stored_actions[ $action->ID ] = $action; |
| 639 | 526 | $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
| 640 | 527 | |
| 641 | 528 | unset( $action ); |
| 642 | - }//end foreach | |
| 529 | + } | |
| 643 | 530 | |
| 644 | 531 | if ( ! empty( $stored_actions ) ) { |
| 645 | 532 | asort( $action_priority ); |
| 646 | 533 | |
| @@ -648,42 +535,25 @@ | ||
| 648 | 535 | new FrmNotification(); |
| 649 | 536 | |
| 650 | 537 | foreach ( $action_priority as $action_id => $priority ) { |
| 651 | 538 | $action = $stored_actions[ $action_id ]; |
| 539 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); | |
| 540 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); | |
| 652 | 541 | |
| 653 | - /** | |
| 654 | - * Allows custom form action trigger. | |
| 655 | - * | |
| 656 | - * @since 6.10 | |
| 657 | - * | |
| 658 | - * @param bool $skip Skip default trigger. | |
| 659 | - * @param object $action Action object. | |
| 660 | - * @param object $entry Entry object. | |
| 661 | - * @param object $form Form object. | |
| 662 | - * @param string $event Event ('create' or 'update'). | |
| 663 | - */ | |
| 664 | - if ( false === apply_filters( 'frm_custom_trigger_action', false, $action, $entry, $form, $event ) ) { | |
| 665 | - do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); | |
| 666 | - do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); | |
| 667 | - } | |
| 668 | - | |
| 669 | 542 | // If post is created, get updated $entry object. |
| 670 | - if ( $action->post_excerpt === 'wppost' && $event === 'create' ) { | |
| 543 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { | |
| 671 | 544 | $entry = FrmEntry::getOne( $entry->id, true ); |
| 672 | 545 | } |
| 673 | - }//end foreach | |
| 674 | - }//end if | |
| 546 | + } | |
| 547 | + } | |
| 675 | 548 | } |
| 676 | 549 | |
| 677 | 550 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 678 | - if ( empty( $args['old_id'] ) ) { | |
| 551 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { | |
| 679 | 552 | // Continue if we know which actions to copy. |
| 680 | 553 | return; |
| 681 | 554 | } |
| 682 | 555 | |
| 683 | - /** | |
| 684 | - * @var array | |
| 685 | - */ | |
| 686 | 556 | $action_controls = self::get_form_actions(); |
| 687 | 557 | |
| 688 | 558 | foreach ( $action_controls as $action_control ) { |
| 689 | 559 | $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
| @@ -700,24 +570,8 @@ | ||
| 700 | 570 | |
| 701 | 571 | $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
| 702 | 572 | |
| 703 | 573 | return $where; |
| 704 | - } | |
| 705 | - | |
| 706 | - /** | |
| 707 | - * Prevent WPML from filtering form actions based on the active language. | |
| 708 | - * | |
| 709 | - * @since 6.20 | |
| 710 | - * | |
| 711 | - * @param bool|null $null | |
| 712 | - * @param string $post_type | |
| 713 | - * @return bool|null | |
| 714 | - */ | |
| 715 | - public static function prevent_wpml_translations( $null, $post_type ) { | |
| 716 | - if ( self::$action_post_type === $post_type ) { | |
| 717 | - return false; | |
| 718 | - } | |
| 719 | - return $null; | |
| 720 | 574 | } |
| 721 | 575 | } |
| 722 | 576 | |
| 723 | 577 | class Frm_Form_Action_Factory { |