An Extreme AdSense Optimization Plugin Request for WordPress

I'm writing this in the hope that one or more aggressive WordPress plugin developers will see it and turn my dreams into reality. I have written about optimizing AdSense in the past, but I don't want to go back into those articles to point out relative information.

Read the rest of this entry »

PHPText Blogger: Pre-Alpha Software Notes

I'm working on a programming project as the sole developer of a browser-based software application. I've dubbed it "PHPText Blogger" as a working name because it's only using PHP and text files formatted specifically for this application.

In order to use this browser-based application on Windows or Linux, I only need to have a web server installed which includes the PHP software. I'm using XAMPP for Windows right now.

Read the rest of this entry »

When Google AdSense Just Doesn't Pay Enough

moola I'm always testing different advertising methods. I move ads around, I change the sizes and I even change the sources. I'm glad I don't have to rely on advertising revenue to live, or I'd be screwed by all the experimenting I do.

Anyone who's been using advertising services for any length of time should already know about the alternate URLs that can be used for contextual ad services when ads for a specific context aren't available. There are other ways, ways that I use, to choose which ad service to display ads for.

Read the rest of this entry »

Bypass WordPress Content Plugins with a Simple Hack

There are a few WordPress plugins that add text to the main content, such as "Related Entries" and "Similar Posts". (I prefer the latter due it being updated frequently.)

Other types of of plugins are available, but for my example I want to use Similar Posts. The proper way to include the plugin, in addition to the initial installation, is to add a line of code to single.php and/or index.php, similar to this:

<?php if (function_exists('similar_posts')) similar_posts(); ?>

By including the code in the theme, the plugin affects every post. How do you prevent it from affecting a specific post? Change that line to:

<?php if (function_exists('similar_posts') && !stristr($post->post_content, '<!– No Similar Posts –>')) similar_posts(); ?>

When you write or edit a post, you would simply add   <!– No Similar Posts –> to the end of the post, which would basically tell the post to ignore that plugin.

This kind of hack will work for any plugin that adds text onto the content. Sometimes it's easier to do it this way than to try to use the options available with the plugins.

Bowing Down Before The Google Gods

Back in August, I made a decision to stop displaying Google Ads. I've now made another decision: To start displaying them again. Don't worry. If you're a regular reader, you won't see them (except maybe the first time).

I'll be using the Who Sees Ads plugin from planetOzh. I'm not going to display the ads to returning readers or on posts less than a week old. Many of you will forget they're even there.

I investigated and signed up with more than 3 companies that claimed to be different, but what I saw was that they were Google AdSense "wannebees". Uh, no thanks. I also investigated and even displayed "in-line" text links for a few days. Again, no thanks. I considered Amazon for my other blog, because can I do specific targeting there, but I decided against it.

I never took the AdSense off the other blog. I couldn't find the time to mess with it until yesterday. Ah, yesterday. That was the day I made TONS of changes on both blogs, CSS and theme files alike. I cleaned out unused code on this blog's style sheet and added code to the other. The header at the other blog is a bit different now. I changed it so that it wouldn't look so much like the theme the splogs seem to be using a lot.

I'm trying to move away from sponsored posts, for the most part. There just aren't many opportunities available to PR0 blogs. Once SocialSpark gets underway, I may be inclined to head back in that direction again, but only if the opportunities warrant it. In the meantime, I need to make up the difference of what the exchange rate between the American dollar and the Philippine peso used to be and what it is now. It dropped from 52 pesos per dollar last year to 42 pesos per dollar recently. I can't wait for the dollar to rebound.

Hacking the 'Shylock Adsense Plugin' for WordPress

I usually refrain from hacking plugins. Normally, I'll send messages to the plugin authors with any needed changes, wait for the next version or find another plugin that works better. Other than a flaw in my theme causing problems, the Shylock Adsense Plugin for WordPress does what I want it to do.

Briefly, what the plugin does is allow you to place a maximum of three ads on the front, index page and then up to three ads on any single post page and any static page. It also has an exclusion feature, where you enter the post IDs, which will prevent ads from appearing on selective posts. This is very handy for keeping extra ads out of the sponsored posts. The plugin also allows you to change the ads, and the position of the ads, in older posts.

The flaw in my theme is that whenever an ad is placed on either the left or right side of an article, and the article includes a video, the video ends up either covering subsequent text or bleeding over the lower border of the post. This isn't a flaw in the plugin; it's a flaw in how my theme handles the content area of the post. I could probably fix it permanently if I knew exactly what to look for. Instead, I decided to hack this plugin.

Since I wanted my articles over seven days old to switch to an ad on the right side of the articles, I entered the necessary AdSense code in the plugin options. Of course, I knew it would cause those articles with the videos to get whacked out. I entered a single line into the plugin, under the "shylock_show_code($code_id,$content)" function and replacing the blank line (line 43) with this:

if (stristr($content, 'youtube.com/watch') and ($align == 'top_left' or $align == 'top-right')) {$code_id = '1'; $align = 'top';}

What it does is tell the plugin to use the same ad as the one I use for new posts on those specific posts. If I later add Google Video or other video sources, I can add one or more "or" conditions to the line, but so far I have only used YouTube videos. There are other ways to accomplish the same desired outcome, but I found this to be the easiest and not requiring me to edit the plugin or the theme every time I post a YouTube video.

Anyway, this is the plugin Chris from Blog-Op wanted when he wrote "Turn this into a plugin RT, and you could be onto a winner.". I'm considering whether to hack the exclusion function to be specific to the "This is a sponsored post" line, just so that I don't have to add post IDs to the plugin over and over again. Probably not, since I can use it the way it is to exclude other than sponsored posts.

Blog Tip: Comply With Google AdSense Restrictions On Your WordPress Index Page

Google's "AdSense for Content" policies restrict every page on your blog to three ad units, three link units, three referral units and two search boxes (see Google AdSense Program Policies). Many of you place at least one ad unit in the content section of each article. On the index page (the home page) it's a good idea to place a single ad on three individual articles instead of multiple ads on one article.

How do you comply with the restrictions if you're displaying more than three articles on your index page? The answer lies in editing the theme. Yes, there are plugins that will insert your code into specific places in your theme. At least one of them purports to limit the ad units to three on the index page, but I never tested it to find out. Editing the relevant part of the theme is easy. You only need to concern yourself with the index.php file. The instructions that follow are the way I control my ad placements on the index page.

You start by placing your AdSense code where you want it to display, the best place being between the post title and the content. Once you have it in place, insert this code just before the beginning "<script" line:

<?php
$gcount++; // google post counter
if ($gadv < 3) { // how many ads to display?
if ($gcount%1 == 0) { // display ad after how many posts?
$gadv++; // count number of advertisements
print '

Then after the "</script>" of the final line of the code:

';
}
}
?>

After you get it set up properly, it doesn't matter if you display three or ten articles on the index page. Only the first three will only have ad units on them. If you need help with your theme, feel free to send me a message via my contact page.

This is not the only way to control ad placement on the index page. I recommend you read Darren Rowse's article, "Introduction to Advertising Optimization – Ad Position", and Aaron Brazelle's article, "How to: Placing Adsense Strategically Between Posts".

Thanks to Matthew of eJabs for sending me the code a few months ago.

(Update 2007-08-11: I now use the Shylock Adsense Plugin to do the dirty work for me. I made one change to the plugin to make it work with certain kinds of posts but other than that, it does the job.)

Comment Posting Was Broken!

See what happens when you let a neophyte programmer get behind the keyboard? I altered a plugin this morning and had no idea that in the form itself that I'd left out the closing form tag. Everything looked normal and seemed normal. That is, until I was told that an error page came up when someone tried to post a comment.

I fixed it, but it took me the last hour to find it. The form was in a plugin and I was looking through the template files. Doh!

Protect Your Blog From Digg and More

Are you afraid of what will happen to your blog should it get Digg slammed or suffer from the Slashdot effect? Have you seen your bandwidth usage rise along with the popularity of your blog? I have the solution to your problems.

When I wrote my article, Saving My Bandwidth and My Sanity, I was not aware that the Coralize plugin existed. I found out today.

In my article, I explained how to do it with the .htaccess file for the Apache web server. With this plugin, you don't have to worry about it! The plugin has the option to specify which social sites to preemptively coralize your whole site for.

There was one thing missing from the plugin, which I think I fixed myself. When a thumbnail linked to a larger image, the thumbnail would be coralized but the larger image would not. Here's the code I changed:

From:

//LOCAL IMAGES
if(get_option('coralize_imgs_lc')){
$preg_host = preg_quote($_SERVER["HTTP_HOST"], '/');
$content = preg_replace('/(\<img\s+.*?src\=["\']http\:\/\/'.$preg_host.')(\/.*?["\'].*?\>)/i', '$1.nyud.net:8080$2', $content);
$content = preg_replace('/(\<img\s+.*?src\=["\'])(\/.*?["\'].*?\>)/i', '$1http://'.$_SERVER['HTTP_HOST'].'.nyud.net:8080$2', $content);
}

To:

//LOCAL IMAGES
if(get_option('coralize_imgs_lc')){
$preg_host = preg_quote($_SERVER["HTTP_HOST"], '/');
$content = preg_replace('/(\<img\s+.*?src\=["\']http\:\/\/'.$preg_host.')(\/.*?["\'].*?\>)/i', '$1.nyud.net:8080$2', $content);
$content = preg_replace('/(\<img\s+.*?src\=["\'])(\/.*?["\'].*?\>)/i', '$1http://'.$_SERVER['HTTP_HOST'].'.nyud.net:8080$2', $content);
if (strpos($content, ".jpg") || strpos($content, ".gif") || strpos($content, ".png")) {
$content = preg_replace('/(\<a\s+.*?href\=["\']http\:\/\/'.$preg_host.')(\/.*?["\'].*?\>)/i', '$1.nyud.net:8080$2', $content);
$content = preg_replace('/(\<a\s+.*?href\=["\'])(\/.*?["\'].*?\>)/i', '$1http://'.$_SERVER['HTTP_HOST'].'.nyud.net:8080$2', $content);
}
}

The second "if" condition is the addition. If you want to try this, don't just copy and paste. The pretty single and full quotes here won't work and you'll have to replace them. You can send me an email message or ask for it in the comments and I'll send the changed plugin to you. I already forwarded the suggested additions to the author of the plugin.

I haven't been "dugg" since the plugin was put in place, so I can't guarantee the success of that part yet. If someone would like to digg this article and quite a few others would vote it up, I'm sure I could report on success or failure. That task, however, is up to you.

Update: Someone dugg me and it appears the plugin did not work, so I switched the .htaccess file and now it works again. The image caching does work with the plugin, so I have no idea why the digg protection doesn't. (I turned off the .htaccess until it appears a slam is in effect.)

***

Blog Appreciation:

One of my favorite blogs, that I never get over to enough, is DragonLady's World. I try to get there often, I really do, because I thoroughly enjoy reading the details she exposes about herself from time to time.

Search Engine Optimization (SEO) for WordPress, Part 4

In the last three parts of the series, I introduced you to some concept, some code and some plugins to help you optimize your WordPress blog to make it more attractive to search engines. There are more things you can do, to be sure, but I'm not experienced enough to talk about it.

In Part 1, I wrote about the .htaccess file for the Apache web server and rewrite rules to make your blog land on a single front index page. I spotted the code and other interesting things at Niche Marketing – Andy Beard which took to me to Alister Cameron // Blogologist where I was able to read even more. Both of these blogs are valuable resources for anyone that wants to continue to optimize their own blogs for the best search engine performance.

In Part 2, I wrote about a plugin and a theory on reducing outbound links to the sidebars of the front page. I found the plugin on my own but the idea to even look for it came from Andy Beard.

In Part 3, I wrote about reformatting your blog posts to make them more unique to the search engines. I was introduced to the concept of it by reading a post at MacBros' Place which directed me to Entropy and the articles there.

This concludes this particular series. Thank you for reading.