On a live site, I have found it useful to disable google ads and show the placeholder for specific users who are
not site admin. These are users which run and manage the site, are on it a lot of the time and do not want to be exposed to accidentally clicking on the live ad. But they need to see where they are placed, and check that all is correct.

I created the new permission 'show placeholder' which can be assigned to any role as usual. It is checked in adsense_display() in addition to when the entire site ads are disabled and/or the user is the site admin. Patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathan1055’s picture

Title: New permission 'show adsense placeholders' » New permission 'show placeholder'
Version: 7.x-1.x-dev » 6.x-1.4
Status: Reviewed & tested by the community » Active
FileSize
1.25 KB

Here is the patch against 6.x-1.4 as that is what I am using in production.
It applies ok to the latest dev but with offsets.

Three functions are changed: hook_perm(), adsense_display() and _adsense_check_if_enabled()

jonathan1055’s picture

Status: Active » Needs review

Forgot to change the status.

fenstrat’s picture

Title: New permission 'show placeholder' » New permission 'show adsense placeholders'
Version: 6.x-1.4 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
FileSize
1.76 KB
1.66 KB

Works well. I've made a couple minor changes:

  • "show placeholder" is to generic a permissions, changed to "show adsense placeholders".
  • Placeholders also output "Ads disabled for site admin", so I've also changed that to use $user->name.
  • Also included a D7 version.
  • RTBC as these changes are minor and the new permission works as expected.
jcnventura’s picture

Title: New permission 'show placeholder' » New permission 'show adsense placeholders'
Version: 6.x-1.4 » 7.x-1.x-dev
Status: Active » Fixed
jonathan1055’s picture

Your welcome. Thanks for committing.

fenstrat’s picture

Nice to see the work you're putting into the module atm @jcnventura thanks!

jcnventura’s picture

It's polishing up, so that I can start work on porting it to D8.. I did a sorry job of updating it to D7. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

fix typo