AdSense Enzymes are very simple.
At the simplest level of abstraction, I can directly trasclude the custom field which I’ve stored the ad code into. And I can do it either by means of a statement into the content of a post or a page, or by means of a call to the metabolize function (available in Enzymes 1.1) into the php code of a WordPress template file.
The former method is useful when I want to place an ad unit in a particular/variable position inside the content of a post or a page; the latter method is useful when I want to place an ad unit in a general/constant position inside the blog.
For example, if I put the statement {[1.ad001]} here, it would reproduce by itself the ad unit right here, because in the first post I’ve stored the ad code in a custom field called ad001. But to make the ad unit appear before any post, I need to find the line in the index.php file of my default theme that reads
<?php if (have_posts()) : ?>
and replace it with this line
<?php metabolize( "{[1.ad001]}" ); if (have_posts()) : ?>
Taking the abstraction one step further, I’d like to store the string 1.ad001 in a new home field, so that I can provide a separation layer that makes it possible for me to replace the ad code simply by changing the content of a field, rather than having to change the php file again.
Indirect transclusion is not directly available in Enzymes, but it can be easily achieved by means of a simple enzyme like this
preg_match( '/'.$this->e['substrate'].'/', $this->substrate, $matches );
return $this->item( $matches['sub_id'], $matches['sub_key'] );
I’ve called this enzyme get, and I’ve put it into the first post. So the Enzymes statement becomes {[1.get(1.home)]} and the edited line for the index.php file becomes
<?php metabolize( "{[1.get(1.home)]}" ); if (have_posts()) : ?>
I’m currently using the latter for my blog home, so I don’t have to worry about placing ads every time I post a new log, and the former for my pages, so that I can place the ads insdide the content, in a position that I hope will fit better.
Why does Google limit to three the number of ad units per page? Is it a technical reason?