public function __get($name) { global $wf; // is we're accessing the set named "content" and it exists, prioritise this first // this allows us to call "content()" to get the standard content FIELD. if ($name == "content") { $set = $this->set("content"); if ($set->exists()) { return $set; } } // fallback to WOOF_Wrap's get FIRST. $value = $this->get($name); if (is_woof_silent($value)) { $value = $this->set($name); } if (!is_woof_silent($value)) { return $value; } // look for "incoming" post types, so that we can get "incoming_cars" for example if (preg_match("/incoming\_([a-z0-9\_]+)/", $name, $matches)) { $pt_name = $matches[1]; $singular = WOOF_Inflector::singularize($pt_name); foreach ($wf->types() as $type) { if ($type->name == $pt_name) { return $this->incoming("post_type=".$pt_name)->first(); // return the first incoming post } else if ($type->name == $singular) { return $this->incoming("post_type=".$singular); } } // next we'll try taxonomy names foreach ($wf->taxonomies() as $tax) { if ($tax->name == $singular) { return $this->incoming_terms($tax); } } } else { $singular = WOOF_Inflector::singularize($name); foreach ($wf->types() as $type) { if ($type->name == $name) { return $this->posts("post_type=".$name)->first(); // return the first post (ignore the args) } else if ($type->name == $singular) { return $this->posts("post_type=" . $singular); } } } // fallback to the parent method return parent::__get($name); }