Commit 7d1a5aa6 authored by mark burdett's avatar mark burdett
Browse files

Issue #3116573 by mfb, shadowwolf218: Does noscript inherit role/page...

Issue #3116573 by mfb, shadowwolf218: Does noscript inherit role/page restrictions from Matomo Analytics module?
parent 0e0edab5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -9,10 +9,22 @@
 * Adds Matomo noscript tag to bottom of the page.
 */
function piwik_noscript_preprocess_html(&$variables) {
  global $user;
  // Return early if not configured.
  if (!piwik_noscript_configured()) {
    return;
  }
  // Respect Matomo module visibility settings.
  foreach (array('matomo', 'piwik') as $module) {
    $function = "_{$module}_visibility_pages";
    if (function_exists($function) && !$function()) {
      return;
    }
    $function = "_{$module}_visibility_user";
    if (function_exists($function) && !$function($user)) {
      return;
    }
  }
  $options = piwik_noscript_options();
  // The head title needs to be un-HTML-encoded.
  $options['query']['action_name'] = decode_entities($variables['head_title']);