You are here

function _simplenews_statistics_parse_links in Simplenews Statistics 7

Same name and namespace in other branches
  1. 6.3 simplenews_statistics.module \_simplenews_statistics_parse_links()
  2. 7.2 simplenews_statistics.module \_simplenews_statistics_parse_links()

Helper function to parse links in the body.

1 call to _simplenews_statistics_parse_links()
simplenews_statistics_mail_alter in ./simplenews_statistics.module
Implements hook_mail_alter().

File

./simplenews_statistics.module, line 233
Main simplenews statistics file.

Code

function _simplenews_statistics_parse_links(&$body, $nid, $snid) {
  if (is_array($body)) {
    foreach ($body as $key => $element) {
      _simplenews_statistics_parse_links($body[$key], $nid, $snid);
    }
  }
  else {

    // @todo: Try and write some cleaner code here.
    $body = preg_replace_callback('/<a([^>]*)href=[\\"\']([^\\"\']*)[\\"\']([^>]*)>/mi', function ($matches) use ($nid, $snid) {
      $value = _simplenews_statistics_replace_url($matches[2], $nid, $snid);
      return '<a' . $matches[1] . 'href="' . $value . '"' . $matches[3] . '>';
    }, $body);
  }
}