PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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 / modules / default-styles / import-export-customization / runners / export.php

export.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/default-styles/import-export-customization/runners/export.php

75 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\DefaultStyles\ImportExportCustomization\Runners;
4
5 use Elementor\App\Modules\ImportExportCustomization\Runners\Export\Export_Runner_Base;
6 use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
7 use Elementor\Modules\DefaultStyles\Default_Styles_Repository;
8 use Elementor\Modules\DefaultStyles\ImportExportCustomization\Import_Export_Customization;
9 use Elementor\Plugin;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 class Export extends Export_Runner_Base {
16 public static function get_name(): string {
17 return 'default-styles';
18 }
19
20 public function should_export( array $data ): bool {
21 return (
22 isset( $data['include'] ) &&
23 in_array( 'settings', $data['include'], true ) &&
24 $this->is_feature_active()
25 );
26 }
27
28 private function is_feature_active(): bool {
29 return Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_NAME );
30 }
31
32 public function export( array $data ): array {
33 $kit = Plugin::$instance->kits_manager->get_active_kit();
34
35 if ( ! $kit ) {
36 return $this->empty_result();
37 }
38
39 $files = [];
40 $skip_migration = true;
41
42 Default_Styles_Repository::make( $kit )->each_item(
43 static function ( array $style_data ) use ( &$files ) {
44 if ( empty( $style_data['id'] ) || ! is_string( $style_data['id'] ) ) {
45 return;
46 }
47
48 $tag = $style_data['id'];
49
50 $files[] = [
51 'path' => Import_Export_Customization::DIRECTORY_NAME . '/' . $tag . '.json',
52 'data' => wp_json_encode( $style_data ),
53 ];
54 },
55 $skip_migration
56 );
57
58 if ( empty( $files ) ) {
59 return $this->empty_result();
60 }
61
62 return [
63 'files' => $files,
64 'manifest' => [],
65 ];
66 }
67
68 private function empty_result(): array {
69 return [
70 'manifest' => [],
71 'files' => [],
72 ];
73 }
74 }
75