get_results("SHOW TABLES LIKE '".$GLOBALS['table_prefix']."%'", ARRAY_N);
}
function aiomh_prefix_renameTables($tables, $currentPrefix, $newPrefix)
{
global $wpdb;
$changedTables = array();
foreach ($tables as $k=>$table) {
$tableOldName = $table[0];
// Hide errors
$wpdb->hide_errors();
// To rename the table
$tableNewName = substr_replace($tableOldName, $newPrefix, 0, strlen($currentPrefix));
$wpdb->query("RENAME TABLE `{$tableOldName}` TO `{$tableNewName}`");
array_push($changedTables, $tableNewName);
}
return $changedTables;
}
function aiomh_prefix_renameDbFields($oldPrefix,$newPrefix)
{
global $wpdb;
/*
* usermeta table
*===========================
wp_*
* options table
* ===========================
wp_user_roles
*/
$str = '';
if (false === $wpdb->query("UPDATE {$newPrefix}options SET option_name='{$newPrefix}user_roles' WHERE option_name='{$oldPrefix}user_roles';")) {
$str .= '
Changing value: '.$newPrefix.'user_roles in table '.$newPrefix.'options: Failed';
}
$query = 'update '.$newPrefix.'usermeta set meta_key = CONCAT(replace(left(meta_key, ' . strlen($oldPrefix) . "), '{$oldPrefix}', '{$newPrefix}'), SUBSTR(meta_key, " . (strlen($oldPrefix) + 1) . ")) where meta_key in ('{$oldPrefix}autosave_draft_ids', '{$oldPrefix}capabilities', '{$oldPrefix}metaboxorder_post', '{$oldPrefix}user_level', '{$oldPrefix}usersettings','{$oldPrefix}usersettingstime', '{$oldPrefix}user-settings', '{$oldPrefix}user-settings-time', '{$oldPrefix}dashboard_quick_press_last_post_id')";
if (false === $wpdb->query($query)) {
$str .= '
Changing values in table '.$newPrefix.'usermeta: Failed';
}
if (!empty($str)) {
$str = '
Changing database prefix:
'.$str.'
'; } return $str; } global $wpdb; $bprefix_Message=""; $bprefix_prefix=$wpdb->prefix; if((isset($_POST['aiomh_prefix_hidden']) && $_POST['aiomh_prefix_hidden']=='Y') && (isset($_POST['Submit']))) { echo '