You are here

function _cookie_content_blocker_replace_tags in Cookie Content Blocker 7

Replaces cookie content blocker tags for the given text.

Parameters

string $text: The HTML/Text where we want to replace tags for.

Return value

string The original string with tags replaced.

1 call to _cookie_content_blocker_replace_tags()
_cookie_content_blocker_filter_process in ./cookie_content_blocker.module
Process callback for the Cookie content blocker text filter.

File

./cookie_content_blocker.module, line 409
Contains the main module code for Cookie content blocker.

Code

function _cookie_content_blocker_replace_tags($text) {
  list($matches, $settings, $content) = _cookie_content_blocker_match_tags($text);
  if (empty($matches)) {
    return $text;
  }
  foreach ($matches as $index => $match) {
    if (empty($content[$index])) {
      continue;
    }
    $blocker_settings = isset($settings[$index]) ? _cookie_content_blocker_settings_decode($settings[$index]) : array();
    $blocked_content_element = array(
      // We depend on other filters to have sanitized the content.
      '#markup' => $content[$index],
      '#cookie_content_blocker' => !empty($blocker_settings) ? $blocker_settings : TRUE,
    );
    $blocked_content = drupal_render($blocked_content_element);
    $text = str_replace($match, $blocked_content, $text);
  }
  return $text;
}