PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.1
Elementor Website Builder – more than just a page builder v3.31.1
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / app / modules / import-export-customization / data / routes / export.php

export.php in Elementor Website Builder – more than just a page builder 3.31.1, at app/modules/import-export-customization/data/routes/export.php

118 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\App\Modules\ImportExportCustomization\Data\Routes;
3
4 use Elementor\Plugin;
5 use Elementor\App\Modules\ImportExportCustomization\Data\Response;
6 use Elementor\Utils as ElementorUtils;
7
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 class Export extends Base_Route {
14
15 protected function get_route(): string {
16 return 'export';
17 }
18
19 protected function get_method(): string {
20 return \WP_REST_Server::CREATABLE;
21 }
22
23 protected function callback( $request ): \WP_REST_Response {
24 try {
25 $settings = [
26 'include' => $request->get_param( 'include' ),
27 'kitInfo' => $request->get_param( 'kitInfo' ),
28 'plugins' => $request->get_param( 'plugins' ),
29 'selectedCustomPostTypes' => $request->get_param( 'selectedCustomPostTypes' ),
30 'screenShotBlob' => $request->get_param( 'screenShotBlob' ),
31 ];
32
33 $settings = array_filter( $settings );
34
35 $source = $settings['kitInfo']['source'];
36
37 $module = Plugin::$instance->app->get_component( 'import-export-customization' );
38
39 $export = $module->export_kit( $settings );
40
41 $file_name = $export['file_name'];
42 $file = ElementorUtils::file_get_contents( $file_name );
43
44 if ( ! $file ) {
45 throw new \Error( 'Could not read the exported file.' );
46 }
47
48 Plugin::$instance->uploads_manager->remove_file_or_dir( dirname( $file_name ) );
49
50 $result = apply_filters(
51 'elementor/export/kit/export-result',
52 [
53 'manifest' => $export['manifest'],
54 'file' => base64_encode( $file ),
55 ],
56 $source,
57 $export,
58 $settings,
59 $file,
60 );
61
62 if ( is_wp_error( $result ) ) {
63 throw new \Error( $result->get_error_message() );
64 }
65
66 return Response::success( $result );
67
68 } catch ( \Error |\Exception $e ) {
69 Plugin::$instance->logger->get_logger()->error( $e->getMessage(), [
70 'meta' => [
71 'trace' => $e->getTraceAsString(),
72 ],
73 ] );
74
75 return Response::error( 'export_error', $e->getMessage() );
76 }
77 }
78
79 protected function get_args(): array {
80 return [
81 'include' => [
82 'type' => 'array',
83 'description' => 'Content types to include in export',
84 'required' => false,
85 'default' => [ 'templates', 'content', 'settings', 'plugins' ],
86 ],
87 'kitInfo' => [
88 'type' => 'object',
89 'description' => 'Kit information',
90 'required' => false,
91 'default' => [
92 'title' => 'Elementor Website Template',
93 'description' => '',
94 'source' => 'local',
95 ],
96 ],
97 'plugins' => [
98 'type' => 'array',
99 'description' => 'Selected plugins to export',
100 'required' => false,
101 'default' => [],
102 ],
103 'selectedCustomPostTypes' => [
104 'type' => 'array',
105 'description' => 'Selected custom post types',
106 'required' => false,
107 'default' => [],
108 ],
109 'screenShotBlob' => [
110 'type' => 'string',
111 'description' => 'Base64 encoded screenshot for cloud exports',
112 'required' => false,
113 'default' => null,
114 ],
115 ];
116 }
117 }
118