# Action On Export
Elementor Pro AdvancedBest practice is to exclude action settings when exporting Elementor data. If your form action adds some settings (action controls), you should not export them.
# On Export Method
The method that excludes data from the export process is called on_export()
. This method can be used to exclude action data when you export.
class Elementor_Test_Action extends \ElementorPro\Modules\Forms\Classes\Action_Base {
public function on_export( $element ) {
return $element;
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
- On Export - The
on_export()
method is used to clear settings when exporting. The$element
parameter is an array containing the data of the exported element.
# Exclude Settings
In the following example will register a new section with two controls - an api key and an app id. Then we will exclude them from the exported data:
class Elementor_Test_Action extends \ElementorPro\Modules\Forms\Classes\Action_Base {
public function register_settings_section( $widget ) {
$widget->start_controls_section(
'custom_action_section',
[
'label' => esc_html__( 'Custom Action', 'textdomain' ),
'condition' => [
'submit_actions' => $this->get_name(),
],
]
);
$widget->add_control(
'custom_action_api_key',
[
'label' => esc_html__( 'API Key', 'textdomain' ),
'type' => \Elementor\Controls_Manager::TEXT,
]
);
$widget->add_control(
'custom_action_app_id',
[
'label' => esc_html__( 'App ID', 'textdomain' ),
'type' => \Elementor\Controls_Manager::TEXT,
]
);
$widget->end_controls_section();
}
public function on_export( $element ) {
unset(
$element['custom_action_api_key'],
$element['custom_action_app_id'],
);
return $element;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46