| Server IP : 172.67.71.254 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/kirki/app/Services/ |
Upload File : |
<?php
namespace Kirki\App\Services;
defined('ABSPATH') || exit;
use Exception;
use Kirki\Ajax\Collection;
use Kirki\App\Constants\PageMetaKeys;
use Kirki\App\Constants\PostTypes;
use Kirki\App\Constants\UtilityPageType;
use Kirki\App\Models\Page as PageModel;
use Kirki\Framework\Database\Query\QueryBuilder;
use Kirki\Framework\Http\Response;
class UtilityPageService
{
/**
* Create a new instance of the service
* @return UtilityPageService
*/
public static function create()
{
return new static();
}
/**
* Check if a utility page exists
*
* @param string $utility_type
*
* @return bool
*/
public function exists(string $utility_type)
{
if (!in_array($utility_type, UtilityPageType::get_constant_values(), true)) {
throw new Exception(
esc_html(
/** translators: %s: Utility page type */
sprintf(__('Invalid utility page type: %s'), $utility_type)
),
Response::UNPROCESSABLE_ENTITY
);
}
return PageModel::query()
->where('post_type', '=', PostTypes::UTILITY)
->where_has('meta', function (QueryBuilder $query) use ($utility_type) {
$query->where('meta_key', '=', PageMetaKeys::UTILITY_PAGE_TYPE)
->where('meta_value', '=', $utility_type);
})
->exists();
}
/**
* Get all utility pages
*
* @return Collection
*/
public function get_utility_pages()
{
return PageModel::query()
->with([
'meta' => function (QueryBuilder $query) {
$query->where('meta_key', '=', PageMetaKeys::UTILITY_PAGE_TYPE)
->where_in('meta_value', UtilityPageType::get_constant_values());
}
])
->where('post_type', '=', PostTypes::UTILITY)
->get();
}
}