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
windpress / src / Integration / GreenShift / Compile.php

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

54 lines 2.4 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\GreenShift;
13
14 use WindPress\WindPress\Core\Scanner\PostQuery;
15 use WindPress\WindPress\Core\Scanner\PostRenderer;
16 /**
17 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
18 */
19 class Compile
20 {
21 /**
22 * @param array $metadata
23 */
24 public function __invoke($metadata): array
25 {
26 if (!defined('GREENSHIFT_DIR_PATH')) {
27 return [];
28 }
29 return $this->get_contents($metadata);
30 }
31 public function get_contents($metadata): array
32 {
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];
52 }
53 }
54