+ # Starting in Wordpress 4.7, install now redirects you directly
+ # to login page. So... don't check.
+ #if "Finished" not in result and "Success" not in result:
+ # raise app.InstallFailure()
+
+ if version < distutils.version.LooseVersion("3.0"):
+ meta = sql.connect(options.dsn)
+ wp_users = meta.tables["wp_users"]
+ hashed_pass = hashlib.md5(options.admin_password).hexdigest()
+ wp_users.update().where(wp_users.c.ID == 1).values(user_login=options.admin_name,user_nicename=options.admin_name,display_name=options.admin_name,user_pass=hashed_pass).execute()
+ wp_usermeta = meta.tables["wp_usermeta"]
+ wp_usermeta.delete().where(wp_usermeta.c.user_id==1 and wp_usermeta.c.meta_key == "default_password_nag").execute()
+
+ # now we can restore the wp_mail function in wp-includes/pluggable[-functions].php
+ pluggable_file = open(pluggable_path,'w')
+ pluggable_file.write(pluggable)
+ pluggable_file.close()
+
+ # replace random variable stubs with real values
+ old_config = open('wp-config.php').read()
+ def replace_with_random(s):
+ return s.replace('put your unique phrase here', util.random_key(), 1)
+ config = replace_with_random(old_config)
+ while config != old_config:
+ old_config = config
+ config = replace_with_random(config)
+ open('wp-config.php', 'w').write(config)
+
+ php.ini_replace_vars()
+ def upgrade(self, d, version, options):
+ result = d.fetch("wp-admin/upgrade.php?step=1")
+ if "Upgrade Complete" not in result and "Update Complete" not in result and \
+ "No Upgrade Required" not in result and "No Update Required" not in result:
+ raise app.UpgradeFailure(result)
+ @app.throws_database_errors
+ def backup(self, deployment, backup_dir, options):
+ sql.backup(backup_dir, deployment)
+ @app.throws_database_errors
+ def restore(self, deployment, backup_dir, options):
+ sql.restore(backup_dir, deployment)
+ @app.throws_database_errors
+ def remove(self, deployment, options):
+ sql.drop(deployment.dsn)
+
+Application.resolutions = {
+'wp-config.php': [
+ ("""
+<<<<<<<