function mailchimp_campaign_convert_url in Mailchimp 7.2
Same name and namespace in other branches
- 7.5 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_convert_url()
- 7.3 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_convert_url()
- 7.4 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_convert_url()
Change the relative URLs to absolute ones in the message.
1 call to mailchimp_campaign_convert_url()
- mailchimp_campaign_filter_campaign_process in modules/
mailchimp_campaign/ mailchimp_campaign.module - Process callback for mailchimp_campaign_filter_info().
File
- modules/
mailchimp_campaign/ mailchimp_campaign.module, line 364
Code
function mailchimp_campaign_convert_url($text) {
global $base_url;
$matches = array();
preg_match_all('/<(a|img).*?(href|src)="(.*?)"/', $text, $matches);
foreach ($matches[3] as $key => $url) {
if ($url[0] == '/') {
$new_url = $base_url . $url;
$new_match = str_replace($url, $new_url, $matches[0][$key]);
$text = str_replace($matches[0][$key], $new_match, $text);
}
}
return $text;
}