Created
November 18, 2011 17:42
-
-
Save ocean90/1377168 to your computer and use it in GitHub Desktop.
Drop existing WP install and install a new clean WP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Place the file into WordPress root folder and open the file in your browser. */ | |
/* Settings */ | |
define( 'BLOG_TITLE', 'WordPress Dev' ); | |
define( 'USER_NAME', 'admin' ); | |
define( 'USER_EMAIL', '[email protected]' ); | |
define( 'USER_PASSWORD', '123456' ); | |
define( 'WP_SITEURL', 'http://wp.dev' ); | |
/* Init */ | |
if ( ! defined( 'ABSPATH' ) ) | |
define( 'ABSPATH', dirname( __FILE__ ) . '/' ); | |
require_once( ABSPATH . 'wp-config.php' ); | |
define( 'WP_INSTALLING', 1 ); | |
require_once( ABSPATH . 'wp-settings.php' ); | |
/* Delete Tables */ | |
global $wpdb; | |
$tables = $wpdb->get_col( 'SHOW TABLES;' ); | |
foreach ( $tables as $table ) | |
$wpdb->query( "DROP TABLE IF EXISTS {$table}" ); | |
/* Install WP */ | |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
$result = wp_install( BLOG_TITLE, USER_NAME, USER_EMAIL, true, '', USER_PASSWORD ); | |
if ( true == is_blog_installed() ) { | |
/* Login */ | |
$creds = array(); | |
$creds['user_login'] = USER_NAME; | |
$creds['user_password'] = USER_PASSWORD; | |
$creds['remember'] = true; | |
$user = wp_signon( $creds, false ); | |
/* Redirect */ | |
if ( ! is_wp_error( $user ) ) | |
header('Location: ' . $result['url'] . '/wp-admin/' ); | |
} else { | |
echo '<pre>'; | |
var_dump( $result ); | |
echo '</pre>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment