执行WordPress 1.5中所做的更改。
原型
upgrade_130()
源文件
路径:wp-admin/includes/upgrade.php
<?php
...
$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
}
}
endif;
}
/**
* Execute changes made in WordPress 1.0.1.
*
* @ignore
* @since 1.0.1
*
* @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_101() {
global $wpdb;
// Clean up indices, add a few
add_clean_index($wpdb->posts, 'post_name');
add_clean_index($wpdb->posts, 'post_status');
add_clean_index($wpdb->categories, 'category_nicename');
add_clean_index($wpdb->comments, 'comment_approved');
add_clean_index($wpdb->comments, 'comment_post_ID');
add_clean_index($wpdb->links , 'link_category');
add_clean_index($wpdb->links , 'link_visible');
}
/**
* Execute changes made in WordPress 1.2.
*
* @ignore
* @since 1.2.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*/
function upgrade_110() {
global $wpdb;
// Set user_nicename.
$users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
foreach ($users as $user) {
if ('' == $user->user_nicename) {
$newname = sanitize_title($user->user_nickname);
$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
}
}
$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
foreach ($users as $row) {
if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
}
}
// Get the GMT offset, we'll use that later on
$all_options = get_alloptions_110();
$time_difference = $all_options->time_difference;
$server_time = time()+date('Z');
$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
$gmt_time = time();
$diff_gmt_server = ($gmt_time - $server_time) / HOUR_IN_SECONDS;
$diff_weblogger_server = ($weblogger_time - $server_time) / HOUR_IN_SECONDS;
$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
$gmt_offset = -$diff_gmt_weblogger;
// Add a gmt_offset option, with value $gmt_offset
add_option('gmt_offset', $gmt_offset);
// Check if we already set the GMT fields (if we did, then
// MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
// <michel_v> I just slapped myself silly for not thinking about it earlier
$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
if (!$got_gmt_fields) {
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/upgrade_130/