在里面wp-admin/includes/upgrade.php
是用于数据库升级的特定于版本的功能。它们包括对架构的更改。3.4.0和3.5.0的示例:
/**
* Execute changes made in WordPress 3.4.
*
* @since 3.4.0
*/
function upgrade_340() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 19798 ) {
$wpdb->hide_errors();
$wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
$wpdb->show_errors();
}
if ( $wp_current_db_version < 19799 ) {
$wpdb->hide_errors();
$wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
$wpdb->show_errors();
}
if ( $wp_current_db_version < 20022 && is_main_site() && ! defined( \'DO_NOT_UPGRADE_GLOBAL_TABLES\' ) ) {
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = \'themes_last_view\'" );
}
if ( $wp_current_db_version < 20080 ) {
if ( \'yes\' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = \'uninstall_plugins\'" ) ) {
$uninstall_plugins = get_option( \'uninstall_plugins\' );
delete_option( \'uninstall_plugins\' );
add_option( \'uninstall_plugins\', $uninstall_plugins, null, \'no\' );
}
}
}
/**
* Execute changes made in WordPress 3.5.
*
* @since 3.5.0
*/
function upgrade_350() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
update_option( \'link_manager_enabled\', 1 ); // Previously set to 0 by populate_options()
if ( $wp_current_db_version < 21811 && is_main_site() && ! defined( \'DO_NOT_UPGRADE_GLOBAL_TABLES\' ) ) {
$meta_keys = array();
foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
if ( false !== strpos( $name, \'-\' ) )
$meta_keys[] = \'edit_\' . str_replace( \'-\', \'_\', $name ) . \'_per_page\';
}
if ( $meta_keys ) {
$meta_keys = implode( "\', \'", $meta_keys );
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN (\'$meta_keys\')" );
}
}
if ( $wp_current_db_version < 22422 && $term = get_term_by( \'slug\', \'post-format-standard\', \'post_format\' ) )
wp_delete_term( $term->term_id, \'post_format\' );
}
法典中有一些关于
Database description 页