PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.5.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.5.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/Platform/Elementor.php +7 -60 3.7.13.5.3 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';
@@ -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,9 +55,8 @@
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 59 templately()->assets->enqueue( 'templately-elementor', 'js/elementor.js', [ 'jquery' ], true );
63 60 templately()->admin->scripts( 'elementor' );
64 61 }
65 62
@@ -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 ) {
@@ -288,9 +285,9 @@
288 285 'visit' => get_permalink( $inserted_ID )
289 286 ];
290 287 }
291 288
292 - public function import_in_library( $id, $importer = null, $settings = [], $template_type = '', $type = '' ) {
289 + public function import_in_library( $id, $importer = null, $settings = [] ) {
293 290 $template_data = $importer->get_content( $id, 'elementor', 'remote' );
294 291
295 292 if ( is_wp_error( $template_data ) ) {
296 293 return $template_data;
@@ -299,21 +296,8 @@
299 296 if ( ! empty( $settings ) && ! empty( $template_data['content'] ) && is_array( $template_data['content'] ) ) {
300 297 $template_data['content'] = \Templately\Core\Importer\Utils\ElementorSettingsMerger::merge( $template_data['content'], $settings );
301 298 }
302 299
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 300 $importer = new ElementorImporter;
317 301 $imported_template = $importer->import_in_library( $template_data );
318 302
319 303 if( is_wp_error( $imported_template ) ) {
@@ -319,25 +303,12 @@
319 303 if( is_wp_error( $imported_template ) ) {
320 304 return $imported_template;
321 305 }
322 306
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 307 return [
337 - 'post_id' => $post_id,
338 - 'edit_link' => get_edit_post_link( $post_id, 'internal' ),
339 - 'elementor_edit_link' => $elementor_edit_link,
308 + 'post_id' => $imported_template['template_id'],
309 + 'edit_link' => get_edit_post_link( $imported_template['template_id'], 'internal' ),
310 + 'elementor_edit_link' => Plugin::$instance->documents->get( $imported_template['template_id'] )->get_edit_url(),
340 311 'visit' => $imported_template['url']
341 312 ];
342 313 }
343 314
@@ -361,13 +332,9 @@
361 332
362 333 return $_response;
363 334 }
364 335
365 - public function insert( $data, $postId = 0, $settings = [] ) {
366 - if ( ! empty( $settings ) && is_array( $settings ) && ! empty( $data['content'] ) && is_array( $data['content'] ) ) {
367 - $data['content'] = \Templately\Core\Importer\Utils\ElementorSettingsMerger::merge( $data['content'], $settings );
368 - }
369 -
336 + public function insert( $data ) {
370 337 $importer = new ElementorImporter();
371 338
372 339 return $importer->get_data( $data );
373 340 }
@@ -372,28 +339,8 @@
372 339 return $importer->get_data( $data );
373 340 }
374 341
375 342 /**
376 - * Register the Pro-promotion child-type fix once per request.
377 - *
378 - * Templates can reference Elementor Pro widgets (e.g. nested-carousel) that aren't
379 - * installed. Elementor substitutes a Pro_Widget_Promotion placeholder, but its
380 - * get_child_type() can't resolve the original nested children — so saving such a
381 - * template fatals with "get_default_args() on array". filter_child_type() restores
382 - * the correct child type. FSI registers this in FullSiteImport; single-template
383 - * imports go through Importer\Elementor::get_data(), which calls this so the filter
384 - * is active for every import path.
385 - */
386 - public static function register_child_type_filter() {
387 - static $registered = false;
388 - if ( $registered ) {
389 - return;
390 - }
391 - $registered = true;
392 - add_filter( 'elementor/element/get_child_type', [ __CLASS__, 'filter_child_type' ], 10, 3 );
393 - }
394 -
395 - /**
396 343 * Filter Child Type
397 344 *
398 345 * @param $child_type
399 346 * @param $element_data
@@ -418,5 +365,5 @@
418 365 }
419 366
420 367 return $child_type;
421 368 }
422 -}
369 +}