PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.3.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.3.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 +6 -71 3.6.63.3.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';
@@ -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 ) {
@@ -243,9 +240,9 @@
243 240 * @since 2.0.0
244 241 *
245 242 * @return array|WP_Error array on success, WP_Error on failure.
246 243 */
247 - public function create_page( $id, $title, $importer = null, $settings = [] ) {
244 + public function create_page( $id, $title, $importer = null ) {
248 245 $template_data = $importer->get_content( $id );
249 246
250 247 if ( is_wp_error( $template_data ) ) {
251 248 return $template_data;
@@ -250,12 +247,8 @@
250 247 if ( is_wp_error( $template_data ) ) {
251 248 return $template_data;
252 249 }
253 250
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 251 $importer = new ElementorImporter;
259 252 $template_data = $importer->get_data( $template_data );
260 253
261 254 if ( ! empty( $title ) ) {
@@ -288,9 +281,9 @@
288 281 'visit' => get_permalink( $inserted_ID )
289 282 ];
290 283 }
291 284
292 - public function import_in_library( $id, $importer = null, $settings = [], $template_type = '', $type = '' ) {
285 + public function import_in_library( $id, $importer = null ) {
293 286 $template_data = $importer->get_content( $id, 'elementor', 'remote' );
294 287
295 288 if ( is_wp_error( $template_data ) ) {
296 289 return $template_data;
@@ -295,25 +288,8 @@
295 288 if ( is_wp_error( $template_data ) ) {
296 289 return $template_data;
297 290 }
298 291
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 292 $importer = new ElementorImporter;
317 293 $imported_template = $importer->import_in_library( $template_data );
318 294
319 295 if( is_wp_error( $imported_template ) ) {
@@ -319,25 +295,12 @@
319 295 if( is_wp_error( $imported_template ) ) {
320 296 return $imported_template;
321 297 }
322 298
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 299 return [
337 - 'post_id' => $post_id,
338 - 'edit_link' => get_edit_post_link( $post_id, 'internal' ),
339 - 'elementor_edit_link' => $elementor_edit_link,
300 + 'post_id' => $imported_template['template_id'],
301 + 'edit_link' => get_edit_post_link( $imported_template['template_id'], 'internal' ),
302 + 'elementor_edit_link' => Plugin::$instance->documents->get( $imported_template['template_id'] )->get_edit_url(),
340 303 'visit' => $imported_template['url']
341 304 ];
342 305 }
343 306
@@ -365,34 +328,6 @@
365 328 public function insert( $data ) {
366 329 $importer = new ElementorImporter();
367 330
368 331 return $importer->get_data( $data );
369 - }
370 -
371 - /**
372 - * Filter Child Type
373 - *
374 - * @param $child_type
375 - * @param $element_data
376 - * @param $element
377 - *
378 - * @return mixed
379 - */
380 - public static function filter_child_type( $child_type, $element_data, $element ) {
381 - // Fix for Elementor Pro Promotion Widget
382 - if ( is_a( $element, 'Elementor\Modules\Promotions\Widgets\Pro_Widget_Promotion' ) || ( is_object( $element ) && 'pro-promotion' === $element->get_name() ) ) {
383 - $el_types = array_keys( Plugin::$instance->elements_manager->get_element_types() );
384 -
385 - if ( isset( $element_data['elType'] ) && in_array( $element_data['elType'], $el_types, true ) ) {
386 - return Plugin::$instance->elements_manager->get_element_types( $element_data['elType'] );
387 - }
388 -
389 - if ( ! isset( $element_data['widgetType'] ) ) {
390 - return null;
391 - }
392 -
393 - return Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] );
394 - }
395 -
396 - return $child_type;
397 332 }
398 333 }