/** * Returns the model's backend storage container. * * @return \WordPress\Model\StorageInterface */ public function getStorage() { if (!isset($this->storage)) { $this->storage = new DatabaseTable(App::instance()->get('dbConnection'), $this->getName()); } return $this->storage; }
/** * Locates and loads a theme template. * * Replacement for WordPress function get_template_part() * * @see get_template_part() * * @param string $slug Template slug. * @param string $name [Optional] Optional template name. * @return void */ function template_part($slug, $name = null) { $slug = App::instance()->get('theme')->getTemplatePartPath($slug); do_action("get_template_part_{$slug}", $slug, $name); $templates = array(); if (!empty($name)) { $templates[] = "{$slug}-{$name}.php"; } $templates[] = "{$slug}.php"; include_template(locate_template($templates)); }
public function execute() { do_action($this->getName(), App::instance()); }
/** * Allows DI services to be resolved by static method call. * * @param string $func * @param array $args * * @return mixed */ public static function __callStatic($func, array $args) { return static::$instance->get($func, empty($args) ? null : $args); }
/** * Queries the database using multiple fields (i.e. column) * * @param array $where Array of "column" => "value" args * @param string $select The SQL "SELECT" string * @return mixed */ public static function findOne(array $where) { $class = get_called_class(); if ($definition = App::instance()->get('modelManager')->getDefinition($class)) { $results = $definition->getStorage()->findOne($where); return $class::forgeObject($results); } }
/** * Loads a file within the object's scope (i.e. with $this available in the file). * * @param string $__file * @param boolean $__return [Optional] Default = false. Whether to return the output rather than print it. * @return void|string */ public function includeFile($__file, $__return = false) { if ($__return) { ob_start(); } global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; /** @var $app \WordPress\App */ $app = App::instance(); /** @var $di \WordPress\DI */ $di = $app; /** @var $theme \WordPress\Theme\ActiveTheme */ $theme = $app->get('theme'); if (!empty($wp_query->query_vars) && is_array($wp_query->query_vars)) { extract($wp_query->query_vars, EXTR_SKIP); } if ($di->has('templateVars')) { extract($di->get('templateVars'), EXTR_SKIP); } include $__file; if ($__return) { return ob_get_clean(); } }