Changeset 6588 for trunk/wp-admin/admin-ajax.php
- Timestamp:
- 01/10/2008 09:39:35 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r6584 r6588 158 158 die('-1'); 159 159 $names = explode(',', $_POST['newcat']); 160 if ( 0 > $parent = (int) $_POST['newcat_parent'] ) 161 $parent = 0; 162 163 $checked_categories = array_map( 'absint', (array) $_POST['post_category'] ); 164 160 165 $x = new WP_Ajax_Response(); 161 166 foreach ( $names as $cat_name ) { … … 164 169 if ( '' === $category_nicename ) 165 170 continue; 166 $cat_id = wp_create_category( $cat_name ); 167 $cat_name = wp_specialchars(stripslashes($cat_name)); 171 $cat_id = wp_create_category( $cat_name, $parent ); 172 $checked_categories[] = $cat_id; 173 if ( $parent ) // Do these all at once in a second 174 continue; 175 $category = get_category( $cat_id ); 176 $category->_is_checked = true; 177 ob_start(); 178 dropdown_categories( 0, $category ); 179 $data = ob_get_contents(); 180 ob_end_clean(); 168 181 $x->add( array( 169 182 'what' => 'category', 170 183 'id' => $cat_id, 171 'data' => "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>",184 'data' => $data, 172 185 'position' => -1 173 186 ) ); 187 } 188 if ( $parent ) { // Foncy - replace the parent and all its children 189 $parent = get_category( $parent ); 190 ob_start(); 191 dropdown_categories( 0, $parent ); 192 $data = ob_get_contents(); 193 ob_end_clean(); 194 $x->add( array( 195 'what' => 'category', 196 'id' => $parent->term_id, 197 'old_id' => $parent->term_id, 198 'data' => $data, 199 'position' => -1 200 ) ); 201 174 202 } 175 203 $x->send();
Note: See TracChangeset
for help on using the changeset viewer.