upgrade_110

Execute changes made in WordPress 1.2.

Description

upgrade_110(); 

Usage

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

Defined (1)

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

/wp-admin/includes/upgrade.php  
  1. function upgrade_110() { 
  2. global $wpdb; 
  3.  
  4. // Set user_nicename. 
  5. $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); 
  6. foreach ($users as $user) { 
  7. if ('' == $user->user_nicename) { 
  8. $newname = sanitize_title($user->user_nickname); 
  9. $wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) ); 
  10.  
  11. $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); 
  12. foreach ($users as $row) { 
  13. if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { 
  14. $wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) ); 
  15.  
  16. // Get the GMT offset, we'll use that later on 
  17. $all_options = get_alloptions_110(); 
  18.  
  19. $time_difference = $all_options->time_difference; 
  20.  
  21. $server_time = time()+date('Z'); 
  22. $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS
  23. $gmt_time = time(); 
  24.  
  25. $diff_gmt_server = ($gmt_time - $server_time) / HOUR_IN_SECONDS
  26. $diff_weblogger_server = ($weblogger_time - $server_time) / HOUR_IN_SECONDS
  27. $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server; 
  28. $gmt_offset = -$diff_gmt_weblogger; 
  29.  
  30. // Add a gmt_offset option, with value $gmt_offset 
  31. add_option('gmt_offset', $gmt_offset); 
  32.  
  33. // Check if we already set the GMT fields (if we did, then 
  34. // MAX(post_date_gmt) can't be '0000-00-00 00:00:00' 
  35. // <michel_v> I just slapped myself silly for not thinking about it earlier 
  36. $got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00'); 
  37.  
  38. if (!$got_gmt_fields) { 
  39.  
  40. // Add or subtract time to all dates, to get GMT dates 
  41. $add_hours = intval($diff_gmt_weblogger); 
  42. $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours)); 
  43. $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); 
  44. $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date"); 
  45. $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'"); 
  46. $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); 
  47. $wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)"); 
  48.