. * */ namespace Vvveb\Controller\Content; use Vvveb\Sql\categorySQL; use Vvveb\Sql\taxonomySQL; trait TaxonomiesTrait { protected function taxonomies($post_id = false) { //get taxonomies for post type $taxonomies = new taxonomySQL(); $results = $taxonomies->getAll( ['post_type' => $this->type] ); //get taxonomies content if ($results) { $taxonomy_itemSql = new categorySQL(); $options = [ 'post_type' => $this->type, 'start' => 0, 'limit' => 1000, ] + $this->global; if ($post_id) { $options["{$this->object}_id"] = $post_id; } if (isset($results['taxonomy'])) { foreach ($results['taxonomy'] as $id => &$taxonomy_item) { $taxonomy_item['taxonomy_item'] = []; //for tags don't retrive taxonomies if no post id provided if ($taxonomy_item['type'] != 'tags' || $post_id) { $options = ['taxonomy_id' => $id, 'type' => $taxonomy_item['type']] + $options; $taxonomy_item['taxonomy_item'] = $taxonomy_itemSql->getCategories($options); } } } } return $results['taxonomy'] ?? []; } }