Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#27678 closed enhancement (duplicate)

Add pre_insert_term filter to /wp-includes/taxonomy.php function wp_insert_term

Reported by: jdonna's profile jdonna Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Due to the way I am working with wp_terms, I needed my client to be able to create wp_terms with the same name(IE Green) on different taxonomies, and instead of using the same term name/id on creation(if slug is not specified), the slug needed to be unique.

There was no filter for me to adjust the slug, if my client does not specify the slug.

I added the filter
$slug = apply_filters( 'pre_insert_term', sanitize_title($name));
On line 2148 on revision 27778

Attached is my taxonomy.diff, which is a patch for /wp-includes/taxonomy.php

Also this is an example of me using this filter:

add_filter ('pre_insert_term_slug', array(&$this, 'pre_insert_term_slug'));

function pre_insert_term_slug($slug){
	return wp_unique_term_slug($slug, (object) $args);
}

Attachments (1)

taxonomy.diff (517 bytes) - added by jdonna 10 years ago.
Adds filter to /wp-includes/taxonomy.php

Download all attachments as: .zip

Change History (2)

@jdonna
10 years ago

Adds filter to /wp-includes/taxonomy.php

#1 @boonebgorges
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #22293.

Note: See TracTickets for help on using tickets.