WordPress Ad Widget - Version 2.1.0

Version Description

Download this release

Release Info

Developer broadstreetads
Plugin Icon wp plugin WordPress Ad Widget
Version 2.1.0
Comparing to
See all releases

Version 2.1.0

Files changed (4) hide show
  1. adwidget.php +229 -0
  2. assets/widgets.js +19 -0
  3. readme.txt +32 -0
  4. views/admin.php +32 -0
adwidget.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1.0
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'));
14
+
15
+ /**
16
+ * This class is the core of Ad Widget
17
+ */
18
+ class AdWidget_Core
19
+ {
20
+ /**
21
+ * The callback used to register the scripts
22
+ */
23
+ static function registerScripts()
24
+ {
25
+ # Include thickbox on widgets page
26
+ if($GLOBALS['pagenow'] == 'widgets.php')
27
+ {
28
+ wp_enqueue_script('thickbox');
29
+ wp_enqueue_style('thickbox');
30
+ wp_enqueue_script('adwidget-main', self::getBaseURL().'assets/widgets.js');
31
+ }
32
+ }
33
+
34
+ /**
35
+ * The callback used to register the widget
36
+ */
37
+ static function registerWidgets()
38
+ {
39
+ register_widget('AdWidget_HTMLWidget');
40
+ register_widget('AdWidget_ImageWidget');
41
+ }
42
+
43
+ /**
44
+ * Get the base URL of the plugin installation
45
+ * @return string the base URL
46
+ */
47
+ public static function getBaseURL()
48
+ {
49
+ return (get_bloginfo('url') . '/wp-content/plugins/adwidget/');
50
+ }
51
+
52
+ /**
53
+ * Register the admin settings page
54
+ */
55
+ static function registerAdmin()
56
+ {
57
+ add_options_page('Ad Widget', 'Ad Widget', 'edit_pages', 'adwidget.php', array(__CLASS__, 'adminMenuCallback'));
58
+ }
59
+
60
+ /**
61
+ * The function used by WP to print the admin settings page
62
+ */
63
+ static function adminMenuCallback()
64
+ {
65
+ include dirname(__FILE__) . '/views/admin.php';
66
+ }
67
+ }
68
+
69
+
70
+ /**
71
+ * The HTML Widget
72
+ */
73
+ class AdWidget_HTMLWidget extends WP_Widget
74
+ {
75
+ /**
76
+ * Set the widget options
77
+ */
78
+ function AdWidget_HTMLWidget()
79
+ {
80
+ $widget_ops = array('classname' => 'AdWidget_HTMLWidget', 'description' => 'Place an ad code like Google ads or other ad provider');
81
+ $this->WP_Widget('AdWidget_HTMLWidget', 'Ad: HTML/Javascript Ad', $widget_ops);
82
+ }
83
+
84
+ /**
85
+ * Display the widget on the sidebar
86
+ * @param array $args
87
+ * @param array $instance
88
+ */
89
+ function widget($args, $instance)
90
+ {
91
+ extract($args);
92
+
93
+ echo $before_widget;
94
+
95
+ $instance['w_adcode'];
96
+
97
+ echo $after_widget;
98
+ }
99
+
100
+ /**
101
+ * Update the widget info from the admin panel
102
+ * @param array $new_instance
103
+ * @param array $old_instance
104
+ * @return array
105
+ */
106
+ function update($new_instance, $old_instance)
107
+ {
108
+ $instance = $old_instance;
109
+
110
+ $instance['w_adcode'] = $new_instance['w_adcode'];
111
+
112
+ return $instance;
113
+ }
114
+
115
+ /**
116
+ * Display the widget update form
117
+ * @param array $instance
118
+ */
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">
126
+ <p>Paste your Google ad tag, or any other ad tag in this widget below.</p>
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
133
+ }
134
+ }
135
+
136
+ /**
137
+ * This is an optional widget to display GitHub projects
138
+ */
139
+ class AdWidget_ImageWidget extends WP_Widget
140
+ {
141
+ /**
142
+ * Set the widget options
143
+ */
144
+ function AdWidget_ImageWidget()
145
+ {
146
+ $widget_ops = array('classname' => 'AdWidget_ImageWidget', 'description' => 'Place an image ad with a link');
147
+ $this->WP_Widget('AdWidget_ImageWidget', 'Ad: Image/Banner Ad', $widget_ops);
148
+ }
149
+
150
+ /**
151
+ * Display the widget on the sidebar
152
+ * @param array $args
153
+ * @param array $instance
154
+ */
155
+ function widget($args, $instance)
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
+ }
168
+
169
+ /**
170
+ * Update the widget info from the admin panel
171
+ * @param array $new_instance
172
+ * @param array $old_instance
173
+ * @return array
174
+ */
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
+ }
184
+
185
+ /**
186
+ * Display the widget update form
187
+ * @param array $instance
188
+ */
189
+ function form($instance)
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/>
215
+ <p>
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
+
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;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
+ });
readme.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1.0
7
+
8
+ This is a Wordpress plugin that will list your open source projects from
9
+ github or bitbucket in-page or via sidebar.
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
+ * 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
+ == Demo ==
24
+
25
+ Watch a short video demo: http://www.screenr.com/u0t7
26
+
27
+ == Installation ==
28
+
29
+ There aren't any special instructions for installing this plug-in. Once
30
+ installed, go to Appearance -> Widgets, and look for the "Ad Widget" widgets!
31
+
32
+ You can also go to Settings -> Ad Widget for a video demo on how to use it.
views/admin.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
11
+ <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>
12
+
13
+ <p>To put an ad on your website, just go to <a href="widgets.php">the widgets page</a>,
14
+ and look for:</p>
15
+
16
+ <ul>
17
+ <li><strong>Ad: HTML/Javascript Ad</strong></li>
18
+ <li><strong>Ad: Image/Banner Ad</strong></li>
19
+ </ul>
20
+
21
+ <p>
22
+ Drag one of those into your a widget area, like a sidebar, and follow the
23
+ instructions! Send questions to kenny@broadstreetads.com .
24
+ </p>
25
+
26
+ <p>
27
+ Here's a short instructional video if you need help:
28
+ </p>
29
+
30
+ <iframe src="http://www.screenr.com/embed/u0t7" width="650" height="396" frameborder="0"></iframe>
31
+
32
+ </div>