AdSense Enzymes

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?

5 Replies to “AdSense Enzymes”

  1. I believe Google limits to three because the top three most relevant ads are syndicated across its partners. I think three is a magic number that’s used in many places in their AdSense and AdWords syndication.

  2. I’m trying to make it a little easier for contributors to post code using chili + enzymes. What I want is an enzyme that’s something like {[1.postcode(.codeInTheSamePost)]}

    I’ve got an enzyme template coded that parses the first line to discover the language, then posts the rest as code highlighted for that language. I’m having problems getting it to run properly though. I’m trying things based off of your get enzyme above, but to no avail. Can you suggest a way to accomplish this task?

  3. Chili + Enzymes is easy.

    For example, for posting an SQL snippet, I put the snippet in a “snippet” custom field in the same post. Then, in the content of the post, at the position where I want the snippet to appear I put {[.snippet /enzymes/chili-sql.php]}. That’s all!

    But if yours is an easier method, please formulate again what you want to do using the example I’ve just provided, so that we play on a common ground.

  4. Nothing like verbal obsfucation to tranclude confusion into a newbie’s metabolized concept of Enzyme’s functionality.

    So this is a plug-in that allows you to place code snippets inside WordPress posts and themes, eh?

  5. No. There is really no such a thing, like the plugin you mention.

    AdSense Enzymes is an application of the Enzymes plugin, which is a general purpose plugin.

    Chili + Enzymes is another application of the Enzymes plugin, and it “allows you to place code snippets inside WordPress posts and themes”, but it’s not a plugin by itself.

    Thanks for the pig latin, I didn’t know it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.