upgrade_130

Execute changes made in WordPress 1.5.

Description

upgrade_130(); 

Usage

  1. if ( !function_exists( 'upgrade_130' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = upgrade_130(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/upgrade.php  
  1. function upgrade_130() { 
  2. global $wpdb; 
  3.  
  4. // Remove extraneous backslashes. 
  5. $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); 
  6. if ($posts) { 
  7. foreach ($posts as $post) { 
  8. $post_content = addslashes(deslash($post->post_content)); 
  9. $post_title = addslashes(deslash($post->post_title)); 
  10. $post_excerpt = addslashes(deslash($post->post_excerpt)); 
  11. if ( empty($post->guid) ) 
  12. $guid = get_permalink($post->ID); 
  13. else 
  14. $guid = $post->guid; 
  15.  
  16. $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); 
  17.  
  18.  
  19. // Remove extraneous backslashes. 
  20. $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); 
  21. if ($comments) { 
  22. foreach ($comments as $comment) { 
  23. $comment_content = deslash($comment->comment_content); 
  24. $comment_author = deslash($comment->comment_author); 
  25.  
  26. $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) ); 
  27.  
  28. // Remove extraneous backslashes. 
  29. $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); 
  30. if ($links) { 
  31. foreach ($links as $link) { 
  32. $link_name = deslash($link->link_name); 
  33. $link_description = deslash($link->link_description); 
  34.  
  35. $wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) ); 
  36.  
  37. $active_plugins = __get_option('active_plugins'); 
  38.  
  39. /** 
  40. * If plugins are not stored in an array, they're stored in the old 
  41. * newline separated format. Convert to new format. 
  42. */ 
  43. if ( !is_array( $active_plugins ) ) { 
  44. $active_plugins = explode("\n", trim($active_plugins)); 
  45. update_option('active_plugins', $active_plugins); 
  46.  
  47. // Obsolete tables 
  48. $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues'); 
  49. $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes'); 
  50. $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups'); 
  51. $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options'); 
  52.  
  53. // Update comments table to use comment_type 
  54. $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'"); 
  55. $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'"); 
  56.  
  57. // Some versions have multiple duplicate option_name rows with the same values 
  58. $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name"); 
  59. foreach ( $options as $option ) { 
  60. if ( 1 != $option->dupes ) { // Could this be done in the query? 
  61. $limit = $option->dupes - 1; 
  62. $dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) ); 
  63. if ( $dupe_ids ) { 
  64. $dupe_ids = join($dupe_ids, ', '); 
  65. $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)"); 
  66.