PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.3
Elementor Website Builder – more than just a page builder v3.2.3
4.3.0-beta3 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 All 452 releases
← All changes | includes/template-library/sources/base.php +1 -222 4.1.53.2.3 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2 namespace Elementor\TemplateLibrary;
3 3
4 4 use Elementor\Controls_Stack;
5 -use Elementor\Core\Settings\Page\Model;
6 5 use Elementor\Plugin;
7 6 use Elementor\Utils;
8 7
9 8 if ( ! defined( 'ABSPATH' ) ) {
@@ -276,9 +275,9 @@
276 275 protected function replace_elements_ids( $content ) {
277 276 return Plugin::$instance->db->iterate_data( $content, function( $element ) {
278 277 $element['id'] = Utils::generate_random_string();
279 278
280 - return apply_filters( 'elementor/document/element/replace_id', $element );
279 + return $element;
281 280 } );
282 281 }
283 282
284 283 /**
@@ -364,226 +363,6 @@
364 363 }
365 364 }
366 365
367 366 return $element_data;
368 - }
369 -
370 - public function get_item_children( array $args = [] ) {
371 - return [];
372 - }
373 -
374 - public function search_templates( array $args = [] ) {
375 - return [];
376 - }
377 -
378 - public function save_folder( array $folder_data = [] ) {
379 - return new \WP_Error( 'template_error', 'Folders cannot be created in this source' );
380 - }
381 -
382 - public function move_template_to_folder( array $folder_data = [] ) {
383 - return new \WP_Error( 'template_error', 'Templates cannot be moved in this source' );
384 - }
385 -
386 - public function move_bulk_templates_to_folder( array $folder_data = [] ) {
387 - return new \WP_Error( 'template_error', 'Templates cannot be moved in this source' );
388 - }
389 -
390 - public function save_bulk_items( array $args = [] ) {
391 - return [];
392 - }
393 -
394 - public function get_bulk_items( array $args = [] ) {
395 - return [];
396 - }
397 -
398 - /**
399 - * @param int $template_id
400 - * @return \Elementor\Core\Base\Document|\WP_Error
401 - */
402 - public function create_document_for_preview( int $template_id ) {
403 - return new \WP_Error( 'template_error', 'Can not generate preview for this source' );
404 - }
405 -
406 - /**
407 - * @param int $template_id
408 - * @param mixed $data
409 - * @return string|\WP_Error
410 - * @throws \Exception If template source operation fails or validation errors occur.
411 - */
412 - public function save_item_preview( int $template_id, $data ) {
413 - return new \WP_Error( 'template_error', 'Cannot save previews for this source' );
414 - }
415 -
416 - /**
417 - * @param int $template_id
418 - * @param string $error
419 - * @return string|\WP_Error
420 - * @throws \Exception If template processing fails or data validation errors occur.
421 - */
422 - public function mark_preview_as_failed( int $template_id, string $error ) {
423 - return new \WP_Error( 'template_error', 'Cannot mark preview as failed for this source' );
424 - }
425 -
426 - /**
427 - * @param int[] $template_ids
428 - * @return bool|\WP_Error
429 - */
430 - public function bulk_delete_items( array $template_ids ) {
431 - return new \WP_Error( 'template_error', 'Bulk delete action is not supported for this source' );
432 - }
433 -
434 - /**
435 - * @param int[] $template_ids
436 - * @return bool|\WP_Error
437 - */
438 - public function bulk_undo_delete_items( array $template_ids ) {
439 - return new \WP_Error( 'template_error', 'Undo delete action is not supported for this source' );
440 - }
441 -
442 - /**
443 - * @return array|\WP_Error
444 - */
445 - public function get_quota() {
446 - return new \WP_Error( 'template_error', 'This source does not support quotas' );
447 - }
448 -
449 - /**
450 - * @return array|\WP_Error
451 - */
452 - public function import_template( $name, $path, $import_mode = 'match_site' ) {
453 - return new \WP_Error( 'template_error', 'This source does not support import' );
454 - }
455 -
456 - public function supports_quota(): bool {
457 - return false;
458 - }
459 -
460 - public function validate_quota( array $items ) {
461 - return new \WP_Error( 'quota_error', 'This source does not support quota validation' );
462 - }
463 -
464 - public function prepare_import_template_data( $file_path, $import_mode = 'match_site' ) {
465 - $data = json_decode( Utils::file_get_contents( $file_path ), true );
466 -
467 - if ( empty( $data ) ) {
468 - return new \WP_Error( 'file_error', 'Invalid File' );
469 - }
470 -
471 - $content = $data['content'];
472 -
473 - if ( ! is_array( $content ) ) {
474 - return new \WP_Error( 'file_error', 'Invalid Content In File' );
475 - }
476 -
477 - $content = $this->process_export_import_content( $content, 'on_import' );
478 -
479 - $content = apply_filters(
480 - "elementor/template_library/sources/{$this->get_id()}/import/elements",
481 - $content
482 - );
483 -
484 - $import_result = apply_filters(
485 - 'elementor/template_library/import/process_content',
486 - [ 'content' => $content ],
487 - $import_mode,
488 - $data,
489 - $this
490 - );
491 -
492 - if ( is_array( $import_result ) && isset( $import_result['content'] ) ) {
493 - $content = $import_result['content'];
494 - }
495 -
496 - $page_settings = [];
497 -
498 - if ( ! empty( $data['page_settings'] ) ) {
499 - $page = new Model( [
500 - 'id' => 0,
501 - 'settings' => $data['page_settings'],
502 - ] );
503 -
504 - $page_settings_data = $this->process_element_export_import_content( $page, 'on_import' );
505 -
506 - if ( ! empty( $page_settings_data['settings'] ) ) {
507 - $page_settings = $page_settings_data['settings'];
508 - }
509 - }
510 -
511 - return [
512 - 'content' => $content,
513 - 'page_settings' => $page_settings,
514 - 'title' => $data['title'],
515 - 'type' => $data['type'],
516 - ];
517 - }
518 -
519 - /**
520 - * Send file headers.
521 - *
522 - * Set the file header when export template data to a file.
523 - *
524 - * @since 1.6.0
525 - * @access protected
526 - *
527 - * @param string $file_name File name.
528 - * @param int $file_size File size.
529 - */
530 - protected function send_file_headers( $file_name, $file_size ) {
531 - header( 'Content-Type: application/octet-stream' );
532 - header( 'Content-Disposition: attachment; filename=' . $file_name );
533 - header( 'Expires: 0' );
534 - header( 'Cache-Control: must-revalidate' );
535 - header( 'Pragma: public' );
536 - header( 'Content-Length: ' . $file_size );
537 - }
538 -
539 - protected function filesize( $path ) {
540 - return filesize( $path );
541 - }
542 -
543 - protected function serve_zip( $zip_complete_path ): void {
544 - @ob_end_flush();
545 - @readfile( $zip_complete_path );
546 - }
547 -
548 - protected function serve_file( string $file_content ): void {
549 - @ob_end_clean();
550 - flush();
551 -
552 - // PHPCS - Export widget json
553 - echo $file_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
554 - }
555 -
556 - protected function build_global_styles_snapshots( array $content, $template_id, array $context_data, array $existing_snapshots = [] ): array {
557 - $snapshots = apply_filters(
558 - 'elementor/template_library/export/build_snapshots',
559 - $existing_snapshots,
560 - $content,
561 - $template_id,
562 - $context_data
563 - );
564 -
565 - return $snapshots;
566 - }
567 -
568 - protected function attach_global_styles_to_data( array &$data, array $content, $template_id, array $existing_snapshots = [] ): void {
569 - $snapshots = $this->build_global_styles_snapshots( $content, $template_id, $data, $existing_snapshots );
570 -
571 - if ( ! empty( $snapshots['global_classes'] ) ) {
572 - $data['global_classes'] = $snapshots['global_classes'];
573 - }
574 -
575 - if ( ! empty( $snapshots['global_variables'] ) ) {
576 - $data['global_variables'] = $snapshots['global_variables'];
577 - }
578 - }
579 -
580 - protected static function attach_global_styles_to_data_static( array &$data, array $snapshots ): void {
581 - if ( ! empty( $snapshots['global_classes'] ) ) {
582 - $data['global_classes'] = $snapshots['global_classes'];
583 - }
584 -
585 - if ( ! empty( $snapshots['global_variables'] ) ) {
586 - $data['global_variables'] = $snapshots['global_variables'];
587 - }
588 367 }
589 368 }