PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.0.13
Kirki – Freeform Page Builder, Website Builder & Customizer v6.0.13
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 / UtilityPageService.php
kirki / app / Services Last commit date
AppsService.php 2 weeks ago CollaborationCommentService.php 2 weeks ago CollaborationService.php 2 weeks ago CollectionItemService.php 2 weeks ago CollectionService.php 2 weeks ago EditorService.php 2 weeks ago FontService.php 2 weeks ago MediaService.php 2 weeks ago PageService.php 2 weeks ago PageSettingsService.php 2 weeks ago UtilityPageService.php 2 weeks ago
UtilityPageService.php
72 lines
1 <?php
2
3 namespace Kirki\App\Services;
4
5 defined('ABSPATH') || exit;
6
7 use Exception;
8 use Kirki\Ajax\Collection;
9 use Kirki\App\Constants\PageMetaKeys;
10 use Kirki\App\Constants\PostTypes;
11 use Kirki\App\Constants\UtilityPageType;
12 use Kirki\App\Models\Page as PageModel;
13 use Kirki\Framework\Database\Query\QueryBuilder;
14 use Kirki\Framework\Http\Response;
15
16 class UtilityPageService
17 {
18 /**
19 * Create a new instance of the service
20 * @return UtilityPageService
21 */
22 public static function create()
23 {
24 return new static();
25 }
26
27 /**
28 * Check if a utility page exists
29 *
30 * @param string $utility_type
31 *
32 * @return bool
33 */
34 public function exists(string $utility_type)
35 {
36 if (!in_array($utility_type, UtilityPageType::get_constant_values(), true)) {
37 throw new Exception(
38 esc_html(
39 /** translators: %s: Utility page type */
40 sprintf(__('Invalid utility page type: %s'), $utility_type)
41 ),
42 Response::UNPROCESSABLE_ENTITY
43 );
44 }
45
46 return PageModel::query()
47 ->where('post_type', '=', PostTypes::UTILITY)
48 ->where_has('meta', function (QueryBuilder $query) use ($utility_type) {
49 $query->where('meta_key', '=', PageMetaKeys::UTILITY_PAGE_TYPE)
50 ->where('meta_value', '=', $utility_type);
51 })
52 ->exists();
53 }
54
55 /**
56 * Get all utility pages
57 *
58 * @return Collection
59 */
60 public function get_utility_pages()
61 {
62 return PageModel::query()
63 ->with([
64 'meta' => function (QueryBuilder $query) {
65 $query->where('meta_key', '=', PageMetaKeys::UTILITY_PAGE_TYPE)
66 ->where_in('meta_value', UtilityPageType::get_constant_values());
67 }
68 ])
69 ->where('post_type', '=', PostTypes::UTILITY)
70 ->get();
71 }
72 }