PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.0-dev2
Elementor Website Builder – more than just a page builder v3.1.0-dev2
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 4.0.7 All 451 releases
← All changes | core/base/document.php +69 -10 3.1.0-dev13.1.0-dev2 View file →
@@ -3,9 +3,8 @@
3 3
4 4 use Elementor\Core\Files\CSS\Post as Post_CSS;
5 5 use Elementor\Core\Utils\Exceptions;
6 6 use Elementor\Plugin;
7 -use Elementor\DB;
8 7 use Elementor\Controls_Manager;
9 8 use Elementor\Controls_Stack;
10 9 use Elementor\User;
11 10 use Elementor\Core\Settings\Manager as SettingsManager;
@@ -33,8 +32,36 @@
33 32 */
34 33 const TYPE_META_KEY = '_elementor_template_type';
35 34 const PAGE_META_KEY = '_elementor_page_settings';
36 35
36 + const BUILT_WITH_ELEMENTOR_META_KEY = '_elementor_edit_mode';
37 +
38 + /**
39 + * Document publish status.
40 + */
41 + const STATUS_PUBLISH = 'publish';
42 +
43 + /**
44 + * Document draft status.
45 + */
46 + const STATUS_DRAFT = 'draft';
47 +
48 + /**
49 + * Document private status.
50 + */
51 + const STATUS_PRIVATE = 'private';
52 +
53 + /**
54 + * Document autosave status.
55 + */
56 + const STATUS_AUTOSAVE = 'autosave';
57 +
58 + /**
59 + * Document pending status.
60 + */
61 + const STATUS_PENDING = 'pending';
62 +
63 +
37 64 private $main_id;
38 65
39 66 /**
40 67 * @var bool
@@ -55,8 +82,18 @@
55 82 */
56 83 protected $post;
57 84
58 85 /**
86 + * Settings to be Saved
87 + *
88 + * A variable that temporarily stores the new settings while the document is being saved.
89 + *
90 + * @since 3.1.0
91 + * @access protected
92 + */
93 + protected $settings_to_be_saved;
94 +
95 + /**
59 96 * @since 2.1.0
60 97 * @access protected
61 98 * @static
62 99 */
@@ -551,9 +588,9 @@
551 588 $data = wp_kses_post_deep( $data );
552 589 }
553 590
554 591 if ( ! empty( $data['settings'] ) ) {
555 - if ( isset( $data['settings']['post_status'] ) && DB::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
592 + if ( isset( $data['settings']['post_status'] ) && self::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
556 593 if ( ! defined( 'DOING_AUTOSAVE' ) ) {
557 594 define( 'DOING_AUTOSAVE', true );
558 595 }
559 596 }
@@ -568,10 +605,15 @@
568 605 if ( isset( $data['elements'] ) && is_array( $data['elements'] ) ) {
569 606 $this->save_elements( $data['elements'] );
570 607 }
571 608
609 + // $data['settings'] could be not set, the condition is here to prevent an error when accessed.
610 + $this->settings_to_be_saved = isset( $data['settings'] ) ? $data['settings'] : [];
611 +
572 612 $this->save_template_type();
573 613
614 + unset( $this->settings_to_be_saved );
615 +
574 616 $this->save_version();
575 617
576 618 // Remove Post CSS
577 619 $post_css = Post_CSS::create( $this->post->ID );
@@ -626,12 +668,30 @@
626 668 *
627 669 * @return bool Whether the post was built with Elementor.
628 670 */
629 671 public function is_built_with_elementor() {
630 - return ! ! get_post_meta( $this->post->ID, '_elementor_edit_mode', true );
672 + return ! ! $this->get_meta( self::BUILT_WITH_ELEMENTOR_META_KEY );
631 673 }
632 674
633 675 /**
676 + * Mark the post as "built with elementor" or not.
677 + *
678 + * @param bool $is_built_with_elementor
679 + *
680 + * @return $this
681 + */
682 + public function set_is_built_with_elementor( $is_built_with_elementor ) {
683 + if ( $is_built_with_elementor ) {
684 + // Use the string `builder` and not a boolean for rollback compatibility
685 + $this->update_meta( self::BUILT_WITH_ELEMENTOR_META_KEY, 'builder' );
686 + } else {
687 + $this->delete_meta( self::BUILT_WITH_ELEMENTOR_META_KEY );
688 + }
689 +
690 + return $this;
691 + }
692 +
693 + /**
634 694 * @since 2.0.0
635 695 * @access public
636 696 * @static
637 697 *
@@ -765,12 +825,12 @@
765 825 * @param string $status
766 826 *
767 827 * @return array
768 828 */
769 - public function get_elements_data( $status = DB::STATUS_PUBLISH ) {
829 + public function get_elements_data( $status = self::STATUS_PUBLISH ) {
770 830 $elements = $this->get_json_meta( '_elementor_data' );
771 831
772 - if ( DB::STATUS_DRAFT === $status ) {
832 + if ( self::STATUS_DRAFT === $status ) {
773 833 $autosave = $this->get_newer_autosave();
774 834
775 835 if ( is_object( $autosave ) ) {
776 836 $autosave_elements = Plugin::$instance->documents
@@ -859,19 +919,18 @@
859 919 if ( ! $elements_data ) {
860 920 $elements_data = $this->get_elements_data();
861 921 }
862 922
863 - $is_legacy_mode_active = Plugin::instance()->get_legacy_mode( 'elementWrappers' );
864 -
923 + $is_dom_optimization_active = Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' );
865 924 ?>
866 925 <div <?php echo Utils::render_html_attributes( $this->get_container_attributes() ); ?>>
867 - <?php if ( $is_legacy_mode_active ) { ?>
926 + <?php if ( ! $is_dom_optimization_active ) { ?>
868 927 <div class="elementor-inner">
869 928 <?php } ?>
870 929 <div class="elementor-section-wrap">
871 930 <?php $this->print_elements( $elements_data ); ?>
872 931 </div>
873 - <?php if ( $is_legacy_mode_active ) { ?>
932 + <?php if ( ! $is_dom_optimization_active ) { ?>
874 933 </div>
875 934 <?php } ?>
876 935 </div>
877 936 <?php
@@ -1257,9 +1316,9 @@
1257 1316
1258 1317 $post_type_object = get_post_type_object( $this->post->post_type );
1259 1318
1260 1319 $can_publish = $post_type_object && current_user_can( $post_type_object->cap->publish_posts );
1261 - $is_published = DB::STATUS_PUBLISH === $this->post->post_status || DB::STATUS_PRIVATE === $this->post->post_status;
1320 + $is_published = self::STATUS_PUBLISH === $this->post->post_status || self::STATUS_PRIVATE === $this->post->post_status;
1262 1321
1263 1322 if ( $is_published || $can_publish || ! Plugin::$instance->editor->is_edit_mode() ) {
1264 1323
1265 1324 $statuses = $this->get_post_statuses();