Make WordPress Core

Ticket #5538: advanced-config-options.diff

File advanced-config-options.diff, 3.9 KB (added by davidszp, 18 years ago)

Adds preliminary advanced config options to wp-config.php generator

  • wp-admin/setup-config.php

     
    111111
    112112        case 1:
    113113                display_header();
     114                require_once('../wp-includes/pluggable.php'); // to generate secret key
    114115        ?>
    115116</p>
    116117<form method="post" action="setup-config.php?step=2">
     
    142143                        <td>If you want to run multiple WordPress installations in a single database, change this.</td>
    143144                </tr>
    144145        </table>
     146<h2>Advanced</h2>
     147<p>You will not likely need to edit these settings; the defaults should be fine. But you may modify them if you wish.</p>
     148        <table>
     149                <tr>
     150                        <th scope="row">Secret Key</th>
     151                        <td><input name="secret" type="text" size="25" value="<?php echo md5(wp_generate_password()); ?>" autocomplete="off" /></td>
     152                        <td>The secret key used to encrypt login cookies. It should be long and random, and you don't need to remember it.</td>
     153                </tr>
     154                <tr>
     155                        <th scope="row">Home URL</th>
     156                        <td><input name="wphome" type="text" size="25" value="" /></td>
     157                        <td>WP_HOME value</td>
     158                </tr>
     159                <tr>
     160                        <th scope="row">Site URL</th>
     161                        <td><input name="wpsiteurl" type="text" size="25" value="" /></td>
     162                        <td>WP_SITEURL value</td>
     163                </tr>
     164                <tr>
     165                        <th scope="row">Database Character Set</th>
     166                        <td><input name="dbcharset" type="text" size="25" value="utf8" /></td>
     167                        <td>Character set used in database.</td>
     168                </tr>
     169                <tr>
     170                        <th scope="row">Database Collation</th>
     171                        <td><input name="dbcollate" type="text" value="" size="25" /></td>
     172                        <td>Collation used in database.</td>
     173                </tr>
     174                <tr>
     175                        <th scope="row">Language</th>
     176                        <td><input name="lang" type="text" value="" size="2" /></td>
     177                        <td>Two-letter language code to localize install. A corresponding MO file for the chosen language must be installed to wp-content/languages.</td>
     178                </tr>
     179        </table>
    145180        <h2 class="step">
    146181        <input name="submit" type="submit" value="Submit" />
    147182        </h2>
     
    156191        $dbhost  = trim($_POST['dbhost']);
    157192        $prefix  = trim($_POST['prefix']);
    158193        if (empty($prefix)) $prefix = 'wp_';
     194       
     195        $secret     = trim($_POST['secret']);
     196        $wphome     = trim($_POST['wphome']);
     197        $wpsiteurl  = trim($_POST['wpsiteurl']);
     198        $dbcharset  = trim($_POST['dbcharset']);
     199        $dbcollate  = trim($_POST['dbcollate']);
     200        $lang  = trim($_POST['lang']);
    159201
    160202        // Test the db connection.
    161203        define('DB_NAME', $dbname);
     
    168210        if ( !empty($wpdb->error) )
    169211                wp_die($wpdb->error->get_error_message());
    170212
     213        // Fail here if language specified but language file does not exist
     214        if ( strlen($lang) > 0 && !file_exists('../wp-content/languages/$lang.mo'))
     215        wp_die("Sorry, you specified language <strong><code>$lang</code></strong> but this file doesn't exist. Please re-upload language file <strong><code>wp-content/languages/$lang.mo</code></strong> and try again.");
     216
    171217        $handle = fopen('../wp-config.php', 'w');
    172218
    173219        foreach ($configFile as $line_num => $line) {
     
    187233                        case '$table_prefix  =':
    188234                                fwrite($handle, str_replace('wp_', $prefix, $line));
    189235                                break;
     236                        case "define('SECRET_K":
     237                                fwrite($handle, str_replace("'put your unique phrase here'", "'$secret'", $line));
     238                                break;
     239                        case "define('DB_CHARS":
     240                                fwrite($handle, str_replace("utf8", $dbcharset, $line));
     241                                break;
     242                        case "define('DB_COLLA":
     243                                fwrite($handle, str_replace("''", "'$dbcollate'", $line));
     244                                break;
     245                        case "define('WPLANG',":
     246                                fwrite($handle, str_replace("''", "'$lang'", $line));
     247                                break;
     248                        case "/* That's all, s":
     249                                if ( strlen($wphome) > 0 ) { fwrite($handle, "// The Home URL\ndefine('WP_HOME', '$wphome');\n"); }
     250                                if ( strlen($wpsiteurl) > 0 ) { fwrite($handle, "// The WordPress Site URL\ndefine('WP_SITEURL', '$wpsiteurl');\n"); }
     251                                if ( strlen($wphome) > 0 || strlen($wpsiteurl) > 0 ) { fwrite($handle, "\n"); }
     252                                fwrite($handle, $line);
     253                                break;
    190254                        default:
    191255                                fwrite($handle, $line);
    192256                }