Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dev.biuro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Biuro
dev.biuro
Commits
4f3c01ad
Commit
4f3c01ad
authored
Feb 14, 2019
by
Andrius Mickus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pods after creation
parent
8b34bd49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
15 deletions
+36
-15
JobsImporter.php
wp-content/plugins/jobs-importer/JobsImporter.php
+11
-12
jobs-importer.php
wp-content/plugins/jobs-importer/jobs-importer.php
+25
-3
No files found.
wp-content/plugins/jobs-importer/JobsImporter.php
View file @
4f3c01ad
...
...
@@ -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);
// }
}
}
}
...
...
wp-content/plugins/jobs-importer/jobs-importer.php
View file @
4f3c01ad
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment