PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.0.4
WindPress – Tailwind CSS integration for WordPress v3.0.4
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
windpress / src / Integration / Elementor / Compile.php

Compile.php in WindPress – Tailwind CSS integration for WordPress 3.0.4, at src/Integration/Elementor/Compile.php

59 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the WindPress package.
5 *
6 * (c) Joshua Gugun Siagian <suabahasa@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 declare (strict_types=1);
12 namespace WindPress\WindPress\Integration\Elementor;
13
14 use Elementor\Plugin;
15 use WP_Query;
16 /**
17 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
18 */
19 class Compile
20 {
21 private array $post_meta_keys = ['_elementor_data'];
22 public function __invoke() : array
23 {
24 if (!\defined('ELEMENTOR_VERSION')) {
25 return [];
26 }
27 return $this->get_contents();
28 }
29 public function get_contents() : array
30 {
31 $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,
36 'fields' => 'ids',
37 'post_type' => $post_types,
38 'post_status' => \get_post_stati(),
39 // 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 ]);
42 foreach ($wpQuery->posts as $post_id) {
43 $contents = [...$contents, ...$this->get_post_metas($post_id)];
44 }
45 return $contents;
46 }
47 public function get_post_metas($post_id) : array
48 {
49 $contents = [];
50 foreach ($this->post_meta_keys as $post_metum_key) {
51 $meta_value = \get_post_meta($post_id, $post_metum_key, \true);
52 if ($meta_value) {
53 $contents[] = ['name' => $post_id, 'content' => $meta_value];
54 }
55 }
56 return $contents;
57 }
58 }
59