From 4b88d15411ec33cc6b5839206cfc7195d68d1deb Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 26 Feb 2010 07:40:35 +0000 Subject: [PATCH] Add pre_insert_term hook to wp_insert_term(). fixes #10943 props sirzooro git-svn-id: http://svn.automattic.com/wordpress/trunk@13430 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 5b789aa50b..f554226e63 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1444,6 +1444,7 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { * @since 2.3.0 * @uses $wpdb * + * @uses apply_filters() Calls 'pre_insert_term' hook with term and taxonomy as parameters. * @uses do_action() Calls 'create_term' hook with the term id and taxonomy id as parameters. * @uses do_action() Calls 'create_$taxonomy' hook with term id and taxonomy id as parameters. * @uses apply_filters() Calls 'term_id_filter' hook with term id and taxonomy id as parameters. @@ -1461,6 +1462,10 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { if ( ! is_taxonomy($taxonomy) ) return new WP_Error('invalid_taxonomy', __('Invalid taxonomy')); + $term = apply_filters( 'pre_insert_term', $term, $taxonomy ); + if ( is_wp_error( $term ) ) + return $term; + if ( is_int($term) && 0 == $term ) return new WP_Error('invalid_term_id', __('Invalid term ID'));