| @@ -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,11 @@ | ||
| 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 | - const CACHE_META_KEY = '_elementor_element_cache'; | |
| 49 | - | |
| 50 | - const UNEDITABLE_WITH_ELEMENTOR_TYPES = [ 'kit' ]; | |
| 51 | - | |
| 52 | 46 | /** |
| 53 | 47 | * Document publish status. |
| 54 | 48 | */ |
| 55 | 49 | const STATUS_PUBLISH = 'publish'; |
| @@ -73,11 +67,9 @@ | ||
| 73 | 67 | * Document pending status. |
| 74 | 68 | */ |
| 75 | 69 | const STATUS_PENDING = 'pending'; |
| 76 | 70 | |
| 77 | - /** | |
| 78 | - * @var int | |
| 79 | - */ | |
| 71 | + | |
| 80 | 72 | private $main_id; |
| 81 | 73 | |
| 82 | 74 | /** |
| 83 | 75 | * @var bool |
| @@ -166,15 +158,8 @@ | ||
| 166 | 158 | 'edit_capability' => '', |
| 167 | 159 | 'show_in_finder' => true, |
| 168 | 160 | 'show_on_admin_bar' => true, |
| 169 | 161 | 'support_kit' => false, |
| 170 | - 'show_navigator' => true, | |
| 171 | - 'allow_adding_widgets' => true, | |
| 172 | - 'support_page_layout' => true, | |
| 173 | - 'show_copy_and_share' => false, | |
| 174 | - 'library_close_title' => esc_html__( 'Close', 'elementor' ), | |
| 175 | - 'publish_button_title' => esc_html__( 'Publish', 'elementor' ), | |
| 176 | - 'allow_closing_remote_library' => true, | |
| 177 | 162 | ]; |
| 178 | 163 | } |
| 179 | 164 | |
| 180 | 165 | /** |
| @@ -196,20 +181,11 @@ | ||
| 196 | 181 | 'default_route' => $default_route, |
| 197 | 182 | 'has_elements' => static::get_property( 'has_elements' ), |
| 198 | 183 | 'support_kit' => static::get_property( 'support_kit' ), |
| 199 | 184 | 'messages' => [ |
| 200 | - 'publish_notification' => sprintf( | |
| 201 | - /* translators: %s: Document title. */ | |
| 202 | - esc_html__( 'Hurray! Your %s is live.', 'elementor' ), | |
| 203 | - static::get_title() | |
| 204 | - ), | |
| 185 | + /* translators: %s: Document title. */ | |
| 186 | + 'publish_notification' => sprintf( esc_html__( 'Hurray! Your %s is live.', 'elementor' ), static::get_title() ), | |
| 205 | 187 | ], |
| 206 | - 'show_navigator' => static::get_property( 'show_navigator' ), | |
| 207 | - 'allow_adding_widgets' => static::get_property( 'allow_adding_widgets' ), | |
| 208 | - 'show_copy_and_share' => static::get_property( 'show_copy_and_share' ), | |
| 209 | - 'library_close_title' => static::get_property( 'library_close_title' ), | |
| 210 | - 'publish_button_title' => static::get_property( 'publish_button_title' ), | |
| 211 | - 'allow_closing_remote_library' => static::get_property( 'allow_closing_remote_library' ), | |
| 212 | 188 | ]; |
| 213 | 189 | } |
| 214 | 190 | |
| 215 | 191 | public static function get_filtered_editor_panel_categories(): array { |
| @@ -232,16 +208,9 @@ | ||
| 232 | 208 | * |
| 233 | 209 | * @return array |
| 234 | 210 | */ |
| 235 | 211 | 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 ) { | |
| 212 | + if ( ! $has_pro ) { | |
| 244 | 213 | $categories[ $index ]['promotion'] = Filtered_Promotions_Manager::get_filtered_promotion_data( |
| 245 | 214 | $promotion, |
| 246 | 215 | 'elementor/panel/' . $index . '/custom_promotion', |
| 247 | 216 | 'url' |
| @@ -272,13 +241,9 @@ | ||
| 272 | 241 | return static::get_title(); |
| 273 | 242 | } |
| 274 | 243 | |
| 275 | 244 | public static function get_add_new_title() { |
| 276 | - return sprintf( | |
| 277 | - /* translators: %s: Document title. */ | |
| 278 | - esc_html__( 'Add New %s', 'elementor' ), | |
| 279 | - static::get_title() | |
| 280 | - ); | |
| 245 | + return sprintf( esc_html__( 'Add New %s', 'elementor' ), static::get_title() ); | |
| 281 | 246 | } |
| 282 | 247 | |
| 283 | 248 | /** |
| 284 | 249 | * Get property. |
| @@ -559,10 +524,12 @@ | ||
| 559 | 524 | * |
| 560 | 525 | * @since 2.0.0 |
| 561 | 526 | * @access public |
| 562 | 527 | * |
| 528 | + * | |
| 563 | 529 | * @return bool|Document |
| 564 | 530 | */ |
| 531 | + | |
| 565 | 532 | public function get_newer_autosave() { |
| 566 | 533 | $autosave = $this->get_autosave(); |
| 567 | 534 | |
| 568 | 535 | // Detect if there exists an autosave newer than the post. |
| @@ -617,12 +584,8 @@ | ||
| 617 | 584 | |
| 618 | 585 | if ( $autosave_id ) { |
| 619 | 586 | $document = Plugin::$instance->documents->get( $autosave_id ); |
| 620 | 587 | } elseif ( $create ) { |
| 621 | - if ( ! function_exists( 'wp_create_post_autosave' ) ) { | |
| 622 | - require_once ABSPATH . 'wp-admin/includes/post.php'; | |
| 623 | - } | |
| 624 | - | |
| 625 | 588 | $autosave_id = wp_create_post_autosave( [ |
| 626 | 589 | 'post_ID' => $this->post->ID, |
| 627 | 590 | 'post_type' => $this->post->post_type, |
| 628 | 591 | 'post_title' => $this->post->post_title, |
| @@ -651,14 +614,14 @@ | ||
| 651 | 614 | * Fired by `post_row_actions` and `page_row_actions` filters. |
| 652 | 615 | * |
| 653 | 616 | * @access public |
| 654 | 617 | * |
| 655 | - * @param array $actions An array of row action links. | |
| 618 | + * @param array $actions An array of row action links. | |
| 656 | 619 | * |
| 657 | 620 | * @return array An updated array of row action links. |
| 658 | 621 | */ |
| 659 | 622 | public function filter_admin_row_actions( $actions ) { |
| 660 | - if ( $this->is_editable_with_elementor() ) { | |
| 623 | + if ( $this->is_built_with_elementor() && $this->is_editable_by_current_user() ) { | |
| 661 | 624 | $actions['edit_with_elementor'] = sprintf( |
| 662 | 625 | '<a href="%1$s">%2$s</a>', |
| 663 | 626 | $this->get_edit_url(), |
| 664 | 627 | __( 'Edit with Elementor', 'elementor' ) |
| @@ -667,16 +630,8 @@ | ||
| 667 | 630 | |
| 668 | 631 | return $actions; |
| 669 | 632 | } |
| 670 | 633 | |
| 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 | 634 | /** |
| 680 | 635 | * @since 2.0.0 |
| 681 | 636 | * @access public |
| 682 | 637 | */ |
| @@ -746,16 +701,19 @@ | ||
| 746 | 701 | |
| 747 | 702 | do_action( 'elementor/document/before_get_config', $this ); |
| 748 | 703 | |
| 749 | 704 | 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(); | |
| 705 | + $container_config = []; | |
| 706 | + $experiments_manager = Plugin::$instance->experiments; | |
| 754 | 707 | |
| 708 | + if ( $experiments_manager->is_feature_active( 'container' ) ) { | |
| 709 | + $container_config = [ | |
| 710 | + 'container' => Plugin::$instance->elements_manager->get_element_types( 'container' )->get_config(), | |
| 711 | + ]; | |
| 712 | + } | |
| 713 | + | |
| 755 | 714 | $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() ); | |
| 715 | + $config['widgets'] = $container_config + Plugin::$instance->widgets_manager->get_widget_types_config(); | |
| 758 | 716 | } |
| 759 | 717 | |
| 760 | 718 | $additional_config = []; |
| 761 | 719 | |
| @@ -853,9 +811,9 @@ | ||
| 853 | 811 | */ |
| 854 | 812 | do_action( 'elementor/document/before_save', $this, $data ); |
| 855 | 813 | |
| 856 | 814 | if ( ! current_user_can( 'unfiltered_html' ) ) { |
| 857 | - $data = Utils::kses_post_deep( $data ); | |
| 815 | + $data = wp_kses_post_deep( $data ); | |
| 858 | 816 | } |
| 859 | 817 | |
| 860 | 818 | if ( ! empty( $data['settings'] ) ) { |
| 861 | 819 | if ( isset( $data['settings']['post_status'] ) && self::STATUS_AUTOSAVE === $data['settings']['post_status'] ) { |
| @@ -882,11 +840,8 @@ | ||
| 882 | 840 | $post_css = Post_CSS::create( $this->post->ID ); |
| 883 | 841 | |
| 884 | 842 | $post_css->delete(); |
| 885 | 843 | |
| 886 | - // Remove Document Cache | |
| 887 | - $this->delete_cache(); | |
| 888 | - | |
| 889 | 844 | /** |
| 890 | 845 | * After document save. |
| 891 | 846 | * |
| 892 | 847 | * Fires when document save is complete. |
| @@ -940,9 +895,9 @@ | ||
| 940 | 895 | * |
| 941 | 896 | * @return bool Whether the post was built with Elementor. |
| 942 | 897 | */ |
| 943 | 898 | public function is_built_with_elementor() { |
| 944 | - return (bool) $this->get_meta( self::BUILT_WITH_ELEMENTOR_META_KEY ); | |
| 899 | + return ! ! $this->get_meta( self::BUILT_WITH_ELEMENTOR_META_KEY ); | |
| 945 | 900 | } |
| 946 | 901 | |
| 947 | 902 | /** |
| 948 | 903 | * Mark the post as "built with elementor" or not. |
| @@ -1052,9 +1007,9 @@ | ||
| 1052 | 1007 | return $meta; |
| 1053 | 1008 | } |
| 1054 | 1009 | |
| 1055 | 1010 | public function update_json_meta( $key, $value ) { |
| 1056 | - return $this->update_meta( | |
| 1011 | + $this->update_meta( | |
| 1057 | 1012 | $key, |
| 1058 | 1013 | // `wp_slash` in order to avoid the unslashing during the `update_post_meta` |
| 1059 | 1014 | wp_slash( wp_json_encode( $value ) ) |
| 1060 | 1015 | ); |
| @@ -1067,10 +1022,8 @@ | ||
| 1067 | 1022 | * @param null $data |
| 1068 | 1023 | * @param bool $with_html_content |
| 1069 | 1024 | * |
| 1070 | 1025 | * @return array |
| 1071 | - * | |
| 1072 | - * @throws \Exception If elements retrieval fails or data processing errors occur. | |
| 1073 | 1026 | */ |
| 1074 | 1027 | public function get_elements_raw_data( $data = null, $with_html_content = false ) { |
| 1075 | 1028 | if ( ! static::get_property( 'has_elements' ) ) { |
| 1076 | 1029 | return []; |
| @@ -1079,23 +1032,8 @@ | ||
| 1079 | 1032 | if ( is_null( $data ) ) { |
| 1080 | 1033 | $data = $this->get_elements_data(); |
| 1081 | 1034 | } |
| 1082 | 1035 | |
| 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 | 1036 | // Change the current documents, so widgets can use `documents->get_current` and other post data |
| 1099 | 1037 | Plugin::$instance->documents->switch_to_document( $this ); |
| 1100 | 1038 | |
| 1101 | 1039 | $editor_data = []; |
| @@ -1120,9 +1058,9 @@ | ||
| 1120 | 1058 | $element_data = $element->get_raw_data( $with_html_content ); |
| 1121 | 1059 | } |
| 1122 | 1060 | |
| 1123 | 1061 | $editor_data[] = $element_data; |
| 1124 | - } | |
| 1062 | + } // End foreach(). | |
| 1125 | 1063 | |
| 1126 | 1064 | Plugin::$instance->documents->restore_document(); |
| 1127 | 1065 | |
| 1128 | 1066 | return $editor_data; |
| @@ -1136,9 +1074,9 @@ | ||
| 1136 | 1074 | * |
| 1137 | 1075 | * @return array |
| 1138 | 1076 | */ |
| 1139 | 1077 | public function get_elements_data( $status = self::STATUS_PUBLISH ) { |
| 1140 | - $elements = $this->get_json_meta( self::ELEMENTOR_DATA_META_KEY ); | |
| 1078 | + $elements = $this->get_json_meta( '_elementor_data' ); | |
| 1141 | 1079 | |
| 1142 | 1080 | if ( self::STATUS_DRAFT === $status ) { |
| 1143 | 1081 | $autosave = $this->get_newer_autosave(); |
| 1144 | 1082 | |
| @@ -1144,9 +1082,9 @@ | ||
| 1144 | 1082 | |
| 1145 | 1083 | if ( is_object( $autosave ) ) { |
| 1146 | 1084 | $autosave_elements = Plugin::$instance->documents |
| 1147 | 1085 | ->get( $autosave->get_post()->ID ) |
| 1148 | - ->get_json_meta( self::ELEMENTOR_DATA_META_KEY ); | |
| 1086 | + ->get_json_meta( '_elementor_data' ); | |
| 1149 | 1087 | } |
| 1150 | 1088 | } |
| 1151 | 1089 | |
| 1152 | 1090 | if ( Plugin::$instance->editor->is_edit_mode() ) { |
| @@ -1251,13 +1189,10 @@ | ||
| 1251 | 1189 | * @access public |
| 1252 | 1190 | */ |
| 1253 | 1191 | public function get_panel_page_settings() { |
| 1254 | 1192 | return [ |
| 1255 | - 'title' => sprintf( | |
| 1256 | - /* translators: %s: Document title. */ | |
| 1257 | - esc_html__( '%s Settings', 'elementor' ), | |
| 1258 | - static::get_title() | |
| 1259 | - ), | |
| 1193 | + /* translators: %s: Document title. */ | |
| 1194 | + 'title' => sprintf( esc_html__( '%s Settings', 'elementor' ), static::get_title() ), | |
| 1260 | 1195 | ]; |
| 1261 | 1196 | } |
| 1262 | 1197 | |
| 1263 | 1198 | /** |
| @@ -1314,9 +1249,9 @@ | ||
| 1314 | 1249 | * @param array|null $controls The available controls. |
| 1315 | 1250 | * |
| 1316 | 1251 | * @return array Element data. |
| 1317 | 1252 | */ |
| 1318 | - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array { | |
| 1253 | + public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ) : array { | |
| 1319 | 1254 | foreach ( $config as &$element_config ) { |
| 1320 | 1255 | $element_instance = Plugin::$instance->elements_manager->create_element_instance( $element_config ); |
| 1321 | 1256 | |
| 1322 | 1257 | if ( is_null( $element_instance ) ) { |
| @@ -1383,9 +1318,9 @@ | ||
| 1383 | 1318 | // We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta` |
| 1384 | 1319 | $json_value = wp_slash( wp_json_encode( $editor_data ) ); |
| 1385 | 1320 | |
| 1386 | 1321 | // 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 ); | |
| 1322 | + $is_meta_updated = update_metadata( 'post', $this->post->ID, '_elementor_data', $json_value ); | |
| 1388 | 1323 | |
| 1389 | 1324 | /** |
| 1390 | 1325 | * Before saving data. |
| 1391 | 1326 | * |
| @@ -1453,8 +1388,9 @@ | ||
| 1453 | 1388 | * |
| 1454 | 1389 | * @since 2.5.12 |
| 1455 | 1390 | * |
| 1456 | 1391 | * @param \Elementor\Core\Base\Document $this The current document. |
| 1392 | + * | |
| 1457 | 1393 | */ |
| 1458 | 1394 | do_action( 'elementor/document/save_version', $this ); |
| 1459 | 1395 | } |
| 1460 | 1396 | } |
| @@ -1491,9 +1427,9 @@ | ||
| 1491 | 1427 | * @since 2.0.4 |
| 1492 | 1428 | * @access public |
| 1493 | 1429 | * |
| 1494 | 1430 | * @param string $key Meta data key. |
| 1495 | - * @param mixed $value Meta data value. | |
| 1431 | + * @param string $value Meta data value. | |
| 1496 | 1432 | * |
| 1497 | 1433 | * @return bool|int |
| 1498 | 1434 | */ |
| 1499 | 1435 | public function update_main_meta( $key, $value ) { |
| @@ -1568,21 +1504,13 @@ | ||
| 1568 | 1504 | $date = date_i18n( _x( 'M j, H:i', 'revision date format', 'elementor' ), strtotime( $post->post_modified ) ); |
| 1569 | 1505 | $display_name = get_the_author_meta( 'display_name', $post->post_author ); |
| 1570 | 1506 | |
| 1571 | 1507 | if ( $autosave_post || 'revision' === $post->post_type ) { |
| 1572 | - $last_edited = sprintf( | |
| 1573 | - /* translators: 1: Saving date, 2: Author display name. */ | |
| 1574 | - esc_html__( 'Draft saved on %1$s by %2$s', 'elementor' ), | |
| 1575 | - '<time>' . $date . '</time>', | |
| 1576 | - $display_name | |
| 1577 | - ); | |
| 1508 | + /* translators: 1: Saving date, 2: Author display name. */ | |
| 1509 | + $last_edited = sprintf( esc_html__( 'Draft saved on %1$s by %2$s', 'elementor' ), '<time>' . $date . '</time>', $display_name ); | |
| 1578 | 1510 | } else { |
| 1579 | - $last_edited = sprintf( | |
| 1580 | - /* translators: 1: Editing date, 2: Author display name. */ | |
| 1581 | - esc_html__( 'Last edited on %1$s by %2$s', 'elementor' ), | |
| 1582 | - '<time>' . $date . '</time>', | |
| 1583 | - $display_name | |
| 1584 | - ); | |
| 1511 | + /* translators: 1: Editing date, 2: Author display name. */ | |
| 1512 | + $last_edited = sprintf( esc_html__( 'Last edited on %1$s by %2$s', 'elementor' ), '<time>' . $date . '</time>', $display_name ); | |
| 1585 | 1513 | } |
| 1586 | 1514 | |
| 1587 | 1515 | return $last_edited; |
| 1588 | 1516 | } |
| @@ -1621,9 +1549,9 @@ | ||
| 1621 | 1549 | } else { |
| 1622 | 1550 | $this->post = get_post( $data['post_id'] ); |
| 1623 | 1551 | |
| 1624 | 1552 | if ( ! $this->post ) { |
| 1625 | - throw new \Exception( sprintf( 'Post ID #%s does not exist.', esc_html( $data['post_id'] ) ), Exceptions::NOT_FOUND ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 1553 | + throw new \Exception( sprintf( 'Post ID #%s does not exist.', $data['post_id'] ), Exceptions::NOT_FOUND ); | |
| 1626 | 1554 | } |
| 1627 | 1555 | } |
| 1628 | 1556 | |
| 1629 | 1557 | // Each Control_Stack is based on a unique ID. |
| @@ -1641,9 +1569,9 @@ | ||
| 1641 | 1569 | |
| 1642 | 1570 | parent::__construct( $data ); |
| 1643 | 1571 | } |
| 1644 | 1572 | |
| 1645 | - /** | |
| 1573 | + /* | |
| 1646 | 1574 | * Get Export Data |
| 1647 | 1575 | * |
| 1648 | 1576 | * Filters a document's data on export |
| 1649 | 1577 | * |
| @@ -1655,10 +1583,8 @@ | ||
| 1655 | 1583 | public function get_export_data() { |
| 1656 | 1584 | $content = Plugin::$instance->db->iterate_data( $this->get_elements_data(), function( $element_data ) { |
| 1657 | 1585 | $element_data['id'] = Utils::generate_random_string(); |
| 1658 | 1586 | |
| 1659 | - $element_data = apply_filters( 'elementor/document/element/replace_id', $element_data ); | |
| 1660 | - | |
| 1661 | 1587 | $element = Plugin::$instance->elements_manager->create_element_instance( $element_data ); |
| 1662 | 1588 | |
| 1663 | 1589 | // If the widget/element does not exist, like a plugin that creates a widget but deactivated. |
| 1664 | 1590 | if ( ! $element ) { |
| @@ -1682,9 +1608,9 @@ | ||
| 1682 | 1608 | 'thumbnail' => get_the_post_thumbnail_url( $this->post ), |
| 1683 | 1609 | ]; |
| 1684 | 1610 | } |
| 1685 | 1611 | |
| 1686 | - /** | |
| 1612 | + /* | |
| 1687 | 1613 | * Get Import Data |
| 1688 | 1614 | * |
| 1689 | 1615 | * Filters a document's data on import |
| 1690 | 1616 | * |
| @@ -1828,92 +1754,18 @@ | ||
| 1828 | 1754 | } |
| 1829 | 1755 | |
| 1830 | 1756 | /** |
| 1831 | 1757 | * @since 2.1.3 |
| 1832 | - * @access public | |
| 1758 | + * @access protected | |
| 1833 | 1759 | */ |
| 1834 | - public function print_elements( $elements_data ) { | |
| 1835 | - $is_element_cache_active = 'disable' !== get_option( 'elementor_element_cache_ttl', '' ); | |
| 1836 | - if ( ! $is_element_cache_active ) { | |
| 1837 | - ob_start(); | |
| 1760 | + protected function print_elements( $elements_data ) { | |
| 1761 | + // Collect all data updaters that should be updated on runtime. | |
| 1762 | + $runtime_elements_iteration_actions = $this->get_runtime_elements_iteration_actions(); | |
| 1838 | 1763 | |
| 1839 | - $this->do_print_elements( $elements_data ); | |
| 1840 | - | |
| 1841 | - $content = ob_get_clean(); | |
| 1842 | - | |
| 1843 | - if ( has_blocks( $content ) ) { | |
| 1844 | - $content = do_blocks( $content ); | |
| 1845 | - } | |
| 1846 | - | |
| 1847 | - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1848 | - | |
| 1849 | - return; | |
| 1764 | + if ( $runtime_elements_iteration_actions ) { | |
| 1765 | + $this->iterate_elements( $elements_data, $runtime_elements_iteration_actions, 'render' ); | |
| 1850 | 1766 | } |
| 1851 | 1767 | |
| 1852 | - $cached_data = $this->get_document_cache(); | |
| 1853 | - | |
| 1854 | - if ( false === $cached_data ) { | |
| 1855 | - add_filter( 'elementor/element/should_render_shortcode', '__return_true' ); | |
| 1856 | - | |
| 1857 | - $scripts_to_queue = []; | |
| 1858 | - $styles_to_queue = []; | |
| 1859 | - | |
| 1860 | - global $wp_scripts, $wp_styles; | |
| 1861 | - | |
| 1862 | - $should_store_scripts = $wp_scripts instanceof \WP_Scripts && $wp_styles instanceof \WP_Styles; | |
| 1863 | - if ( $should_store_scripts ) { | |
| 1864 | - $scripts_ignored = $wp_scripts->queue; | |
| 1865 | - $styles_ignored = $wp_styles->queue; | |
| 1866 | - } | |
| 1867 | - | |
| 1868 | - ob_start(); | |
| 1869 | - | |
| 1870 | - $this->do_print_elements( $elements_data ); | |
| 1871 | - | |
| 1872 | - if ( $should_store_scripts ) { | |
| 1873 | - $scripts_to_queue = array_values( array_diff( $wp_scripts->queue, $scripts_ignored ) ); | |
| 1874 | - $styles_to_queue = array_values( array_diff( $wp_styles->queue, $styles_ignored ) ); | |
| 1875 | - } | |
| 1876 | - | |
| 1877 | - $cached_data = [ | |
| 1878 | - 'content' => ob_get_clean(), | |
| 1879 | - 'scripts' => $scripts_to_queue, | |
| 1880 | - 'styles' => $styles_to_queue, | |
| 1881 | - ]; | |
| 1882 | - | |
| 1883 | - if ( $this->should_store_cache_elements() ) { | |
| 1884 | - $this->set_document_cache( $cached_data ); | |
| 1885 | - } | |
| 1886 | - | |
| 1887 | - remove_filter( 'elementor/element/should_render_shortcode', '__return_true' ); | |
| 1888 | - } else { | |
| 1889 | - if ( ! empty( $cached_data['scripts'] ) ) { | |
| 1890 | - foreach ( $cached_data['scripts'] as $script_handle ) { | |
| 1891 | - wp_enqueue_script( $script_handle ); | |
| 1892 | - } | |
| 1893 | - } | |
| 1894 | - | |
| 1895 | - if ( ! empty( $cached_data['styles'] ) ) { | |
| 1896 | - foreach ( $cached_data['styles'] as $style_handle ) { | |
| 1897 | - wp_enqueue_style( $style_handle ); | |
| 1898 | - } | |
| 1899 | - } | |
| 1900 | - } | |
| 1901 | - | |
| 1902 | - if ( ! empty( $cached_data['content'] ) ) { | |
| 1903 | - $content = do_shortcode( $cached_data['content'] ); | |
| 1904 | - | |
| 1905 | - if ( has_blocks( $content ) ) { | |
| 1906 | - $content = do_blocks( $content ); | |
| 1907 | - } | |
| 1908 | - | |
| 1909 | - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1910 | - } | |
| 1911 | - } | |
| 1912 | - | |
| 1913 | - protected function do_print_elements( $elements_data ) { | |
| 1914 | - $this->update_runtime_elements( $elements_data ); | |
| 1915 | - | |
| 1916 | 1768 | foreach ( $elements_data as $element_data ) { |
| 1917 | 1769 | $element = Plugin::$instance->elements_manager->create_element_instance( $element_data ); |
| 1918 | 1770 | |
| 1919 | 1771 | if ( ! $element ) { |
| @@ -1923,75 +1775,8 @@ | ||
| 1923 | 1775 | $element->print_element(); |
| 1924 | 1776 | } |
| 1925 | 1777 | } |
| 1926 | 1778 | |
| 1927 | - public function update_runtime_elements( $elements_data = null ) { | |
| 1928 | - if ( null === $elements_data ) { | |
| 1929 | - $elements_data = $this->get_elements_data(); | |
| 1930 | - } | |
| 1931 | - | |
| 1932 | - // Collect all data updaters that should be updated on runtime. | |
| 1933 | - $runtime_elements_iteration_actions = $this->get_runtime_elements_iteration_actions(); | |
| 1934 | - | |
| 1935 | - if ( $runtime_elements_iteration_actions ) { | |
| 1936 | - $this->iterate_elements( $elements_data, $runtime_elements_iteration_actions, 'render' ); | |
| 1937 | - } | |
| 1938 | - } | |
| 1939 | - | |
| 1940 | - public function set_document_cache( $value ) { | |
| 1941 | - $expiration_hours = get_option( 'elementor_element_cache_ttl', '' ); | |
| 1942 | - | |
| 1943 | - if ( empty( $expiration_hours ) || ! is_numeric( $expiration_hours ) ) { | |
| 1944 | - $expiration_hours = '24'; | |
| 1945 | - } | |
| 1946 | - | |
| 1947 | - $expiration_hours = absint( $expiration_hours ); | |
| 1948 | - | |
| 1949 | - $expiration = '+' . $expiration_hours . ' hours'; | |
| 1950 | - | |
| 1951 | - $data = [ | |
| 1952 | - 'timeout' => strtotime( $expiration, current_time( 'timestamp' ) ), | |
| 1953 | - 'value' => $value, | |
| 1954 | - ]; | |
| 1955 | - | |
| 1956 | - $this->update_json_meta( static::CACHE_META_KEY, $data ); | |
| 1957 | - } | |
| 1958 | - | |
| 1959 | - private function get_document_cache() { | |
| 1960 | - $cache = $this->get_json_meta( static::CACHE_META_KEY ); | |
| 1961 | - | |
| 1962 | - if ( empty( $cache['timeout'] ) ) { | |
| 1963 | - return false; | |
| 1964 | - } | |
| 1965 | - | |
| 1966 | - if ( current_time( 'timestamp' ) > $cache['timeout'] ) { | |
| 1967 | - return false; | |
| 1968 | - } | |
| 1969 | - | |
| 1970 | - if ( ! is_array( $cache['value'] ) ) { | |
| 1971 | - return false; | |
| 1972 | - } | |
| 1973 | - | |
| 1974 | - return $cache['value']; | |
| 1975 | - } | |
| 1976 | - | |
| 1977 | - protected function delete_cache() { | |
| 1978 | - $this->delete_meta( static::CACHE_META_KEY ); | |
| 1979 | - } | |
| 1980 | - | |
| 1981 | - private function should_store_cache_elements() { | |
| 1982 | - static $should_store_cache_elements = null; | |
| 1983 | - | |
| 1984 | - if ( null === $should_store_cache_elements ) { | |
| 1985 | - $should_store_cache_elements = ( | |
| 1986 | - ! is_admin() | |
| 1987 | - && ! Plugin::$instance->preview->is_preview_mode() | |
| 1988 | - ); | |
| 1989 | - } | |
| 1990 | - | |
| 1991 | - return $should_store_cache_elements; | |
| 1992 | - } | |
| 1993 | - | |
| 1994 | 1779 | protected function register_document_controls() { |
| 1995 | 1780 | $this->start_controls_section( |
| 1996 | 1781 | 'document_settings', |
| 1997 | 1782 | [ |
| @@ -2122,10 +1907,6 @@ | ||
| 2122 | 1907 | $this->elements_iteration_actions[] = new Assets_Iteration_Action( $this ); |
| 2123 | 1908 | } |
| 2124 | 1909 | |
| 2125 | 1910 | return $this->elements_iteration_actions; |
| 2126 | - } | |
| 2127 | - | |
| 2128 | - public function get_elementor_version() { | |
| 2129 | - return $this->get_main_meta( '_elementor_version' ); | |
| 2130 | 1911 | } |
| 2131 | 1912 | } |