PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / trunk
Kirki – Freeform Page Builder, Website Builder & Customizer vtrunk
6.3.0 6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / app / Services / PostService.php
kirki / app / Services Last commit date
AppsService.php 1 month ago CollaborationCommentService.php 23 hours ago CollaborationService.php 1 month ago CollectionItemService.php 23 hours ago CollectionService.php 1 month ago ContentManagerTemplateBinder.php 1 month ago ContentManagerTemplateService.php 1 month ago EditorService.php 2 months ago FontService.php 2 weeks ago FormSubmissionService.php 23 hours ago GlobalDataService.php 1 month ago MediaService.php 2 months ago PageService.php 1 month ago PageSettingsService.php 2 months ago PostService.php 1 month ago UtilityPageService.php 1 month ago
PostService.php
35 lines
1 <?php
2
3 namespace Kirki\App\Services;
4
5 defined('ABSPATH') || exit;
6
7 use Kirki\App\Constants\PostTypes;
8 use Kirki\App\Models\Post as PostModel;
9
10 class PostService
11 {
12 public function get_all_posts_grouped_by_type(string $search = '')
13 {
14 $post_types = get_post_types();
15 $post_types[PostTypes::TEMPLATE] = PostTypes::TEMPLATE;
16 $post_types[PostTypes::UTILITY] = PostTypes::UTILITY;
17 $post_types[PostTypes::POPUP] = PostTypes::POPUP;
18
19 $discarded_post_types = ['attachment', 'custom_css', 'customize_changeset', 'wp_global_styles', 'revision', 'nav_menu_item', 'oembed_cache', 'user_request', 'wp_block', 'wp_template', 'wp_template_part', 'wp_navigation'];
20
21 $post_types = array_diff_key($post_types, array_flip($discarded_post_types));
22
23 $posts = PostModel::filter_post_type($post_types)
24 ->exclude_trash()
25 ->search($search)
26 ->get()
27 ->group_by(function ($page) {
28 $group_keys = [PostTypes::TEMPLATE, PostTypes::UTILITY, PostTypes::POPUP];
29
30 return in_array($page->post_type, $group_keys, true) ? PostTypes::WP_PAGE : $page->post_type;
31 });
32
33 return $posts;
34 }
35 }