src/class-extended-cpt.php
public function add_taxonomy( string $taxonomy, array $args = [], array $names = [] ) : WP_Taxonomy {

		if ( taxonomy_exists( $taxonomy ) ) {
			register_taxonomy_for_object_type( $taxonomy, $this->post_type );
		} else {
			register_extended_taxonomy( $taxonomy, $this->post_type, $args, $names );
		}

		return get_taxonomy( $taxonomy );

	}
public function add_taxonomy( string $taxonomy, array $args = [], array $names = [] ) : WP_Taxonomy {

		if ( taxonomy_exists( $taxonomy ) ) {
			register_taxonomy_for_object_type( $taxonomy, $this->post_type );
		} else {
			register_extended_taxonomy( $taxonomy, $this->post_type, $args, $names );
		}

		return get_taxonomy( $taxonomy );

	}
public function add_taxonomy ( string $ taxonomy , array $ args = [ ] , array $ names = [ ] ) : WP_Taxonomy { if ( taxonomy_exists ( $ taxonomy ) ) { register_taxonomy_for_object_type ( $ taxonomy , $ this -> post_type ) ; } else { register_extended_taxonomy ( $ taxonomy , $ this -> post_type , $ args , $ names ) ; } return get_taxonomy ( $ taxonomy ) ; }
Helper function for registering a taxonomy and adding it to this post type.

Accepts the same parameters as `register_extended_taxonomy()`, minus the `$object_type` parameter.

Example usage:

$events   = register_extended_post_type( 'event' );
$location = $events->add_taxonomy( 'location' );

@param  string $taxonomy The taxonomy name.
@param  array  $args     Optional. The taxonomy arguments.
@param  array  $names    Optional. An associative array of the plural, singular, and slug names.
@return WP_Taxonomy      Taxonomy object.
Helper function for registering a taxonomy and adding it to this post type .