Commit 1ac291c6 authored by Andrius Mickus's avatar Andrius Mickus

importer LV/EE

parent 2d58587b
...@@ -38,24 +38,8 @@ function importer_admin_menu() ...@@ -38,24 +38,8 @@ function importer_admin_menu()
*/ */
function do_import() function do_import()
{ {
// Set environment type $env = getEnvironment();
$env = 'prod'; $inputFile = getSource($env);
//Set dev env. only on dev subdomain
$subDomain = strstr($_SERVER['SERVER_NAME'], '.biuro.lt', true);
if ($subDomain == 'dev') {
$env = 'dev';
}
// Set data source path by environment type
if ($env === 'dev') {
// $inputFile = plugin_dir_path(__FILE__) . "source_data/wp_biuro.php.xml";
// $inputFile = "https://base.biuro.lt/_export/wp_biuro.php";
$inputFile = "https://base.biuro.lt/_export/new_wp.php";
} elseif ($env === 'prod') {
// $inputFile = "http://export.biuro.lt/wp_biuro.php";
$inputFile = "http://export.biuro.lt/new_wp.php";
}
print_r("<div style='background: lightgrey;'> print_r("<div style='background: lightgrey;'>
<small style='float: right;'>Working in <strong>$env</strong> mode</small> <small style='float: right;'>Working in <strong>$env</strong> mode</small>
...@@ -107,6 +91,51 @@ function do_import() ...@@ -107,6 +91,51 @@ function do_import()
} }
function getSource($env)
{
$url = parse_url(site_url());
$exploded = explode('.', $url['host']);
$site = strtoupper(end($exploded));
switch ($site) {
case 'LT':
$script = 'new_wp.php';
break;
case 'LV':
$script = 'new_wp_lv.php';
break;
case 'EE':
$script = 'new_wp_ee.php';
break;
}
// Set data source path by environment type
if ($env === 'dev') {
// $inputFile = plugin_dir_path(__FILE__) . "source_data/wp_biuro.php.xml";
// $inputFile = "https://base.biuro.lt/_export/wp_biuro.php";
$inputFile = "https://base.biuro.lt/_export/{$script}";
} elseif ($env === 'prod') {
// $inputFile = "http://export.biuro.lt/wp_biuro.php";
$inputFile = "http://export.biuro.lt/{$script}";
}
return $inputFile;
}
function getEnvironment()
{
// Set environment type
$env = 'prod';
//Set dev env. only on dev subdomain
$subDomain = strstr($_SERVER['SERVER_NAME'], '.biuro.lt', true);
if ($subDomain == 'dev') {
$env = 'dev';
}
return $env;
}
function current_location() function current_location()
{ {
if (isset($_SERVER['HTTPS']) && if (isset($_SERVER['HTTPS']) &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment