add autoupdate facility and update readme
This commit is contained in:
parent
d28fe8eaf3
commit
844e0f9fd0
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Plugin Wonderful
|
||||
Plugin URI: http://www.coswellproductions.com
|
||||
Plugin URI: http://www.coswellproductions.com/wordpress/wordpress-plugins/
|
||||
Description: Easily embed a Project Wonderful publisher's advertisements.
|
||||
Version: 0.2
|
||||
Version: 0.3
|
||||
Author: John Bintz
|
||||
Author URI: http://www.coswellproductions.org/wordpress/
|
||||
|
||||
@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
require_once('classes/PWAdboxesClient.php');
|
||||
|
||||
define('PLUGIN_WONDERFUL_XML_URL', 'http://www.projectwonderful.com/xmlpublisherdata.php?publisher=%d');
|
||||
define('PLUGIN_WONDERFUL_UPDATE_TIME', 60 * 60 * 12); // every 12 hours
|
||||
|
||||
class PluginWonderful {
|
||||
var $messages, $adboxes_client, $publisher_info, $member_id;
|
||||
@ -39,6 +40,16 @@ class PluginWonderful {
|
||||
|
||||
if ($member_id = get_option('plugin-wonderful-memberid')) {
|
||||
$this->publisher_info = $this->adboxes_client->get_ads($member_id);
|
||||
|
||||
if ((get_option('plugin-wonderful-last-update') + PLUGIN_WONDERFUL_UPDATE_TIME) < time()) {
|
||||
if (($result = file_get_contents(sprintf(PLUGIN_WONDERFUL_XML_URL, (int)get_option('plugin-wonderful-memberid')))) !== false) {
|
||||
$this->publisher_info = new PublisherInfo();
|
||||
if ($this->publisher_info->parse($result)) {
|
||||
$this->adboxes_client->post_ads($this->publisher_info);
|
||||
update_option('plugin-wonderful-last-update', time());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = get_option('plugin-wonderful-database-version');
|
||||
@ -62,6 +73,11 @@ class PluginWonderful {
|
||||
}
|
||||
}
|
||||
|
||||
function insert_activation_ad() {
|
||||
$result = get_option('plugin-wonderful-activate-ad-code');
|
||||
if (!empty($result)) { echo $result; }
|
||||
}
|
||||
|
||||
function render_widget($options, $adboxid) {
|
||||
if ($this->publisher_info !== false) {
|
||||
foreach ($this->publisher_info->adboxes as $adbox) {
|
||||
@ -115,6 +131,9 @@ class PluginWonderful {
|
||||
function get_view($function_name) {
|
||||
$target = $this->_create_target(str_replace('plugin_wonderful_', '', $function_name), "views");
|
||||
if (file_exists($target)) {
|
||||
|
||||
$info = get_plugin_data(realpath(__FILE__));
|
||||
|
||||
echo '<div class="wrap">';
|
||||
echo '<div id="icon-edit" class="icon32"><br /></div>';
|
||||
echo '<h2>' . __("Plugin Wonderful", 'plugin-wonderful') . '</h2>';
|
||||
@ -125,13 +144,13 @@ class PluginWonderful {
|
||||
|
||||
echo '<div style="margin-top: 20px; border-top: solid #E3E3E3 1px; overflow: hidden">';
|
||||
echo '<form style="float: right; display: inline" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="3215507"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>';
|
||||
echo 'Plugin Wonderful Version 0.2 by <a href="http://www.coswellproductions.com/wordpress/">John Bintz</a> | ';
|
||||
echo '<a href="http://www.projectwonderful.com/login.php">Manage your Project Wonderful publisher account</a>';
|
||||
echo sprintf(__('%1$s Version %2$s by %3$s', 'plugin-wonderful'), $info['Title'], $info['Version'], $info['Author']) . ' | ';
|
||||
echo __('<a href="http://www.projectwonderful.com/login.php">Manage your Project Wonderful publisher account</a>', 'plugin-wonderful');
|
||||
echo '<br style="clear: both" />';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
} else {
|
||||
die("View not found: " . str_replace('plugin-wonderful_', '', $function_name));
|
||||
die(__("View not found: ", 'plugin-wonderful') . str_replace('plugin-wonderful_', '', $function_name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +159,28 @@ class PluginWonderful {
|
||||
if (method_exists($this, $action)) { call_user_func(array($this, $action)); }
|
||||
}
|
||||
|
||||
function handle_action_activate_ad() {
|
||||
if (isset($_POST['submit'])) {
|
||||
$original_ad_code = get_option('plugin-wonderful-activate-ad-code');
|
||||
update_option('plugin-wonderful-activate-ad-code', $_POST['activate-ad-code']);
|
||||
|
||||
if (empty($_POST['activate-ad-code'])) {
|
||||
$this->messages[] = __('Adbox for activation removed.', 'plugin-wonderful');
|
||||
} else {
|
||||
$this->messages[] = __('Adbox for activation changed. Return to Project Wonderful to finish activating your ad, then return here and click the Finished button.', 'plugin-wonderful');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['finished'])) {
|
||||
update_option('plugin-wonderful-activate-ad-code', "");
|
||||
$this->messages[] = __('Adbox for activation removed and all adboxes redownloaded.', 'plugin-wonderful');
|
||||
|
||||
if ($member_id = get_option('plugin-wonderful-memberid')) {
|
||||
$this->publisher_info = $this->adboxes_client->get_ads($member_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handle_action_change_adbox_settings() {
|
||||
if ($member_id = get_option('plugin-wonderful-memberid')) {
|
||||
if (isset($_POST['template_tag_id']) && is_array($_POST['template_tag_id'])) {
|
||||
@ -252,6 +293,7 @@ $plugin_wonderful = new PluginWonderful();
|
||||
add_action('admin_menu', array($plugin_wonderful, 'set_up_menu'));
|
||||
add_action('init', array($plugin_wonderful, 'set_up_widgets'));
|
||||
add_filter('the_excerpt_rss', array($plugin_wonderful, 'insert_rss_feed_ads'));
|
||||
add_filter('wp_footer', array($plugin_wonderful, 'insert_activation_ad'));
|
||||
|
||||
register_activation_hook(__FILE__, array($plugin_wonderful, 'handle_activation'));
|
||||
|
||||
|
24
readme.txt
24
readme.txt
@ -3,14 +3,18 @@ Contributors: johncoswell
|
||||
Tags: ads, sidebar, widget
|
||||
Requires at least: 2.7
|
||||
Tested up to: 2.7.1
|
||||
Stable tag: 0.2
|
||||
Stable tag: 0.3
|
||||
Donate link: http://www.coswellproductions.com/wordpress/wordpress-plugins/
|
||||
|
||||
Plugin Wonderful lets Project Wonderful publishers quickly and easily add their adboxes to thier WordPress blog.
|
||||
Plugin Wonderful lets Project Wonderful publishers quickly and easily add their adboxes to thier WordPress site.
|
||||
|
||||
== Description ==
|
||||
|
||||
Plugin Wonderful downloads your adbox information from Project Wonderful and creates a series of widgets that can easily be added to your sidebars. It also adds a new template tag, `the_project_wonderful_ad()`, that lets you embed Project Wonderful ads directly into your site. Adbox code is downloaded straight from Project Wonderful, so your adboxes are always displayed correctly.
|
||||
Plugin Wonderful downloads your adbox information from Project Wonderful and creates a series of widgets that can easily be added to your sidebars. It also adds a new template tag, `the_project_wonderful_ad()`, that lets you embed Project Wonderful ads directly into your site. Adbox code is downloaded straight from Project Wonderful, so your adboxes are always displayed correctly. You can also easily activate new ads without having to modify your theme.
|
||||
|
||||
== Installation ==
|
||||
|
||||
Copy the plugin-wonderful folder to your wp-content/plugins folder and activate it from Plugins -> Installed. Activating the plugin creates a new database table, {prefix}_pw_adboxes, that you can safely remove if you are no longer using the plugin.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
@ -24,8 +28,22 @@ If you want to refer to an ad by an arbitrary name, rather than the adbox id, yo
|
||||
|
||||
`the_project_wonderful_ad('header')`
|
||||
|
||||
= How does quick ad activation work? =
|
||||
|
||||
When you create an adbox on Project Wonderful, before people can bid on the ad you need to activate the adbox, by placing in on your page and letting PW check the ad's existence. Since only activated ads appear in your adbox listing, you can't automatically ad the adbox to your site. Quick activation lets you temporarily place the adbox code from PW into the footer of all pages on your site so that PW can find the ad for activation purposes. After it's activated, it will appear in your adbox list. Follow the instructions given by the plugin to quickly activate new Project Wonderful ads.
|
||||
|
||||
= How robust is placing ads in the RSS feed? =
|
||||
|
||||
Project Wonderful does support placing ads in the RSS feed. In this case, all of the JavaScript is stripped out, since many RSS feed readers don't support JavaScript in the feed. The ads are placed above any excerpts in the feed. Some readers may not like the markup used. Until further testing is done, there are no good answers on how well PW ads delivered by Plugin Wonderful will perform.
|
||||
|
||||
Additonally, the ad that you use in your RSS feed will need to be accessible by Project Wonderful's ad verification crawlers, so you'll need to place the ad somewhere on your site before you can use it in your RSS feed.
|
||||
|
||||
= How often is adbox information redownloaded? =
|
||||
|
||||
Plugin Wonderful checks your Project Wonderful account every 12 hours for adbox changes. If there are any, it will apply the changes to your adboxes.
|
||||
|
||||
= I am a theme author who wants to include pre-built hooks for Project Wonderful ads. How do I safely add those hooks? =
|
||||
|
||||
Wrap the call to `the_project_wonderful_ad()` in a `function_exists()` call:
|
||||
|
||||
`<?php if (function_exists('the_project_wonderful_ad')) { the_project_wonderful_ad('header'); } ?>`
|
@ -34,13 +34,12 @@
|
||||
<input type="hidden" name="action" value="change-adbox-settings" />
|
||||
<table class="widefat post fixed">
|
||||
<tr>
|
||||
<th width="15%" class="manage-column"><?php _e('Site Name', 'plugin-wonderful') ?></th>
|
||||
<th width="15%" class="manage-column"><?php _e('Description', 'plugin-wonderful') ?></th>
|
||||
<th width="12%" class="manage-column"><?php _e('Site Name', 'plugin-wonderful') ?></th>
|
||||
<th width="13%" class="manage-column"><?php _e('Description', 'plugin-wonderful') ?></th>
|
||||
<th class="manage-column" align="center"><?php _e('Size & Dimensions', 'plugin-wonderful') ?></th>
|
||||
<th class="manage-column" align="center"><?php _e('Category', 'plugin-wonderful') ?></th>
|
||||
<th class="manage-column" align="center"><?php _e('Template Tag Identifier', 'plugin-wonderful') ?></th>
|
||||
<th width="100" class="manage-column" align="center"><?php _e('Template Tag Identifier', 'plugin-wonderful') ?></th>
|
||||
<th class="manage-column" align="center"><?php _e('Use in RSS Feed?', 'plugin-wonderful') ?></th>
|
||||
<th style="text-align: right !important" width="30%" class="manage-column"><?php _e('Raw Template Tag <em>(for direct use in theme)</em>', 'plugin-wonderful') ?></th>
|
||||
<th style="text-align: right !important" width="35%" class="manage-column"><?php _e('Raw Template Tag <em>(for direct use in theme)</em>', 'plugin-wonderful') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$first_adboxid = null;
|
||||
@ -64,8 +63,7 @@
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $adbox->adtype ?> - <?php echo $adbox->dimensions ?></td>
|
||||
<td><?php echo $adbox->category ?></td>
|
||||
<td><input type="text" size="8" name="template_tag_id[<?php echo $adbox->adboxid ?>]" value="<?php echo $adbox->template_tag_id ?>" /></td>
|
||||
<td><input type="text" style="width: 100px" name="template_tag_id[<?php echo $adbox->adboxid ?>]" value="<?php echo $adbox->template_tag_id ?>" /></td>
|
||||
<td align="center"><input type="checkbox" name="in_rss_feed[<?php echo $adbox->adboxid ?>]" value="yes" <?php echo !empty($adbox->in_rss_feed) ? " checked" : "" ?> /></td>
|
||||
<td align="right">
|
||||
<tt>the_project_wonderful_ad(<?php
|
||||
@ -85,7 +83,28 @@
|
||||
<input type="submit" class="button" value="<?php _e('Submit Adbox Changes', 'plugin-wonderful') ?>" />
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<table class="form-table" cellspacing="0">
|
||||
<tr>
|
||||
<td style="padding-left: 0" width="30%">
|
||||
<h3><?php _e('Quickly Set Up A New Adbox For Activation', 'plugin-wonderful') ?></h3>
|
||||
|
||||
<p><?php _e("Copy and paste your new ad's code from Project Wonderful into the textbox on the right and click Submit. Your ad will appear in the footer of all the pages on your site so that Project Wonderful can detect it. Click the Finished button after you've activated your ad and it will appear in the list of available advertisements above.", 'plugin-wonderful') ?></p>
|
||||
</td>
|
||||
<td style="padding-right: 0">
|
||||
<form action="" method="post">
|
||||
<input type="hidden" name="action" value="activate-ad" />
|
||||
<textarea name="activate-ad-code" style="width: 100%; height: 100px"><?php echo get_option('plugin-wonderful-activate-ad-code') ?></textarea>
|
||||
<br />
|
||||
<input class="button" type="submit" name="submit" value="Submit" />
|
||||
<input class="button" type="submit" name="finished" value="Finished" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php if ($this->publisher_info !== false) { ?>
|
||||
<h3><?php _e('Using Widgets to Put Ads on Your Site', 'plugin-wonderful') ?></h3>
|
||||
<p>
|
||||
<?php _e('Visit <a href="widgets.php">Appearance -> Widgets</a> to quickly add Project Wonderful advertisements to your site. Plugin Wonderful widgets start with "PW".', 'plugin-wonderful') ?>
|
||||
|
Loading…
Reference in New Issue
Block a user