Ticket #6593: match_tag_names.diff
File match_tag_names.diff, 2.5 KB (added by , 17 years ago) |
---|
-
opt/www/eclipsework/WPDev/wp-includes/post.php
1469 1469 if ( empty($tags) ) 1470 1470 $tags = array(); 1471 1471 $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 1472 wp_set_object_terms($post_id, $tags, 'post_tag', $append );1472 wp_set_object_terms($post_id, $tags, 'post_tag', $append, true); 1473 1473 } 1474 1474 1475 1475 /** -
opt/www/eclipsework/WPDev/wp-includes/taxonomy.php
735 735 * @param string $taxonomy The taxonomy name to use 736 736 * @return mixed Get the term id or Term Object, if exists. 737 737 */ 738 function is_term($term, $taxonomy = '' ) {738 function is_term($term, $taxonomy = '', $allow_match_name = false) { 739 739 global $wpdb; 740 740 741 741 if ( is_int($term) ) { … … 743 743 return 0; 744 744 $where = $wpdb->prepare( "t.term_id = %d", $term ); 745 745 } else { 746 $tname = $term; 746 747 if ( '' === $term = sanitize_title($term) ) 747 748 return 0; 748 749 $where = $wpdb->prepare( "t.slug = %s", $term ); 750 if( $allow_match_name ) { 751 $where .= ' OR ' . $wpdb->prepare( "t.name = %s", $tname ); 752 } 749 753 } 750 754 751 755 if ( !empty($taxonomy) ) … … 1248 1252 * @uses $wpdb 1249 1253 * 1250 1254 * @param int $object_id The object to relate to. 1251 * @param array|int|string $term The slug or id of the term.1255 * @param array|int|string $terms The slugs or ids of the terms (or names if $allow_match_names is true). 1252 1256 * @param array|string $taxonomy The context in which to relate the term to the object. 1253 1257 * @param bool $append If false will delete difference of terms. 1258 * @param bool $allow_match_names If true, $terms can contain term names as well as slugs or IDs 1254 1259 * @return array|WP_Error Affected Term IDs 1255 1260 */ 1256 function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false ) {1261 function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false, $allow_match_names = false) { 1257 1262 global $wpdb; 1258 1263 1259 1264 $object_id = (int) $object_id; … … 1274 1279 if ( !strlen(trim($term)) ) 1275 1280 continue; 1276 1281 1277 if ( !$id = is_term($term, $taxonomy ) )1282 if ( !$id = is_term($term, $taxonomy, $allow_match_names) ) 1278 1283 $id = wp_insert_term($term, $taxonomy); 1279 1284 if ( is_wp_error($id) ) 1280 1285 return $id;