Commit 4f3c01ad authored by Andrius Mickus's avatar Andrius Mickus

update pods after creation

parent 8b34bd49
......@@ -94,6 +94,12 @@ class JobsImporter
$relations
);
// if ($ad['properties'][$this->primaryKey] == 14531) {
//
// var_dump($ad);
// var_dump($adData);
// }
// Unique key of post
$primaryKey = $adData[$this->primaryKey];
......@@ -104,6 +110,8 @@ class JobsImporter
try {
$podId = $pod->save($adData);
// Set post language
$this->setPostLang($podId, $ad['lang']);
print_r("Old record ($this->primaryKey: $primaryKey) has been updated. <br>");
} catch (Exception $e) {
......@@ -115,24 +123,15 @@ class JobsImporter
try {
$podId = $this->pods->add($adData);
// Set post language
$this->setPostLang($podId, $ad['lang']);
$this->getPod($primaryKey)->save($adData); // Save related data, cause didn't saved on creation
print_r("New record ($this->primaryKey: $primaryKey) has been created. <br>");
} catch (Exception $e) {
print_r("Error while creating record ($this->primaryKey: $primaryKey). Error: $e->getMessage()<br>");
}
}
if (isset($podId)) {
// Set post language
$this->setPostLang($podId, $ad['lang']);
// if (isset($custom_uri)) {
// $permalink_manager_uris[$podId] = $custom_uri;
// update_option('permalink-manager-uris', $permalink_manager_uris);
// }
}
}
}
......
......@@ -55,7 +55,6 @@ function do_import()
$inputFile = "http://export.biuro.lt/wp_biuro.php";
}
print_r("<div style='background: lightgrey;'>
<small style='float: right;'>Working in <strong>$env</strong> mode</small>
<div style='clear: both;'></div>
......@@ -64,6 +63,14 @@ function do_import()
echo "<pre>";
print_r('<h4>Biuro Jobs importer</h4>');
// if (pll_current_language() != '')
// {
// print_r("<h5 class='warning'>Polylang must be set in 'All languages' mode.</h5>");
// pll_the_languages( array( 'dropdown' => 1 ) );
// exit();
// }
print_r("Data source: $inputFile<br><br>");
// JSON reader
......@@ -75,12 +82,14 @@ function do_import()
if (empty($_POST)) {
print_r("<form method='post'>");
// Form for import start, set polylang to 'All lang.' for action
print_r("<form method='post' action='" . current_location() . "&lang=all'>");
print_r("<div style='margin-top: 10px;'><button name='import' value='true'>Import</button></div>");
print_r("</form>");
}
if (isset($_POST['import'])) {
// for cron, needs add to url ...&lang=all&proceed=1
if (isset($_POST['import']) || isset($_GET['proceed'])) {
print_r("importing....<br><br>");
......@@ -93,4 +102,17 @@ function do_import()
echo "</pre>";
}
function current_location()
{
if (isset($_SERVER['HTTPS']) &&
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
return $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
\ No newline at end of file
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