You are here

function _adsense_page_match in Google AdSense integration 7

Same name and namespace in other branches
  1. 5.3 adsense.module \_adsense_page_match()
  2. 5 adsense.module \_adsense_page_match()
  3. 5.2 adsense.module \_adsense_page_match()
  4. 6 adsense.module \_adsense_page_match()

Determine if AdSense has permission to be used on the current page.

Return value

bool TRUE if can render, FALSE if not allowed.

6 calls to _adsense_page_match()
adsense_cse_block_view in cse/adsense_cse.module
Implements hook_block_view().
adsense_display in ./adsense.module
Generates the Google AdSense Ad.
adsense_managed_block_view in managed/adsense_managed.module
Implements hook_block_view().
adsense_managed_init in managed/adsense_managed.module
Implements hook_init().
adsense_oldcode_block_view in old/oldcode/adsense_oldcode.module
Implements hook_block_view().

... See full list

File

./adsense.module, line 634
Displays Google AdSense ads on Drupal pages.

Code

function _adsense_page_match() {
  $pages = variable_get('adsense_access_pages', ADSENSE_ACCESS_PAGES_DEFAULT);
  $visibility = variable_get('adsense_visibility', ADSENSE_VISIBILITY_DEFAULT);
  if ($pages) {
    if ($visibility == 2) {
      return php_eval($pages);
    }
    $path = drupal_get_path_alias($_GET['q']);
    $page_match = drupal_match_path($path, $pages);
    if ($path != $_GET['q']) {
      $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
    }
    return !($visibility xor $page_match);
  }
  else {
    return !$visibility;
  }
}