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.

Comments

jonathan1055’s picture

Comment #1

jonathan1055 commented
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
StatusFileSize
new _1819510_1.adsense.placeholder_perm.d6.patch 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

Comment #2

jonathan1055 commented
Status: Active » Needs review

Forgot to change the status.

fenstrat’s picture

Comment #3

fenstrat
he/him
Primary language English
Location Australia
commented
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
StatusFileSize
new 1819510-3-placeholder_permission-d7.patch 1.76 KB
new 1819510-3-placeholder_permission-d6.patch 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

Comment #4

jcnventura
Primary language English
commented
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

Comment #5

jonathan1055 commented

Your welcome. Thanks for committing.

fenstrat’s picture

Comment #6

fenstrat
he/him
Primary language English
Location Australia
commented

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

jcnventura’s picture

Comment #7

jcnventura
Primary language English
commented

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. :)

Comment #8

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Comment #8.0

(not verified) commented
Issue summary: View changes

fix typo