Simple PW Ads

I mainly wrote Simple PW Ads for myself, but I thought others might find it useful. It allows you to download all your Project Wonderful ad information, then display any of those ads through a widget, shortcode, or template tag.


A screenshot of the widget:

A screenshot of the management page:

Shortcode and Template Tag

The added shortcode is:

[spw_ad managed_ad="x"]

The added template tag is:

spw_insert_ad( 'x' )

“x” corresponds with “Ad Number” on the management page.

For legacy purposes, the old shortcode and template tag will still work as long as the given ad code corresponds with an ad on the management page (any number after “y” is now ignored). You really shouldn’t use these:

 [spw_ad ad="xxxxx_y"]
spw_insert_ad( 'xxxxx_y' )

How it Works

When you ad your publisher ID/member number, Simple PW Ads downloads and displays all your ad information directly from Project Wonderful. Then, when you use the included widget, shortcode, or template tag, the proper code is placed in that position. If you set it to use the asynchronous version of the code, it will then place the needed JavaScript in the footer.


To use the management page, type in your Project Wonderful publisher ID/member number. Then select whether you wish to use the standard code (only works if JavaScript is enabled) or the advanced code (works even when JavaScript is disabled) and whether or not you wish to load your ads asynchronously. Once you click “Synchronize Ad Data”, all ads for your account will be displayed. You can then use the provided widget, shortcode, or template tag to display your ads.

Your member number can be found here:

To use the widget, select the appropriate ad from the dropdown.

To use the shortcode, use the number under “Ad Number” on the management page.

[spw_ad managed_ad="x"]

For legacy reasons, using your ad code will still work as long as the ad corresponds to an ad on the management page.

[spw_ad ad="xxxxx_y"]

Your ad will appear at that exact location in which you add it to the post/page.

To use the template tag, use the number under “Ad Number” on the management page.

<?php spw_insert_ad( 'x' ); ?>

For legacy reasons, using your ad code will still work as long as the ad corresponds to an ad on the management page.

<?php spw_insert_ad( 'xxxxx_y' ); ?>

I recommend you wrap the template tag like the following.

<?php if ( function_exists( 'spw_insert_ad' ) ) {
    spw_insert_ad( 'x' );
} ?>

This will make sure that php won’t complain if you ever need to disable Simple PW Ads.


-Added several sanity checks and more detailed error reporting.
-Switched to WordPress’ HTTP API to make fetching XML from Project Wonderful more robust.
-Fixed a logic error: In 3.0.0 deleting an ad box in Project Wonderful would make every subsequent ad number decrease by one. Now, ad numbers are immutable and, once associated with an ad, will never change.

-Now uses Project Wonderful’s xmlpublisherdata.php to retrieve all ad information with only a publisher ID/member number.
-Allows for the use of standard and advanced code in normal or asynchronous mode.
-General bug squashing.
-Fixes a major bug in the way the asynchronous Project Wonderful code was added to the footer which could prevent new ads from being unactivated and cause current ads to be deactivated. Do not use any version of Simple PW Ads prior to this one.

-Added management page.
-Updated widget, shortcode, and template tag to use ads added through management page.
-Replaced any uses of split() with explode() since split() is now deprecated.

-Added internationalization support.

-Nicer code.

-initial release


If you enjoy the use of this plugin and feel absolutely compelled to donate a bit, you should first consider donating to a good charity. If after that you still happen to have a dollar you’re looking to send my way, I certainly won’t stop you.

PayPal - The safer, easier way to pay online!

Facebook Twitter Digg Stumble Delicous Email