Version Description
Download this release
Release Info
Developer | broadstreetads |
Plugin | WordPress Ad Widget |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2.0 to 2.2.1
- adwidget.php +23 -242
- readme.txt +4 -5
- trunk/adwidget.php +448 -0
- {assets → trunk/assets}/sample-ad.png +0 -0
- trunk/assets/widgets.js +19 -0
- {lib → trunk/lib}/Broadstreet.php +0 -0
- {lib → trunk/lib}/Utility.php +4 -1
- trunk/readme.txt +35 -0
- trunk/views/admin.php +89 -0
- {views → trunk/views}/modal/footer.php +0 -0
- {views → trunk/views}/modal/header.php +0 -0
- {views → trunk/views}/modal/index.php +0 -0
- {views → trunk/views}/modal/reports.php +0 -0
- {views → trunk/views}/modal/signedup.php +0 -0
- {views → trunk/views}/modal/signup.php +0 -0
- views/admin.php +3 -60
adwidget.php
CHANGED
@@ -3,13 +3,11 @@
|
|
3 |
Plugin Name: Wordpress Ad Widget
|
4 |
Plugin URI: https://github.com/broadstreetads/wordpress-ad-widget
|
5 |
Description: The easiest way to place ads in your Wordpress sidebar. Go to Settings -> Ad Widget
|
6 |
-
Version: 2.
|
7 |
Author: Broadstreet Ads
|
8 |
Author URI: http://broadstreetads.com
|
9 |
*/
|
10 |
|
11 |
-
require_once 'lib/Utility.php';
|
12 |
-
|
13 |
add_action('admin_init', array('AdWidget_Core', 'registerScripts'));
|
14 |
add_action('widgets_init', array('AdWidget_Core', 'registerWidgets'));
|
15 |
add_action('admin_menu', array('AdWidget_Core', 'registerAdmin'));
|
@@ -19,9 +17,6 @@ add_action('admin_menu', array('AdWidget_Core', 'registerAdmin'));
|
|
19 |
*/
|
20 |
class AdWidget_Core
|
21 |
{
|
22 |
-
CONST KEY_INSTALL_REPORT = 'AdWidget_Installed';
|
23 |
-
CONST VERSION = '2.2.0';
|
24 |
-
|
25 |
/**
|
26 |
* The callback used to register the scripts
|
27 |
*/
|
@@ -51,7 +46,7 @@ class AdWidget_Core
|
|
51 |
*/
|
52 |
public static function getBaseURL()
|
53 |
{
|
54 |
-
return (get_bloginfo('url') . '/wp-content/plugins/
|
55 |
}
|
56 |
|
57 |
/**
|
@@ -67,97 +62,8 @@ class AdWidget_Core
|
|
67 |
*/
|
68 |
static function adminMenuCallback()
|
69 |
{
|
70 |
-
self::sendInstallReportIfNew();
|
71 |
-
|
72 |
-
if(isset($_POST['cancel']))
|
73 |
-
Broadstreet_Mini_Utility::hasAdserving(false);
|
74 |
-
|
75 |
-
if(isset($_POST['subscribe']))
|
76 |
-
Broadstreet_Mini_Utility::hasAdserving(true);
|
77 |
-
|
78 |
include dirname(__FILE__) . '/views/admin.php';
|
79 |
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Makes a call to the Broadstreet service to collect information information
|
83 |
-
* on the blog in case of errors and other needs.
|
84 |
-
*/
|
85 |
-
public static function sendReport($message = 'General')
|
86 |
-
{
|
87 |
-
|
88 |
-
$report = "$message\n";
|
89 |
-
$report .= get_bloginfo('name'). "\n";
|
90 |
-
$report .= get_bloginfo('url'). "\n";
|
91 |
-
$report .= get_bloginfo('admin_email'). "\n";
|
92 |
-
$report .= 'WP Version: ' . get_bloginfo('version'). "\n";
|
93 |
-
$report .= 'Plugin Version: ' . self::VERSION . "\n";
|
94 |
-
$report .= "$message\n";
|
95 |
-
|
96 |
-
@wp_mail('plugin@broadstreetads.com', "Report: $message", $report);
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* If this is a new installation and we've never sent a report to the
|
101 |
-
* Broadstreet server, send a packet of basic info about this blog in case
|
102 |
-
* issues should arise in the future.
|
103 |
-
*/
|
104 |
-
public static function sendInstallReportIfNew()
|
105 |
-
{
|
106 |
-
$install_key = self::KEY_INSTALL_REPORT;
|
107 |
-
$upgrade_key = self::KEY_INSTALL_REPORT .'_'. self::VERSION;
|
108 |
-
|
109 |
-
$installed = self::getOption($install_key);
|
110 |
-
$upgraded = self::getOption($upgrade_key);
|
111 |
-
|
112 |
-
$sent = ($installed && $upgraded);
|
113 |
-
|
114 |
-
if($sent === FALSE)
|
115 |
-
{
|
116 |
-
if(!$installed)
|
117 |
-
{
|
118 |
-
self::sendReport("Installation");
|
119 |
-
self::setOption($install_key, 'true');
|
120 |
-
self::setOption($upgrade_key, 'true');
|
121 |
-
}
|
122 |
-
else
|
123 |
-
{
|
124 |
-
self::sendReport("Upgrade");
|
125 |
-
self::setOption($upgrade_key, 'true');
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Sets a Wordpress option
|
132 |
-
* @param string $name The name of the option to set
|
133 |
-
* @param string $value The value of the option to set
|
134 |
-
*/
|
135 |
-
public static function setOption($name, $value)
|
136 |
-
{
|
137 |
-
if (get_option($name) !== FALSE)
|
138 |
-
{
|
139 |
-
update_option($name, $value);
|
140 |
-
}
|
141 |
-
else
|
142 |
-
{
|
143 |
-
$deprecated = ' ';
|
144 |
-
$autoload = 'yes';
|
145 |
-
add_option($name, $value, $deprecated, $autoload);
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Gets a Wordpress option
|
151 |
-
* @param string $name The name of the option
|
152 |
-
* @param mixed $default The default value to return if one doesn't exist
|
153 |
-
* @return string The value if the option does exist
|
154 |
-
*/
|
155 |
-
public static function getOption($name, $default = FALSE)
|
156 |
-
{
|
157 |
-
$value = get_option($name);
|
158 |
-
if( $value !== FALSE ) return $value;
|
159 |
-
return $default;
|
160 |
-
}
|
161 |
}
|
162 |
|
163 |
|
@@ -186,7 +92,7 @@ class AdWidget_HTMLWidget extends WP_Widget
|
|
186 |
|
187 |
echo $before_widget;
|
188 |
|
189 |
-
|
190 |
|
191 |
echo $after_widget;
|
192 |
}
|
@@ -201,34 +107,7 @@ class AdWidget_HTMLWidget extends WP_Widget
|
|
201 |
{
|
202 |
$instance = $old_instance;
|
203 |
|
204 |
-
$instance['w_adcode']
|
205 |
-
$instance['w_adv'] = $new_instance['w_adv'];
|
206 |
-
|
207 |
-
/* New ad? Upload it to Broadstreet */
|
208 |
-
if($instance['w_adcode'] && Broadstreet_Mini_Utility::hasAdserving()) {
|
209 |
-
|
210 |
-
$advertisement_id = false;
|
211 |
-
# New ad?
|
212 |
-
if(is_numeric(@$instance['bs_ad_id'])) $advertisement_id = $instance['bs_ad_id'];
|
213 |
-
|
214 |
-
# New advertiser?
|
215 |
-
if(!$advertisement_id) {
|
216 |
-
$api = Broadstreet_Mini_Utility::getClient();
|
217 |
-
$adv = $api->createAdvertiser(Broadstreet_Mini_Utility::getNetworkID(), $instance['w_adv']);
|
218 |
-
$instance['bs_adv_id'] = $adv->id;
|
219 |
-
}
|
220 |
-
|
221 |
-
$ad = Broadstreet_Mini_Utility::importHTMLAd(Broadstreet_Mini_Utility::getNetworkID(),
|
222 |
-
$instance['bs_adv_id'],
|
223 |
-
$instance['w_adcode'],
|
224 |
-
$advertisement_id);
|
225 |
-
|
226 |
-
if(!$advertisement_id) {
|
227 |
-
$instance['bs_ad_html'] = $ad->html;
|
228 |
-
$instance['bs_ad_id'] = $ad->id;
|
229 |
-
$instance['bs_adv_id'] = $adv->id;
|
230 |
-
}
|
231 |
-
}
|
232 |
|
233 |
return $instance;
|
234 |
}
|
@@ -240,7 +119,7 @@ class AdWidget_HTMLWidget extends WP_Widget
|
|
240 |
function form($instance)
|
241 |
{
|
242 |
|
243 |
-
$defaults = array('w_adcode' => ''
|
244 |
$instance = wp_parse_args((array) $instance, $defaults);
|
245 |
?>
|
246 |
<div class="widget-content">
|
@@ -248,10 +127,6 @@ class AdWidget_HTMLWidget extends WP_Widget
|
|
248 |
<p>
|
249 |
<label for="<?php echo $this->get_field_id('w_adcode'); ?>">Ad Code</label>
|
250 |
<textarea style="height: 100px;" class="widefat" id="<?php echo $this->get_field_id( 'w_adcode' ); ?>" name="<?php echo $this->get_field_name('w_adcode'); ?>"><?php echo $instance['w_adcode']; ?></textarea>
|
251 |
-
</p>
|
252 |
-
<p>
|
253 |
-
<label for="<?php echo $this->get_field_id('w_adv'); ?>">Advertiser Name</label>
|
254 |
-
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_adv'); ?>" name="<?php echo $this->get_field_name('w_adv'); ?>" value="<?php echo $instance['w_adv']; ?>" />
|
255 |
</p>
|
256 |
</div>
|
257 |
<?php
|
@@ -281,37 +156,12 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
281 |
{
|
282 |
extract($args);
|
283 |
|
284 |
-
$link
|
285 |
-
$img
|
286 |
-
$resize = @$instance['w_resize'];
|
287 |
-
$id = rand(1, 100000);
|
288 |
-
|
289 |
-
if($resize == 'yes')
|
290 |
-
{
|
291 |
-
$resize_s = "style='width: 100%;'";
|
292 |
-
}
|
293 |
-
else
|
294 |
-
{
|
295 |
-
$resize_s = '';
|
296 |
-
}
|
297 |
|
298 |
echo $before_widget;
|
299 |
-
|
300 |
-
|
301 |
-
{
|
302 |
-
$img = AdWidget_Core::getBaseURL() . 'assets/sample-ad.png';
|
303 |
-
$link = 'http://adsofthefuture.com';
|
304 |
-
}
|
305 |
-
|
306 |
-
if(Broadstreet_Mini_Utility::hasAdserving() && is_numeric($instance['bs_ad_id']))
|
307 |
-
{
|
308 |
-
if($resize == 'yes') echo '<style type="text/css">.adwidget-id'.$id.' img { width: 100% !important; height: auto !important; }</style>';
|
309 |
-
echo "<span class='adwidget-id$id'>{$instance['bs_ad_html']}</span>";
|
310 |
-
}
|
311 |
-
else
|
312 |
-
{
|
313 |
-
echo "<a target='_blank' href='$link' alt='Ad'><img $resize_s src='$img' alt='Ad' /></a>";
|
314 |
-
}
|
315 |
|
316 |
echo $after_widget;
|
317 |
}
|
@@ -325,41 +175,9 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
325 |
function update($new_instance, $old_instance)
|
326 |
{
|
327 |
$instance = $old_instance;
|
328 |
-
|
329 |
-
$changed = ($instance['w_img'] != $new_instance['w_img']
|
330 |
-
|| $instance['w_link'] !== $new_instance['w_link']);
|
331 |
-
|
332 |
-
$instance['w_link'] = $new_instance['w_link'];
|
333 |
-
$instance['w_img'] = $new_instance['w_img'];
|
334 |
-
$instance['w_resize'] = @$new_instance['w_resize'];
|
335 |
-
$instance['w_adv'] = $new_instance['w_adv'];
|
336 |
-
|
337 |
-
/* New ad? Upload it to Broadstreet */
|
338 |
-
if($instance['w_img'] && $changed && Broadstreet_Mini_Utility::hasAdserving()) {
|
339 |
-
|
340 |
-
$advertisement_id = false;
|
341 |
-
# New ad?
|
342 |
-
if(is_numeric(@$instance['bs_ad_id'])) $advertisement_id = $instance['bs_ad_id'];
|
343 |
-
|
344 |
-
# New advertiser?
|
345 |
-
if(!$advertisement_id) {
|
346 |
-
$api = Broadstreet_Mini_Utility::getClient();
|
347 |
-
$adv = $api->createAdvertiser(Broadstreet_Mini_Utility::getNetworkID(), $instance['w_adv']);
|
348 |
-
$instance['bs_adv_id'] = $adv->id;
|
349 |
-
}
|
350 |
-
|
351 |
-
$ad = Broadstreet_Mini_Utility::importImageAd(Broadstreet_Mini_Utility::getNetworkID(),
|
352 |
-
$instance['bs_adv_id'],
|
353 |
-
$instance['w_img'],
|
354 |
-
$instance['w_link'],
|
355 |
-
$advertisement_id);
|
356 |
|
357 |
-
|
358 |
-
|
359 |
-
$instance['bs_ad_id'] = $ad->id;
|
360 |
-
$instance['bs_adv_id'] = $adv->id;
|
361 |
-
}
|
362 |
-
}
|
363 |
|
364 |
return $instance;
|
365 |
}
|
@@ -372,25 +190,25 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
372 |
{
|
373 |
$link_id = $this->get_field_id('w_link');
|
374 |
$img_id = $this->get_field_id('w_img');
|
|
|
375 |
|
376 |
-
$defaults = array('w_link' => get_bloginfo('url'), 'w_img' => ''
|
377 |
|
378 |
$instance = wp_parse_args((array) $instance, $defaults);
|
379 |
|
380 |
-
$img
|
381 |
$link = $instance['w_link'];
|
382 |
-
|
383 |
-
|
384 |
?>
|
385 |
<div class="widget-content">
|
386 |
<p style="text-align: center;" class="bs-proof">
|
387 |
<?php if($instance['w_img']): ?>
|
388 |
Your ad is ready.
|
389 |
<br/><br/><strong>Scaled Visual:</strong><br/>
|
390 |
-
<div class="bs-proof"><img style="width:100%;" src="<?php echo $instance['w_img'] ?>" alt="Ad" /></div
|
|
|
|
|
391 |
<?php endif; ?>
|
392 |
-
<a href="#" class="upload-button" rel="<?php echo $img_id ?>">Click here to upload a new image.</a> You can also paste in an image URL below.
|
393 |
-
|
394 |
</p>
|
395 |
<input class="widefat tag" placeholder="Image URL" type="text" id="<?php echo $img_id; ?>" name="<?php echo $this->get_field_name('w_img'); ?>" value="<?php echo htmlentities($instance['w_img']); ?>" />
|
396 |
<br/><br/>
|
@@ -398,51 +216,14 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
398 |
<label for="<?php echo $this->get_field_id('w_link'); ?>">Ad Click Destination:</label><br/>
|
399 |
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_link'); ?>" name="<?php echo $this->get_field_name('w_link'); ?>" value="<?php echo $instance['w_link']; ?>" />
|
400 |
</p>
|
401 |
-
<p>
|
402 |
-
<label for="<?php echo $this->get_field_id('w_adv'); ?>">Advertiser Name:</label><br/>
|
403 |
-
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_adv'); ?>" name="<?php echo $this->get_field_name('w_adv'); ?>" value="<?php echo $instance['w_adv']; ?>" />
|
404 |
-
</p>
|
405 |
-
<p>
|
406 |
-
<label for="<?php echo $this->get_field_id('w_resize'); ?>">Auto Resize to Max Width? </label>
|
407 |
-
<input type="checkbox" name="<?php echo $this->get_field_name('w_resize'); ?>" value="yes" <?php if($instance['w_resize'] == 'yes') echo 'checked'; ?> />
|
408 |
-
</p>
|
409 |
-
<?php if(!Broadstreet_Mini_Utility::hasAdserving()): ?>
|
410 |
<p>
|
411 |
-
|
412 |
-
<script language="javascript">
|
413 |
-
if(!window.broadstreet_upgrade)
|
414 |
-
{
|
415 |
-
function broadstreet_upgrade()
|
416 |
-
{
|
417 |
-
window.send_to_editor = function(html) {
|
418 |
-
tb_remove();
|
419 |
-
alert('Save any unsaved widgets and refresh this page to see new upgraded options');
|
420 |
-
};
|
421 |
-
|
422 |
-
tb_show('Broadstreet', '<?php echo bs_get_base_url('views/modal/') ?>' + '?fake=fake&width=650&height=580&TB_iframe=true');
|
423 |
-
}
|
424 |
-
}
|
425 |
-
</script>
|
426 |
-
</p>
|
427 |
-
<?php elseif(isset($instance['bs_ad_id'])): ?>
|
428 |
-
<p>
|
429 |
-
Reporting: <a target="_blank" href="#" onclick="broadstreet_reports(); return false;">View stats for clicks and views</a>
|
430 |
-
<script language="javascript">
|
431 |
-
if(!window.broadstreet_reports)
|
432 |
-
{
|
433 |
-
function broadstreet_reports()
|
434 |
-
{
|
435 |
-
window.send_to_editor = function(html) {
|
436 |
-
tb_remove();
|
437 |
-
};
|
438 |
-
|
439 |
-
tb_show('Broadstreet', '<?php echo bs_get_base_url('views/modal/?step=reports&adv_id=' . @$instance['bs_adv_id'] . '&ad_id=' . @$instance['bs_ad_id']) ?>' + '&width=650&height=580&TB_iframe=true');
|
440 |
-
}
|
441 |
-
}
|
442 |
-
</script>
|
443 |
</p>
|
444 |
-
<?php endif; ?>
|
445 |
</div>
|
446 |
<?php
|
447 |
}
|
448 |
}
|
|
|
|
|
|
|
|
3 |
Plugin Name: Wordpress Ad Widget
|
4 |
Plugin URI: https://github.com/broadstreetads/wordpress-ad-widget
|
5 |
Description: The easiest way to place ads in your Wordpress sidebar. Go to Settings -> Ad Widget
|
6 |
+
Version: 2.1.1
|
7 |
Author: Broadstreet Ads
|
8 |
Author URI: http://broadstreetads.com
|
9 |
*/
|
10 |
|
|
|
|
|
11 |
add_action('admin_init', array('AdWidget_Core', 'registerScripts'));
|
12 |
add_action('widgets_init', array('AdWidget_Core', 'registerWidgets'));
|
13 |
add_action('admin_menu', array('AdWidget_Core', 'registerAdmin'));
|
17 |
*/
|
18 |
class AdWidget_Core
|
19 |
{
|
|
|
|
|
|
|
20 |
/**
|
21 |
* The callback used to register the scripts
|
22 |
*/
|
46 |
*/
|
47 |
public static function getBaseURL()
|
48 |
{
|
49 |
+
return (get_bloginfo('url') . '/wp-content/plugins/adwidget/');
|
50 |
}
|
51 |
|
52 |
/**
|
62 |
*/
|
63 |
static function adminMenuCallback()
|
64 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
include dirname(__FILE__) . '/views/admin.php';
|
66 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
|
92 |
|
93 |
echo $before_widget;
|
94 |
|
95 |
+
$instance['w_adcode'];
|
96 |
|
97 |
echo $after_widget;
|
98 |
}
|
107 |
{
|
108 |
$instance = $old_instance;
|
109 |
|
110 |
+
$instance['w_adcode'] = $new_instance['w_adcode'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
return $instance;
|
113 |
}
|
119 |
function form($instance)
|
120 |
{
|
121 |
|
122 |
+
$defaults = array('w_adcode' => '');
|
123 |
$instance = wp_parse_args((array) $instance, $defaults);
|
124 |
?>
|
125 |
<div class="widget-content">
|
127 |
<p>
|
128 |
<label for="<?php echo $this->get_field_id('w_adcode'); ?>">Ad Code</label>
|
129 |
<textarea style="height: 100px;" class="widefat" id="<?php echo $this->get_field_id( 'w_adcode' ); ?>" name="<?php echo $this->get_field_name('w_adcode'); ?>"><?php echo $instance['w_adcode']; ?></textarea>
|
|
|
|
|
|
|
|
|
130 |
</p>
|
131 |
</div>
|
132 |
<?php
|
156 |
{
|
157 |
extract($args);
|
158 |
|
159 |
+
$link = $instance['w_link'];
|
160 |
+
$img = $instance['w_img'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
echo $before_widget;
|
163 |
+
|
164 |
+
echo "<a target='_blank' href='$link' alt='Ad'><img style='width: 100%' src='$img' alt='Ad' /></a>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
echo $after_widget;
|
167 |
}
|
175 |
function update($new_instance, $old_instance)
|
176 |
{
|
177 |
$instance = $old_instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
+
$instance['w_link'] = $new_instance['w_link'];
|
180 |
+
$instance['w_img'] = $new_instance['w_img'];
|
|
|
|
|
|
|
|
|
181 |
|
182 |
return $instance;
|
183 |
}
|
190 |
{
|
191 |
$link_id = $this->get_field_id('w_link');
|
192 |
$img_id = $this->get_field_id('w_img');
|
193 |
+
|
194 |
|
195 |
+
$defaults = array('w_link' => get_bloginfo('url'), 'w_img' => '');
|
196 |
|
197 |
$instance = wp_parse_args((array) $instance, $defaults);
|
198 |
|
199 |
+
$img = $instance['w_img'];
|
200 |
$link = $instance['w_link'];
|
201 |
+
|
|
|
202 |
?>
|
203 |
<div class="widget-content">
|
204 |
<p style="text-align: center;" class="bs-proof">
|
205 |
<?php if($instance['w_img']): ?>
|
206 |
Your ad is ready.
|
207 |
<br/><br/><strong>Scaled Visual:</strong><br/>
|
208 |
+
<div class="bs-proof"><img style="width:100%;" src="<?php echo $instance['w_img'] ?>" alt="Ad" /></div>
|
209 |
+
<?php else: ?>
|
210 |
+
<a href="#" class="upload-button" rel="<?php echo $img_id ?>">Click here to upload a new image.</a> You can also paste in an image URL below.
|
211 |
<?php endif; ?>
|
|
|
|
|
212 |
</p>
|
213 |
<input class="widefat tag" placeholder="Image URL" type="text" id="<?php echo $img_id; ?>" name="<?php echo $this->get_field_name('w_img'); ?>" value="<?php echo htmlentities($instance['w_img']); ?>" />
|
214 |
<br/><br/>
|
216 |
<label for="<?php echo $this->get_field_id('w_link'); ?>">Ad Click Destination:</label><br/>
|
217 |
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_link'); ?>" name="<?php echo $this->get_field_name('w_link'); ?>" value="<?php echo $instance['w_link']; ?>" />
|
218 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
<p>
|
220 |
+
When you're ready for a more powerful adserver, visit <a target="_blank" href="http://broadstreetads.com/ad-platform/adserving/">Broadstreet</a>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
</p>
|
|
|
222 |
</div>
|
223 |
<?php
|
224 |
}
|
225 |
}
|
226 |
+
|
227 |
+
|
228 |
+
|
229 |
+
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: Broadstreet
|
|
3 |
Tags: wordpress,ad,widget,sidebar,google,tag,code
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.5.1
|
6 |
-
Stable tag: 2.
|
7 |
|
8 |
Easily upload ad images and ad code to your sidebar. For those that don't need or
|
9 |
want a complicated ad management system.
|
@@ -13,16 +13,15 @@ want a complicated ad management system.
|
|
13 |
This is the easiest way to place ads in your Wordpress site. Just drag a widget
|
14 |
to the sidebar, upload, an ad, and save.
|
15 |
|
16 |
-
Watch a short video demo: http://www.screenr.com/u0t7
|
17 |
-
|
18 |
* Extremely intuitive for beginners
|
19 |
* No clunky ad management interface
|
20 |
* Easily place image banner ads
|
21 |
* Easily place Google ad tags and other ad code
|
22 |
-
* Easily upgrade to **cloud-based adserving power** backed by [Broadstreet Ads](http://broadstreetads.com)
|
23 |
|
24 |
You will not find an easier way to run ads on your website!
|
25 |
|
|
|
|
|
26 |
== Demo ==
|
27 |
|
28 |
Watch a short video demo: http://www.screenr.com/u0t7
|
@@ -32,4 +31,4 @@ Watch a short video demo: http://www.screenr.com/u0t7
|
|
32 |
There aren't any special instructions for installing this plug-in. Once
|
33 |
installed, go to Appearance -> Widgets, and look for the "Ad Widget" widgets!
|
34 |
|
35 |
-
You can also go to Settings -> Ad Widget for a video demo on how to use it.
|
3 |
Tags: wordpress,ad,widget,sidebar,google,tag,code
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.5.1
|
6 |
+
Stable tag: 2.1.1
|
7 |
|
8 |
Easily upload ad images and ad code to your sidebar. For those that don't need or
|
9 |
want a complicated ad management system.
|
13 |
This is the easiest way to place ads in your Wordpress site. Just drag a widget
|
14 |
to the sidebar, upload, an ad, and save.
|
15 |
|
|
|
|
|
16 |
* Extremely intuitive for beginners
|
17 |
* No clunky ad management interface
|
18 |
* Easily place image banner ads
|
19 |
* Easily place Google ad tags and other ad code
|
|
|
20 |
|
21 |
You will not find an easier way to run ads on your website!
|
22 |
|
23 |
+
Watch a short video demo: http://www.screenr.com/u0t7
|
24 |
+
|
25 |
== Demo ==
|
26 |
|
27 |
Watch a short video demo: http://www.screenr.com/u0t7
|
31 |
There aren't any special instructions for installing this plug-in. Once
|
32 |
installed, go to Appearance -> Widgets, and look for the "Ad Widget" widgets!
|
33 |
|
34 |
+
You can also go to Settings -> Ad Widget for a video demo on how to use it.
|
trunk/adwidget.php
ADDED
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Wordpress Ad Widget
|
4 |
+
Plugin URI: https://github.com/broadstreetads/wordpress-ad-widget
|
5 |
+
Description: The easiest way to place ads in your Wordpress sidebar. Go to Settings -> Ad Widget
|
6 |
+
Version: 2.2.1
|
7 |
+
Author: Broadstreet Ads
|
8 |
+
Author URI: http://broadstreetads.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
require_once 'lib/Utility.php';
|
12 |
+
|
13 |
+
add_action('admin_init', array('AdWidget_Core', 'registerScripts'));
|
14 |
+
add_action('widgets_init', array('AdWidget_Core', 'registerWidgets'));
|
15 |
+
add_action('admin_menu', array('AdWidget_Core', 'registerAdmin'));
|
16 |
+
|
17 |
+
/**
|
18 |
+
* This class is the core of Ad Widget
|
19 |
+
*/
|
20 |
+
class AdWidget_Core
|
21 |
+
{
|
22 |
+
CONST KEY_INSTALL_REPORT = 'AdWidget_Installed';
|
23 |
+
CONST VERSION = '2.2.1';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* The callback used to register the scripts
|
27 |
+
*/
|
28 |
+
static function registerScripts()
|
29 |
+
{
|
30 |
+
# Include thickbox on widgets page
|
31 |
+
if($GLOBALS['pagenow'] == 'widgets.php')
|
32 |
+
{
|
33 |
+
wp_enqueue_script('thickbox');
|
34 |
+
wp_enqueue_style('thickbox');
|
35 |
+
wp_enqueue_script('adwidget-main', self::getBaseURL().'assets/widgets.js');
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* The callback used to register the widget
|
41 |
+
*/
|
42 |
+
static function registerWidgets()
|
43 |
+
{
|
44 |
+
register_widget('AdWidget_HTMLWidget');
|
45 |
+
register_widget('AdWidget_ImageWidget');
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get the base URL of the plugin installation
|
50 |
+
* @return string the base URL
|
51 |
+
*/
|
52 |
+
public static function getBaseURL()
|
53 |
+
{
|
54 |
+
return (get_bloginfo('url') . '/wp-content/plugins/ad-widget/');
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Register the admin settings page
|
59 |
+
*/
|
60 |
+
static function registerAdmin()
|
61 |
+
{
|
62 |
+
add_options_page('Ad Widget', 'Ad Widget', 'edit_pages', 'adwidget.php', array(__CLASS__, 'adminMenuCallback'));
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* The function used by WP to print the admin settings page
|
67 |
+
*/
|
68 |
+
static function adminMenuCallback()
|
69 |
+
{
|
70 |
+
self::sendInstallReportIfNew();
|
71 |
+
|
72 |
+
if(isset($_POST['cancel']))
|
73 |
+
Broadstreet_Mini_Utility::hasAdserving(false);
|
74 |
+
|
75 |
+
if(isset($_POST['subscribe']))
|
76 |
+
Broadstreet_Mini_Utility::hasAdserving(true);
|
77 |
+
|
78 |
+
include dirname(__FILE__) . '/views/admin.php';
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Makes a call to the Broadstreet service to collect information information
|
83 |
+
* on the blog in case of errors and other needs.
|
84 |
+
*/
|
85 |
+
public static function sendReport($message = 'General')
|
86 |
+
{
|
87 |
+
|
88 |
+
$report = "$message\n";
|
89 |
+
$report .= get_bloginfo('name'). "\n";
|
90 |
+
$report .= get_bloginfo('url'). "\n";
|
91 |
+
$report .= get_bloginfo('admin_email'). "\n";
|
92 |
+
$report .= 'WP Version: ' . get_bloginfo('version'). "\n";
|
93 |
+
$report .= 'Plugin Version: ' . self::VERSION . "\n";
|
94 |
+
$report .= "$message\n";
|
95 |
+
|
96 |
+
@wp_mail('plugin@broadstreetads.com', "Report: $message", $report);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* If this is a new installation and we've never sent a report to the
|
101 |
+
* Broadstreet server, send a packet of basic info about this blog in case
|
102 |
+
* issues should arise in the future.
|
103 |
+
*/
|
104 |
+
public static function sendInstallReportIfNew()
|
105 |
+
{
|
106 |
+
$install_key = self::KEY_INSTALL_REPORT;
|
107 |
+
$upgrade_key = self::KEY_INSTALL_REPORT .'_'. self::VERSION;
|
108 |
+
|
109 |
+
$installed = self::getOption($install_key);
|
110 |
+
$upgraded = self::getOption($upgrade_key);
|
111 |
+
|
112 |
+
$sent = ($installed && $upgraded);
|
113 |
+
|
114 |
+
if($sent === FALSE)
|
115 |
+
{
|
116 |
+
if(!$installed)
|
117 |
+
{
|
118 |
+
self::sendReport("Installation");
|
119 |
+
self::setOption($install_key, 'true');
|
120 |
+
self::setOption($upgrade_key, 'true');
|
121 |
+
}
|
122 |
+
else
|
123 |
+
{
|
124 |
+
self::sendReport("Upgrade");
|
125 |
+
self::setOption($upgrade_key, 'true');
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Sets a Wordpress option
|
132 |
+
* @param string $name The name of the option to set
|
133 |
+
* @param string $value The value of the option to set
|
134 |
+
*/
|
135 |
+
public static function setOption($name, $value)
|
136 |
+
{
|
137 |
+
if (get_option($name) !== FALSE)
|
138 |
+
{
|
139 |
+
update_option($name, $value);
|
140 |
+
}
|
141 |
+
else
|
142 |
+
{
|
143 |
+
$deprecated = ' ';
|
144 |
+
$autoload = 'yes';
|
145 |
+
add_option($name, $value, $deprecated, $autoload);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Gets a Wordpress option
|
151 |
+
* @param string $name The name of the option
|
152 |
+
* @param mixed $default The default value to return if one doesn't exist
|
153 |
+
* @return string The value if the option does exist
|
154 |
+
*/
|
155 |
+
public static function getOption($name, $default = FALSE)
|
156 |
+
{
|
157 |
+
$value = get_option($name);
|
158 |
+
if( $value !== FALSE ) return $value;
|
159 |
+
return $default;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
/**
|
165 |
+
* The HTML Widget
|
166 |
+
*/
|
167 |
+
class AdWidget_HTMLWidget extends WP_Widget
|
168 |
+
{
|
169 |
+
/**
|
170 |
+
* Set the widget options
|
171 |
+
*/
|
172 |
+
function AdWidget_HTMLWidget()
|
173 |
+
{
|
174 |
+
$widget_ops = array('classname' => 'AdWidget_HTMLWidget', 'description' => 'Place an ad code like Google ads or other ad provider');
|
175 |
+
$this->WP_Widget('AdWidget_HTMLWidget', 'Ad: HTML/Javascript Ad', $widget_ops);
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Display the widget on the sidebar
|
180 |
+
* @param array $args
|
181 |
+
* @param array $instance
|
182 |
+
*/
|
183 |
+
function widget($args, $instance)
|
184 |
+
{
|
185 |
+
extract($args);
|
186 |
+
|
187 |
+
echo $before_widget;
|
188 |
+
|
189 |
+
echo "<div style='text-align: center;'>{$instance['w_adcode']}</div>";
|
190 |
+
|
191 |
+
echo $after_widget;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Update the widget info from the admin panel
|
196 |
+
* @param array $new_instance
|
197 |
+
* @param array $old_instance
|
198 |
+
* @return array
|
199 |
+
*/
|
200 |
+
function update($new_instance, $old_instance)
|
201 |
+
{
|
202 |
+
$instance = $old_instance;
|
203 |
+
|
204 |
+
$instance['w_adcode'] = $new_instance['w_adcode'];
|
205 |
+
$instance['w_adv'] = $new_instance['w_adv'];
|
206 |
+
|
207 |
+
/* New ad? Upload it to Broadstreet */
|
208 |
+
if($instance['w_adcode'] && Broadstreet_Mini_Utility::hasAdserving()) {
|
209 |
+
|
210 |
+
$advertisement_id = false;
|
211 |
+
# New ad?
|
212 |
+
if(is_numeric(@$instance['bs_ad_id'])) $advertisement_id = $instance['bs_ad_id'];
|
213 |
+
|
214 |
+
# New advertiser?
|
215 |
+
if(!$advertisement_id) {
|
216 |
+
$api = Broadstreet_Mini_Utility::getClient();
|
217 |
+
$adv = $api->createAdvertiser(Broadstreet_Mini_Utility::getNetworkID(), $instance['w_adv']);
|
218 |
+
$instance['bs_adv_id'] = $adv->id;
|
219 |
+
}
|
220 |
+
|
221 |
+
$ad = Broadstreet_Mini_Utility::importHTMLAd(Broadstreet_Mini_Utility::getNetworkID(),
|
222 |
+
$instance['bs_adv_id'],
|
223 |
+
$instance['w_adcode'],
|
224 |
+
$advertisement_id);
|
225 |
+
|
226 |
+
if(!$advertisement_id) {
|
227 |
+
$instance['bs_ad_html'] = $ad->html;
|
228 |
+
$instance['bs_ad_id'] = $ad->id;
|
229 |
+
$instance['bs_adv_id'] = $adv->id;
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
return $instance;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Display the widget update form
|
238 |
+
* @param array $instance
|
239 |
+
*/
|
240 |
+
function form($instance)
|
241 |
+
{
|
242 |
+
|
243 |
+
$defaults = array('w_adcode' => '', 'w_adv' => 'New Advertiser');
|
244 |
+
$instance = wp_parse_args((array) $instance, $defaults);
|
245 |
+
?>
|
246 |
+
<div class="widget-content">
|
247 |
+
<p>Paste your Google ad tag, or any other ad tag in this widget below.</p>
|
248 |
+
<p>
|
249 |
+
<label for="<?php echo $this->get_field_id('w_adcode'); ?>">Ad Code</label>
|
250 |
+
<textarea style="height: 100px;" class="widefat" id="<?php echo $this->get_field_id( 'w_adcode' ); ?>" name="<?php echo $this->get_field_name('w_adcode'); ?>"><?php echo $instance['w_adcode']; ?></textarea>
|
251 |
+
</p>
|
252 |
+
<p>
|
253 |
+
<label for="<?php echo $this->get_field_id('w_adv'); ?>">Advertiser Name</label>
|
254 |
+
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_adv'); ?>" name="<?php echo $this->get_field_name('w_adv'); ?>" value="<?php echo $instance['w_adv']; ?>" />
|
255 |
+
</p>
|
256 |
+
</div>
|
257 |
+
<?php
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* This is an optional widget to display GitHub projects
|
263 |
+
*/
|
264 |
+
class AdWidget_ImageWidget extends WP_Widget
|
265 |
+
{
|
266 |
+
/**
|
267 |
+
* Set the widget options
|
268 |
+
*/
|
269 |
+
function AdWidget_ImageWidget()
|
270 |
+
{
|
271 |
+
$widget_ops = array('classname' => 'AdWidget_ImageWidget', 'description' => 'Place an image ad with a link');
|
272 |
+
$this->WP_Widget('AdWidget_ImageWidget', 'Ad: Image/Banner Ad', $widget_ops);
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Display the widget on the sidebar
|
277 |
+
* @param array $args
|
278 |
+
* @param array $instance
|
279 |
+
*/
|
280 |
+
function widget($args, $instance)
|
281 |
+
{
|
282 |
+
extract($args);
|
283 |
+
|
284 |
+
$link = @$instance['w_link'];
|
285 |
+
$img = @$instance['w_img'];
|
286 |
+
$resize = @$instance['w_resize'];
|
287 |
+
$id = rand(1, 100000);
|
288 |
+
|
289 |
+
if($resize == 'yes')
|
290 |
+
{
|
291 |
+
$resize_s = "style='width: 100%;'";
|
292 |
+
}
|
293 |
+
else
|
294 |
+
{
|
295 |
+
$resize_s = '';
|
296 |
+
}
|
297 |
+
|
298 |
+
echo $before_widget;
|
299 |
+
|
300 |
+
if(!$img)
|
301 |
+
{
|
302 |
+
$img = AdWidget_Core::getBaseURL() . 'assets/sample-ad.png';
|
303 |
+
$link = 'http://adsofthefuture.com';
|
304 |
+
}
|
305 |
+
|
306 |
+
if(Broadstreet_Mini_Utility::hasAdserving() && is_numeric($instance['bs_ad_id']))
|
307 |
+
{
|
308 |
+
if($resize == 'yes') echo '<style type="text/css">.adwidget-id'.$id.' img { width: 100% !important; height: auto !important; }</style>';
|
309 |
+
echo "<span class='adwidget-id$id'>{$instance['bs_ad_html']}</span>";
|
310 |
+
}
|
311 |
+
else
|
312 |
+
{
|
313 |
+
echo "<a target='_blank' href='$link' alt='Ad'><img $resize_s src='$img' alt='Ad' /></a>";
|
314 |
+
}
|
315 |
+
|
316 |
+
echo $after_widget;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Update the widget info from the admin panel
|
321 |
+
* @param array $new_instance
|
322 |
+
* @param array $old_instance
|
323 |
+
* @return array
|
324 |
+
*/
|
325 |
+
function update($new_instance, $old_instance)
|
326 |
+
{
|
327 |
+
$instance = $old_instance;
|
328 |
+
|
329 |
+
$changed = ($instance['w_img'] != $new_instance['w_img']
|
330 |
+
|| $instance['w_link'] !== $new_instance['w_link']);
|
331 |
+
|
332 |
+
$instance['w_link'] = $new_instance['w_link'];
|
333 |
+
$instance['w_img'] = $new_instance['w_img'];
|
334 |
+
$instance['w_resize'] = @$new_instance['w_resize'];
|
335 |
+
$instance['w_adv'] = $new_instance['w_adv'];
|
336 |
+
|
337 |
+
/* New ad? Upload it to Broadstreet */
|
338 |
+
if($instance['w_img'] && $changed && Broadstreet_Mini_Utility::hasAdserving()) {
|
339 |
+
|
340 |
+
$advertisement_id = false;
|
341 |
+
# New ad?
|
342 |
+
if(is_numeric(@$instance['bs_ad_id'])) $advertisement_id = $instance['bs_ad_id'];
|
343 |
+
|
344 |
+
# New advertiser?
|
345 |
+
if(!$advertisement_id) {
|
346 |
+
$api = Broadstreet_Mini_Utility::getClient();
|
347 |
+
$adv = $api->createAdvertiser(Broadstreet_Mini_Utility::getNetworkID(), $instance['w_adv']);
|
348 |
+
$instance['bs_adv_id'] = $adv->id;
|
349 |
+
}
|
350 |
+
|
351 |
+
$ad = Broadstreet_Mini_Utility::importImageAd(Broadstreet_Mini_Utility::getNetworkID(),
|
352 |
+
$instance['bs_adv_id'],
|
353 |
+
$instance['w_img'],
|
354 |
+
$instance['w_link'],
|
355 |
+
$advertisement_id);
|
356 |
+
|
357 |
+
if(!$advertisement_id) {
|
358 |
+
$instance['bs_ad_html'] = $ad->html;
|
359 |
+
$instance['bs_ad_id'] = $ad->id;
|
360 |
+
$instance['bs_adv_id'] = $adv->id;
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
return $instance;
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Display the widget update form
|
369 |
+
* @param array $instance
|
370 |
+
*/
|
371 |
+
function form($instance)
|
372 |
+
{
|
373 |
+
$link_id = $this->get_field_id('w_link');
|
374 |
+
$img_id = $this->get_field_id('w_img');
|
375 |
+
|
376 |
+
$defaults = array('w_link' => get_bloginfo('url'), 'w_img' => '', 'w_adv' => 'New Advertiser', 'w_resize' => 'no');
|
377 |
+
|
378 |
+
$instance = wp_parse_args((array) $instance, $defaults);
|
379 |
+
|
380 |
+
$img = $instance['w_img'];
|
381 |
+
$link = $instance['w_link'];
|
382 |
+
$adv = $instance['w_adv'];
|
383 |
+
|
384 |
+
?>
|
385 |
+
<div class="widget-content">
|
386 |
+
<p style="text-align: center;" class="bs-proof">
|
387 |
+
<?php if($instance['w_img']): ?>
|
388 |
+
Your ad is ready.
|
389 |
+
<br/><br/><strong>Scaled Visual:</strong><br/>
|
390 |
+
<div class="bs-proof"><img style="width:100%;" src="<?php echo $instance['w_img'] ?>" alt="Ad" /></div><br/>
|
391 |
+
<?php endif; ?>
|
392 |
+
<a href="#" class="upload-button" rel="<?php echo $img_id ?>">Click here to upload a new image.</a> You can also paste in an image URL below.
|
393 |
+
|
394 |
+
</p>
|
395 |
+
<input class="widefat tag" placeholder="Image URL" type="text" id="<?php echo $img_id; ?>" name="<?php echo $this->get_field_name('w_img'); ?>" value="<?php echo htmlentities($instance['w_img']); ?>" />
|
396 |
+
<br/><br/>
|
397 |
+
<p>
|
398 |
+
<label for="<?php echo $this->get_field_id('w_link'); ?>">Ad Click Destination:</label><br/>
|
399 |
+
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_link'); ?>" name="<?php echo $this->get_field_name('w_link'); ?>" value="<?php echo $instance['w_link']; ?>" />
|
400 |
+
</p>
|
401 |
+
<p>
|
402 |
+
<label for="<?php echo $this->get_field_id('w_adv'); ?>">Advertiser Name:</label><br/>
|
403 |
+
<input class="widefat" type="text" id="<?php echo $this->get_field_id('w_adv'); ?>" name="<?php echo $this->get_field_name('w_adv'); ?>" value="<?php echo $instance['w_adv']; ?>" />
|
404 |
+
</p>
|
405 |
+
<p>
|
406 |
+
<label for="<?php echo $this->get_field_id('w_resize'); ?>">Auto Resize to Max Width? </label>
|
407 |
+
<input type="checkbox" name="<?php echo $this->get_field_name('w_resize'); ?>" value="yes" <?php if($instance['w_resize'] == 'yes') echo 'checked'; ?> />
|
408 |
+
</p>
|
409 |
+
<?php if(!Broadstreet_Mini_Utility::hasAdserving()): ?>
|
410 |
+
<p>
|
411 |
+
<span style="color: green; font-weight: bold;">New!</span> When you're ready for a more powerful adserver with click reporting <a target="_blank" href="#" onclick="broadstreet_upgrade(); return false;">click here</a>.
|
412 |
+
<script language="javascript">
|
413 |
+
if(!window.broadstreet_upgrade)
|
414 |
+
{
|
415 |
+
function broadstreet_upgrade()
|
416 |
+
{
|
417 |
+
window.send_to_editor = function(html) {
|
418 |
+
tb_remove();
|
419 |
+
alert('Save any unsaved widgets and refresh this page to see new upgraded options');
|
420 |
+
};
|
421 |
+
|
422 |
+
tb_show('Broadstreet', '<?php echo bs_get_base_url('views/modal/') ?>' + '?fake=fake&width=650&height=580&TB_iframe=true');
|
423 |
+
}
|
424 |
+
}
|
425 |
+
</script>
|
426 |
+
</p>
|
427 |
+
<?php elseif(isset($instance['bs_ad_id'])): ?>
|
428 |
+
<p>
|
429 |
+
Reporting: <a target="_blank" href="#" onclick="broadstreet_reports(); return false;">View stats for clicks and views</a>
|
430 |
+
<script language="javascript">
|
431 |
+
if(!window.broadstreet_reports)
|
432 |
+
{
|
433 |
+
function broadstreet_reports()
|
434 |
+
{
|
435 |
+
window.send_to_editor = function(html) {
|
436 |
+
tb_remove();
|
437 |
+
};
|
438 |
+
|
439 |
+
tb_show('Broadstreet', '<?php echo bs_get_base_url('views/modal/?step=reports&adv_id=' . @$instance['bs_adv_id'] . '&ad_id=' . @$instance['bs_ad_id']) ?>' + '&width=650&height=580&TB_iframe=true');
|
440 |
+
}
|
441 |
+
}
|
442 |
+
</script>
|
443 |
+
</p>
|
444 |
+
<?php endif; ?>
|
445 |
+
</div>
|
446 |
+
<?php
|
447 |
+
}
|
448 |
+
}
|
{assets → trunk/assets}/sample-ad.png
RENAMED
File without changes
|
trunk/assets/widgets.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function($) {
|
2 |
+
$('.upload-button').live('click', function(e) {
|
3 |
+
window.adcode_id = $(e.target).attr('rel');
|
4 |
+
window.send_to_editor = image_upload_handler;
|
5 |
+
|
6 |
+
tb_show('', 'media-upload.php?type=image&amp;amp;TB_iframe=true');
|
7 |
+
|
8 |
+
return false;
|
9 |
+
});
|
10 |
+
|
11 |
+
function image_upload_handler(html) {
|
12 |
+
imgurl = $('img',html).attr('src');
|
13 |
+
if(!imgurl) imgurl = $(html).attr('src');
|
14 |
+
|
15 |
+
$('#' + window.adcode_id).val(imgurl);
|
16 |
+
|
17 |
+
tb_remove();
|
18 |
+
};
|
19 |
+
});
|
{lib → trunk/lib}/Broadstreet.php
RENAMED
File without changes
|
{lib → trunk/lib}/Utility.php
RENAMED
@@ -302,9 +302,12 @@ class Broadstreet_Mini_Utility
|
|
302 |
public static function importImageAd($network_id, $advertiser_id, $image_url, $link, $advertisement_id = false) {
|
303 |
$api = self::getClient();
|
304 |
|
|
|
|
|
|
|
305 |
$params = array();
|
306 |
$params['name'] = 'WordPress Widget Ad ' . date('Y-m-d H:i:s');
|
307 |
-
$params['active_base64'] = base64_encode(
|
308 |
$params['destination'] = $link;
|
309 |
|
310 |
try {
|
302 |
public static function importImageAd($network_id, $advertiser_id, $image_url, $link, $advertisement_id = false) {
|
303 |
$api = self::getClient();
|
304 |
|
305 |
+
$img = wp_remote_get($image_url);
|
306 |
+
$img = $img['body'];
|
307 |
+
|
308 |
$params = array();
|
309 |
$params['name'] = 'WordPress Widget Ad ' . date('Y-m-d H:i:s');
|
310 |
+
$params['active_base64'] = base64_encode($img);
|
311 |
$params['destination'] = $link;
|
312 |
|
313 |
try {
|
trunk/readme.txt
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: Broadstreet
|
3 |
+
Tags: wordpress,ad,widget,sidebar,google,tag,code
|
4 |
+
Requires at least: 3.0
|
5 |
+
Tested up to: 3.5.1
|
6 |
+
Stable tag: 2.2.1
|
7 |
+
|
8 |
+
Easily upload ad images and ad code to your sidebar. For those that don't need or
|
9 |
+
want a complicated ad management system.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
This is the easiest way to place ads in your Wordpress site. Just drag a widget
|
14 |
+
to the sidebar, upload, an ad, and save.
|
15 |
+
|
16 |
+
Watch a short video demo: http://www.screenr.com/u0t7
|
17 |
+
|
18 |
+
* Extremely intuitive for beginners
|
19 |
+
* No clunky ad management interface
|
20 |
+
* Easily place image banner ads
|
21 |
+
* Easily place Google ad tags and other ad code
|
22 |
+
* Easily upgrade to **cloud-based adserving power** backed by [Broadstreet Ads](http://broadstreetads.com)
|
23 |
+
|
24 |
+
You will not find an easier way to run ads on your website!
|
25 |
+
|
26 |
+
== Demo ==
|
27 |
+
|
28 |
+
Watch a short video demo: http://www.screenr.com/u0t7
|
29 |
+
|
30 |
+
== Installation ==
|
31 |
+
|
32 |
+
There aren't any special instructions for installing this plug-in. Once
|
33 |
+
installed, go to Appearance -> Widgets, and look for the "Ad Widget" widgets!
|
34 |
+
|
35 |
+
You can also go to Settings -> Ad Widget for a video demo on how to use it.
|
trunk/views/admin.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div style="float: left; width: 650px;">
|
2 |
+
<script>(function(d, s, id) {
|
3 |
+
var js, fjs = d.getElementsByTagName(s)[0];
|
4 |
+
if (d.getElementById(id)) return;
|
5 |
+
js = d.createElement(s); js.id = id;
|
6 |
+
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=313569238757581";
|
7 |
+
fjs.parentNode.insertBefore(js, fjs);
|
8 |
+
}(document, 'script', 'facebook-jssdk'));</script>
|
9 |
+
<script>window.admin_email = '<?php bloginfo('admin_email'); ?>';</script>
|
10 |
+
<script>
|
11 |
+
jQuery(function() {
|
12 |
+
var bs = new Broadstreet.Network();
|
13 |
+
bs.postList('#bs-blog');
|
14 |
+
});
|
15 |
+
</script>
|
16 |
+
|
17 |
+
<h1>Wordpress Ad Widget</h1>
|
18 |
+
<script src="https://broadstreet-common.s3.amazonaws.com/broadstreet-net/init.js"></script>
|
19 |
+
<script type="text/javascript" src="http://cdn.broadstreetads.com/init.js"></script>
|
20 |
+
<script type="text/javascript">broadstreet.zone(423);</script>
|
21 |
+
|
22 |
+
<?php if(Broadstreet_Mini_Utility::hasAdserving()): ?>
|
23 |
+
|
24 |
+
<h2>Adserver Subscription</h2>
|
25 |
+
|
26 |
+
You are currently subscribed to Broadstreet's Adserver, giving your site stress-free adserving,
|
27 |
+
and click/view reporting. You can cancel this subscription here. Canceling will revert
|
28 |
+
your ads to start serving from your site instead of an adserver.
|
29 |
+
|
30 |
+
<form method="post">
|
31 |
+
<input style="background-color: red; color: white;" type="submit" name="cancel" value="Cancel Adserving Subscription">
|
32 |
+
</form>
|
33 |
+
|
34 |
+
<?php endif; ?>
|
35 |
+
|
36 |
+
<?php if(!Broadstreet_Mini_Utility::hasAdserving() && Broadstreet_Mini_Utility::hasNetwork()): ?>
|
37 |
+
|
38 |
+
<h2>Adserver Subscription</h2>
|
39 |
+
|
40 |
+
You were once subscribed to Broadstreet's Adserver, giving your site stress-free adserving,
|
41 |
+
and click/view reporting. You can re-enable your subscription here. Changes will
|
42 |
+
be immediate.
|
43 |
+
|
44 |
+
<form method="post">
|
45 |
+
<input style="background-color: green; color: white;" type="submit" name="subscribe" value="Subscribe me for $5 / month">
|
46 |
+
</form>
|
47 |
+
|
48 |
+
<?php endif; ?>
|
49 |
+
|
50 |
+
<p>Thank you for using our plugin! This plugin was built by <a href="http://broadstreetads.com">Broadstreet</a>, the
|
51 |
+
company for independent publishers.</p>
|
52 |
+
|
53 |
+
<p>If you're a local publisher, please <strong><a href="http://broadstreetads.us5.list-manage.com/subscribe?u=508de363fda633d674a0a123b&id=e2fbcef169">sign up for our newsletter</a></strong>, and join the community.</p>
|
54 |
+
|
55 |
+
<p>To put an ad on your website, just go to <a href="widgets.php">the widgets page</a>,
|
56 |
+
and look for:</p>
|
57 |
+
|
58 |
+
<ul>
|
59 |
+
<li><strong>Ad: HTML/Javascript Ad</strong></li>
|
60 |
+
<li><strong>Ad: Image/Banner Ad</strong></li>
|
61 |
+
</ul>
|
62 |
+
|
63 |
+
<p>
|
64 |
+
Drag one of those into your a widget area, like a sidebar, and follow the
|
65 |
+
instructions! Send questions to kenny@broadstreetads.com .
|
66 |
+
</p>
|
67 |
+
|
68 |
+
<p>
|
69 |
+
Here's a short instructional video if you need help:
|
70 |
+
</p>
|
71 |
+
|
72 |
+
<iframe src="http://www.screenr.com/embed/u0t7" width="650" height="396" frameborder="0"></iframe>
|
73 |
+
|
74 |
+
</div>
|
75 |
+
|
76 |
+
<div style="float: right; width: 250px; margin-top: 150px;">
|
77 |
+
<h2>The Streetlight</h2>
|
78 |
+
<p>A blog for local news publishers</p>
|
79 |
+
<div id="bs-blog"></div>
|
80 |
+
|
81 |
+
<div>
|
82 |
+
<div class="fb-like" data-href="http://www.facebook.com/broadstreetads" data-send="false" data-layout="box_count" data-width="450" data-show-faces="true"></div>
|
83 |
+
<a href="https://twitter.com/broadstreetads" class="twitter-follow-button" data-show-count="false">Follow @broadstreetads</a>
|
84 |
+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
85 |
+
</div>
|
86 |
+
|
87 |
+
</div>
|
88 |
+
|
89 |
+
<div style="clear:both;"></div>
|
{views → trunk/views}/modal/footer.php
RENAMED
File without changes
|
{views → trunk/views}/modal/header.php
RENAMED
File without changes
|
{views → trunk/views}/modal/index.php
RENAMED
File without changes
|
{views → trunk/views}/modal/reports.php
RENAMED
File without changes
|
{views → trunk/views}/modal/signedup.php
RENAMED
File without changes
|
{views → trunk/views}/modal/signup.php
RENAMED
File without changes
|
views/admin.php
CHANGED
@@ -1,52 +1,10 @@
|
|
1 |
-
<div style="
|
2 |
-
<script>(function(d, s, id) {
|
3 |
-
var js, fjs = d.getElementsByTagName(s)[0];
|
4 |
-
if (d.getElementById(id)) return;
|
5 |
-
js = d.createElement(s); js.id = id;
|
6 |
-
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=313569238757581";
|
7 |
-
fjs.parentNode.insertBefore(js, fjs);
|
8 |
-
}(document, 'script', 'facebook-jssdk'));</script>
|
9 |
-
<script>window.admin_email = '<?php bloginfo('admin_email'); ?>';</script>
|
10 |
-
<script>
|
11 |
-
jQuery(function() {
|
12 |
-
var bs = new Broadstreet.Network();
|
13 |
-
bs.postList('#bs-blog');
|
14 |
-
});
|
15 |
-
</script>
|
16 |
|
17 |
<h1>Wordpress Ad Widget</h1>
|
18 |
-
|
19 |
<script type="text/javascript" src="http://cdn.broadstreetads.com/init.js"></script>
|
20 |
<script type="text/javascript">broadstreet.zone(423);</script>
|
21 |
|
22 |
-
<?php if(Broadstreet_Mini_Utility::hasAdserving()): ?>
|
23 |
-
|
24 |
-
<h2>Adserver Subscription</h2>
|
25 |
-
|
26 |
-
You are currently subscribed to Broadstreet's Adserver, giving your site stress-free adserving,
|
27 |
-
and click/view reporting. You can cancel this subscription here. Canceling will revert
|
28 |
-
your ads to start serving from your site instead of an adserver.
|
29 |
-
|
30 |
-
<form method="post">
|
31 |
-
<input style="background-color: red; color: white;" type="submit" name="cancel" value="Cancel Adserving Subscription">
|
32 |
-
</form>
|
33 |
-
|
34 |
-
<?php endif; ?>
|
35 |
-
|
36 |
-
<?php if(!Broadstreet_Mini_Utility::hasAdserving() && Broadstreet_Mini_Utility::hasNetwork()): ?>
|
37 |
-
|
38 |
-
<h2>Adserver Subscription</h2>
|
39 |
-
|
40 |
-
You were once subscribed to Broadstreet's Adserver, giving your site stress-free adserving,
|
41 |
-
and click/view reporting. You can re-enable your subscription here. Changes will
|
42 |
-
be immediate.
|
43 |
-
|
44 |
-
<form method="post">
|
45 |
-
<input style="background-color: green; color: white;" type="submit" name="subscribe" value="Subscribe me for $5 / month">
|
46 |
-
</form>
|
47 |
-
|
48 |
-
<?php endif; ?>
|
49 |
-
|
50 |
<p>Thank you for using our plugin! This plugin was built by <a href="http://broadstreetads.com">Broadstreet</a>, the
|
51 |
company for independent publishers.</p>
|
52 |
|
@@ -71,19 +29,4 @@ Here's a short instructional video if you need help:
|
|
71 |
|
72 |
<iframe src="http://www.screenr.com/embed/u0t7" width="650" height="396" frameborder="0"></iframe>
|
73 |
|
74 |
-
</div>
|
75 |
-
|
76 |
-
<div style="float: right; width: 250px; margin-top: 150px;">
|
77 |
-
<h2>The Streetlight</h2>
|
78 |
-
<p>A blog for local news publishers</p>
|
79 |
-
<div id="bs-blog"></div>
|
80 |
-
|
81 |
-
<div>
|
82 |
-
<div class="fb-like" data-href="http://www.facebook.com/broadstreetads" data-send="false" data-layout="box_count" data-width="450" data-show-faces="true"></div>
|
83 |
-
<a href="https://twitter.com/broadstreetads" class="twitter-follow-button" data-show-count="false">Follow @broadstreetads</a>
|
84 |
-
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
85 |
-
</div>
|
86 |
-
|
87 |
-
</div>
|
88 |
-
|
89 |
-
<div style="clear:both;"></div>
|
1 |
+
<div style="width: 650px;">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
<h1>Wordpress Ad Widget</h1>
|
4 |
+
|
5 |
<script type="text/javascript" src="http://cdn.broadstreetads.com/init.js"></script>
|
6 |
<script type="text/javascript">broadstreet.zone(423);</script>
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
<p>Thank you for using our plugin! This plugin was built by <a href="http://broadstreetads.com">Broadstreet</a>, the
|
9 |
company for independent publishers.</p>
|
10 |
|
29 |
|
30 |
<iframe src="http://www.screenr.com/embed/u0t7" width="650" height="396" frameborder="0"></iframe>
|
31 |
|
32 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|