Ejemplo n.º 1
0
 /**
  * @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') {
         $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 = TimberPostGetter::loop_to_id())) {
         $pid = $pid_from_loop;
     }
     return $pid;
 }
Ejemplo n.º 2
0
 /**
  *  If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
  * @param mixed $pid
  * @return \TimberPost TimberPost object -- woo!
  */
 function __construct($pid = null)
 {
     if ($pid === null && get_the_ID()) {
         $pid = get_the_ID();
         $this->ID = $pid;
     } else {
         if ($pid === null && ($pid_from_loop = TimberPostGetter::loop_to_id())) {
             $this->ID = $pid_from_loop;
         }
     }
     if (is_numeric($pid)) {
         $this->ID = $pid;
     }
     $this->init($pid);
 }
Ejemplo n.º 3
0
 /**
  *  If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
  * @param mixed $pid
  * @return \TimberPost TimberPost object -- woo!
  */
 function __construct($pid = null)
 {
     global $wp_query;
     if ($pid === null && isset($wp_query->queried_object_id) && $wp_query->queried_object_id) {
         $pid = $wp_query->queried_object_id;
         $this->ID = $pid;
     } else {
         if ($pid === null && get_the_ID()) {
             $pid = get_the_ID();
             $this->ID = $pid;
         } else {
             if ($pid === null && ($pid_from_loop = TimberPostGetter::loop_to_id())) {
                 $this->ID = $pid_from_loop;
             }
         }
     }
     if (is_numeric($pid)) {
         $this->ID = $pid;
     }
     $this->init($pid);
 }