Inventory_Presser_Plugin::change_term_links( string $termlink, object $term )

Change links to terms in our taxonomies to include /inventory before /tax/term.


Parameters Parameters

$termlink

(string) (Required) URL to modify.

$term

(object) (Required) An instance of the WP_Term class.


Top ↑

Return Return

(string) A modified term link that has our post type slug prepended.


Top ↑

Source Source

File: inventory-presser.php

	public function change_term_links( $termlink, $term ) {
		$taxonomy = get_taxonomy( $term->taxonomy );

		if ( ! in_array( INVP::POST_TYPE, $taxonomy->object_type, true ) ) {
			return $termlink;
		}

		$post_type = get_post_type_object( INVP::POST_TYPE );
		if ( empty( $post_type ) ) {
			return $termlink;
		}

		$termlink = $post_type->rewrite['slug'] . $termlink;
		return $termlink;
	}