Version Description
Download this release
Release Info
Developer | broadstreetads |
Plugin | WordPress Ad Widget |
Version | 2.5.1 |
Comparing to | |
See all releases |
Code changes from version 2.5.0 to 2.5.1
- adwidget.php +16 -16
- lib/Broadstreet.php +29 -4
- lib/Utility.php +29 -29
- readme.txt +2 -2
- views/admin.php +2 -2
- views/modal/index.php +5 -5
- views/modal/reports.php +2 -2
- views/modal/signup.php +1 -1
adwidget.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.5.
|
7 |
Author: Broadstreet Ads
|
8 |
Author URI: http://broadstreetads.com
|
9 |
*/
|
@@ -20,7 +20,7 @@ add_action('admin_menu', array('AdWidget_Core', 'registerAdmin'));
|
|
20 |
class AdWidget_Core
|
21 |
{
|
22 |
CONST KEY_INSTALL_REPORT = 'AdWidget_Installed';
|
23 |
-
CONST VERSION = '2.5.
|
24 |
|
25 |
/**
|
26 |
* The callback used to register the scripts
|
@@ -70,10 +70,10 @@ class AdWidget_Core
|
|
70 |
self::sendInstallReportIfNew();
|
71 |
|
72 |
if(isset($_POST['cancel']))
|
73 |
-
|
74 |
|
75 |
if(isset($_POST['subscribe']))
|
76 |
-
|
77 |
|
78 |
include dirname(__FILE__) . '/views/admin.php';
|
79 |
}
|
@@ -205,7 +205,7 @@ class AdWidget_HTMLWidget extends WP_Widget
|
|
205 |
$instance['w_adv'] = $new_instance['w_adv'];
|
206 |
|
207 |
/* New ad? Upload it to Broadstreet */
|
208 |
-
if($instance['w_adcode'] &&
|
209 |
|
210 |
$advertisement_id = false;
|
211 |
# New ad?
|
@@ -213,12 +213,12 @@ class AdWidget_HTMLWidget extends WP_Widget
|
|
213 |
|
214 |
# New advertiser?
|
215 |
if(!$advertisement_id) {
|
216 |
-
$api =
|
217 |
-
$adv = $api->createAdvertiser(
|
218 |
$instance['bs_adv_id'] = $adv->id;
|
219 |
}
|
220 |
|
221 |
-
$ad =
|
222 |
$instance['bs_adv_id'],
|
223 |
$instance['w_adcode'],
|
224 |
$advertisement_id);
|
@@ -314,7 +314,7 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
314 |
$link = 'http://adsofthefuture.com';
|
315 |
}
|
316 |
|
317 |
-
if(
|
318 |
{
|
319 |
if($resize == 'yes') echo '<style type="text/css">.adwidget-id'.$id.' img { width: 100% !important; height: auto !important; }</style>';
|
320 |
echo "<span class='adwidget-id$id'>{$instance['bs_ad_html']}</span>";
|
@@ -347,7 +347,7 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
347 |
$instance['w_adv'] = $new_instance['w_adv'];
|
348 |
|
349 |
/* New ad? Upload it to Broadstreet */
|
350 |
-
if($instance['w_img'] && $changed &&
|
351 |
|
352 |
$advertisement_id = false;
|
353 |
# New ad?
|
@@ -355,12 +355,12 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
355 |
|
356 |
# New advertiser?
|
357 |
if(!$advertisement_id) {
|
358 |
-
$api =
|
359 |
-
$adv = $api->createAdvertiser(
|
360 |
$instance['bs_adv_id'] = $adv->id;
|
361 |
}
|
362 |
|
363 |
-
$ad =
|
364 |
$instance['bs_adv_id'],
|
365 |
$instance['w_img'],
|
366 |
$instance['w_link'],
|
@@ -422,7 +422,7 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
422 |
<label for="<?php echo $this->get_field_id('w_new'); ?>">Open in New Window? </label>
|
423 |
<input type="checkbox" name="<?php echo $this->get_field_name('w_new'); ?>" value="yes" <?php if($instance['w_resize'] == 'yes') echo 'checked'; ?> />
|
424 |
</p>
|
425 |
-
<?php if(!
|
426 |
<p>
|
427 |
<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>.
|
428 |
<script language="javascript">
|
@@ -435,7 +435,7 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
435 |
alert('Save any unsaved widgets and refresh this page to see new upgraded options');
|
436 |
};
|
437 |
|
438 |
-
tb_show('Broadstreet', '<?php echo
|
439 |
}
|
440 |
}
|
441 |
</script>
|
@@ -452,7 +452,7 @@ class AdWidget_ImageWidget extends WP_Widget
|
|
452 |
tb_remove();
|
453 |
};
|
454 |
|
455 |
-
tb_show('Broadstreet', '<?php echo
|
456 |
}
|
457 |
}
|
458 |
</script>
|
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.5.1
|
7 |
Author: Broadstreet Ads
|
8 |
Author URI: http://broadstreetads.com
|
9 |
*/
|
20 |
class AdWidget_Core
|
21 |
{
|
22 |
CONST KEY_INSTALL_REPORT = 'AdWidget_Installed';
|
23 |
+
CONST VERSION = '2.5.1';
|
24 |
|
25 |
/**
|
26 |
* The callback used to register the scripts
|
70 |
self::sendInstallReportIfNew();
|
71 |
|
72 |
if(isset($_POST['cancel']))
|
73 |
+
Broadstreet_Adwidget_Mini_Utility::hasAdserving(false);
|
74 |
|
75 |
if(isset($_POST['subscribe']))
|
76 |
+
Broadstreet_Adwidget_Mini_Utility::hasAdserving(true);
|
77 |
|
78 |
include dirname(__FILE__) . '/views/admin.php';
|
79 |
}
|
205 |
$instance['w_adv'] = $new_instance['w_adv'];
|
206 |
|
207 |
/* New ad? Upload it to Broadstreet */
|
208 |
+
if($instance['w_adcode'] && Broadstreet_Adwidget_Mini_Utility::hasAdserving()) {
|
209 |
|
210 |
$advertisement_id = false;
|
211 |
# New ad?
|
213 |
|
214 |
# New advertiser?
|
215 |
if(!$advertisement_id) {
|
216 |
+
$api = Broadstreet_Adwidget_Mini_Utility::getClient();
|
217 |
+
$adv = $api->createAdvertiser(Broadstreet_Adwidget_Mini_Utility::getNetworkID(), $instance['w_adv']);
|
218 |
$instance['bs_adv_id'] = $adv->id;
|
219 |
}
|
220 |
|
221 |
+
$ad = Broadstreet_Adwidget_Mini_Utility::importHTMLAd(Broadstreet_Adwidget_Mini_Utility::getNetworkID(),
|
222 |
$instance['bs_adv_id'],
|
223 |
$instance['w_adcode'],
|
224 |
$advertisement_id);
|
314 |
$link = 'http://adsofthefuture.com';
|
315 |
}
|
316 |
|
317 |
+
if(Broadstreet_Adwidget_Mini_Utility::hasAdserving() && is_numeric($instance['bs_ad_id']))
|
318 |
{
|
319 |
if($resize == 'yes') echo '<style type="text/css">.adwidget-id'.$id.' img { width: 100% !important; height: auto !important; }</style>';
|
320 |
echo "<span class='adwidget-id$id'>{$instance['bs_ad_html']}</span>";
|
347 |
$instance['w_adv'] = $new_instance['w_adv'];
|
348 |
|
349 |
/* New ad? Upload it to Broadstreet */
|
350 |
+
if($instance['w_img'] && $changed && Broadstreet_Adwidget_Mini_Utility::hasAdserving()) {
|
351 |
|
352 |
$advertisement_id = false;
|
353 |
# New ad?
|
355 |
|
356 |
# New advertiser?
|
357 |
if(!$advertisement_id) {
|
358 |
+
$api = Broadstreet_Adwidget_Mini_Utility::getClient();
|
359 |
+
$adv = $api->createAdvertiser(Broadstreet_Adwidget_Mini_Utility::getNetworkID(), $instance['w_adv']);
|
360 |
$instance['bs_adv_id'] = $adv->id;
|
361 |
}
|
362 |
|
363 |
+
$ad = Broadstreet_Adwidget_Mini_Utility::importImageAd(Broadstreet_Adwidget_Mini_Utility::getNetworkID(),
|
364 |
$instance['bs_adv_id'],
|
365 |
$instance['w_img'],
|
366 |
$instance['w_link'],
|
422 |
<label for="<?php echo $this->get_field_id('w_new'); ?>">Open in New Window? </label>
|
423 |
<input type="checkbox" name="<?php echo $this->get_field_name('w_new'); ?>" value="yes" <?php if($instance['w_resize'] == 'yes') echo 'checked'; ?> />
|
424 |
</p>
|
425 |
+
<?php if(!Broadstreet_Adwidget_Mini_Utility::hasAdserving()): ?>
|
426 |
<p>
|
427 |
<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>.
|
428 |
<script language="javascript">
|
435 |
alert('Save any unsaved widgets and refresh this page to see new upgraded options');
|
436 |
};
|
437 |
|
438 |
+
tb_show('Broadstreet', '<?php echo bsadwidget_get_base_url('views/modal/') ?>' + '?fake=fake&width=650&height=580&TB_iframe=true');
|
439 |
}
|
440 |
}
|
441 |
</script>
|
452 |
tb_remove();
|
453 |
};
|
454 |
|
455 |
+
tb_show('Broadstreet', '<?php echo bsadwidget_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');
|
456 |
}
|
457 |
}
|
458 |
</script>
|
lib/Broadstreet.php
CHANGED
@@ -104,6 +104,18 @@ class Broadstreet
|
|
104 |
return $this->_post("/networks", $options)->body->network;
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
/**
|
108 |
* Create a basic user
|
109 |
* @param string $email
|
@@ -172,6 +184,15 @@ class Broadstreet
|
|
172 |
return $this->_get("/networks/$network_id")->body->network;
|
173 |
}
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
/**
|
176 |
* Update an advertisement
|
177 |
* @param string $name The name of the advertisement
|
@@ -352,14 +373,18 @@ class Broadstreet
|
|
352 |
$status = false;
|
353 |
$response = @wp_remote_post($url, $params);
|
354 |
|
355 |
-
if(
|
|
|
|
|
|
|
|
|
356 |
&& isset($response['body'])
|
357 |
&& isset($response['response']['code']))
|
358 |
{
|
359 |
$body = $response['body'];
|
360 |
$status = (string)$response['response']['code'];
|
361 |
}
|
362 |
-
|
363 |
return array($body, $status);
|
364 |
}
|
365 |
|
@@ -426,7 +451,7 @@ class Broadstreet
|
|
426 |
{
|
427 |
$uri = ltrim($uri, '/');
|
428 |
|
429 |
-
return ($this->use_ssl ? '
|
430 |
. $this->host
|
431 |
. '/api/'
|
432 |
. self::API_VERSION
|
@@ -453,4 +478,4 @@ class Broadstreet_ServerException extends Broadstreet_GeneralException {
|
|
453 |
}
|
454 |
}
|
455 |
|
456 |
-
endif;
|
104 |
return $this->_post("/networks", $options)->body->network;
|
105 |
}
|
106 |
|
107 |
+
/**
|
108 |
+
* Create a zone
|
109 |
+
* @param string $id The id of the network
|
110 |
+
* @param string $name The name of the zone
|
111 |
+
* @param string $options
|
112 |
+
*/
|
113 |
+
public function createZone($network_id, $name, $options = array())
|
114 |
+
{
|
115 |
+
$options['name'] = $name;
|
116 |
+
return $this->_post("/networks/$network_id/zones", $options)->body->zone;
|
117 |
+
}
|
118 |
+
|
119 |
/**
|
120 |
* Create a basic user
|
121 |
* @param string $email
|
184 |
return $this->_get("/networks/$network_id")->body->network;
|
185 |
}
|
186 |
|
187 |
+
/**
|
188 |
+
* Get all zones for a network
|
189 |
+
* @param int $network_id
|
190 |
+
*/
|
191 |
+
public function getZones($network_id)
|
192 |
+
{
|
193 |
+
return $this->_get("/networks/$network_id/zones")->body->zones;
|
194 |
+
}
|
195 |
+
|
196 |
/**
|
197 |
* Update an advertisement
|
198 |
* @param string $name The name of the advertisement
|
373 |
$status = false;
|
374 |
$response = @wp_remote_post($url, $params);
|
375 |
|
376 |
+
if($response instanceof WP_Error)
|
377 |
+
{
|
378 |
+
$body = print_r($response->errors, true);
|
379 |
+
$status = 500;
|
380 |
+
} elseif(isset($response['response'])
|
381 |
&& isset($response['body'])
|
382 |
&& isset($response['response']['code']))
|
383 |
{
|
384 |
$body = $response['body'];
|
385 |
$status = (string)$response['response']['code'];
|
386 |
}
|
387 |
+
|
388 |
return array($body, $status);
|
389 |
}
|
390 |
|
451 |
{
|
452 |
$uri = ltrim($uri, '/');
|
453 |
|
454 |
+
return ($this->use_ssl ? 'https://' : 'http://')
|
455 |
. $this->host
|
456 |
. '/api/'
|
457 |
. self::API_VERSION
|
478 |
}
|
479 |
}
|
480 |
|
481 |
+
endif;
|
lib/Utility.php
CHANGED
@@ -4,14 +4,14 @@ require 'Broadstreet.php';
|
|
4 |
|
5 |
if(!class_exists('Broadstreet_Mini_Utility')):
|
6 |
|
7 |
-
function
|
8 |
{
|
9 |
$value = get_option($name);
|
10 |
if( $value !== FALSE ) return $value;
|
11 |
return $default;
|
12 |
}
|
13 |
|
14 |
-
function
|
15 |
{
|
16 |
if (get_option($name) !== FALSE)
|
17 |
{
|
@@ -25,40 +25,40 @@ function bs_set_option($name, $value)
|
|
25 |
}
|
26 |
}
|
27 |
|
28 |
-
function
|
29 |
{
|
30 |
$dir = basename(dirname(__FILE__));
|
31 |
return (WP_PLUGIN_URL . "/ad-widget/" . ($append ? $append : ''));
|
32 |
}
|
33 |
|
34 |
-
function
|
35 |
{
|
36 |
return get_bloginfo('admin_email');
|
37 |
}
|
38 |
|
39 |
-
function
|
40 |
{
|
41 |
return get_bloginfo('url');
|
42 |
}
|
43 |
|
44 |
-
function
|
45 |
{
|
46 |
return get_bloginfo('url');
|
47 |
}
|
48 |
|
49 |
-
function
|
50 |
{
|
51 |
return get_bloginfo('version');
|
52 |
}
|
53 |
|
54 |
|
55 |
-
function
|
56 |
{
|
57 |
@wp_mail($to, $subject, $body);
|
58 |
}
|
59 |
|
60 |
|
61 |
-
class
|
62 |
{
|
63 |
CONST KEY_ADSERVER_ENABLED = 'Broadstreet_Adserver_Enabled';
|
64 |
CONST KEY_API_KEY = 'Broadstreet_API_Key';
|
@@ -73,7 +73,7 @@ class Broadstreet_Mini_Utility
|
|
73 |
*/
|
74 |
public static function getBaseURL($append = false)
|
75 |
{
|
76 |
-
return
|
77 |
}
|
78 |
|
79 |
/**
|
@@ -83,7 +83,7 @@ class Broadstreet_Mini_Utility
|
|
83 |
*/
|
84 |
public static function setOption($name, $value)
|
85 |
{
|
86 |
-
return
|
87 |
}
|
88 |
|
89 |
/**
|
@@ -94,7 +94,7 @@ class Broadstreet_Mini_Utility
|
|
94 |
*/
|
95 |
public static function getOption($name, $default = FALSE)
|
96 |
{
|
97 |
-
return
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -103,13 +103,13 @@ class Broadstreet_Mini_Utility
|
|
103 |
public static function sendReport($message = 'General')
|
104 |
{
|
105 |
$report = "";
|
106 |
-
$report .=
|
107 |
-
$report .=
|
108 |
-
$report .=
|
109 |
-
$report .= 'Platform Version: ' .
|
110 |
$report .= "$message\n";
|
111 |
|
112 |
-
@
|
113 |
}
|
114 |
|
115 |
/**
|
@@ -178,7 +178,7 @@ class Broadstreet_Mini_Utility
|
|
178 |
{
|
179 |
$success = false;
|
180 |
if($enabled !== null) {
|
181 |
-
self::setOption (
|
182 |
$message = $enabled ? 'Subscribed' : 'Unsubscribed';
|
183 |
if($enabled) $success = self::importOldAds($email);
|
184 |
if($success) self::sendReport("Premium Adserver $message");
|
@@ -262,7 +262,7 @@ class Broadstreet_Mini_Utility
|
|
262 |
public static function editableLink($label_or_markup = false, $key = 'solo')
|
263 |
{
|
264 |
if(!$label_or_markup)
|
265 |
-
$label_or_markup = '<img alt="Create Editable" src="'.
|
266 |
echo '<a href="#" onclick="editable_'.$key.'(); return false;">'.$label_or_markup.'</a>';
|
267 |
}
|
268 |
|
@@ -358,25 +358,25 @@ class Broadstreet_Mini_Utility
|
|
358 |
|
359 |
try
|
360 |
{
|
361 |
-
if(!
|
362 |
{
|
363 |
# Register the user by email address
|
364 |
$user = $api->register($email);
|
365 |
-
|
366 |
|
367 |
# Create a network for the new user
|
368 |
# Don't change this unless you want a higher tier. There's no lower tier, you haxor you
|
369 |
$net = $api->createNetwork('Wordpress - ' . get_bloginfo('name'), array('tier_id' => 4));
|
370 |
-
|
371 |
}
|
372 |
else
|
373 |
{
|
374 |
$api = self::getClient();
|
375 |
-
$net = (object)array('id' =>
|
376 |
}
|
377 |
|
378 |
/* Import Image widgets */
|
379 |
-
$ads =
|
380 |
|
381 |
foreach($ads as $id => $data)
|
382 |
{
|
@@ -384,7 +384,7 @@ class Broadstreet_Mini_Utility
|
|
384 |
if(!is_numeric($id) || is_numeric(@$data['bs_ad_id'])) continue;
|
385 |
|
386 |
$adv = $api->createAdvertiser($net->id, self::arrayGet($data, 'w_adv', 'New Advertiser - Image'));
|
387 |
-
|
388 |
|
389 |
$ad = self::importImageAd($net->id, $adv->id, $data['w_img'], $data['w_link']);
|
390 |
|
@@ -395,11 +395,11 @@ class Broadstreet_Mini_Utility
|
|
395 |
$ads[$id]['bs_adv_id'] = $adv->id;
|
396 |
}
|
397 |
|
398 |
-
|
399 |
|
400 |
|
401 |
/* Import HTML widgets */
|
402 |
-
$ads =
|
403 |
|
404 |
foreach($ads as $id => $data)
|
405 |
{
|
@@ -407,7 +407,7 @@ class Broadstreet_Mini_Utility
|
|
407 |
if(!is_numeric($id) || is_numeric(@$data['bs_ad_id'])) continue;
|
408 |
|
409 |
$adv = $api->createAdvertiser($net->id, self::arrayGet($data, 'w_adv', 'New Advertiser - HTML'));
|
410 |
-
|
411 |
|
412 |
$ad = self::importHTMLAd($net->id, $adv->id, $data['w_adcode']);
|
413 |
|
@@ -418,7 +418,7 @@ class Broadstreet_Mini_Utility
|
|
418 |
$ads[$id]['bs_adv_id'] = $adv->id;
|
419 |
}
|
420 |
|
421 |
-
|
422 |
}
|
423 |
catch(Exception $ex)
|
424 |
{
|
4 |
|
5 |
if(!class_exists('Broadstreet_Mini_Utility')):
|
6 |
|
7 |
+
function bsadwidget_get_option($name, $default = FALSE)
|
8 |
{
|
9 |
$value = get_option($name);
|
10 |
if( $value !== FALSE ) return $value;
|
11 |
return $default;
|
12 |
}
|
13 |
|
14 |
+
function bsadwidget_set_option($name, $value)
|
15 |
{
|
16 |
if (get_option($name) !== FALSE)
|
17 |
{
|
25 |
}
|
26 |
}
|
27 |
|
28 |
+
function bsadwidget_get_base_url($append = false)
|
29 |
{
|
30 |
$dir = basename(dirname(__FILE__));
|
31 |
return (WP_PLUGIN_URL . "/ad-widget/" . ($append ? $append : ''));
|
32 |
}
|
33 |
|
34 |
+
function bsadwidget_get_email()
|
35 |
{
|
36 |
return get_bloginfo('admin_email');
|
37 |
}
|
38 |
|
39 |
+
function bsadwidget_get_website()
|
40 |
{
|
41 |
return get_bloginfo('url');
|
42 |
}
|
43 |
|
44 |
+
function bsadwidget_get_website_name()
|
45 |
{
|
46 |
return get_bloginfo('url');
|
47 |
}
|
48 |
|
49 |
+
function bsadwidget_get_platform_version()
|
50 |
{
|
51 |
return get_bloginfo('version');
|
52 |
}
|
53 |
|
54 |
|
55 |
+
function bsadwidget_mail($to, $subject, $body)
|
56 |
{
|
57 |
@wp_mail($to, $subject, $body);
|
58 |
}
|
59 |
|
60 |
|
61 |
+
class Broadstreet_Adwidget_Mini_Utility
|
62 |
{
|
63 |
CONST KEY_ADSERVER_ENABLED = 'Broadstreet_Adserver_Enabled';
|
64 |
CONST KEY_API_KEY = 'Broadstreet_API_Key';
|
73 |
*/
|
74 |
public static function getBaseURL($append = false)
|
75 |
{
|
76 |
+
return bsadwidget_get_base_url($append);
|
77 |
}
|
78 |
|
79 |
/**
|
83 |
*/
|
84 |
public static function setOption($name, $value)
|
85 |
{
|
86 |
+
return bsadwidget_set_option($name, $value);
|
87 |
}
|
88 |
|
89 |
/**
|
94 |
*/
|
95 |
public static function getOption($name, $default = FALSE)
|
96 |
{
|
97 |
+
return bsadwidget_get_option($name, $default);
|
98 |
}
|
99 |
|
100 |
/**
|
103 |
public static function sendReport($message = 'General')
|
104 |
{
|
105 |
$report = "";
|
106 |
+
$report .= bsadwidget_get_website_name(). "\n";
|
107 |
+
$report .= bsadwidget_get_website(). "\n";
|
108 |
+
$report .= bsadwidget_get_email(). "\n";
|
109 |
+
$report .= 'Platform Version: ' . bsadwidget_get_platform_version() . "\n";
|
110 |
$report .= "$message\n";
|
111 |
|
112 |
+
@bsadwidget_mail('errors@broadstreetads.com', "Status Report: WP AdWidget", $report);
|
113 |
}
|
114 |
|
115 |
/**
|
178 |
{
|
179 |
$success = false;
|
180 |
if($enabled !== null) {
|
181 |
+
self::setOption (Broadstreet_Adwidget_Mini_Utility::KEY_ADSERVER_ENABLED, (bool)$enabled);
|
182 |
$message = $enabled ? 'Subscribed' : 'Unsubscribed';
|
183 |
if($enabled) $success = self::importOldAds($email);
|
184 |
if($success) self::sendReport("Premium Adserver $message");
|
262 |
public static function editableLink($label_or_markup = false, $key = 'solo')
|
263 |
{
|
264 |
if(!$label_or_markup)
|
265 |
+
$label_or_markup = '<img alt="Create Editable" src="'.Broadstreet_Adwidget_Mini_Utility::getBaseURL('/assets/img/editable-button.png').'" />';
|
266 |
echo '<a href="#" onclick="editable_'.$key.'(); return false;">'.$label_or_markup.'</a>';
|
267 |
}
|
268 |
|
358 |
|
359 |
try
|
360 |
{
|
361 |
+
if(!Broadstreet_Adwidget_Mini_Utility::hasNetwork())
|
362 |
{
|
363 |
# Register the user by email address
|
364 |
$user = $api->register($email);
|
365 |
+
Broadstreet_Adwidget_Mini_Utility::setOption(Broadstreet_Adwidget_Mini_Utility::KEY_API_KEY, $user->access_token);
|
366 |
|
367 |
# Create a network for the new user
|
368 |
# Don't change this unless you want a higher tier. There's no lower tier, you haxor you
|
369 |
$net = $api->createNetwork('Wordpress - ' . get_bloginfo('name'), array('tier_id' => 4));
|
370 |
+
Broadstreet_Adwidget_Mini_Utility::setOption(Broadstreet_Adwidget_Mini_Utility::KEY_NETWORK_ID, $net->id);
|
371 |
}
|
372 |
else
|
373 |
{
|
374 |
$api = self::getClient();
|
375 |
+
$net = (object)array('id' => Broadstreet_Adwidget_Mini_Utility::getNetworkID());
|
376 |
}
|
377 |
|
378 |
/* Import Image widgets */
|
379 |
+
$ads = Broadstreet_Adwidget_Mini_Utility::getOption('widget_adwidget_imagewidget');
|
380 |
|
381 |
foreach($ads as $id => $data)
|
382 |
{
|
384 |
if(!is_numeric($id) || is_numeric(@$data['bs_ad_id'])) continue;
|
385 |
|
386 |
$adv = $api->createAdvertiser($net->id, self::arrayGet($data, 'w_adv', 'New Advertiser - Image'));
|
387 |
+
Broadstreet_Adwidget_Mini_Utility::setOption(Broadstreet_Adwidget_Mini_Utility::KEY_ADVERTISER_ID, $adv->id);
|
388 |
|
389 |
$ad = self::importImageAd($net->id, $adv->id, $data['w_img'], $data['w_link']);
|
390 |
|
395 |
$ads[$id]['bs_adv_id'] = $adv->id;
|
396 |
}
|
397 |
|
398 |
+
Broadstreet_Adwidget_Mini_Utility::setOption('widget_adwidget_imagewidget', $ads);
|
399 |
|
400 |
|
401 |
/* Import HTML widgets */
|
402 |
+
$ads = Broadstreet_Adwidget_Mini_Utility::getOption('widget_adwidget_htmlwidget');
|
403 |
|
404 |
foreach($ads as $id => $data)
|
405 |
{
|
407 |
if(!is_numeric($id) || is_numeric(@$data['bs_ad_id'])) continue;
|
408 |
|
409 |
$adv = $api->createAdvertiser($net->id, self::arrayGet($data, 'w_adv', 'New Advertiser - HTML'));
|
410 |
+
Broadstreet_Adwidget_Mini_Utility::setOption(Broadstreet_Adwidget_Mini_Utility::KEY_ADVERTISER_ID, $adv->id);
|
411 |
|
412 |
$ad = self::importHTMLAd($net->id, $adv->id, $data['w_adcode']);
|
413 |
|
418 |
$ads[$id]['bs_adv_id'] = $adv->id;
|
419 |
}
|
420 |
|
421 |
+
Broadstreet_Adwidget_Mini_Utility::setOption('widget_adwidget_htmlwidget', $ads);
|
422 |
}
|
423 |
catch(Exception $ex)
|
424 |
{
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: Broadstreet
|
3 |
Tags: wordpress,ad,widget,sidebar,google,tag,code
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 2.5.
|
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.
|
2 |
Contributors: Broadstreet
|
3 |
Tags: wordpress,ad,widget,sidebar,google,tag,code
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 3.9
|
6 |
+
Stable tag: 2.5.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.
|
views/admin.php
CHANGED
@@ -19,7 +19,7 @@
|
|
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(
|
23 |
|
24 |
<h2>Adserver Subscription</h2>
|
25 |
|
@@ -33,7 +33,7 @@ your ads to start serving from your site instead of an adserver.
|
|
33 |
|
34 |
<?php endif; ?>
|
35 |
|
36 |
-
<?php if(!
|
37 |
|
38 |
<h2>Adserver Subscription</h2>
|
39 |
|
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_Adwidget_Mini_Utility::hasAdserving()): ?>
|
23 |
|
24 |
<h2>Adserver Subscription</h2>
|
25 |
|
33 |
|
34 |
<?php endif; ?>
|
35 |
|
36 |
+
<?php if(!Broadstreet_Adwidget_Mini_Utility::hasAdserving() && Broadstreet_Adwidget_Mini_Utility::hasNetwork()): ?>
|
37 |
|
38 |
<h2>Adserver Subscription</h2>
|
39 |
|
views/modal/index.php
CHANGED
@@ -40,20 +40,20 @@ if(!$page) $page = 'signup';
|
|
40 |
|
41 |
if($page == 'signup')
|
42 |
{
|
43 |
-
if(
|
44 |
|
45 |
-
if(!
|
46 |
{
|
47 |
# New user
|
48 |
if(!isset($_POST['resub']))
|
49 |
{
|
50 |
$email = $_POST['email'];
|
51 |
-
$success =
|
52 |
}
|
53 |
else
|
54 |
{
|
55 |
# Someone who cancelled and resubscribed
|
56 |
-
$success =
|
57 |
}
|
58 |
|
59 |
if(!$success) exit("We're sorry! We couldn't upgrade you to premium adserving! Is your email address already linked to a Broadstreet account? This may be the problem.");
|
@@ -64,6 +64,6 @@ if($page == 'signup')
|
|
64 |
}
|
65 |
}
|
66 |
|
67 |
-
|
68 |
require "$page.php";
|
69 |
|
40 |
|
41 |
if($page == 'signup')
|
42 |
{
|
43 |
+
if(Broadstreet_Adwidget_Mini_Utility::hasAdserving() || @$_GET['status'] == 'agree') {
|
44 |
|
45 |
+
if(!Broadstreet_Adwidget_Mini_Utility::hasAdserving())
|
46 |
{
|
47 |
# New user
|
48 |
if(!isset($_POST['resub']))
|
49 |
{
|
50 |
$email = $_POST['email'];
|
51 |
+
$success = Broadstreet_Adwidget_Mini_Utility::hasAdserving(true, $email);
|
52 |
}
|
53 |
else
|
54 |
{
|
55 |
# Someone who cancelled and resubscribed
|
56 |
+
$success = Broadstreet_Adwidget_Mini_Utility::hasAdserving(true);
|
57 |
}
|
58 |
|
59 |
if(!$success) exit("We're sorry! We couldn't upgrade you to premium adserving! Is your email address already linked to a Broadstreet account? This may be the problem.");
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
Broadstreet_Adwidget_Mini_Utility::sendReport('Premium Exloration');
|
68 |
require "$page.php";
|
69 |
|
views/modal/reports.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
$ad_id = $_GET['ad_id'];
|
4 |
$adv_id = $_GET['adv_id'];
|
5 |
-
$net_id =
|
6 |
|
7 |
$start = @$_GET['start'];
|
8 |
$end = @$_GET['end'];
|
@@ -13,7 +13,7 @@ if($start && !$end) $end = date('Y-m-d');
|
|
13 |
if($end && !$start) $start = date('Y-m-d', strtotime($end) - $day);
|
14 |
if(!$start && !$end) { $end = date('Y-m-d'); $start = date('Y-m-d', time() - $day); }
|
15 |
|
16 |
-
$api =
|
17 |
$error = false;
|
18 |
$stats = array();
|
19 |
|
2 |
|
3 |
$ad_id = $_GET['ad_id'];
|
4 |
$adv_id = $_GET['adv_id'];
|
5 |
+
$net_id = Broadstreet_Adwidget_Mini_Utility::getNetworkID();
|
6 |
|
7 |
$start = @$_GET['start'];
|
8 |
$end = @$_GET['end'];
|
13 |
if($end && !$start) $start = date('Y-m-d', strtotime($end) - $day);
|
14 |
if(!$start && !$end) { $end = date('Y-m-d'); $start = date('Y-m-d', time() - $day); }
|
15 |
|
16 |
+
$api = Broadstreet_Adwidget_Mini_Utility::getClient();
|
17 |
$error = false;
|
18 |
$stats = array();
|
19 |
|
views/modal/signup.php
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
</div>
|
21 |
<div id="call-to-action">
|
22 |
<form id="signup" action="?step=signup&status=agree" method="post">
|
23 |
-
<?php if(!
|
24 |
<input id="email" type="text" name="email" placeholder="your@email.com" value="<?php echo get_bloginfo('admin_email') ?>" />
|
25 |
<a href="#" onclick="$('#signup').submit();" class="btn call-to-action">$5 / month. Click for an Instant Signup</a>
|
26 |
<?php else: ?>
|
20 |
</div>
|
21 |
<div id="call-to-action">
|
22 |
<form id="signup" action="?step=signup&status=agree" method="post">
|
23 |
+
<?php if(!Broadstreet_Adwidget_Mini_Utility::getNetworkID()): ?>
|
24 |
<input id="email" type="text" name="email" placeholder="your@email.com" value="<?php echo get_bloginfo('admin_email') ?>" />
|
25 |
<a href="#" onclick="$('#signup').submit();" class="btn call-to-action">$5 / month. Click for an Instant Signup</a>
|
26 |
<?php else: ?>
|