PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 2.2.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v2.2.2
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/Platform/Elementor.php +11 -102 3.6.72.2.2 View file →
@@ -15,9 +15,8 @@
15 15 use Elementor\Plugin;
16 16 use Elementor\Core\Kits\Documents\Kit;
17 17 use Elementor\Core\Settings\Manager as SettingsManager;
18 18 use Templately\Core\Importer\Elementor as ElementorImporter;
19 -use Templately\Core\Importer\Utils\Utils;
20 19 use Elementor\TemplateLibrary\Source_Local as ElementorLocal;
21 20
22 21 class Elementor extends Platform {
23 22 private $id = 'elementor';
@@ -38,9 +37,9 @@
38 37 public function hooks() {
39 38 if ( class_exists( '\Elementor\Plugin' ) ) {
40 39 add_action( 'elementor/preview/enqueue_styles', [ $this, 'styles' ] );
41 40 add_action( 'elementor/editor/before_enqueue_styles', [ $this, 'styles' ] );
42 - add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'scripts' ] );
41 + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'scripts' ] );
43 42 }
44 43 }
45 44
46 45 /**
@@ -48,9 +47,8 @@
48 47 * @return void
49 48 */
50 49 public function styles() {
51 50 templately()->assets->enqueue( 'templately-elementor-preview', 'css/elementor.css' );
52 - templately()->assets->enqueue( 'templately-tailwind', 'css/tailwind.css', ['templately-elementor-preview'] );
53 51 }
54 52
55 53 /**
56 54 * Assets Enqueueing
@@ -57,10 +55,9 @@
57 55 * @return void
58 56 */
59 57 public function scripts() {
60 58 templately()->assets->enqueue( 'templately-elementor', 'css/elementor.css' );
61 - templately()->assets->enqueue( 'templately-tailwind', 'css/tailwind.css', ['templately-elementor'] );
62 - templately()->assets->enqueue( 'templately-elementor', 'js/elementor.js', [ 'jquery' ], true );
59 + templately()->assets->enqueue( 'templately-elementor', 'js/elementor.js', [ 'jquery' ] );
63 60 templately()->admin->scripts( 'elementor' );
64 61 }
65 62
66 63 /**
@@ -77,9 +74,9 @@
77 74 * Checking the template eligibility for import.
78 75 *
79 76 * @return WP_Error|void
80 77 */
81 - protected function is_eligible( $template, $types = [ 'page', 'section', 'block' ] ) {
78 + protected function is_eligible( $template, $types = [ 'page', 'section' ] ) {
82 79 if ( ! Helper::is_plugin_active( 'elementor-pro/elementor-pro.php' ) &&
83 80 isset( $template['type'] ) &&
84 81 ! in_array( $template['type'], $types, true )
85 82 ) {
@@ -97,12 +94,8 @@
97 94 }
98 95 }
99 96
100 97 public function get_saved_templates( $params = [] ) {
101 - if ( ! function_exists( 'is_plugin_active' ) ){
102 - require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
103 - }
104 -
105 98 $_page_number = isset( $params['page'] ) ? intval( $params['page'] ) : 1;
106 99
107 100 $args = [
108 101 'post_type' => 'elementor_library',
@@ -135,13 +128,11 @@
135 128 wp_reset_postdata();
136 129 wp_reset_query();
137 130
138 131 return array(
139 - 'current_page' => $templates->query_vars['paged'],
140 - 'total_page' => $templates->max_num_pages,
141 - 'items' => $templateList,
142 - 'has_elementor' => rest_sanitize_boolean( \is_plugin_active( 'elementor/elementor.php' ) ),
143 - 'has_elementor_pro' => rest_sanitize_boolean( \is_plugin_active( 'elementor-pro/elementor-pro.php' ) ),
132 + 'current_page' => $templates->query_vars['paged'],
133 + 'total_page' => $templates->max_num_pages,
134 + 'items' => $templateList,
144 135 );
145 136 }
146 137
147 138 private function get_export_link( $template_id ) {
@@ -243,9 +234,9 @@
243 234 * @since 2.0.0
244 235 *
245 236 * @return array|WP_Error array on success, WP_Error on failure.
246 237 */
247 - public function create_page( $id, $title, $importer = null, $settings = [] ) {
238 + public function create_page( $id, $title, $importer = null ) {
248 239 $template_data = $importer->get_content( $id );
249 240
250 241 if ( is_wp_error( $template_data ) ) {
251 242 return $template_data;
@@ -250,12 +241,8 @@
250 241 if ( is_wp_error( $template_data ) ) {
251 242 return $template_data;
252 243 }
253 244
254 - if ( ! empty( $settings ) && ! empty( $template_data['content'] ) && is_array( $template_data['content'] ) ) {
255 - $template_data['content'] = \Templately\Core\Importer\Utils\ElementorSettingsMerger::merge( $template_data['content'], $settings );
256 - }
257 -
258 245 $importer = new ElementorImporter;
259 246 $template_data = $importer->get_data( $template_data );
260 247
261 248 if ( ! empty( $title ) ) {
@@ -288,9 +275,9 @@
288 275 'visit' => get_permalink( $inserted_ID )
289 276 ];
290 277 }
291 278
292 - public function import_in_library( $id, $importer = null, $settings = [], $template_type = '', $type = '' ) {
279 + public function import_in_library( $id, $importer = null ) {
293 280 $template_data = $importer->get_content( $id, 'elementor', 'remote' );
294 281
295 282 if ( is_wp_error( $template_data ) ) {
296 283 return $template_data;
@@ -295,25 +282,8 @@
295 282 if ( is_wp_error( $template_data ) ) {
296 283 return $template_data;
297 284 }
298 285
299 - if ( ! empty( $settings ) && ! empty( $template_data['content'] ) && is_array( $template_data['content'] ) ) {
300 - $template_data['content'] = \Templately\Core\Importer\Utils\ElementorSettingsMerger::merge( $template_data['content'], $settings );
301 - }
302 -
303 - // Frontend-provided template_type (from item details API) takes precedence over
304 - // whatever the fetched content JSON reports.
305 - if ( ! empty( $template_type ) ) {
306 - $template_data['template_type'] = $template_type;
307 - }
308 -
309 - // Resolve the correct Builder Type using template_type before passing to the importer.
310 - try {
311 - $template_data['type'] = static::resolve_library_type( $template_data );
312 - } catch ( \InvalidArgumentException $e ) {
313 - return Helper::error( 'unsupported_template_type', $e->getMessage(), 'import', 400 );
314 - }
315 -
316 286 $importer = new ElementorImporter;
317 287 $imported_template = $importer->import_in_library( $template_data );
318 288
319 289 if( is_wp_error( $imported_template ) ) {
@@ -319,25 +289,12 @@
319 289 if( is_wp_error( $imported_template ) ) {
320 290 return $imported_template;
321 291 }
322 292
323 - $post_id = $imported_template['template_id'];
324 -
325 - // Companion content for archive/fluent types — same side effects (Shop page,
326 - // page_for_posts, LearnDash courses slug, fluent single-page template) the FSI
327 - // Templates runner performs when importing these template types.
328 - Utils::create_companion_content( $template_data['type'], $template_data['title'] ?? '', 'elementor' );
329 -
330 - // Mark user as having imported a template
331 - \Templately\Utils\Options::get_instance()->set( 'has_imported_template', true );
332 -
333 - $document = Plugin::$instance->documents->get( $post_id );
334 - $elementor_edit_link = $document ? $document->get_edit_url() : admin_url( 'post.php?post=' . $post_id . '&action=elementor' );
335 -
336 293 return [
337 - 'post_id' => $post_id,
338 - 'edit_link' => get_edit_post_link( $post_id, 'internal' ),
339 - 'elementor_edit_link' => $elementor_edit_link,
294 + 'post_id' => $imported_template['template_id'],
295 + 'edit_link' => get_edit_post_link( $imported_template['template_id'], 'internal' ),
296 + 'elementor_edit_link' => Plugin::$instance->documents->get( $imported_template['template_id'] )->get_edit_url(),
340 297 'visit' => $imported_template['url']
341 298 ];
342 299 }
343 300
@@ -365,54 +322,6 @@
365 322 public function insert( $data ) {
366 323 $importer = new ElementorImporter();
367 324
368 325 return $importer->get_data( $data );
369 - }
370 -
371 - /**
372 - * Register the Pro-promotion child-type fix once per request.
373 - *
374 - * Templates can reference Elementor Pro widgets (e.g. nested-carousel) that aren't
375 - * installed. Elementor substitutes a Pro_Widget_Promotion placeholder, but its
376 - * get_child_type() can't resolve the original nested children — so saving such a
377 - * template fatals with "get_default_args() on array". filter_child_type() restores
378 - * the correct child type. FSI registers this in FullSiteImport; single-template
379 - * imports go through Importer\Elementor::get_data(), which calls this so the filter
380 - * is active for every import path.
381 - */
382 - public static function register_child_type_filter() {
383 - static $registered = false;
384 - if ( $registered ) {
385 - return;
386 - }
387 - $registered = true;
388 - add_filter( 'elementor/element/get_child_type', [ __CLASS__, 'filter_child_type' ], 10, 3 );
389 - }
390 -
391 - /**
392 - * Filter Child Type
393 - *
394 - * @param $child_type
395 - * @param $element_data
396 - * @param $element
397 - *
398 - * @return mixed
399 - */
400 - public static function filter_child_type( $child_type, $element_data, $element ) {
401 - // Fix for Elementor Pro Promotion Widget
402 - if ( is_a( $element, 'Elementor\Modules\Promotions\Widgets\Pro_Widget_Promotion' ) || ( is_object( $element ) && 'pro-promotion' === $element->get_name() ) ) {
403 - $el_types = array_keys( Plugin::$instance->elements_manager->get_element_types() );
404 -
405 - if ( isset( $element_data['elType'] ) && in_array( $element_data['elType'], $el_types, true ) ) {
406 - return Plugin::$instance->elements_manager->get_element_types( $element_data['elType'] );
407 - }
408 -
409 - if ( ! isset( $element_data['widgetType'] ) ) {
410 - return null;
411 - }
412 -
413 - return Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] );
414 - }
415 -
416 - return $child_type;
417 326 }
418 327 }