/** * Magic method for calling inaccessible methods * Examples: * $this->date Return original ISO 8601 date format from model * $this->get_date() Return custom formatted date * $this->get_date_html() Return custom formatted date HTML * $this->the_date() Output custom formatted date * $this->the_date_html() Output custom formatted date HTML * * @param string $method_name * @param array $args * * @return mixed|null */ function __call($method_name, $args = array()) { $value = null; if (false !== strpos($method_name, 'the_')) { $value = WPLib::do_the_methods($this, $this->model(), $method_name, $args); } else { $value = call_user_func_array(array($this->model(), $method_name), $args); } return $value; }
/** * Generate debugging error message for attempts to call a non-existent method. * * @param string $method_name * @param array $args * * @return mixed */ function __call($method_name, $args) { $value = null; if (preg_match('#^the_#', $method_name) && is_callable(array($this, $method_name))) { $value = WPLib::do_the_methods($this, $this, $method_name, $args); } else { /* * Oops. No method was found. Output an error message. */ $message = sprintf(__('ERROR: There is no method %s() in class %s. ', 'wplib'), $method_name, get_class($this)); WPLib::trigger_error($message, E_USER_ERROR); } return $value; }