Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r19470 r20704  
    3636 */
    3737function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '' ) {
    38         global $wp_rewrite;
    39 
    4038        if ( !empty( $deprecated ) )
    4139                _deprecated_argument( __FUNCTION__, '2.6' );
    … …  
    5957                update_option('default_pingback_flag', 0);
    6058
    61         // Create default user.  If the user already exists, the user tables are
    62         // being shared among blogs.  Just set the role in that case.
     59        // Create default user. If the user already exists, the user tables are
     60        // being shared among blogs. Just set the role in that case.
    6361        $user_id = username_exists($user_name);
    6462        $user_password = trim($user_password);
    … …  
    7573                $user_id = wp_create_user($user_name, $user_password, $user_email);
    7674        } else {
    77                 $message =  __('User already exists. Password inherited.');
     75                $message = __('User already exists. Password inherited.');
    7876        }
    7977
    … …  
    8381        wp_install_defaults($user_id);
    8482
    85         $wp_rewrite->flush_rules();
     83        flush_rewrite_rules();
    8684
    8785        wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
    … …  
    148146        // Now drop in some default links
    149147        $default_links = array();
    150         $default_links[] = array(       'link_url' => 'http://codex.wordpress.org/',
    151                                                                 'link_name' => 'Documentation',
     148        $default_links[] = array(       'link_url' => __( 'http://codex.wordpress.org/' ),
     149                                                                'link_name' => __( 'Documentation' ),
    152150                                                                'link_rss' => '',
    153151                                                                'link_notes' => '');
    154152
    155         $default_links[] = array(       'link_url' => 'http://wordpress.org/news/',
    156                                                                 'link_name' => 'WordPress Blog',
    157                                                                 'link_rss' => 'http://wordpress.org/news/feed/',
     153        $default_links[] = array(       'link_url' => __( 'http://wordpress.org/news/' ),
     154                                                                'link_name' => __( 'WordPress Blog' ),
     155                                                                'link_rss' => __( 'http://wordpress.org/news/feed/' ),
    158156                                                                'link_notes' => '');
    159157
    160         $default_links[] = array(       'link_url' => 'http://wordpress.org/extend/ideas/',
    161                                                                 'link_name' => 'Suggest Ideas',
     158        $default_links[] = array(       'link_url' => __( 'http://wordpress.org/support/' ),
     159                                                                'link_name' => _x( 'Support Forums', 'default link' ),
    162160                                                                'link_rss' => '',
    163161                                                                'link_notes' =>'');
    164162
    165         $default_links[] = array(       'link_url' => 'http://wordpress.org/support/',
    166                                                                 'link_name' => 'Support Forum',
     163        $default_links[] = array(       'link_url' => 'http://wordpress.org/extend/plugins/',
     164                                                                'link_name' => _x( 'Plugins', 'Default link to wordpress.org/extend/plugins/' ),
    167165                                                                'link_rss' => '',
    168166                                                                'link_notes' =>'');
    169167
    170         $default_links[] = array(       'link_url' => 'http://wordpress.org/extend/plugins/',
    171                                                                 'link_name' => 'Plugins',
     168        $default_links[] = array(       'link_url' => 'http://wordpress.org/extend/themes/',
     169                                                                'link_name' => _x( 'Themes', 'Default link to wordpress.org/extend/themes/' ),
    172170                                                                'link_rss' => '',
    173171                                                                'link_notes' =>'');
    174172
    175         $default_links[] = array(       'link_url' => 'http://wordpress.org/extend/themes/',
    176                                                                 'link_name' => 'Themes',
     173        $default_links[] = array(       'link_url' => __( 'http://wordpress.org/support/forum/requests-and-feedback' ),
     174                                                                'link_name' => __( 'Feedback' ),
    177175                                                                'link_rss' => '',
    178176                                                                'link_notes' =>'');
    179177
    180         $default_links[] = array(       'link_url' => 'http://planet.wordpress.org/',
    181                                                                 'link_name' => 'WordPress Planet',
     178        $default_links[] = array(       'link_url' => __( 'http://planet.wordpress.org/' ),
     179                                                                'link_name' => __( 'WordPress Planet' ),
    182180                                                                'link_rss' => '',
    183181                                                                'link_notes' =>'');
    … …  
    303301                // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
    304302                if ( !is_super_admin( $user_id ) && $user_id != 1 )
    305                         $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );
     303                        $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
    306304        }
    307305}
    … …  
    359357        $wp_current_db_version = __get_option('db_version');
    360358
    361         // We are up-to-date.  Nothing to do.
     359        // We are up-to-date. Nothing to do.
    362360        if ( $wp_db_version == $wp_current_db_version )
    363361                return;
    … …  
    392390 */
    393391function upgrade_all() {
    394         global $wp_current_db_version, $wp_db_version, $wp_rewrite;
     392        global $wp_current_db_version, $wp_db_version;
    395393        $wp_current_db_version = __get_option('db_version');
    396394
    397         // We are up-to-date.  Nothing to do.
     395        // We are up-to-date. Nothing to do.
    398396        if ( $wp_db_version == $wp_current_db_version )
    399397                return;
    … …  
    459457        if ( $wp_current_db_version < 19389 )
    460458                upgrade_330();
     459
     460        if ( $wp_current_db_version < 20080 )
     461                upgrade_340();
    461462
    462463        maybe_disable_automattic_widgets();
    … …  
    566567        $time_difference = $all_options->time_difference;
    567568
    568         $server_time = time()+date('Z');
     569                $server_time = time()+date('Z');
    569570        $weblogger_time = $server_time + $time_difference*3600;
    570571        $gmt_time = time();
    … …  
    647648
    648649        // If plugins are not stored in an array, they're stored in the old
    649         // newline separated format.  Convert to new format.
     650        // newline separated format. Convert to new format.
    650651        if ( !is_array( $active_plugins ) ) {
    651652                $active_plugins = explode("\n", trim($active_plugins));
    … …  
    899900        }
    900901
    901         // < 3570 we used linkcategories.  >= 3570 we used categories and link2cat.
     902        // < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
    902903        if ( $wp_current_db_version < 3570 ) {
    903                 // Create link_category terms for link categories.  Create a map of link cat IDs
     904                // Create link_category terms for link categories. Create a map of link cat IDs
    904905                // to link_category terms.
    905906                $link_cat_id_map = array();
    … …  
    11511152                $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
    11521153        }
    1153 
    1154         // 3.3-beta. Can remove before release.
    1155         if ( $wp_current_db_version > 18715 && $wp_current_db_version < 19389
    1156                 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) )
    1157                         delete_metadata( 'user', 0, 'dismissed_wp_pointers', '', true );
    11581154
    11591155        if ( $wp_current_db_version >= 11548 )
    … …  
    12151211
    12161212/**
     1213 * Execute changes made in WordPress 3.4.
     1214 *
     1215 * @since 3.4.0
     1216 */
     1217function upgrade_340() {
     1218        global $wp_current_db_version, $wpdb;
     1219
     1220        if ( $wp_current_db_version < 19798 ) {
     1221                $wpdb->hide_errors();
     1222                $wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
     1223                $wpdb->show_errors();
     1224        }
     1225
     1226        if ( $wp_current_db_version < 19799 ) {
     1227                $wpdb->hide_errors();
     1228                $wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
     1229                $wpdb->show_errors();
     1230        }
     1231
     1232        if ( $wp_current_db_version < 20022 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
     1233                $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
     1234        }
     1235
     1236        if ( $wp_current_db_version < 20080 ) {
     1237                if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
     1238                        $uninstall_plugins = get_option( 'uninstall_plugins' );
     1239                        delete_option( 'uninstall_plugins' );
     1240                        add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
     1241                }
     1242        }
     1243}
     1244
     1245/**
    12171246 * Execute network level changes
    12181247 *
    … …  
    12491278                }
    12501279        }
     1280
    12511281        // 3.0
    12521282        if ( $wp_current_db_version < 13576 )
    12531283                update_site_option( 'global_terms_enabled', '1' );
     1284
    12541285        // 3.3
    12551286        if ( $wp_current_db_version < 19390 )
    12561287                update_site_option( 'initial_db_version', $wp_current_db_version );
     1288
    12571289        if ( $wp_current_db_version < 19470 ) {
    12581290                if ( false === get_site_option( 'active_sitewide_plugins' ) )
    12591291                        update_site_option( 'active_sitewide_plugins', array() );
     1292        }
     1293
     1294        // 3.4
     1295        if ( $wp_current_db_version < 20148 ) {
     1296                // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
     1297                $allowedthemes  = get_site_option( 'allowedthemes'  );
     1298                $allowed_themes = get_site_option( 'allowed_themes' );
     1299                if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
     1300                        $converted = array();
     1301                        $themes = wp_get_themes();
     1302                        foreach ( $themes as $stylesheet => $theme_data ) {
     1303                                if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
     1304                                        $converted[ $stylesheet ] = true;
     1305                        }
     1306                        update_site_option( 'allowedthemes', $converted );
     1307                        delete_site_option( 'allowed_themes' );
     1308                }
    12601309        }
    12611310}
    … …  
    13361385 */
    13371386function maybe_add_column($table_name, $column_name, $create_ddl) {
    1338         global $wpdb, $debug;
     1387        global $wpdb;
    13391388        foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
    1340                 if ($debug) echo("checking $column == $column_name<br />");
    13411389                if ($column == $column_name) {
    13421390                        return true;
    … …  
    13631411function get_alloptions_110() {
    13641412        global $wpdb;
    1365         if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
    1366                 foreach ($options as $option) {
    1367                         // "When trying to design a foolproof system,
    1368                         //  never underestimate the ingenuity of the fools :)" -- Dougal
    1369                         if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    1370                         if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    1371                         if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
    1372                         $all_options->{$option->option_name} = stripslashes($option->option_value);
     1413        $all_options = new stdClass;
     1414        if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
     1415                foreach ( $options as $option ) {
     1416                        if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
     1417                                $option->option_value = untrailingslashit( $option->option_value );
     1418                        $all_options->{$option->option_name} = stripslashes( $option->option_value );
    13731419                }
    13741420        }
    … …  
    13881434        global $wpdb;
    13891435
    1390         if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
    1391                 return preg_replace( '|/+$|', '', WP_HOME );
    1392         }
    1393 
    1394         if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
    1395                 return preg_replace( '|/+$|', '', WP_SITEURL );
    1396         }
    1397 
    1398         $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting) );
     1436        if ( $setting == 'home' && defined( 'WP_HOME' ) )
     1437                return untrailingslashit( WP_HOME );
     1438
     1439        if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
     1440                return untrailingslashit( WP_SITEURL );
     1441
     1442        $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
    13991443
    14001444        if ( 'home' == $setting && '' == $option )
    1401                 return __get_option('siteurl');
    1402 
    1403         if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
    1404                 $option = preg_replace('|/+$|', '', $option);
    1405 
    1406         @ $kellogs = unserialize($option);
    1407         if ($kellogs !== FALSE)
     1445                return __get_option( 'siteurl' );
     1446
     1447        if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
     1448                $option = untrailingslashit( $option );
     1449
     1450        @ $kellogs = unserialize( $option );
     1451        if ( $kellogs !== false )
    14081452                return $kellogs;
    14091453        else
    … …  
    14581502        if ( !is_array($queries) ) {
    14591503                $queries = explode( ';', $queries );
    1460                 if ('' == $queries[count($queries) - 1]) array_pop($queries);
     1504                $queries = array_filter( $queries );
    14611505        }
    14621506        $queries = apply_filters( 'dbdelta_queries', $queries );
    … …  
    14691513        foreach($queries as $qry) {
    14701514                if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
    1471                         $cqueries[trim( strtolower($matches[1]), '`' )] = $qry;
     1515                        $cqueries[ trim( $matches[1], '`' ) ] = $qry;
    14721516                        $for_update[$matches[1]] = 'Created table '.$matches[1];
    14731517                } else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
    … …  
    16681712 * @since 1.5.0
    16691713 */
    1670 function make_db_current_silent(  $tables = 'all' ) {
     1714function make_db_current_silent( $tables = 'all' ) {
    16711715        $alterations = dbDelta( $tables );
    16721716}
    … …  
    16911735
    16921736        // Copy files from the old locations to the site theme.
    1693         // TODO: This does not copy arbitrary include dependencies.  Only the
     1737        // TODO: This does not copy arbitrary include dependencies. Only the
    16941738        // standard WP files are copied.
    16951739        $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
    … …  
    18491893        if (file_exists(ABSPATH . 'wp-layout.css')) {
    18501894                if (! make_site_theme_from_oldschool($theme_name, $template)) {
    1851                         // TODO:  rm -rf the site theme directory.
     1895                        // TODO: rm -rf the site theme directory.
    18521896                        return false;
    18531897                }
    18541898        } else {
    18551899                if (! make_site_theme_from_default($theme_name, $template))
    1856                         // TODO:  rm -rf the site theme directory.
     1900                        // TODO: rm -rf the site theme directory.
    18571901                        return false;
    18581902        }
    … …  
    19391983        // Upgrade versions prior to 2.9
    19401984        if ( $wp_current_db_version < 11557 ) {
    1941                 // Delete duplicate options.  Keep the option with the highest option_id.
     1985                // Delete duplicate options. Keep the option with the highest option_id.
    19421986                $wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
    19431987
    … …  
    19752019}
    19762020endif;
    1977 ?>
Note: See TracChangeset for help on using the changeset viewer.