[wp-trac] [WordPress Trac] #27678: Add pre_insert_term filter to /wp-includes/taxonomy.php function wp_insert_term

WordPress Trac noreply at wordpress.org
Fri Apr 4 20:16:24 UTC 2014


#27678: Add pre_insert_term filter to /wp-includes/taxonomy.php function
wp_insert_term
-------------------------+-----------------------------
 Reporter:  jdonna       |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Taxonomy     |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 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);
 }

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27678>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list