private function FilterMailchimpCampaign::convertUrl in Mailchimp 8
Same name and namespace in other branches
- 2.x modules/mailchimp_campaign/src/Plugin/Filter/FilterMailchimpCampaign.php \Drupal\mailchimp_campaign\Plugin\Filter\FilterMailchimpCampaign::convertUrl()
Change the relative URLs to absolute ones in the message.
1 call to FilterMailchimpCampaign::convertUrl()
- FilterMailchimpCampaign::process in modules/
mailchimp_campaign/ src/ Plugin/ Filter/ FilterMailchimpCampaign.php - Performs the filter processing.
File
- modules/
mailchimp_campaign/ src/ Plugin/ Filter/ FilterMailchimpCampaign.php, line 89
Class
- FilterMailchimpCampaign
- Provides a filter to add content to and convert URLs for Mailchimp campaigns.
Namespace
Drupal\mailchimp_campaign\Plugin\FilterCode
private function convertUrl($text) {
global $base_url;
$matches = [];
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;
}