| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - die( 'You are not allowed to call this page directly.' ); | |
| 4 | -} | |
| 5 | 2 | |
| 6 | 3 | class FrmFormActionsController { |
| 7 | 4 | public static $action_post_type = 'frm_form_actions'; |
| 8 | 5 | public static $registered_actions; |
| @@ -38,40 +35,33 @@ | ||
| 38 | 35 | self::register_actions(); |
| 39 | 36 | do_action( 'frm_form_actions_init' ); |
| 40 | 37 | } |
| 41 | 38 | |
| 42 | - /** | |
| 43 | - * @return void | |
| 44 | - */ | |
| 45 | 39 | public static function register_actions() { |
| 46 | 40 | $action_classes = array( |
| 47 | - 'on_submit' => 'FrmOnSubmitAction', | |
| 48 | - 'email' => 'FrmEmailAction', | |
| 49 | - 'wppost' => 'FrmDefPostAction', | |
| 50 | - 'register' => 'FrmDefRegAction', | |
| 51 | - 'paypal' => 'FrmDefPayPalAction', | |
| 52 | - 'payment' => 'FrmTransLiteAction', | |
| 53 | - 'quiz' => 'FrmDefQuizAction', | |
| 54 | - 'quiz_outcome' => 'FrmDefQuizOutcomeAction', | |
| 55 | - 'mailchimp' => 'FrmDefMlcmpAction', | |
| 56 | - 'api' => 'FrmDefApiAction', | |
| 57 | - 'salesforce' => 'FrmDefSalesforceAction', | |
| 58 | - 'activecampaign' => 'FrmDefActiveCampaignAction', | |
| 59 | - 'constantcontact' => 'FrmDefConstContactAction', | |
| 60 | - 'getresponse' => 'FrmDefGetResponseAction', | |
| 61 | - 'hubspot' => 'FrmDefHubspotAction', | |
| 62 | - 'zapier' => 'FrmDefZapierAction', | |
| 63 | - 'twilio' => 'FrmDefTwilioAction', | |
| 64 | - 'highrise' => 'FrmDefHighriseAction', | |
| 65 | - 'mailpoet' => 'FrmDefMailpoetAction', | |
| 66 | - 'aweber' => 'FrmDefAweberAction', | |
| 67 | - 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction', | |
| 41 | + 'email' => 'FrmEmailAction', | |
| 42 | + 'wppost' => 'FrmDefPostAction', | |
| 43 | + 'register' => 'FrmDefRegAction', | |
| 44 | + 'paypal' => 'FrmDefPayPalAction', | |
| 45 | + 'payment' => 'FrmDefHrsAction', | |
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', | |
| 47 | + 'api' => 'FrmDefApiAction', | |
| 48 | + | |
| 49 | + 'salesforce' => 'FrmDefSalesforceAction', | |
| 50 | + 'activecampaign' => 'FrmDefActiveCampaignAction', | |
| 51 | + 'constantcontact' => 'FrmDefConstContactAction', | |
| 52 | + 'getresponse' => 'FrmDefGetResponseAction', | |
| 53 | + 'hubspot' => 'FrmDefHubspotAction', | |
| 54 | + 'twilio' => 'FrmDefTwilioAction', | |
| 55 | + 'highrise' => 'FrmDefHighriseAction', | |
| 56 | + 'mailpoet' => 'FrmDefMailpoetAction', | |
| 57 | + 'aweber' => 'FrmDefAweberAction', | |
| 68 | 58 | ); |
| 69 | 59 | |
| 70 | 60 | $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes ); |
| 71 | 61 | |
| 72 | - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'; | |
| 73 | - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'; | |
| 62 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); | |
| 63 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); | |
| 74 | 64 | |
| 75 | 65 | foreach ( $action_classes as $action_class ) { |
| 76 | 66 | self::$registered_actions->register( $action_class ); |
| 77 | 67 | } |
| @@ -90,9 +80,9 @@ | ||
| 90 | 80 | self::maybe_add_action_to_group( $action_controls, $groups ); |
| 91 | 81 | |
| 92 | 82 | $allowed = self::active_actions( $action_controls ); |
| 93 | 83 | |
| 94 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php'; | |
| 84 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php' ); | |
| 95 | 85 | } |
| 96 | 86 | |
| 97 | 87 | /** |
| 98 | 88 | * Add unknown actions to a group. |
| @@ -132,9 +122,9 @@ | ||
| 132 | 122 | * @return array |
| 133 | 123 | */ |
| 134 | 124 | public static function form_action_groups() { |
| 135 | 125 | $groups = array( |
| 136 | - 'misc' => array( | |
| 126 | + 'misc' => array( | |
| 137 | 127 | 'name' => '', |
| 138 | 128 | 'icon' => 'frm_icon_font frm_shuffle_icon', |
| 139 | 129 | 'actions' => array( |
| 140 | 130 | 'email', |
| @@ -139,10 +129,8 @@ | ||
| 139 | 129 | 'actions' => array( |
| 140 | 130 | 'email', |
| 141 | 131 | 'wppost', |
| 142 | 132 | 'register', |
| 143 | - 'quiz', | |
| 144 | - 'quiz_outcome', | |
| 145 | 133 | 'twilio', |
| 146 | 134 | ), |
| 147 | 135 | ), |
| 148 | 136 | 'payment' => array( |
| @@ -211,9 +199,9 @@ | ||
| 211 | 199 | |
| 212 | 200 | /* translators: %s: Name of form action */ |
| 213 | 201 | $upgrade_label = sprintf( esc_html__( '%s form actions', 'formidable' ), $action_control->action_options['tooltip'] ); |
| 214 | 202 | |
| 215 | - $default_shown = array( 'wppost', 'register', 'payment', 'quiz', 'hubspot' ); | |
| 203 | + $default_shown = array( 'wppost', 'register', 'paypal', 'payment', 'mailchimp' ); | |
| 216 | 204 | $default_shown = array_values( array_diff( $default_shown, $allowed ) ); |
| 217 | 205 | $default_position = array_search( $action_control->id_base, $default_shown ); |
| 218 | 206 | $allowed_count = count( $allowed ); |
| 219 | 207 | |
| @@ -231,28 +219,19 @@ | ||
| 231 | 219 | $upgrading = FrmAddonsController::install_link( $action_control->action_options['plugin'] ); |
| 232 | 220 | if ( isset( $upgrading['url'] ) ) { |
| 233 | 221 | $data['data-oneclick'] = json_encode( $upgrading ); |
| 234 | 222 | } |
| 235 | - | |
| 236 | - if ( isset( $action_control->action_options['message'] ) ) { | |
| 237 | - $data['data-message'] = $action_control->action_options['message']; | |
| 238 | - } | |
| 239 | - | |
| 240 | - $requires = FrmFormsHelper::get_plan_required( $upgrading ); | |
| 241 | - if ( $requires && 'free' !== $requires ) { | |
| 242 | - $data['data-requires'] = $requires; | |
| 243 | - } | |
| 244 | 223 | } |
| 245 | 224 | |
| 246 | 225 | // HTML to include on the icon. |
| 247 | 226 | $icon_atts = array(); |
| 248 | - if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) { | |
| 227 | + if ( $action_control->action_options['color'] !== 'var(--primary-hover)' ) { | |
| 249 | 228 | $icon_atts = array( |
| 250 | - 'style' => '--primary-700:' . $action_control->action_options['color'], | |
| 229 | + 'style' => '--primary-hover:' . $action_control->action_options['color'], | |
| 251 | 230 | ); |
| 252 | 231 | } |
| 253 | 232 | |
| 254 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php'; | |
| 233 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php' ); | |
| 255 | 234 | } |
| 256 | 235 | |
| 257 | 236 | public static function get_form_actions( $action = 'all' ) { |
| 258 | 237 | $temp_actions = self::$registered_actions; |
| @@ -318,9 +297,9 @@ | ||
| 318 | 297 | $action_control->_set( $action_key ); |
| 319 | 298 | |
| 320 | 299 | $use_logging = self::should_show_log_message( $form_action->post_excerpt ); |
| 321 | 300 | |
| 322 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php'; | |
| 301 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); | |
| 323 | 302 | } |
| 324 | 303 | |
| 325 | 304 | public static function add_form_action() { |
| 326 | 305 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| @@ -341,9 +320,9 @@ | ||
| 341 | 320 | |
| 342 | 321 | $values = array(); |
| 343 | 322 | $form = self::fields_to_values( $form_id, $values ); |
| 344 | 323 | |
| 345 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php'; | |
| 324 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); | |
| 346 | 325 | wp_die(); |
| 347 | 326 | } |
| 348 | 327 | |
| 349 | 328 | public static function fill_action() { |
| @@ -364,9 +343,9 @@ | ||
| 364 | 343 | $form = self::fields_to_values( $form_action->menu_order, $values ); |
| 365 | 344 | |
| 366 | 345 | $use_logging = self::should_show_log_message( $action_type ); |
| 367 | 346 | |
| 368 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php'; | |
| 347 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); | |
| 369 | 348 | wp_die(); |
| 370 | 349 | } |
| 371 | 350 | |
| 372 | 351 | /** |
| @@ -400,18 +379,12 @@ | ||
| 400 | 379 | |
| 401 | 380 | return $form; |
| 402 | 381 | } |
| 403 | 382 | |
| 404 | - /** | |
| 405 | - * @param int $form_id | |
| 406 | - * @return void | |
| 407 | - */ | |
| 408 | 383 | public static function update_settings( $form_id ) { |
| 409 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 410 | 384 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 411 | 385 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 412 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 413 | - wp_die( esc_html( $frm_settings->admin_permission ) ); | |
| 386 | + wp_die( esc_html__( 'You do not have permission to do that', 'formidable' ) ); | |
| 414 | 387 | } |
| 415 | 388 | |
| 416 | 389 | global $wpdb; |
| 417 | 390 | |
| @@ -440,10 +413,8 @@ | ||
| 440 | 413 | } |
| 441 | 414 | $old_actions = array_diff( $old_actions, $new_actions ); |
| 442 | 415 | |
| 443 | 416 | self::delete_missing_actions( $old_actions ); |
| 444 | - | |
| 445 | - FrmOnSubmitHelper::save_on_submit_settings( $form_id ); | |
| 446 | 417 | } |
| 447 | 418 | |
| 448 | 419 | public static function delete_missing_actions( $old_actions ) { |
| 449 | 420 | if ( ! empty( $old_actions ) ) { |
| @@ -470,9 +441,9 @@ | ||
| 470 | 441 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 471 | 442 | $action_status = array( |
| 472 | 443 | 'post_status' => 'publish', |
| 473 | 444 | ); |
| 474 | - $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status ); | |
| 445 | + $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status ); | |
| 475 | 446 | |
| 476 | 447 | if ( empty( $form_actions ) ) { |
| 477 | 448 | return; |
| 478 | 449 | } |
| @@ -486,9 +457,9 @@ | ||
| 486 | 457 | |
| 487 | 458 | $stored_actions = array(); |
| 488 | 459 | $action_priority = array(); |
| 489 | 460 | |
| 490 | - if ( in_array( $event, array( 'create', 'update' ), true ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 461 | + if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 491 | 462 | $this_event = 'import'; |
| 492 | 463 | } else { |
| 493 | 464 | $this_event = $event; |
| 494 | 465 | } |
| @@ -494,9 +465,9 @@ | ||
| 494 | 465 | } |
| 495 | 466 | |
| 496 | 467 | foreach ( $form_actions as $action ) { |
| 497 | 468 | |
| 498 | - $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt; | |
| 469 | + $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) ); | |
| 499 | 470 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
| 500 | 471 | if ( $skip_this_action ) { |
| 501 | 472 | continue; |
| 502 | 473 | } |
| @@ -504,9 +475,9 @@ | ||
| 504 | 475 | if ( ! is_object( $entry ) ) { |
| 505 | 476 | $entry = FrmEntry::getOne( $entry, true ); |
| 506 | 477 | } |
| 507 | 478 | |
| 508 | - if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) { | |
| 479 | + if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { | |
| 509 | 480 | continue; |
| 510 | 481 | } |
| 511 | 482 | |
| 512 | 483 | $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'] ) ); |
| @@ -543,9 +514,9 @@ | ||
| 543 | 514 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 544 | 515 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 545 | 516 | |
| 546 | 517 | // If post is created, get updated $entry object. |
| 547 | - if ( $action->post_excerpt === 'wppost' && $event === 'create' ) { | |
| 518 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { | |
| 548 | 519 | $entry = FrmEntry::getOne( $entry->id, true ); |
| 549 | 520 | } |
| 550 | 521 | } |
| 551 | 522 | } |
| @@ -551,9 +522,9 @@ | ||
| 551 | 522 | } |
| 552 | 523 | } |
| 553 | 524 | |
| 554 | 525 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 555 | - if ( empty( $args['old_id'] ) ) { | |
| 526 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { | |
| 556 | 527 | // Continue if we know which actions to copy. |
| 557 | 528 | return; |
| 558 | 529 | } |
| 559 | 530 | |