| @@ -82,41 +82,9 @@ | ||
| 82 | 82 | * @type array $values Contains `fields` (form fields) and `id` (form ID). |
| 83 | 83 | * } |
| 84 | 84 | */ |
| 85 | 85 | public static function show_redirect_settings( $args ) { |
| 86 | - $id_attr = $args['action_control']->get_field_id( 'success_url' ); | |
| 87 | - ?> | |
| 88 | - <div class="frm_form_field frm_has_shortcodes"> | |
| 89 | - <label for="<?php echo esc_attr( $id_attr ); ?>"><?php esc_html_e( 'Redirect URL', 'formidable' ); ?></label> | |
| 90 | - <input | |
| 91 | - type="text" | |
| 92 | - id="<?php echo esc_attr( $id_attr ); ?>" | |
| 93 | - name="<?php echo esc_attr( $args['action_control']->get_field_name( 'success_url' ) ); ?>" | |
| 94 | - value="<?php echo esc_attr( $args['form_action']->post_content['success_url'] ); ?>" | |
| 95 | - /> | |
| 96 | - </div> | |
| 97 | - | |
| 98 | - <?php | |
| 99 | - $id_attr = $args['action_control']->get_field_id( 'open_in_new_tab' ); | |
| 100 | - $name_attr = $args['action_control']->get_field_name( 'open_in_new_tab' ); | |
| 101 | - ?> | |
| 102 | - <div class="frm_form_field"> | |
| 103 | - <?php | |
| 104 | - FrmHtmlHelper::toggle( | |
| 105 | - $id_attr, | |
| 106 | - $name_attr, | |
| 107 | - array( | |
| 108 | - 'div_class' => 'with_frm_style frm_toggle', | |
| 109 | - 'checked' => ! empty( $args['form_action']->post_content['open_in_new_tab'] ), | |
| 110 | - 'echo' => true, | |
| 111 | - ) | |
| 112 | - ); | |
| 113 | - ?> | |
| 114 | - <label for="<?php echo esc_attr( $id_attr ); ?>" <?php FrmAppHelper::maybe_add_tooltip( 'new_tab' ); ?>> | |
| 115 | - <?php esc_html_e( 'Open in new tab', 'formidable' ); ?> | |
| 116 | - </label> | |
| 117 | - </div> | |
| 118 | - <?php | |
| 86 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/on_submit_redirect_settings.php'; | |
| 119 | 87 | } |
| 120 | 88 | |
| 121 | 89 | /** |
| 122 | 90 | * Shows page settings. |
| @@ -134,8 +102,11 @@ | ||
| 134 | 102 | public static function show_page_settings( $args ) { |
| 135 | 103 | $name_attr = $args['action_control']->get_field_name( 'success_page_id' ); |
| 136 | 104 | ?> |
| 137 | 105 | <div class="frm_form_field"> |
| 106 | + <div class="frm_note_style"> | |
| 107 | + <?php esc_html_e( 'NOTE: The selected page content will be displayed, but the full page will not be loaded. Traditional URL tracking in Google Analytics and similar tools won\'t register a page load event. If precise tracking is essential, consider using the \'Redirect to URL\' option.', 'formidable' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 108 | + </div> | |
| 138 | 109 | <label for="<?php echo esc_attr( $name_attr ); ?>" class="screen-reader-text"> |
| 139 | 110 | <?php esc_html_e( 'Select a page', 'formidable' ); ?> |
| 140 | 111 | </label> |
| 141 | 112 | <?php |
| @@ -260,10 +231,13 @@ | ||
| 260 | 231 | $form_options[ $opt . 'action' ] = isset( $action->post_content['success_action'] ) ? $action->post_content['success_action'] : 'message'; |
| 261 | 232 | |
| 262 | 233 | switch ( $form_options[ $opt . 'action' ] ) { |
| 263 | 234 | case 'redirect': |
| 264 | - $form_options[ $opt . 'url' ] = isset( $action->post_content['success_url'] ) ? $action->post_content['success_url'] : ''; | |
| 265 | - $form_options['open_in_new_tab'] = ! empty( $action->post_content['open_in_new_tab'] ); | |
| 235 | + $form_options[ $opt . 'url' ] = isset( $action->post_content['success_url'] ) ? $action->post_content['success_url'] : ''; | |
| 236 | + $form_options['open_in_new_tab'] = ! empty( $action->post_content['open_in_new_tab'] ); | |
| 237 | + $form_options['redirect_delay'] = ! empty( $action->post_content['redirect_delay'] ); | |
| 238 | + $form_options['redirect_delay_time'] = $action->post_content['redirect_delay_time']; | |
| 239 | + $form_options['redirect_delay_msg'] = $action->post_content['redirect_delay_msg']; | |
| 266 | 240 | break; |
| 267 | 241 | |
| 268 | 242 | case 'page': |
| 269 | 243 | $form_options[ $opt . 'page_id' ] = isset( $action->post_content['success_page_id'] ) ? $action->post_content['success_page_id'] : ''; |
| @@ -294,9 +268,9 @@ | ||
| 294 | 268 | if ( self::form_has_migrated( $form ) ) { |
| 295 | 269 | return; |
| 296 | 270 | } |
| 297 | 271 | |
| 298 | - $form->id = $form_id; | |
| 272 | + $form->id = $form_id; | |
| 299 | 273 | $action_type = FrmOnSubmitAction::$slug; |
| 300 | 274 | |
| 301 | 275 | // Check if form already has form actions to avoid creating duplicates. |
| 302 | 276 | $has_actions = FrmFormAction::form_has_action_type( $form_id, $action_type ); |
| @@ -394,10 +368,15 @@ | ||
| 394 | 368 | /** |
| 395 | 369 | * @since 6.1.1 |
| 396 | 370 | * |
| 397 | 371 | * @param object $form Limited form object. |
| 372 | + * @return void | |
| 398 | 373 | */ |
| 399 | 374 | private static function save_migrated_success_actions( $form ) { |
| 375 | + // Options may be an empty string. | |
| 376 | + if ( ! is_array( $form->options ) ) { | |
| 377 | + $form->options = array(); | |
| 378 | + } | |
| 400 | 379 | $form->options['on_submit_migrated'] = 1; |
| 401 | 380 | FrmForm::update( $form->id, array( 'options' => $form->options ) ); |
| 402 | 381 | } |
| 403 | 382 | |
| @@ -405,9 +384,9 @@ | ||
| 405 | 384 | * Gets fallback action, used when no actions match. |
| 406 | 385 | * |
| 407 | 386 | * @since 6.1.1 |
| 408 | 387 | * |
| 409 | - * @param string|array $event Uses 'create' or 'update'. | |
| 388 | + * @param array|string $event Uses 'create' or 'update'. | |
| 410 | 389 | * |
| 411 | 390 | * @return object |
| 412 | 391 | */ |
| 413 | 392 | public static function get_fallback_action( $event = 'create' ) { |
| @@ -412,12 +391,20 @@ | ||
| 412 | 391 | */ |
| 413 | 392 | public static function get_fallback_action( $event = 'create' ) { |
| 414 | 393 | $action = new stdClass(); |
| 415 | 394 | |
| 395 | + $default_msg = self::get_default_msg(); | |
| 396 | + if ( current_user_can( 'frm_edit_forms' ) ) { | |
| 397 | + $default_msg .= '<br />'; | |
| 398 | + $default_msg .= '<span style="font-weight: 600; font-style: italic;">'; | |
| 399 | + $default_msg .= __( 'This is the fallback message. No confirmation actions match your conditional logic, or they are invalid.', 'formidable' ); | |
| 400 | + $default_msg .= '</span>'; | |
| 401 | + } | |
| 402 | + | |
| 416 | 403 | $action->post_content = array( |
| 417 | 404 | 'event' => (array) $event, |
| 418 | 405 | 'success_action' => 'message', |
| 419 | - 'success_msg' => self::get_default_msg(), | |
| 406 | + 'success_msg' => $default_msg, | |
| 420 | 407 | ); |
| 421 | 408 | |
| 422 | 409 | return $action; |
| 423 | 410 | } |
| @@ -426,9 +413,9 @@ | ||
| 426 | 413 | * Gets fallback action after opening the redirect URL in a new tab. |
| 427 | 414 | * |
| 428 | 415 | * @since 6.3.1 |
| 429 | 416 | * |
| 430 | - * @param string|array $event Uses 'create' or 'update'. | |
| 417 | + * @param array|string $event Uses 'create' or 'update'. | |
| 431 | 418 | * @return object |
| 432 | 419 | */ |
| 433 | 420 | public static function get_fallback_action_after_open_in_new_tab( $event ) { |
| 434 | 421 | $action = self::get_fallback_action( $event ); |
| @@ -438,9 +425,9 @@ | ||
| 438 | 425 | return $action; |
| 439 | 426 | } |
| 440 | 427 | |
| 441 | 428 | /** |
| 442 | - * Check if the current event has been paased. If not, use create actions. | |
| 429 | + * Check if the current event has been passed. If not, use create actions. | |
| 443 | 430 | * |
| 444 | 431 | * @since 6.1.1 |
| 445 | 432 | * |
| 446 | 433 | * @return string |