[wp-trac] [WordPress Trac] #18628: wp_insert_term bug doesn't update edit-tags.php right side tree
WordPress Trac
wp-trac at lists.automattic.com
Fri Sep 9 17:39:08 UTC 2011
#18628: wp_insert_term bug doesn't update edit-tags.php right side tree
---------------------------+-----------------------------
Reporter: justindgivens | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 3.2.1
Severity: minor | Keywords:
---------------------------+-----------------------------
With a custom taxonomy if I use wp_insert_term() and insert a couple terms
then process to the wp-admin/edit-tags.php page for that term the right
side "tree" don't display the correct "tree". It might display one or two
new items, but not all. Here some test code to duplicate the bug.
{{{
<?php
$category = array('Built-In Oven','Double','Electric'); //Nested Hierarchy
Terms to be inserted.
// Term Hierarchy should come out like 'Built-In Oven' -> 'Double' ->
'Electric'
$catCount = 0;
$tempCatArray = array();
foreach($category as $cat) {
if ($catCount == 0) {
$term_id = term_exists( $cat , 'product_type' );
if ($term_id == 0) {
$term_id = wp_insert_term( $cat , 'product_type' ); //This term
shows up but no children do.
array_push( $tempCatArray , $term_id['term_id'] );
} else {
array_push( $tempCatArray , $term_id['term_id'] );
}
} else {
$term_id = term_exists( $cat , 'product_type' , (int)
$tempCatArray[$catCount-1] );
if ($term_id == 0) {
$term_id = wp_insert_term( $cat , 'product_type' , array( 'parent'
=> (int) $tempCatArray[$catCount-1] ) ); //New inserts aren't showing
until I resaved a term.
array_push( $tempCatArray , $term_id['term_id'] );
} else {
array_push( $tempCatArray , $term_id['term_id'] );
}
}
$catCount++;
}
?>
}}}
Now if I go and edit a term with no changes and hit save. The tree is now
updated correctly. I don't even have to edit one of the new terms, just
any. I've attached two images to show this happening.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18628>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list