PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.4
Elementor Website Builder – more than just a page builder v3.28.4
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 +23 -63 4.2.33.28.4 View file →
@@ -5,9 +5,8 @@
5 5 use Elementor\Core\Base\Elements_Iteration_Actions\Base as Elements_Iteration_Action;
6 6 use Elementor\Core\Behaviors\Interfaces\Lock_Behavior;
7 7 use Elementor\Core\Files\CSS\Post as Post_CSS;
8 8 use Elementor\Core\Settings\Page\Model as Page_Model;
9 -use Elementor\Core\Utils\Collection;
10 9 use Elementor\Core\Utils\Exceptions;
11 10 use Elementor\Includes\Elements\Container;
12 11 use Elementor\Plugin;
13 12 use Elementor\Controls_Manager;
@@ -40,16 +39,13 @@
40 39 * Document type meta key.
41 40 */
42 41 const TYPE_META_KEY = '_elementor_template_type';
43 42 const PAGE_META_KEY = '_elementor_page_settings';
44 - const ELEMENTOR_DATA_META_KEY = '_elementor_data';
45 43
46 44 const BUILT_WITH_ELEMENTOR_META_KEY = '_elementor_edit_mode';
47 45
48 46 const CACHE_META_KEY = '_elementor_element_cache';
49 47
50 - const UNEDITABLE_WITH_ELEMENTOR_TYPES = [ 'kit' ];
51 -
52 48 /**
53 49 * Document publish status.
54 50 */
55 51 const STATUS_PUBLISH = 'publish';
@@ -232,16 +228,9 @@
232 228 *
233 229 * @return array
234 230 */
235 231 private static function get_panel_category_item( $promotion, $index, array $categories, bool $has_pro ): array {
236 - $keep_promotion = $has_pro && apply_filters(
237 - 'elementor/document/panel_category_keep_promotion',
238 - false,
239 - $index,
240 - $promotion
241 - );
242 -
243 - if ( ! $has_pro || $keep_promotion ) {
232 + if ( ! $has_pro ) {
244 233 $categories[ $index ]['promotion'] = Filtered_Promotions_Manager::get_filtered_promotion_data(
245 234 $promotion,
246 235 'elementor/panel/' . $index . '/custom_promotion',
247 236 'url'
@@ -617,12 +606,8 @@
617 606
618 607 if ( $autosave_id ) {
619 608 $document = Plugin::$instance->documents->get( $autosave_id );
620 609 } elseif ( $create ) {
621 - if ( ! function_exists( 'wp_create_post_autosave' ) ) {
622 - require_once ABSPATH . 'wp-admin/includes/post.php';
623 - }
624 -
625 610 $autosave_id = wp_create_post_autosave( [
626 611 'post_ID' => $this->post->ID,
627 612 'post_type' => $this->post->post_type,
628 613 'post_title' => $this->post->post_title,
@@ -651,14 +636,14 @@
651 636 * Fired by `post_row_actions` and `page_row_actions` filters.
652 637 *
653 638 * @access public
654 639 *
655 - * @param array $actions An array of row action links.
640 + * @param array $actions An array of row action links.
656 641 *
657 642 * @return array An updated array of row action links.
658 643 */
659 644 public function filter_admin_row_actions( $actions ) {
660 - if ( $this->is_editable_with_elementor() ) {
645 + if ( $this->is_built_with_elementor() && $this->is_editable_by_current_user() ) {
661 646 $actions['edit_with_elementor'] = sprintf(
662 647 '<a href="%1$s">%2$s</a>',
663 648 $this->get_edit_url(),
664 649 __( 'Edit with Elementor', 'elementor' )
@@ -667,16 +652,8 @@
667 652
668 653 return $actions;
669 654 }
670 655
671 - public function is_editable_with_elementor() {
672 - if ( in_array( $this->get_type(), self::UNEDITABLE_WITH_ELEMENTOR_TYPES ) ) {
673 - return false;
674 - }
675 -
676 - return $this->is_editable_by_current_user() && $this->is_built_with_elementor();
677 - }
678 -
679 656 /**
680 657 * @since 2.0.0
681 658 * @access public
682 659 */
@@ -746,16 +723,22 @@
746 723
747 724 do_action( 'elementor/document/before_get_config', $this );
748 725
749 726 if ( static::get_property( 'has_elements' ) ) {
750 - $elements_config = Collection::make( Plugin::$instance->elements_manager->get_element_types() )
751 - ->filter( fn( $element ) => ( ! empty( $element->get_config()['include_in_widgets_config'] ) ) )
752 - ->map( fn( $element ) => $element->get_config() )
753 - ->all();
727 + $container_config = [];
754 728
729 + if ( Plugin::$instance->experiments->is_feature_active( 'container' ) ) {
730 + $container_config['container'] =
731 + Plugin::$instance->elements_manager->get_element_types( 'container' )->get_config();
732 + }
733 +
734 + if ( Plugin::$instance->experiments->is_feature_active( 'atomic_widgets' ) ) {
735 + $container_config['div-block'] =
736 + Plugin::$instance->elements_manager->get_element_types( 'div-block' )->get_config();
737 + }
738 +
755 739 $config['elements'] = $this->get_elements_raw_data( null, true );
756 - // `get_elements_raw_data` has to be called before `get_widget_types_config`, because it affects it.
757 - $config['widgets'] = array_merge( $elements_config, Plugin::$instance->widgets_manager->get_widget_types_config() );
740 + $config['widgets'] = $container_config + Plugin::$instance->widgets_manager->get_widget_types_config();
758 741 }
759 742
760 743 $additional_config = [];
761 744
@@ -853,9 +836,9 @@
853 836 */
854 837 do_action( 'elementor/document/before_save', $this, $data );
855 838
856 839 if ( ! current_user_can( 'unfiltered_html' ) ) {
857 - $data = Utils::kses_post_deep( $data );
840 + $data = wp_kses_post_deep( $data );
858 841 }
859 842
860 843 if ( ! empty( $data['settings'] ) ) {
861 844 if ( isset( $data['settings']['post_status'] ) && self::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
@@ -1067,10 +1050,8 @@
1067 1050 * @param null $data
1068 1051 * @param bool $with_html_content
1069 1052 *
1070 1053 * @return array
1071 - *
1072 - * @throws \Exception If elements retrieval fails or data processing errors occur.
1073 1054 */
1074 1055 public function get_elements_raw_data( $data = null, $with_html_content = false ) {
1075 1056 if ( ! static::get_property( 'has_elements' ) ) {
1076 1057 return [];
@@ -1079,23 +1060,8 @@
1079 1060 if ( is_null( $data ) ) {
1080 1061 $data = $this->get_elements_data();
1081 1062 }
1082 1063
1083 - /**
1084 - * Filters document elements data after loading.
1085 - *
1086 - * Allows modification of elements data when loading (not saving).
1087 - * Useful for migrations, transformations, or data enrichment.
1088 - *
1089 - * @since 3.35.0
1090 - *
1091 - * @param array $data The elements data array.
1092 - * @param \Elementor\Core\Base\Document $document The document instance.
1093 - */
1094 - if ( ! $this->is_saving ) {
1095 - $data = apply_filters( 'elementor/document/load/data', $data, $this );
1096 - }
1097 -
1098 1064 // Change the current documents, so widgets can use `documents->get_current` and other post data
1099 1065 Plugin::$instance->documents->switch_to_document( $this );
1100 1066
1101 1067 $editor_data = [];
@@ -1136,9 +1102,9 @@
1136 1102 *
1137 1103 * @return array
1138 1104 */
1139 1105 public function get_elements_data( $status = self::STATUS_PUBLISH ) {
1140 - $elements = $this->get_json_meta( self::ELEMENTOR_DATA_META_KEY );
1106 + $elements = $this->get_json_meta( '_elementor_data' );
1141 1107
1142 1108 if ( self::STATUS_DRAFT === $status ) {
1143 1109 $autosave = $this->get_newer_autosave();
1144 1110
@@ -1144,9 +1110,9 @@
1144 1110
1145 1111 if ( is_object( $autosave ) ) {
1146 1112 $autosave_elements = Plugin::$instance->documents
1147 1113 ->get( $autosave->get_post()->ID )
1148 - ->get_json_meta( self::ELEMENTOR_DATA_META_KEY );
1114 + ->get_json_meta( '_elementor_data' );
1149 1115 }
1150 1116 }
1151 1117
1152 1118 if ( Plugin::$instance->editor->is_edit_mode() ) {
@@ -1383,9 +1349,9 @@
1383 1349 // We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
1384 1350 $json_value = wp_slash( wp_json_encode( $editor_data ) );
1385 1351
1386 1352 // Don't use `update_post_meta` that can't handle `revision` post type
1387 - $is_meta_updated = update_metadata( 'post', $this->post->ID, self::ELEMENTOR_DATA_META_KEY, $json_value );
1353 + $is_meta_updated = update_metadata( 'post', $this->post->ID, '_elementor_data', $json_value );
1388 1354
1389 1355 /**
1390 1356 * Before saving data.
1391 1357 *
@@ -1491,9 +1457,9 @@
1491 1457 * @since 2.0.4
1492 1458 * @access public
1493 1459 *
1494 1460 * @param string $key Meta data key.
1495 - * @param mixed $value Meta data value.
1461 + * @param mixed $value Meta data value.
1496 1462 *
1497 1463 * @return bool|int
1498 1464 */
1499 1465 public function update_main_meta( $key, $value ) {
@@ -1655,10 +1621,8 @@
1655 1621 public function get_export_data() {
1656 1622 $content = Plugin::$instance->db->iterate_data( $this->get_elements_data(), function( $element_data ) {
1657 1623 $element_data['id'] = Utils::generate_random_string();
1658 1624
1659 - $element_data = apply_filters( 'elementor/document/element/replace_id', $element_data );
1660 -
1661 1625 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
1662 1626
1663 1627 // If the widget/element does not exist, like a plugin that creates a widget but deactivated.
1664 1628 if ( ! $element ) {
@@ -1828,12 +1792,12 @@
1828 1792 }
1829 1793
1830 1794 /**
1831 1795 * @since 2.1.3
1832 - * @access public
1796 + * @access protected
1833 1797 */
1834 - public function print_elements( $elements_data ) {
1835 - $is_element_cache_active = 'disable' !== get_option( 'elementor_element_cache_ttl', '' );
1798 + protected function print_elements( $elements_data ) {
1799 + $is_element_cache_active = Plugin::$instance->experiments->is_feature_active( 'e_element_cache' ) && 'disable' !== get_option( 'elementor_element_cache_ttl', '' );
1836 1800 if ( ! $is_element_cache_active ) {
1837 1801 ob_start();
1838 1802
1839 1803 $this->do_print_elements( $elements_data );
@@ -2122,10 +2086,6 @@
2122 2086 $this->elements_iteration_actions[] = new Assets_Iteration_Action( $this );
2123 2087 }
2124 2088
2125 2089 return $this->elements_iteration_actions;
2126 - }
2127 -
2128 - public function get_elementor_version() {
2129 - return $this->get_main_meta( '_elementor_version' );
2130 2090 }
2131 2091 }