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/GreenShift/Compile.php +29 -10 3.0.143.2.89 View file →
@@ -10,25 +10,44 @@
10 10 */
11 11 declare (strict_types=1);
12 12 namespace WindPress\WindPress\Integration\GreenShift;
13 13
14 +use WindPress\WindPress\Core\Scanner\PostQuery;
15 +use WindPress\WindPress\Core\Scanner\PostRenderer;
14 16 /**
15 17 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
16 18 */
17 19 class Compile
18 20 {
19 - public function __invoke()
21 + /**
22 + * @param array $metadata
23 + */
24 + public function __invoke($metadata): array
20 25 {
21 - if (!\defined('GREENSHIFT_DIR_PATH')) {
22 - return;
26 + if (!defined('GREENSHIFT_DIR_PATH')) {
27 + return [];
23 28 }
24 - \add_filter('f!windpress/integration/gutenberg/compile:get_contents.post_types', fn(array $post_types): array => $this->get_post_types($post_types));
29 + return $this->get_contents($metadata);
25 30 }
26 - /**
27 - * @param array $post_types
28 - */
29 - public function get_post_types($post_types) : array
31 + public function get_contents($metadata): array
30 32 {
31 - $post_types[] = 'wp_block';
32 - return $post_types;
33 + $contents = [];
34 + $post_types = apply_filters('f!windpress/integration/greenshift/compile:get_contents.post_types', ['wp_block']);
35 + $per_page = apply_filters('f!windpress/integration/greenshift/compile:get_contents.post_per_page', PostQuery::batch_size());
36 + $scan = new PostQuery(['posts_per_page' => $per_page, 'post_type' => $post_types, 'no_found_rows' => \true, 'update_post_meta_cache' => \false, 'update_post_term_cache' => \false, 'ignore_sticky_posts' => \true], $metadata);
37 + $wpQuery = $scan->query;
38 + foreach ($wpQuery->posts as $post) {
39 + $post_content = $post->post_content;
40 + $post_content_trimmed = trim($post_content);
41 + if ($post_content_trimmed === '' || $post_content_trimmed === '0') {
42 + continue;
43 + }
44 + if (apply_filters('f!windpress/integration/greenshift/compile:get_contents.render', \true, $post)) {
45 + $fn_renders = apply_filters('f!windpress/integration/greenshift/compile:get_contents.render_fn', ['do_blocks', 'wptexturize', 'convert_smilies', 'shortcode_unautop', 'wp_filter_content_tags', 'do_shortcode'], $post);
46 + $post_content = PostRenderer::render($post, $fn_renders, 'GreenShift', $wpQuery);
47 + }
48 + $post_content = apply_filters('f!windpress/integration/greenshift/compile:get_contents.post_content', $post_content, $post);
49 + $contents[] = ['source_id' => 'post:' . $post->ID, 'id' => $post->ID, 'title' => sprintf('#%s: %s', $post->ID, $post->post_title), 'content' => $post_content];
50 + }
51 + return ['metadata' => $scan->metadata(), 'contents' => $contents];
33 52 }
34 53 }