Skip to content

Instantly share code, notes, and snippets.

@jmarreros
Last active July 4, 2017 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmarreros/a52b1c904c03aec57c926184db280758 to your computer and use it in GitHub Desktop.
Save jmarreros/a52b1c904c03aec57c926184db280758 to your computer and use it in GitHub Desktop.
Archivo para generar un Quickstart en WordPress, depende del archivo srdb.class.php
<?php
require_once( realpath( dirname( __FILE__ ) ) . '/srdb.class.php' );
if (array_key_exists("step",$_REQUEST) && $_REQUEST["step"] == 2){
add_action("shutdown", "dcms_install_data");
}
function dcms_install_data() {
global $wpdb, $wp_rewrite;
if (!get_option("blogname", false)) {
return;
}
//Reemplazar estos valores
$url_inicial = "http://encurso.app/wordpress473";
$prefijo_inicial = "wp_";
//------------------------
$url_final = get_option("siteurl");
ob_start();
?>
# AQUI COLOCA TU BASE DE DATOS EXPORTADA
<?php
$sql = ob_get_clean();
if ( $prefijo_inicial != $wpdb->prefix ){
$sql = str_replace('`'.$prefijo_inicial, '`'.$wpdb->prefix, $sql);
}
$lines = explode("\n", $sql);
$query = "";
foreach ($lines as $line) {
$line = trim($line);
if (strlen($line)==0) continue;
if (substr($line,-1)==";") {
$query.=" ".$line;
$wpdb->query($query);
$query = "";
} else {
$query.=" ".$line;
}
}
$wp_rewrite->flush_rules();
wp_cache_flush();
$args = array(
'name' => DB_NAME,
'user' => DB_USER,
'pass' => DB_PASSWORD,
'host' => DB_HOST,
'search' => $url_inicial,
'replace' => $url_final,
'dry_run' => false
);
$srdb = new icit_srdb($args);
if ($srdb->errors[ 'results' ]){
echo implode( "\n", $srdb->errors[ 'results' ] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment