-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWpAllImportArticlesFunctions.php
56 lines (42 loc) · 1.43 KB
/
WpAllImportArticlesFunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
function fixImage($image) {
$image = base64_decode($image);
$image = str_replace("/sites/default/files/","/wp-content/uploads/", $image);
return $image;
}
function SEOfield($data, $field = "title") {
$data = base64_decode($data);
$serializedData = serialize_corrector($data);
$serializedData = @unserialize($serializedData);
return $serializedData[$field];
}
function serialize_corrector($serialized_string){
// at first, check if "fixing" is really needed at all. After that, security checkup.
if ( @unserialize($serialized_string) !== true && preg_match('/^[aOs]:/', $serialized_string) ) {
$serialized_string = preg_replace_callback( '/s\:(\d+)\:\"(.*?)\";/s', function($matches){return 's:'.strlen($matches[2]).':"'.$matches[2].'";'; }, $serialized_string );
}
return $serialized_string;
}
function fixStatus($status) {
if($status == "1") { return "publish"; } else { return "draft"; }
}
function fixPermalink($url) {
$url = str_replace("/artikel/","", $url);
return $url;
}
function timeFix($time) {
$newdate = date("Y-M-d", $time);
return $newdate;
}
function findDrupalUser($uid) {
$users = get_users();
// Array of WP_User objects.
foreach ( $users as $user ) {
$drupalUid = get_field('drupalUid', 'user_' . $user->ID );
if($drupalUid == $uid) {
return $user->ID;
}
}
return "3"; // fallback to admin user
}
?>