PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.32.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.32.1
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
formidable / classes / models / FrmOnSubmitAction.php

FrmOnSubmitAction.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.32.1, at classes/models/FrmOnSubmitAction.php

105 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * On Submit form action
4 *
5 * @package Formidable
6 *
7 * @since 6.0
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 die( 'You are not allowed to call this page directly.' );
12 }
13
14 class FrmOnSubmitAction extends FrmFormAction {
15
16 /**
17 * @var string
18 */
19 public static $slug = 'on_submit';
20
21 public function __construct() {
22 $action_ops = array(
23 'classes' => 'frmfont frm_checkmark_circle_icon',
24 'active' => true,
25 'event' => array( 'create' ),
26 'limit' => 99,
27 'priority' => 9,
28 'color' => '#42C1B2',
29 'keywords' => __( 'redirect, success, confirmation, submit', 'formidable' ),
30 );
31 $action_ops = apply_filters( 'frm_' . self::$slug . '_control_settings', $action_ops );
32
33 $this->maybe_save_edit_trigger( $action_ops );
34
35 parent::__construct( self::$slug, self::get_name(), $action_ops );
36 }
37
38 /**
39 * @return string
40 */
41 public static function get_name() {
42 return __( 'Confirmation', 'formidable' );
43 }
44
45 /**
46 * @param object $instance
47 * @param array $args
48 */
49 public function form( $instance, $args = array() ) {
50 include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/on_submit_settings.php';
51 }
52
53 /**
54 * @return array
55 */
56 public function get_defaults() {
57 return array(
58 'success_action' => FrmOnSubmitHelper::get_default_action_type(),
59 'success_msg' => FrmOnSubmitHelper::get_default_msg(),
60 'show_form' => '',
61 'success_url' => '',
62 'success_page_id' => '',
63 'open_in_new_tab' => '',
64 'redirect_delay' => '',
65 // Value in second.
66 'redirect_delay_time' => 8,
67 'redirect_delay_msg' => FrmOnSubmitHelper::get_default_redirect_msg(),
68 );
69 }
70
71 /**
72 * This function should check that $new_instance is set correctly.
73 * The newly calculated value of $instance should be returned.
74 * If "false" is returned, the instance won't be saved/updated.
75 *
76 * @param array $new_instance New settings for this instance as input by the user via form().
77 * @param array $old_instance Old settings for this instance.
78 *
79 * @return array Settings to save or bool false to cancel saving
80 */
81 public function update( $new_instance, $old_instance ) {
82 if ( 'redirect' === $new_instance['post_content']['success_action'] && ! empty( $new_instance['post_content']['success_url'] ) ) {
83 $new_instance['post_content']['success_url'] = FrmFormsHelper::maybe_add_sanitize_url_attr(
84 $new_instance['post_content']['success_url'],
85 (int) $new_instance['menu_order']
86 );
87 }
88 return $new_instance;
89 }
90
91 /**
92 * Add a workaround in case Pro hasn't been updated. We don't want to
93 * lose the trigger and have edit messages start showing on create.
94 *
95 * @param array $action_ops The action setup details.
96 *
97 * @return void
98 */
99 protected function maybe_save_edit_trigger( &$action_ops ) {
100 if ( $action_ops['event'] === array( 'create' ) && FrmAppHelper::pro_is_installed() ) {
101 $action_ops['event'][] = 'update';
102 }
103 }
104 }
105