PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.3
Elementor Website Builder – more than just a page builder v3.17.3
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 4.0.7 All 451 releases
elementor / app / modules / import-export / runners / export / wp-content.php

wp-content.php in Elementor Website Builder – more than just a page builder 3.17.3, at app/modules/import-export/runners/export/wp-content.php

80 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\App\Modules\ImportExport\Runners\Export;
4
5 use Elementor\App\Modules\ImportExport\Utils as ImportExportUtils;
6 use Elementor\Core\Utils\ImportExport\WP_Exporter;
7
8 class Wp_Content extends Export_Runner_Base {
9
10 public static function get_name() : string {
11 return 'wp-content';
12 }
13
14 public function should_export( array $data ) {
15 return (
16 isset( $data['include'] ) &&
17 in_array( 'content', $data['include'], true )
18 );
19 }
20
21 public function export( array $data ) {
22 $post_types = ImportExportUtils::get_builtin_wp_post_types();
23 $custom_post_types = isset( $data['selected_custom_post_types'] ) ? $data['selected_custom_post_types'] : [];
24
25 $files = [];
26 $manifest_data = [];
27
28 foreach ( $post_types as $post_type ) {
29 $export = $this->export_wp_post_type( $post_type );
30 $files[] = $export['file'];
31 $manifest_data['wp-content'][ $post_type ] = $export['manifest_data'];
32 }
33
34 foreach ( $custom_post_types as $post_type ) {
35 $export = $this->export_wp_post_type( $post_type );
36 $files[] = $export['file'];
37 $manifest_data['wp-content'][ $post_type ] = $export['manifest_data'];
38
39 $post_type_object = get_post_type_object( $post_type );
40
41 $manifest_data['custom-post-type-title'][ $post_type ] = [
42 'name' => $post_type_object->name,
43 'label' => $post_type_object->label,
44 ];
45 }
46
47 return [
48 'files' => $files,
49 'manifest' => [
50 $manifest_data,
51 ],
52 ];
53 }
54
55 private function export_wp_post_type( $post_type ) {
56 $wp_exporter = new WP_Exporter( [
57 'content' => $post_type,
58 'status' => 'publish',
59 'limit' => 20,
60 'meta_query' => [
61 [
62 'key' => static::META_KEY_ELEMENTOR_EDIT_MODE,
63 'compare' => 'NOT EXISTS',
64 ],
65 ],
66 'include_post_featured_image_as_attachment' => true,
67 ] );
68
69 $export_result = $wp_exporter->run();
70
71 return [
72 'file' => [
73 'path' => 'wp-content/' . $post_type . '/' . $post_type . '.xml',
74 'data' => $export_result['xml'],
75 ],
76 'manifest_data' => $export_result['ids'],
77 ];
78 }
79 }
80