PluginProbe
Elementor Website Builder – more than just a page builder / 3.27.3
Elementor Website Builder – more than just a page builder v3.27.3
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 +33 -72 4.2.0-dev23.27.3 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;
@@ -21,9 +20,9 @@
21 20 use ElementorPro\Modules\Library\Widgets\Template;
22 21 use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
23 22
24 23 if ( ! defined( 'ABSPATH' ) ) {
25 - exit; // Exit if accessed directly.
24 + exit; // Exit if accessed directly
26 25 }
27 26
28 27 /**
29 28 * Elementor document.
@@ -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'
@@ -559,10 +548,12 @@
559 548 *
560 549 * @since 2.0.0
561 550 * @access public
562 551 *
552 + *
563 553 * @return bool|Document
564 554 */
555 +
565 556 public function get_newer_autosave() {
566 557 $autosave = $this->get_autosave();
567 558
568 559 // Detect if there exists an autosave newer than the post.
@@ -617,12 +608,8 @@
617 608
618 609 if ( $autosave_id ) {
619 610 $document = Plugin::$instance->documents->get( $autosave_id );
620 611 } elseif ( $create ) {
621 - if ( ! function_exists( 'wp_create_post_autosave' ) ) {
622 - require_once ABSPATH . 'wp-admin/includes/post.php';
623 - }
624 -
625 612 $autosave_id = wp_create_post_autosave( [
626 613 'post_ID' => $this->post->ID,
627 614 'post_type' => $this->post->post_type,
628 615 'post_title' => $this->post->post_title,
@@ -651,14 +638,14 @@
651 638 * Fired by `post_row_actions` and `page_row_actions` filters.
652 639 *
653 640 * @access public
654 641 *
655 - * @param array $actions An array of row action links.
642 + * @param array $actions An array of row action links.
656 643 *
657 644 * @return array An updated array of row action links.
658 645 */
659 646 public function filter_admin_row_actions( $actions ) {
660 - if ( $this->is_editable_with_elementor() ) {
647 + if ( $this->is_built_with_elementor() && $this->is_editable_by_current_user() ) {
661 648 $actions['edit_with_elementor'] = sprintf(
662 649 '<a href="%1$s">%2$s</a>',
663 650 $this->get_edit_url(),
664 651 __( 'Edit with Elementor', 'elementor' )
@@ -667,16 +654,8 @@
667 654
668 655 return $actions;
669 656 }
670 657
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 658 /**
680 659 * @since 2.0.0
681 660 * @access public
682 661 */
@@ -746,16 +725,22 @@
746 725
747 726 do_action( 'elementor/document/before_get_config', $this );
748 727
749 728 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();
729 + $container_config = [];
754 730
731 + if ( Plugin::$instance->experiments->is_feature_active( 'container' ) ) {
732 + $container_config['container'] =
733 + Plugin::$instance->elements_manager->get_element_types( 'container' )->get_config();
734 + }
735 +
736 + if ( Plugin::$instance->experiments->is_feature_active( 'atomic_widgets' ) ) {
737 + $container_config['div-block'] =
738 + Plugin::$instance->elements_manager->get_element_types( 'div-block' )->get_config();
739 + }
740 +
755 741 $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() );
742 + $config['widgets'] = $container_config + Plugin::$instance->widgets_manager->get_widget_types_config();
758 743 }
759 744
760 745 $additional_config = [];
761 746
@@ -853,11 +838,9 @@
853 838 */
854 839 do_action( 'elementor/document/before_save', $this, $data );
855 840
856 841 if ( ! current_user_can( 'unfiltered_html' ) ) {
857 - $data = map_deep( $data, function ( $value ) {
858 - return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value );
859 - } );
842 + $data = wp_kses_post_deep( $data );
860 843 }
861 844
862 845 if ( ! empty( $data['settings'] ) ) {
863 846 if ( isset( $data['settings']['post_status'] ) && self::STATUS_AUTOSAVE === $data['settings']['post_status'] ) {
@@ -942,9 +925,9 @@
942 925 *
943 926 * @return bool Whether the post was built with Elementor.
944 927 */
945 928 public function is_built_with_elementor() {
946 - return (bool) $this->get_meta( self::BUILT_WITH_ELEMENTOR_META_KEY );
929 + return ! ! $this->get_meta( self::BUILT_WITH_ELEMENTOR_META_KEY );
947 930 }
948 931
949 932 /**
950 933 * Mark the post as "built with elementor" or not.
@@ -1069,10 +1052,8 @@
1069 1052 * @param null $data
1070 1053 * @param bool $with_html_content
1071 1054 *
1072 1055 * @return array
1073 - *
1074 - * @throws \Exception If elements retrieval fails or data processing errors occur.
1075 1056 */
1076 1057 public function get_elements_raw_data( $data = null, $with_html_content = false ) {
1077 1058 if ( ! static::get_property( 'has_elements' ) ) {
1078 1059 return [];
@@ -1081,23 +1062,8 @@
1081 1062 if ( is_null( $data ) ) {
1082 1063 $data = $this->get_elements_data();
1083 1064 }
1084 1065
1085 - /**
1086 - * Filters document elements data after loading.
1087 - *
1088 - * Allows modification of elements data when loading (not saving).
1089 - * Useful for migrations, transformations, or data enrichment.
1090 - *
1091 - * @since 3.35.0
1092 - *
1093 - * @param array $data The elements data array.
1094 - * @param \Elementor\Core\Base\Document $document The document instance.
1095 - */
1096 - if ( ! $this->is_saving ) {
1097 - $data = apply_filters( 'elementor/document/load/data', $data, $this );
1098 - }
1099 -
1100 1066 // Change the current documents, so widgets can use `documents->get_current` and other post data
1101 1067 Plugin::$instance->documents->switch_to_document( $this );
1102 1068
1103 1069 $editor_data = [];
@@ -1122,9 +1088,9 @@
1122 1088 $element_data = $element->get_raw_data( $with_html_content );
1123 1089 }
1124 1090
1125 1091 $editor_data[] = $element_data;
1126 - }
1092 + } // End foreach().
1127 1093
1128 1094 Plugin::$instance->documents->restore_document();
1129 1095
1130 1096 return $editor_data;
@@ -1138,9 +1104,9 @@
1138 1104 *
1139 1105 * @return array
1140 1106 */
1141 1107 public function get_elements_data( $status = self::STATUS_PUBLISH ) {
1142 - $elements = $this->get_json_meta( self::ELEMENTOR_DATA_META_KEY );
1108 + $elements = $this->get_json_meta( '_elementor_data' );
1143 1109
1144 1110 if ( self::STATUS_DRAFT === $status ) {
1145 1111 $autosave = $this->get_newer_autosave();
1146 1112
@@ -1146,9 +1112,9 @@
1146 1112
1147 1113 if ( is_object( $autosave ) ) {
1148 1114 $autosave_elements = Plugin::$instance->documents
1149 1115 ->get( $autosave->get_post()->ID )
1150 - ->get_json_meta( self::ELEMENTOR_DATA_META_KEY );
1116 + ->get_json_meta( '_elementor_data' );
1151 1117 }
1152 1118 }
1153 1119
1154 1120 if ( Plugin::$instance->editor->is_edit_mode() ) {
@@ -1316,9 +1282,9 @@
1316 1282 * @param array|null $controls The available controls.
1317 1283 *
1318 1284 * @return array Element data.
1319 1285 */
1320 - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array {
1286 + public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ) : array {
1321 1287 foreach ( $config as &$element_config ) {
1322 1288 $element_instance = Plugin::$instance->elements_manager->create_element_instance( $element_config );
1323 1289
1324 1290 if ( is_null( $element_instance ) ) {
@@ -1385,9 +1351,9 @@
1385 1351 // We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
1386 1352 $json_value = wp_slash( wp_json_encode( $editor_data ) );
1387 1353
1388 1354 // Don't use `update_post_meta` that can't handle `revision` post type
1389 - $is_meta_updated = update_metadata( 'post', $this->post->ID, self::ELEMENTOR_DATA_META_KEY, $json_value );
1355 + $is_meta_updated = update_metadata( 'post', $this->post->ID, '_elementor_data', $json_value );
1390 1356
1391 1357 /**
1392 1358 * Before saving data.
1393 1359 *
@@ -1455,8 +1421,9 @@
1455 1421 *
1456 1422 * @since 2.5.12
1457 1423 *
1458 1424 * @param \Elementor\Core\Base\Document $this The current document.
1425 + *
1459 1426 */
1460 1427 do_action( 'elementor/document/save_version', $this );
1461 1428 }
1462 1429 }
@@ -1493,9 +1460,9 @@
1493 1460 * @since 2.0.4
1494 1461 * @access public
1495 1462 *
1496 1463 * @param string $key Meta data key.
1497 - * @param mixed $value Meta data value.
1464 + * @param mixed $value Meta data value.
1498 1465 *
1499 1466 * @return bool|int
1500 1467 */
1501 1468 public function update_main_meta( $key, $value ) {
@@ -1623,9 +1590,9 @@
1623 1590 } else {
1624 1591 $this->post = get_post( $data['post_id'] );
1625 1592
1626 1593 if ( ! $this->post ) {
1627 - throw new \Exception( sprintf( 'Post ID #%s does not exist.', esc_html( $data['post_id'] ) ), Exceptions::NOT_FOUND ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
1594 + throw new \Exception( sprintf( 'Post ID #%s does not exist.', $data['post_id'] ), Exceptions::NOT_FOUND );
1628 1595 }
1629 1596 }
1630 1597
1631 1598 // Each Control_Stack is based on a unique ID.
@@ -1643,9 +1610,9 @@
1643 1610
1644 1611 parent::__construct( $data );
1645 1612 }
1646 1613
1647 - /**
1614 + /*
1648 1615 * Get Export Data
1649 1616 *
1650 1617 * Filters a document's data on export
1651 1618 *
@@ -1657,10 +1624,8 @@
1657 1624 public function get_export_data() {
1658 1625 $content = Plugin::$instance->db->iterate_data( $this->get_elements_data(), function( $element_data ) {
1659 1626 $element_data['id'] = Utils::generate_random_string();
1660 1627
1661 - $element_data = apply_filters( 'elementor/document/element/replace_id', $element_data );
1662 -
1663 1628 $element = Plugin::$instance->elements_manager->create_element_instance( $element_data );
1664 1629
1665 1630 // If the widget/element does not exist, like a plugin that creates a widget but deactivated.
1666 1631 if ( ! $element ) {
@@ -1684,9 +1649,9 @@
1684 1649 'thumbnail' => get_the_post_thumbnail_url( $this->post ),
1685 1650 ];
1686 1651 }
1687 1652
1688 - /**
1653 + /*
1689 1654 * Get Import Data
1690 1655 *
1691 1656 * Filters a document's data on import
1692 1657 *
@@ -1830,12 +1795,12 @@
1830 1795 }
1831 1796
1832 1797 /**
1833 1798 * @since 2.1.3
1834 - * @access public
1799 + * @access protected
1835 1800 */
1836 - public function print_elements( $elements_data ) {
1837 - $is_element_cache_active = 'disable' !== get_option( 'elementor_element_cache_ttl', '' );
1801 + protected function print_elements( $elements_data ) {
1802 + $is_element_cache_active = Plugin::$instance->experiments->is_feature_active( 'e_element_cache' ) && 'disable' !== get_option( 'elementor_element_cache_ttl', '' );
1838 1803 if ( ! $is_element_cache_active ) {
1839 1804 ob_start();
1840 1805
1841 1806 $this->do_print_elements( $elements_data );
@@ -2124,10 +2089,6 @@
2124 2089 $this->elements_iteration_actions[] = new Assets_Iteration_Action( $this );
2125 2090 }
2126 2091
2127 2092 return $this->elements_iteration_actions;
2128 - }
2129 -
2130 - public function get_elementor_version() {
2131 - return $this->get_main_meta( '_elementor_version' );
2132 2093 }
2133 2094 }