/** * Register the taxonomies * WordPress limits calls to register_taxonomy to once per taxonomy * So we need to externalize this from a single TacoPostUtil::load call * @return integer Number of taxonomies registered */ public static function registerTaxonomies() { global $taxonomies_infos; if (!Arr::iterable($taxonomies_infos)) { return 0; } // Start by grouping all taxonomy requests by taxonomy key $count = 0; $grouped = Collection::groupBy($taxonomies_infos, 'key'); foreach ($grouped as $key => $key_taxonomies) { // Now get all the post types $post_types = Collection::pluck($key_taxonomies, 'post_type'); $configs = Collection::pluck($key_taxonomies, 'config'); // Now we can finally register this taxonomy register_taxonomy($key, $post_types, current($configs)); $count++; } return $count; }