public function __call($name, $arguments) { global $wf; $res = parent::__call($name, $arguments); if (is_woof_silent($res)) { if (is_multisite()) { // for unknown methods switch the blog and access this property on WOOF if (switch_to_blog( $this->id(), true )) { if (method_exists($wf, $name)) { $res = call_user_func_array (array($wf, $name), $arguments); } else { $res = $wf->__call($name, $arguments); } restore_current_blog(); if (!is_woof_silent($res)) { return $res; } } } } return $res; }
public function __call($name, $arguments = array()) { if (count($arguments) <= 1) { // if we have a single argument, we can allow posts and terms to be accessed like this: // $wf->car("ferrari"), or $wf->ingredient("lime") // first, try to find a post type with the name of the call, and all the post function $singular = WOOF_Inflector::singularize($name); foreach ($this->types() as $type) { if ($type->name == $name) { return call_user_func_array( array($type, "post"), $arguments ); } else if ($type->name == $singular) { // call multiple object method (e.g. "cars") return call_user_func_array( array($type, "posts"), $arguments ); } } // next, try to find a taxonomy with the name, and call the term function foreach ($this->taxonomies() as $tax) { if ($tax->name == $name) { return call_user_func_array( array($tax, "term"), $arguments ); } else if ($tax->name == $singular) { // call multiple object method (e.g. "cars") return call_user_func_array( array($tax, "terms"), $arguments ); } } } // now try to call a method on the current wordpress object $obj = $this->object(); if (method_exists($obj, $name)) { return call_user_func_array( array($obj, $name), $arguments ); } return parent::__call($name, $arguments); }
public function __get($name) { global $wf; // try to find a post type with this name, to get posts for this term $singular = WOOF_Inflector::singularize($name); $type = $wf->type($singular); if ($type->exists()) { return $this->posts(array("post_type" => $singular)); } return parent::__call($name, array()); }
public function __call($name, $arguments = array()) { global $wf; // try to find a taxonomy whose plural name is this $name $singular = WOOF_Inflector::singularize($name); $tax = $wf->taxonomy($singular); if ($tax->exists()) { return $this->terms($singular); } return parent::__call($name, $arguments); }