public static function __callStatic($func, array $args) { if (empty($args)) { return self::$app->get($func); } array_unshift($args, $func); return call_user_func_array(array(self::$app, 'get'), $args); }
/** * Returns or sets a DI value. * * @param string $key * @param mixed $value [Optional] * @param boolean $shared [Optional] Default = false * * @return mixed|void */ function di($key, $value = null, $shared = false) { if ($value === null) { return WordPress\App::instance()->get($key); } else { WordPress\App::instance()->set($key, $value, $shared); } }
/** * Returns a \WordPress\Model\Post instance for the given post. * * @param null|int|WP_Post $post [Optional] Post ID or object, or null to use global. * @return \WordPress\Model\Post */ function get_custom_post($post = null) { if (null === $post) { return WordPress\App::instance()->getPost(); } else { if (!$post instanceof WP_Post) { $post = get_post($post); } } return WordPress\App::instance()->get('modelManager')->getInstance('post', $post); }
/** * Returns an instance of a model. * * @param string $name * @param mixed $data * @return \WordPress\Model\ModelInterface */ function model_instance($name, $data) { return WordPress\App::instance()->get('modelManager')->getInstance($name, $data); }