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 +8 -17 3.2.833.2.89 View file →
@@ -10,9 +10,10 @@
10 10 */
11 11 declare (strict_types=1);
12 12 namespace WindPress\WindPress\Integration\GreenShift;
13 13
14 -use WP_Query;
14 +use WindPress\WindPress\Core\Scanner\PostQuery;
15 +use WindPress\WindPress\Core\Scanner\PostRenderer;
15 16 /**
16 17 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
17 18 */
18 19 class Compile
@@ -30,11 +31,11 @@
30 31 public function get_contents($metadata): array
31 32 {
32 33 $contents = [];
33 34 $post_types = apply_filters('f!windpress/integration/greenshift/compile:get_contents.post_types', ['wp_block']);
34 - $next_batch = $metadata['next_batch'] !== \false ? $metadata['next_batch'] : 1;
35 - $per_page = apply_filters('f!windpress/integration/greenshift/compile:get_contents.post_per_page', (int) get_option('posts_per_page', 20));
36 - $wpQuery = new WP_Query(['posts_per_page' => $per_page, 'post_type' => $post_types, 'paged' => $next_batch, 'no_found_rows' => \true, 'update_post_meta_cache' => \false, 'update_post_term_cache' => \false, 'ignore_sticky_posts' => \true]);
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;
37 38 foreach ($wpQuery->posts as $post) {
38 39 $post_content = $post->post_content;
39 40 $post_content_trimmed = trim($post_content);
40 41 if ($post_content_trimmed === '' || $post_content_trimmed === '0') {
@@ -41,22 +42,12 @@
41 42 continue;
42 43 }
43 44 if (apply_filters('f!windpress/integration/greenshift/compile:get_contents.render', \true, $post)) {
44 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);
45 - foreach ($fn_renders as $fn_render) {
46 - try {
47 - $post_content = $fn_render($post_content);
48 - } catch (\Throwable $th) {
49 - if (\WP_DEBUG) {
50 - error_log($th->getMessage());
51 - }
52 - }
53 - }
46 + $post_content = PostRenderer::render($post, $fn_renders, 'GreenShift', $wpQuery);
54 47 }
55 48 $post_content = apply_filters('f!windpress/integration/greenshift/compile:get_contents.post_content', $post_content, $post);
56 - $contents[] = ['id' => $post->ID, 'title' => sprintf('#%s: %s', $post->ID, $post->post_title), 'content' => $post_content];
49 + $contents[] = ['source_id' => 'post:' . $post->ID, 'id' => $post->ID, 'title' => sprintf('#%s: %s', $post->ID, $post->post_title), 'content' => $post_content];
57 50 }
58 - $post_count = count($wpQuery->posts);
59 - $has_more = $per_page > 0 && $post_count === $per_page;
60 - return ['metadata' => ['next_batch' => $has_more ? $next_batch + 1 : \false, 'total_batches' => \false], 'contents' => $contents];
51 + return ['metadata' => $scan->metadata(), 'contents' => $contents];
61 52 }
62 53 }