src/GoogleCampaignPlugin.php
public static function embedCampaigns(
        $html,
        $campaign = [],
        $additionalCampaigns = []
    ) {
        $pattern = '/<a(\s[^>]*)href="([^"]*)"([^>]*)>/si';

        $html = preg_replace_callback($pattern, function($matches) use ($campaign, $additionalCampaigns) {
            $href = GoogleCampaignPlugin::replaceLink($matches[2], $campaign, $additionalCampaigns);
            return "<a{$matches[1]}href=\"{$href}\"{$matches[3]}>";
        }, $html);

        return $html;
    }
public static function embedCampaigns(
        $html,
        $campaign = [],
        $additionalCampaigns = []
    ) {
        $pattern = '/<a(\s[^>]*)href="([^"]*)"([^>]*)>/si';

        $html = preg_replace_callback($pattern, function($matches) use ($campaign, $additionalCampaigns) {
            $href = GoogleCampaignPlugin::replaceLink($matches[2], $campaign, $additionalCampaigns);
            return "<a{$matches[1]}href=\"{$href}\"{$matches[3]}>";
        }, $html);

        return $html;
    }
public static function embedCampaigns ( $ html , $ campaign = [ ] , $ additionalCampaigns = [ ] ) { $ pattern = '/<a(\s[^>]*)href="([^"]*)"([^>]*)>/si' ; $ html = preg_replace_callback ( $ pattern , function ( $ matches ) use ( $ campaign , $ additionalCampaigns ) { $ href = GoogleCampaignPlugin :: replaceLink ( $ matches [ 2 ] , $ campaign , $ additionalCampaigns ) ; return "<a{$matches[1]}href=\"{$href}\"{$matches[3]}>" ; } , $ html ) ; return $ html ; }
Embed campaigns into the newsletter and return the updated html

@param  string $html                 the email content
@param  array  $campaign             the general campaign for the newsletter
@param  array  $additionalCampaigns  additional campaigns to be replaced
@return string $html                 html with updated hrefs
Embed campaigns into the newsletter and return the updated html