/**
* tries to figure out what post you want to get if not explictly defined (or if it is, allows it to be passed through)
* @internal
* @param mixed a value to test against
* @return int the numberic id we should be using for this post object
*/
protected function determine_id($pid)
{
global $wp_query;
if ($pid === null && isset($wp_query->queried_object_id) && $wp_query->queried_object_id && isset($wp_query->queried_object) && is_object($wp_query->queried_object) && get_class($wp_query->queried_object) == 'WP_Post') {
if (isset($_GET['preview']) && isset($_GET['preview_nonce']) && wp_verify_nonce($_GET['preview_nonce'], 'post_preview_' . $wp_query->queried_object_id)) {
$pid = $this->get_post_preview_id($wp_query);
} else {
if (!$pid) {
$pid = $wp_query->queried_object_id;
}
}
} else {
if ($pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id) {
//hack for static page as home page
$pid = $wp_query->queried_object_id;
} else {
if ($pid === null) {
$gtid = false;
$maybe_post = get_post();
if (isset($maybe_post->ID)) {
$gtid = true;
}
if ($gtid) {
$pid = get_the_ID();
}
if (!$pid) {
global $wp_query;
if (isset($wp_query->query['p'])) {
$pid = $wp_query->query['p'];
}
}
}
}
}
if ($pid === null && ($pid_from_loop = PostGetter::loop_to_id())) {
$pid = $pid_from_loop;
}
return $pid;
}