/** * @return WPLib_Post_Base * * @todo Make work for non-posts? */ function item() { return $this->has_posts() ? WPLib_Posts::make_new_item($this->post()) : new WPLib_Post_Default(null); }
/** * Returns a WPLib_Item_Base from the queried object, if the queried object is a post. * * Useful for accessing the post prior to $wp_the_query * Similar to single_post_title() in concept * * @return WPLib_Post_Base */ function single_post_item() { /** * @var WP_Post $_post */ return $_post = $this->single_post() ? WPLib_Posts::make_new_item($_post) : null; }
/** * @param WPLib_Item_Base|WP_Post|WP_Term $item * @param array $args * * @return WPLib_Term_Base|WPLib_Post_Base */ static function make_new_item($item, $args = array()) { $class = get_called_class(); if (WPLib::get_constant('POST_TYPE', $class)) { $item = WPLib_Posts::make_new_item($item, $args); } else { if (WPLib::get_constant('TAXONOMY', $class)) { $item = WPLib_Terms::make_new_item($item, $args); } else { $err_msg = __('Cannot make new item. Class %s does not have POST_TYPE or TAXONOMY constant.', 'wplib'); WPLib::trigger_error(sprintf($err_msg, $class)); } } return $item; }