static function get_post_type_class($post_type) { $classes = self::post_type_classes(); return !empty($classes[$post_type]) ? $classes[$post_type] : null; }
/** * @param array $posts * @param array $args */ function __construct($posts, $args = array()) { if (isset($posts) && is_array($posts)) { $args = wp_parse_args($args, array('list_owner' => false)); /** * @var WPLib_Posts $list_owner */ $list_owner = $args['list_owner']; if (!$list_owner) { foreach ($posts as $index => $post) { $posts[$index] = $list_owner::make_new_item($post, $args); } } else { foreach ($posts as $index => $post) { $list_owner = $args['list_owner'] = WPLib_Posts::get_post_type_class($post->post_type); $posts[$index] = $list_owner::make_new_item($post, $args); } } } parent::__construct($posts, $args); }