PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.3.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.3.3
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Core/Importer/Elementor.php +13 -53 3.7.13.3.3 View file →
@@ -8,9 +8,8 @@
8 8 use Elementor\Core\Settings\Page\Model;
9 9
10 10 use Elementor\Plugin as ElementorPlugin;
11 11 use Elementor\TemplateLibrary\Source_Local as ElementorLocal;
12 -use Templately\Core\Importer\Utils\Utils;
13 12
14 13 class Elementor extends ElementorLocal {
15 14 /**
16 15 * Get template data.
@@ -21,36 +20,18 @@
21 20 *
22 21 * @return array Remote Template data.
23 22 */
24 23 public function get_data( array $args ) {
25 - Utils::add_gd_editor_filter();
26 24 ElementorPlugin::$instance->editor->set_edit_mode( true );
27 25
28 - // Ensure the Pro-promotion child-type fix is active for every import path (not just FSI),
29 - // otherwise saving a template that uses an unavailable Elementor Pro widget (e.g.
30 - // nested-carousel) fatals while Elementor resolves its nested children. See
31 - // \Templately\Core\Platform\Elementor::filter_child_type().
32 - \Templately\Core\Platform\Elementor::register_child_type_filter();
33 -
34 26 $args['content'] = $this->replace_elements_ids( $args['content'] );
35 27 $args['content'] = $this->process_export_import_content( $args['content'], 'on_import' );
36 28
37 29 $args['content'] = $this->iterate_data(
38 30 $args['content'], function( $element_data ) {
39 - // A widget with null/missing widgetType causes get_widget_types(null) to return ALL
40 - // registered widgets as an array. The subsequent get_default_args() call then crashes
41 - // with "Call to a member function get_default_args() on array". Guard early.
42 - if ( 'widget' === ( $element_data['elType'] ?? '' ) && ! isset( $element_data['widgetType'] ) ) {
43 - return null;
44 - }
31 + $element = ElementorPlugin::$instance->elements_manager->create_element_instance( $element_data );
45 32
46 - try {
47 - $element = ElementorPlugin::$instance->elements_manager->create_element_instance( $element_data );
48 - } catch ( \Throwable $e ) {
49 - return null;
50 - }
51 -
52 - // If the widget/element doesn't exist, e.g. a deactivated plugin's widget
33 + // If the widget/element isn't exist, like a plugin that creates a widget but deactivated
53 34 if ( ! $element ) {
54 35 return null;
55 36 }
56 37
@@ -83,42 +64,24 @@
83 64 if ( ! is_array( $content ) ) {
84 65 return new WP_Error( 'file_error', 'Invalid File' );
85 66 }
86 67
87 - // type is already resolved by Platform::resolve_library_type() before reaching here.
88 - // Validate it exists; fall back to 'page_single' if somehow unregistered.
89 - $type = $data['type'] ?? 'page_single';
90 - $registered_types = templately()->theme_builder::$templates_manager->get_template_types();
91 - if ( ! isset( $registered_types[ $type ] ) ) {
92 - $type = 'page_single';
93 - }
68 + $page_settings = $this->page_settings( $data );
94 69
95 - $factory = new \Templately\Builder\Factory\TemplateFactory( 'elementor' );
70 + // TODO: type check for (theme builder)
96 71
97 - $template = $factory->create( $type, [
98 - 'post_title' => $data['title'],
99 - 'post_status' => 'publish',
100 - 'post_type' => 'templately_library',
72 + $template_id = $this->save_item( [
73 + 'content' => $content,
74 + 'title' => $data['title'],
75 + 'type' => $data['type'],
76 + 'page_settings' => $page_settings,
101 77 ] );
102 78
103 - if ( is_wp_error( $template ) ) {
104 - return $template;
79 + if ( is_wp_error( $template_id ) ) {
80 + return $template_id;
105 81 }
106 82
107 - $template->import( array_merge( $data, [
108 - 'import_settings' => [
109 - 'title' => $data['title'],
110 - 'type' => $type,
111 - ]
112 - ] ) );
113 -
114 - $post_id = $template->get_main_id();
115 -
116 - return [
117 - 'template_id' => $post_id,
118 - 'edit_link' => get_edit_post_link( $post_id, 'internal' ),
119 - 'url' => get_permalink( $post_id ),
120 - ];
83 + return $this->get_item( $template_id );
121 84 }
122 85
123 86 public function create_page( $template_data ){
124 87 $page_settings = $this->page_settings( $template_data );
@@ -130,13 +93,10 @@
130 93 ];
131 94
132 95 $template_data = wp_parse_args( $template_data, $defaults );
133 96
134 - // Elementor has no 'block' document type; map it to 'section' (saved section).
135 - $doc_type = ( 'block' === $template_data['type'] ) ? 'section' : $template_data['type'];
136 -
137 97 $document = ElementorPlugin::$instance->documents->create(
138 - $doc_type,
98 + $template_data['type'],
139 99 [
140 100 'post_title' => $template_data['post_title'],
141 101 'post_status' => $template_data['status'],
142 102 'post_type' => 'page',