Registers a taxonomy
@param  Taxonomy $taxonomy The taxonomy model
@return object What is being returned by register_taxonomy
761761
private function registerTaxonomy(Taxonomy $taxonomy)
    {
        $labelParser = new LabelParser($taxonomy);
        $labelParser->parse();
        $singular   = $labelParser->singular();
        $plural     = $labelParser->plural();

        $key = $this->model->getWordpressKey() . "_" . $taxonomy->getWordpressKey();

        $customizedOptions = $taxonomy->getConfiguration() + array(
            'hierarchical'               => false,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'update_count_callback'     => '_update_post_term_count',
            'query_var'                 =>  $key,
            'show_in_nav_menus'          => false,
            'show_tagcloud'              => false,
            'rewrite' => array(),
            'capabilities' => array(),
            'labels'=> array()
        );

        $customizedOptions['capabilities'] += array(
            'manage_terms' => 'read',
            'edit_terms'   => 'read',
            'delete_terms' => 'read',
            'assign_terms' => 'read',
        );

        $customizedOptions['rewrite'] += array(
            'with_front' => true,
            'slug' => $key
        );

        $customizedOptions['labels'] += array(
            'name'                => _x($plural, 'Post Type General Name', 'strata'),
            'singular_name'       => _x($singular, 'Post Type Singular Name', 'strata'),
            'menu_name'           => __($plural, 'strata'),
            'parent_item_colon'   => __($singular. ' Item:', 'strata'),
            'all_items'           => __('All ' . $plural, 'strata'),
            'view_item'           => __('View ' . $singular. ' Item', 'strata'),
            'add_new_item'        => __('Add New', 'strata'),
            'add_new'             => __('Add New', 'strata'),
            'edit_item'           => __('Edit ' . $singular, 'strata'),
            'update_item'         => __('Update ' . $singular, 'strata'),
            'search_items'        => __('Search ' . $plural, 'strata'),
            'not_found'           => __('Not found', 'strata'),
            'not_found_in_trash'  => __('Not found in Trash', 'strata'),
        );

        $wordpressKey = $taxonomy->getWordpressKey();
        Strata::app()->setConfig("runtime.taxonomy.query_vars.$wordpressKey", $customizedOptions['query_var']);

        return register_taxonomy($wordpressKey, array($this->model->getWordpressKey()), $customizedOptions);
    }
172325
public function register(array $collection)
    {
        foreach ($collection as $name => $data) {
            $this->plugins[$name] = $data;
        }

        return $this;
    }
827883
public function taxonomy($name)
    {
        foreach($this->data as $post)
        {
            $terms = get_the_terms($post->ID, $name);

            if(!empty($terms))
            {
                $term = array_values($terms)[0];

                $post->$name = (object) [
                    'name' => $term->name,
                    'permalink' => get_term_link($term->slug, $name)
                ];
            }
        }

        return $this;
    }
934585
public function registerTaxonomy($taxonomy, $object_type, $args = array())
    {

        if (empty($taxonomy) || strlen($taxonomy) > 32) {
            return new EtherError('Taxonomy names must be between 1 and 32 characters in length.');
        }

        if (empty($object_type)) {
            return new EtherError('Object type can not be empty');
        }

        $defaults = [
            'labels'             => [],
            'show_ui'            => true,
            'show_in_admin_menu' => null,
            'show_in_nav_menu'   => null,
            'hierarchical'       => false,
            '_built_in'          => false,
        ];


        $args = array_merge($defaults, $args);


        if (null === $args[ 'show_in_admin_menu' ]) {
            $args[ 'show_in_admin_menu' ] = $args[ 'show_ui' ];
        }

        if (null === $args[ 'show_in_nav_menu' ]) {
            $args[ 'show_in_nav_menu' ] = $args[ 'show_ui' ];
        }

        $args[ 'name' ] = $taxonomy;
        $args[ 'object_type' ] = array_unique((array)$object_type);

        $this->taxonomies[ $taxonomy ] = (object)$args;
    }
459863
public function register_taxonomy_rules( $taxonomy, $object_type, $args ) {
		global $wp_rewrite;

		/* for 4.7 */
		$args = (array) $args;

		if ( CPTP_Util::get_no_taxonomy_structure() ) {
			return;
		}

		if ( ! empty( $args['_builtin'] ) ) {
			return;
		}

		if ( false === $args['rewrite'] ) {
			return;
		}

		$post_types = $args['object_type'];
		foreach ( $post_types as $post_type ) :
			$post_type_obj = get_post_type_object( $post_type );
			if ( ! empty( $post_type_obj->rewrite['slug'] ) ) {
				$slug = $post_type_obj->rewrite['slug'];
			} else {
				$slug = $post_type;
			}

			if ( ! empty( $post_type_obj->has_archive ) && is_string( $post_type_obj->has_archive ) ) {
				$slug = $post_type_obj->has_archive;
			};

			if ( ! empty( $post_type_obj->rewrite['with_front'] ) ) {
				$slug = substr( $wp_rewrite->front, 1 ) . $slug;
			}

			if ( 'category' === $taxonomy ) {
				$cb            = get_option( 'category_base' );
				$taxonomy_slug = ( $cb ) ? $cb : $taxonomy;
				$taxonomy_key  = 'category_name';
			} else {
				// Edit by [Xiphe].
				if ( isset( $args['rewrite']['slug'] ) ) {
					$taxonomy_slug = $args['rewrite']['slug'];
				} else {
					$taxonomy_slug = $taxonomy;
				}
				// [Xiphe] stop
				$taxonomy_key = $taxonomy;
			}

			$rules = array(
				// feed.
				array(
					'regex'    => '%s/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&feed=\$matches[2]",
				),
				array(
					'regex'    => '%s/(.+?)/(feed|rdf|rss|rss2|atom)/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&feed=\$matches[2]",
				),
				// year.
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]",
				),
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&paged=\$matches[3]",
				),
				// monthnum.
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]",
				),
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&paged=\$matches[4]",
				),
				// day.
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]",
				),
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]&paged=\$matches[5]",
				),
				// paging.
				array(
					'regex'    => '%s/(.+?)/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&paged=\$matches[2]",
				),
				// tax archive.
				array(
					'regex'    => '%s/(.+?)/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]",
				),
			);

			// no post_type slug.
			foreach ( $rules as $rule ) {
				$regex    = sprintf( $rule['regex'], "{$taxonomy_slug}" );
				$redirect = $rule['redirect'];
				add_rewrite_rule( $regex, $redirect, 'top' );
			}

			if ( get_option( 'add_post_type_for_tax' ) ) {
				foreach ( $rules as $rule ) {
					$regex    = sprintf( $rule['regex'], "{$slug}/{$taxonomy_slug}" );
					$redirect = $rule['redirect'] . "&post_type={$post_type}";
					add_rewrite_rule( $regex, $redirect, 'top' );
				}
			} else {
				foreach ( $rules as $rule ) {
					$regex    = sprintf( $rule['regex'], "{$slug}/{$taxonomy_slug}" );
					$redirect = $rule['redirect'];
					add_rewrite_rule( $regex, $redirect, 'top' );
				}
			}

			do_action( 'CPTP_registered_' . $taxonomy . '_rules', $object_type, $args, $taxonomy_slug );

		endforeach;
	}
438378
public function getTerms($taxonomy = '')
    {
        if ($taxonomy) {
            $term_ids = $this->taxonomies->where('taxonomy', $taxonomy)->pluck('term_id');
        } else {
            $term_ids = $this->getTaxonomies('term_id');
        }

        return Term::whereIn('id', $term_ids)->get();
    }
1361677
function register_taxonomies() {

        if ( is_array( $this->taxonomy_settings ) ) {

            // Foreach taxonomy registered with the post type.
            foreach ( $this->taxonomy_settings as $taxonomy_name => $options ) {

                // Register the taxonomy if it doesn't exist.
                if ( ! taxonomy_exists( $taxonomy_name ) ) {

                    // Register the taxonomy with Wordpress
                    register_taxonomy( $taxonomy_name, $this->post_type_name, $options );

                } else {

                    // If taxonomy exists, register it later with register_exisiting_taxonomies
                    $this->exisiting_taxonomies[] = $taxonomy_name;
                }
            }
        }
    }
954276
public function removeTerm($term_name, $taxonomy = '')
    {
        if (! $term = $this->getTerm($term_name, $taxonomy))
            return null;

        if ($taxonomy) {
            $taxonomy = $this->taxonomies->where('taxonomy', $taxonomy)->where('term_id', $term->id)->first();
        } else {
            $taxonomy = $this->taxonomies->where('term_id', $term->id)->first();
        }

        return $this->taxed()->where('taxonomy_id', $taxonomy->id)->delete();
    }
487890
public function registerTaxonomy()
    {
        if (function_exists('get_field')) {
            $type_definitions = get_field('avabile_dynamic_taxonomies', 'option');

            if (is_array($type_definitions) && !empty($type_definitions)) {
                foreach ($type_definitions as $type_definition_key => $type_definition) {
                    register_taxonomy(
                        sanitize_title($type_definition['label']),
                        $type_definition['connected_post_types'],
                        array(
                            'label' => $type_definition['label'],
                            'rewrite' => array( 'slug' => $type_definition['slug'] ),
                            'hierarchical' => (bool) $type_definition['hierarchical'],
                            'show_admin_column' => (bool) $type_definition['show_ui'],
                            'show_ui' => (bool) $type_definition['show_ui'],
                            'public' => (bool) $type_definition['public']
                        )
                    );
                }
            }
        }
    }
663134
public function register_field( $pod, $field ) {

		if ( is_array( $pod ) && ! empty( $pod ) && ! isset( $pod['name'] ) ) {
			$data = array();

			foreach ( $pod as $p ) {
				$data[] = $this->register_field( $p, $field );
			}

			return $data;
		}

		if ( empty( self::$current_pod_data ) || ! is_object( self::$current_pod_data ) || self::$current_pod_data['name'] != $pod ) {
			self::$current_pod_data = pods_api()->load_pod( array( 'name' => $pod ), false );
		}

		$pod = self::$current_pod_data;

		if ( ! empty( $pod ) ) {
			$type = $pod['type'];

			if ( 'post_type' == $pod['type'] ) {
				$type = 'post_types';
			} elseif ( 'taxonomy' == $pod['type'] ) {
				$type = 'taxonomies';
			} elseif ( 'pod' == $pod['type'] ) {
				$type = 'advanced_content_types';
			}

			if ( ! isset( self::$queue[ $pod['type'] ] ) ) {
				self::$queue[ $type ] = array();
			}

			$field = pods_api()->save_field( $field, false, false, $pod['id'] );

			if ( ! empty( $field ) ) {
				$pod['fields'][ $field['name'] ] = $field;

				self::$queue[ $type ][ $pod['name'] ] = $pod;

				return $field;
			}
		}

		return false;
	}
1262645
public function bindTaxonomyMapper()
    {
        $this->app->bind(TaxonomyMapper::class, function (Application $app) {
            $api = $app->make(ApiClient::class);

            return new TaxonomyMapper($api);
        });
    }
182578
public function add($vocabularyId)
    {
        $this->loadModel('Taxonomy.Vocabularies');
        $vocabulary = $this->Vocabularies->get($vocabularyId);
        $term = $this->Vocabularies->Terms->newEntity(['vocabulary_id' => $vocabulary->id], ['validate' => false]);
        $this->Vocabularies->Terms->addBehavior('Tree', ['scope' => ['vocabulary_id' => $vocabulary->id]]);

        if ($this->request->data()) {
            $term = $this->Vocabularies->Terms->patchEntity($term, $this->request->data, [
                'fieldList' => [
                    'parent_id',
                    'name',
                ]
            ]);

            if ($this->Vocabularies->Terms->save($term)) {
                $this->Flash->success(__d('taxonomy', 'Term has been created.'));
                if (!empty($this->request->data['action_vocabulary'])) {
                    $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'vocabulary', $vocabulary->id]);
                } elseif (!empty($this->request->data['action_add'])) {
                    $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'add', $vocabulary->id]);
                }
            } else {
                $this->Flash->danger(__d('taxonomy', 'Term could not be created, please check your information.'));
            }
        }

        $parentsTree = $this->Vocabularies->Terms
            ->find('treeList', ['spacer' => '--'])
            ->map(function ($link) {
                if (strpos($link, '-') !== false) {
                    $link = str_replace_last('-', '- ', $link);
                }

                return $link;
            });

        $this->title(__d('taxonomy', 'Create New Term'));
        $this->set(compact('vocabulary', 'term', 'parentsTree'));
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('taxonomy', 'Taxonomy'), '/admin/taxonomy/manage')
            ->push(__d('taxonomy', 'Vocabularies'), ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'index'])
            ->push("\"{$vocabulary->name}\"", ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'edit', $vocabulary->id])
            ->push(__d('taxonomy', 'Terms'), ['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'vocabulary', $vocabulary->id])
            ->push(__d('taxonomy', 'Add new term'), '#');
    }
1283861
public function registerCollection(array $collection)
    {
        foreach ($collection as $name => $handler) {
            $this->register($name, $handler);
        }

        return $this;
    }
1010604
public function register() {
		if ($this->registered) {
			require_once __DIR__ . '/Exceptions/RegisterationFailed.php';
			throw new RegistrationFailed('Is already registered');
		}
		
		if ($this->namespaces->isEmpty()) {
			require_once __DIR__ . '/Exceptions/RegisterationFailed.php';
			throw new RegistrationFailed('No namespaces was registered');
		}
		
		spl_autoload_register(function($class) {
			foreach ($this->namespaces as $definition) {
				if (strpos($class, $definition->namespace) === 0) {
					$resolvedClass = substr($class, strlen($definition->namespace));
					
					if ($this->loadClass($resolvedClass, $definition->dirs)) {
						return;
					}
				}
			}
			
			if (! $this->dirs->isEmpty()) {
				$this->loadClass('\\' . $class, $this->dirs);
			}
		});
		
		$this->registered = true;
	}
1322429
private function loadVocabulary($vocabulary) {

    if (!strlen($vocabulary)) {
      throw new \InvalidArgumentException(
        'CategoryRepository requires a taxonomy vocabulary machine name.'
      );
    }

    $vocab = $this->vocabStorage->load($vocabulary);

    if (!$vocab || !$vocab->id()) {
      throw new \InvalidArgumentException(sprintf(
        'CategoryRepository unable to locate vocabulary %s.',
        $vocabulary
      ));
    }

    $this->vocabulary = $vocab;
  }
1354287
protected function get_term_ids( $taxonomy ) {
		$terms = get_the_terms( $this->get_id(), $taxonomy );

		if ( false === $terms || is_wp_error( $terms ) ) {
			return [];
		}

		return wp_list_pluck( $terms, 'term_id' );
	}
181876
protected function buildTaxonomy(TaxonomyFile $taxonomyFile)
    {
        $tax = new Taxonomy(
            $taxonomyFile->getName(),
            $taxonomyFile->getPluralName(),
            $taxonomyFile->getSlug()
        );

        foreach ($taxonomyFile->getTerms() as $data) {
            # Don't add term to Taxonomy here,
            # it's done in constructor of Term.
            new Term($tax, $data['name'], $data['slug']);
        }

        return $tax;
    }