• davidrahrer

    (@davidrahrer)


    The plugin seems to work fine, except that it strips all the blank lines from wp-config.php when writing to it. The replacement for function

    public static function dbprefix_updateWpConfigTablePrefix($dbprefix_wpConfigFile, $oldPrefix, $newPrefix)

    in brozzme_db_prefix_core.php will correct this issue. See below:

    public static function dbprefix_updateWpConfigTablePrefix($dbprefix_wpConfigFile, $oldPrefix, $newPrefix)
    {
    // Check file's status' permissions
    if (!is_writable($dbprefix_wpConfigFile))
    {
    return -1;
    }

    if (!function_exists('file')) {
    return -1;
    }

    // Try to update the wp-config file
    $lines = file($dbprefix_wpConfigFile);
    $fcontent = '';
    $result = -1;
    foreach($lines as $line)
    {
    if (strpos($line, '$table_prefix') !== false){
    $line = preg_replace("/=(.*)\;/", "= '".$newPrefix."';", $line);
    }
    $fcontent .= $line;
    }
    if (!empty($fcontent)){
    // Save wp-config file
    $result = file_put_contents($dbprefix_wpConfigFile, $fcontent);
    }

    return $result;
    }
Viewing 1 replies (of 1 total)
  • Thread Starter davidrahrer

    (@davidrahrer)

    I’ve made a couple of other minor changes that fixed some formatting in the admin output. In file brozzmeDbPSettings.php there are two lines, first 97:

    $bprefix_Message .= esc_html__('All tables have been successfully updated with prefix', 'brozzme-db-prefix-change') .' '.$dbprefix_new.' ! ';

    The second is line 187:

    <p class="margin-top:10px"><?php echo wp_kses_post(_('Allowed characters: all latin alphanumeric as well as the <strong>_</strong> (underscore).', 'brozzme-db-prefix-change')); ?>

    97 is just a space near the end of the line and 187 uses wp_kses_post instead of esc_html so it will render the HTML properly. With those small changes it seems to work just great on php 8.2. Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Fix for blank lines missing in wp-config.php’ is closed to new replies.