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

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