PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.0.6
WindPress – Tailwind CSS integration for WordPress v3.0.6
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 3.0.7 All 142 releases
windpress / src / Integration / Gutenberg / Compile.php

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

56 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\Gutenberg;
13
14 use WP_Query;
15 /**
16 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
17 */
18 class Compile
19 {
20 /**
21 * @param array $metadata
22 */
23 public function __invoke($metadata) : array
24 {
25 return $this->get_contents($metadata);
26 }
27 public function get_contents($metadata) : array
28 {
29 $contents = [];
30 $post_types = \apply_filters('f!windpress/integration/gutenberg/compile:get_contents.post_types', ['post', 'page', 'wp_template']);
31 $next_batch = $metadata['next_batch'] !== \false ? $metadata['next_batch'] : 1;
32 $wpQuery = new WP_Query(['posts_per_page' => \apply_filters('f!windpress/integration/gutenberg/compile:get_contents.post_per_page', (int) \get_option('posts_per_page', 10)), 'post_type' => $post_types, 'paged' => $next_batch]);
33 foreach ($wpQuery->posts as $post) {
34 if (\trim($post->post_content) === '' || \trim($post->post_content) === '0') {
35 continue;
36 }
37 $post_content = $post->post_content;
38 if (\apply_filters('f!windpress/integration/gutenberg/compile:get_contents.render', \true, $post)) {
39 $fn_renders = \apply_filters('f!windpress/integration/gutenberg/compile:get_contents.render_fn', ['do_blocks', 'wptexturize', 'convert_smilies', 'shortcode_unautop', 'wp_filter_content_tags', 'do_shortcode'], $post);
40 foreach ($fn_renders as $fn_render) {
41 try {
42 $post_content = $fn_render($post_content);
43 } catch (\Throwable $th) {
44 if (\WP_DEBUG) {
45 \error_log($th->getMessage());
46 }
47 }
48 }
49 }
50 $post_content = \apply_filters('f!windpress/integration/gutenberg/compile:get_contents.post_content', $post_content, $post);
51 $contents[] = ['id' => $post->ID, 'title' => \sprintf('#%s: %s', $post->ID, $post->post_title), 'content' => $post_content];
52 }
53 return ['metadata' => ['next_batch' => $wpQuery->max_num_pages > $next_batch ? $next_batch + 1 : \false], 'contents' => $contents];
54 }
55 }
56