PluginProbe
Hello Plus / 1.2.0
Hello Plus v1.2.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / forms / actions / redirect.php

redirect.php in Hello Plus 1.2.0, at modules/forms/actions/redirect.php

80 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace HelloPlus\Modules\Forms\Actions;
3
4 use Elementor\Controls_Manager;
5 use Elementor\Modules\DynamicTags\Module as TagsModule;
6 use HelloPlus\Modules\Forms\Classes\Action_Base;
7
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 class Redirect extends Action_Base {
14
15 public function get_name(): string {
16 return 'ehp-redirect';
17 }
18
19 public function get_label(): string {
20 return esc_html__( 'Redirect', 'hello-plus' );
21 }
22
23 public function register_settings_section( $widget ) {
24 $widget->start_controls_section(
25 'section_redirect',
26 [
27 'label' => esc_html__( 'Redirect', 'hello-plus' ),
28 'condition' => [
29 'submit_actions' => $this->get_name(),
30 ],
31 ]
32 );
33
34 $widget->add_control(
35 'redirect_to',
36 [
37 'label' => esc_html__( 'Redirect To', 'hello-plus' ),
38 'type' => Controls_Manager::TEXT,
39 'placeholder' => esc_html__( 'https://your-link.com', 'hello-plus' ),
40 'ai' => [
41 'active' => false,
42 ],
43 'dynamic' => [
44 'active' => true,
45 'categories' => [
46 TagsModule::POST_META_CATEGORY,
47 TagsModule::TEXT_CATEGORY,
48 TagsModule::URL_CATEGORY,
49 ],
50 ],
51 'label_block' => true,
52 'render_type' => 'none',
53 'classes' => 'elementor-control-direction-ltr',
54 ]
55 );
56
57 $widget->end_controls_section();
58 }
59
60 public function on_export( $element ) {
61 unset(
62 $element['settings']['redirect_to']
63 );
64
65 return $element;
66 }
67
68 public function run( $record, $ajax_handler ) {
69 $redirect_to = $record->get_form_settings( 'redirect_to' );
70
71 $redirect_to = $record->replace_setting_shortcodes( $redirect_to, true );
72
73 $redirect_to = esc_url_raw( $redirect_to );
74
75 if ( ! empty( $redirect_to ) && filter_var( $redirect_to, FILTER_VALIDATE_URL ) ) {
76 $ajax_handler->add_response_data( 'redirect_url', $redirect_to );
77 }
78 }
79 }
80