Last active
October 26, 2016 11:35
-
-
Save jmarreros/328908b36ad62dcc816f82fec39c811e to your computer and use it in GitHub Desktop.
Usar este código en un plugin dependiente install.php de WordPress
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 | |
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; | |
} | |
ob_start(); | |
?> | |
-- AQUI VA EL CONTENIDO DE LA BASE DE DATOS | |
<?php | |
$sql = ob_get_clean(); | |
$sql = str_replace(array("@@TABLE_PREFIX@@", "@@SITE_URL@@"),array($wpdb->prefix, get_option("siteurl")),$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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment