You are here

function _adsense_check_if_enabled in Google AdSense integration 7

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

Helper function to verify if ads are currently enabled.

Return value

bool TRUE if ad display is enabled, FALSE otherwise

2 calls to _adsense_check_if_enabled()
adsense_display in ./adsense.module
Generates the Google AdSense Ad.
adsense_managed_init in managed/adsense_managed.module
Implements hook_init().

File

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

Code

function _adsense_check_if_enabled() {
  if (!variable_get('adsense_basic_id', ADSENSE_BASIC_ID_DEFAULT)) {

    // Google AdSense Publisher ID is not configured.
    return FALSE;
  }
  if (variable_get('adsense_disable', ADSENSE_DISABLE_DEFAULT)) {
    return FALSE;
  }
  if (variable_get('adsense_test_mode', ADSENSE_TEST_MODE_DEFAULT)) {
    return TRUE;
  }
  if (user_access('hide adsense')) {
    return FALSE;
  }
  if (user_access('show adsense placeholders')) {

    // AdSense is enabled but this user should only see placeholders instead.
    return FALSE;
  }
  return TRUE;
}