Last active
July 2, 2021 08:26
-
-
Save hayatbiralem/f369bb171e2c1f0b0f764026821321c0 to your computer and use it in GitHub Desktop.
WP All Import helper functions
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 | |
// WP All Import strip host from single image url | |
function reboot_strip_host_from_url_single($featured_image_url){ | |
return str_replace('http://www.example.com/wp-content/', '', $featured_image_url); | |
} | |
// WP All Import strip host from image urls | |
function reboot_strip_host_from_url($featured_image_url, $content_image_urls){ | |
$result = []; | |
if(!empty($featured_image_url)) { | |
$result[] = $featured_image_url; | |
} | |
if(!empty($content_image_urls)) { | |
$content_image_urls = explode('|', $content_image_urls); | |
$result = $result + $content_image_urls; | |
} | |
if(!empty($result)){ | |
foreach($result as &$item) { | |
$item = str_replace('http://www.example.com/wp-content/', '', $item); | |
} | |
unset($item); | |
return implode('|', $result); | |
} | |
return ''; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment