upgrade_330()
Execute changes made in WordPress 3.3.
Description Description
Source Source
File: wp-admin/includes/upgrade.php
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 | if ( ! empty ( $category ->tag_count ) ) { $have_tags = true; $count = (int) $category ->tag_count; $taxonomy = 'post_tag' ; $wpdb ->insert( $wpdb ->term_taxonomy, compact( 'term_id' , 'taxonomy' , 'description' , 'parent' , 'count' ) ); $tt_ids [ $term_id ][ $taxonomy ] = (int) $wpdb ->insert_id; } if ( empty ( $count ) ) { $count = 0; $taxonomy = 'category' ; $wpdb ->insert( $wpdb ->term_taxonomy, compact( 'term_id' , 'taxonomy' , 'description' , 'parent' , 'count' ) ); $tt_ids [ $term_id ][ $taxonomy ] = (int) $wpdb ->insert_id; } } $select = 'post_id, category_id' ; if ( $have_tags ) { $select .= ', rel_type' ; } $posts = $wpdb ->get_results( "SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id" ); foreach ( $posts as $post ) { $post_id = (int) $post ->post_id; $term_id = (int) $post ->category_id; $taxonomy = 'category' ; if ( ! empty ( $post ->rel_type ) && 'tag' == $post ->rel_type ) { $taxonomy = 'tag' ; } $tt_id = $tt_ids [ $term_id ][ $taxonomy ]; if ( empty ( $tt_id ) ) { continue ; } $wpdb ->insert( $wpdb ->term_relationships, array ( 'object_id' => $post_id , 'term_taxonomy_id' => $tt_id , ) ); } // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. if ( $wp_current_db_version < 3570 ) { /* * Create link_category terms for link categories. Create a map of link * cat IDs to link_category terms. */ $link_cat_id_map = array (); $default_link_cat = 0; $tt_ids = array (); $link_cats = $wpdb ->get_results( 'SELECT cat_id, cat_name FROM ' . $wpdb ->prefix . 'linkcategories' ); foreach ( $link_cats as $category ) { $cat_id = (int) $category ->cat_id; $term_id = 0; $name = wp_slash( $category ->cat_name ); $slug = sanitize_title( $name ); $term_group = 0; // Associate terms with the same slug in a term group and make slugs unique. if ( $exists = $wpdb ->get_results( $wpdb ->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s" , $slug ) ) ) { |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.3.0 | Introduced. |