PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.89
WindPress – Tailwind CSS integration for WordPress v3.2.89
3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 143 releases
← All changes | src/Integration/Elementor/Compile.php +31 -17 3.0.43.2.89 View file →
@@ -11,9 +11,9 @@
11 11 declare (strict_types=1);
12 12 namespace WindPress\WindPress\Integration\Elementor;
13 13
14 14 use Elementor\Plugin;
15 -use WP_Query;
15 +use WindPress\WindPress\Core\Scanner\PostQuery;
16 16 /**
17 17 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
18 18 */
19 19 class Compile
@@ -18,40 +18,54 @@
18 18 */
19 19 class Compile
20 20 {
21 21 private array $post_meta_keys = ['_elementor_data'];
22 - public function __invoke() : array
22 + /**
23 + * @param array $metadata
24 + */
25 + public function __invoke($metadata): array
23 26 {
24 - if (!\defined('ELEMENTOR_VERSION')) {
27 + if (!defined('ELEMENTOR_VERSION')) {
25 28 return [];
26 29 }
27 - return $this->get_contents();
30 + return $this->get_contents($metadata);
28 31 }
29 - public function get_contents() : array
32 + public function get_contents($metadata): array
30 33 {
31 34 $contents = [];
32 - $post_types = \get_option('elementor_cpt_support', Plugin::ELEMENTOR_DEFAULT_POST_TYPES);
33 - $post_types = \apply_filters('f!windpress/integration/elementor/compile:get_contents.post_types', $post_types);
34 - $wpQuery = new WP_Query([
35 - 'posts_per_page' => -1,
35 + $post_types = get_option('elementor_cpt_support', Plugin::ELEMENTOR_DEFAULT_POST_TYPES);
36 + $post_types = apply_filters('f!windpress/integration/elementor/compile:get_contents.post_types', $post_types);
37 + $per_page = apply_filters('f!windpress/integration/elementor/compile:get_contents.post_per_page', PostQuery::batch_size());
38 + $scan = new PostQuery([
39 + 'posts_per_page' => $per_page,
36 40 'fields' => 'ids',
37 41 'post_type' => $post_types,
38 - 'post_status' => \get_post_stati(),
42 + 'post_status' => get_post_stati(),
43 + 'no_found_rows' => \true,
44 + 'update_post_meta_cache' => \false,
45 + 'update_post_term_cache' => \false,
46 + 'ignore_sticky_posts' => \true,
39 47 // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- This only run by trigger on specific event
40 - 'meta_query' => ['relation' => 'OR', ...\array_map(static fn($key) => ['key' => $key], $this->post_meta_keys)],
41 - ]);
48 + 'meta_query' => array_merge(['relation' => 'OR'], array_map(static fn($key) => ['key' => $key], $this->post_meta_keys)),
49 + ], $metadata);
50 + $wpQuery = $scan->query;
51 + if ($wpQuery->posts !== []) {
52 + update_meta_cache('post', $wpQuery->posts);
53 + }
42 54 foreach ($wpQuery->posts as $post_id) {
43 - $contents = [...$contents, ...$this->get_post_metas($post_id)];
55 + foreach ($this->get_post_metas($post_id) as $content) {
56 + $contents[] = $content;
57 + }
44 58 }
45 - return $contents;
59 + return ['metadata' => $scan->metadata(), 'contents' => $contents];
46 60 }
47 - public function get_post_metas($post_id) : array
61 + public function get_post_metas($post_id): array
48 62 {
49 63 $contents = [];
50 64 foreach ($this->post_meta_keys as $post_metum_key) {
51 - $meta_value = \get_post_meta($post_id, $post_metum_key, \true);
65 + $meta_value = get_post_meta($post_id, $post_metum_key, \true);
52 66 if ($meta_value) {
53 - $contents[] = ['name' => $post_id, 'content' => $meta_value];
67 + $contents[] = ['source_id' => 'post:' . $post_id . ':meta:' . $post_metum_key, 'name' => $post_id, 'content' => $meta_value, 'type' => 'json'];
54 68 }
55 69 }
56 70 return $contents;
57 71 }