| Server IP : 104.26.5.103 / 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/Utils/ |
Upload File : |
<?php
namespace Kirki\App\Utils;
defined('ABSPATH') || exit;
use Kirki\App\Models\Page;
use Kirki\App\Models\Post;
use Kirki\Framework\Sanitizer;
use ReflectionClass;
use WP_Post;
class PostUtil
{
/**
* Converts a Post object to a WP_Post object
*
* @param Post|Page $post
*/
public static function get_wp_post($post)
{
$vars = [];
$reflection = new ReflectionClass(WP_Post::class);
foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
$name = $property->getName();
$vars[$name] = isset($post->{$name}) ? $post->{$name} : null;
}
$vars['filter'] = 'raw';
return new WP_Post((object) sanitize_post($vars, 'raw'));
}
/**
* Returns the permalink for a Post object
*
* @param Post|Page $post
* @param bool $leave_name
* @return string|false
*/
public static function get_permalink($post, $leave_name = false)
{
return get_permalink(static::get_wp_post($post), $leave_name);
}
/**
* Get post id from url
*
* @return int
*/
public static function get_post_id_from_url()
{
if (isset($GLOBALS['wp']->query_vars[KIRKI_CONTENT_MANAGER_PREFIX . '_child_post'])) {
return $GLOBALS['wp']->query_vars[KIRKI_CONTENT_MANAGER_PREFIX . '_child_post'];
} elseif (isset($GLOBALS['wp']->query_vars[KIRKI_CONTENT_MANAGER_PREFIX . '_parent_post']) && false) { // Disable content manager archive page logic
return $GLOBALS['wp']->query_vars[KIRKI_CONTENT_MANAGER_PREFIX . '_parent_post'];
}
$post_id = filter_input(INPUT_GET, 'p', FILTER_VALIDATE_INT);
if ($post_id) {
return Sanitizer::apply_rule($post_id, Sanitizer::INT);
}
$post_id = filter_input(INPUT_POST, 'post_id', FILTER_VALIDATE_INT);
if ($post_id) {
return Sanitizer::apply_rule($post_id, Sanitizer::INT);
}
$post_id = filter_input(INPUT_GET, 'post_id', FILTER_VALIDATE_INT);
if ($post_id) {
return Sanitizer::apply_rule($post_id, Sanitizer::INT);
}
return (int) get_the_ID();
}
}