PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.7
Elementor Website Builder – more than just a page builder v3.35.7
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 | modules/components/styles/component-styles.php +6 -35 4.2.43.35.7 View file →
@@ -23,48 +23,19 @@
23 23 add_action(
24 24 'elementor/core/files/clear_cache',
25 25 fn() => $this->invalidate_cache(),
26 26 );
27 -
28 - add_filter(
29 - 'elementor/document/related_posts',
30 - fn( array $related, $post_id ) => $this->get_related_posts( $related, $post_id ),
31 - 10,
32 - 2
33 - );
34 27 }
35 28
36 29 private function render_post( string $post_id ) {
37 - $component_ids = $this->get_component_ids_from_post_cached( $post_id );
30 + $cache_validity = new Cache_Validity();
38 31
39 - $this->declare_components_rendered( $component_ids );
40 - }
32 + if ( $cache_validity->is_valid( [ self::CACHE_ROOT_KEY, $post_id ] ) ) {
33 + $component_ids = $cache_validity->get_meta( [ self::CACHE_ROOT_KEY, $post_id ] );
41 34
42 - /**
43 - * Handler for the `elementor/document/related_posts` filter.
44 - *
45 - * @param int[] $related Accumulated ids from previous filter handlers.
46 - * @param string|int $post_id Parent post id being inspected.
47 - * @return int[] Merged list of related post ids.
48 - */
49 - private function get_related_posts( array $related, $post_id ): array {
50 - $component_ids = $this->get_component_ids_from_post_cached( (string) $post_id );
35 + $this->declare_components_rendered( $component_ids );
51 36
52 - return array_values( array_unique( array_merge( $related, array_map( 'intval', $component_ids ) ) ) );
53 - }
54 -
55 - /**
56 - * Returns the component ids embedded in $post_id, reading from the
57 - * traversal cache when available and writing to it otherwise.
58 - *
59 - * Both the render-action listener and the `elementor/document/related_posts`
60 - * filter handler delegate here so the traversal logic lives in one place.
61 - */
62 - private function get_component_ids_from_post_cached( string $post_id ): array {
63 - $cache_validity = new Cache_Validity();
64 -
65 - if ( $cache_validity->is_valid( [ self::CACHE_ROOT_KEY, $post_id ] ) ) {
66 - return (array) $cache_validity->get_meta( [ self::CACHE_ROOT_KEY, $post_id ] );
37 + return;
67 38 }
68 39
69 40 $components = $this->get_components_from_post( $post_id );
70 41 $component_ids = Collection::make( $components )
@@ -74,9 +45,9 @@
74 45 ->all();
75 46
76 47 $cache_validity->validate( [ self::CACHE_ROOT_KEY, $post_id ], $component_ids );
77 48
78 - return $component_ids;
49 + $this->declare_components_rendered( $component_ids );
79 50 }
80 51
81 52 private function declare_components_rendered( array $post_ids ) {
82 53 foreach ( $post_ids as $post_id ) {