| 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 |
public static function get_name() { |
| 35 |
return __( 'Confirmation', 'formidable' ); |
| 36 |
} |
| 37 |
|
| 38 |
public function form( $instance, $args = array() ) { |
| 39 |
include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/on_submit_settings.php'; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_defaults() { |
| 43 |
return array( |
| 44 |
'success_action' => FrmOnSubmitHelper::get_default_action_type(), |
| 45 |
'success_msg' => FrmOnSubmitHelper::get_default_msg(), |
| 46 |
'show_form' => '', |
| 47 |
'success_url' => '', |
| 48 |
'success_page_id' => '', |
| 49 |
); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Add a workaround in case Pro hasn't been updated. We don't want to |
| 54 |
* lose the trigger and have edit messages start showing on create. |
| 55 |
* |
| 56 |
* @param array $action_ops The action setup details. |
| 57 |
* |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
protected function maybe_save_edit_trigger( &$action_ops ) { |
| 61 |
if ( $action_ops['event'] === array( 'create' ) && FrmAppHelper::pro_is_installed() ) { |
| 62 |
$action_ops['event'][] = 'update'; |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
|