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 / template-parts / classes / runners / export.php

export.php in Hello Plus 1.2.0, at modules/template-parts/classes/runners/export.php

68 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace HelloPlus\Modules\TemplateParts\Classes\Runners;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 use Elementor\App\Modules\ImportExport\Runners\Export\Export_Runner_Base;
9 use Elementor\Core\Base\Document;
10 use Elementor\TemplateLibrary\Source_Local;
11 use HelloPlus\Includes\Utils;
12
13 class Export extends Export_Runner_Base {
14 public static function get_name(): string {
15 return 'templates';
16 }
17
18 public function should_export( array $data ) {
19 return (
20 isset( $data['include'] ) &&
21 in_array( 'templates', $data['include'], true )
22 );
23 }
24
25 public function export( array $data ) {
26 $template_types = array_values( Source_Local::get_template_types() );
27
28 $query_args = [
29 'post_type' => Source_Local::CPT,
30 'post_status' => 'publish',
31 'posts_per_page' => -1,
32 'meta_query' => [
33 [
34 'key' => Document::TYPE_META_KEY,
35 'value' => $template_types,
36 ],
37 ],
38 ];
39
40 $templates_query = new \WP_Query( $query_args );
41
42 $templates_manifest_data = [];
43 $files = [];
44
45 foreach ( $templates_query->posts as $template_post ) {
46 $template_id = $template_post->ID;
47
48 $template_document = Utils::elementor()->documents->get( $template_id );
49
50 $templates_manifest_data[ $template_id ] = $template_document->get_export_summary();
51
52 $files[] = [
53 'path' => 'templates/' . $template_id,
54 'data' => $template_document->get_export_data(),
55 ];
56 }
57
58 $manifest_data['templates'] = $templates_manifest_data;
59
60 return [
61 'files' => $files,
62 'manifest' => [
63 $manifest_data,
64 ],
65 ];
66 }
67 }
68