WP125 - Version 1.1.1

Version Description

Download this release

Release Info

Developer redwallhp
Plugin Icon wp plugin WP125
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.1.1

Files changed (6) hide show
  1. adminmenus.php +61 -13
  2. installer.php +23 -25
  3. readme.txt +19 -2
  4. wp125.css +13 -0
  5. wp125.php +96 -26
  6. youradhere.jpg +0 -0
adminmenus.php CHANGED
@@ -74,8 +74,9 @@ echo '</tr>';
74
  } else { echo '<tr> <td colspan="8">No ads found.</td> </tr>'; }
75
 
76
  echo '</tbody>
77
- </table>
78
- </div>';
 
79
  }
80
 
81
  function wp125_write_addeditmenu() {
@@ -211,25 +212,43 @@ document.getElementById("adexp-date").style.display = "none";
211
  </table>
212
  <p class="submit"><input type="submit" name="Submit" value="Save Ad" /> &nbsp; <?php if ($_GET['editad']!='') { ?><input type="submit" name="deletead" value="Delete Ad" /><?php } ?></p>
213
  </form>
 
214
  </div><?php
215
  }
216
 
217
  function wp125_write_settingsmenu() {
218
  //DB Data
219
  global $wpdb;
220
- $settingtable_name = $wpdb->prefix . "wp125_settings";
221
  //Add settings, if submitted
222
  if ($_POST['issubmitted']=='yes') {
223
  $post_adorient = $wpdb->escape($_POST['adorient']);
224
  $post_numslots = $wpdb->escape($_POST['numads']);
225
  $post_adorder = $wpdb->escape($_POST['adorder']);
226
  $post_salespage = $wpdb->escape($_POST['salespage']);
227
- $updatedb = "UPDATE $settingtable_name SET ad_orientation='$post_adorient', num_slots='$post_numslots', ad_order='$post_adorder', buyad_url='$post_salespage' WHERE ad_orientation != ''";
228
- $results = $wpdb->query($updatedb);
 
 
 
 
 
 
 
 
 
 
 
229
  echo '<div id="message" class="updated fade"><p>Settings updated.</p></div>';
230
  }
231
- // Retrieve settings
232
- $wp125settings = $wpdb->get_row("SELECT * FROM $settingtable_name WHERE ad_orientation != '' ", OBJECT);
 
 
 
 
 
 
 
233
  ?><div class="wrap">
234
  <h2>Settings</h2>
235
  <form method="post" action="admin.php?page=wp125_settings">
@@ -239,29 +258,49 @@ $wp125settings = $wpdb->get_row("SELECT * FROM $settingtable_name WHERE ad_orien
239
  <th scope="row">Ad Orientation</th>
240
  <td><label for="adorient">
241
  <select name="adorient" id="adorient">
242
- <option <?php if ($wp125settings->ad_orientation=='1c') { echo 'selected="selected"'; } ?> value="1c">One Column</option>
243
- <option <?php if ($wp125settings->ad_orientation=='2c') { echo 'selected="selected"'; } ?> value="2c">Two Column</option>
244
  </select></label>
245
  <br/>How many columns should the ads be displayed in?
246
  </td></tr>
247
 
248
  <tr valign="top">
249
  <th scope="row">Number of Ad Slots</th>
250
- <td><input name="numads" type="text" id="numads" value="<?php echo $wp125settings->num_slots; ?>" size="2" /><br/>How many ads should be shown?</td>
251
  </tr>
252
 
253
  <tr valign="top">
254
  <th scope="row">Ad Order</th>
255
  <td><label for="adorder">
256
  <select name="adorder" id="adorder">
257
- <option selected="selected" value="normal" <?php if ($wp125settings->ad_order=='normal') { echo 'selected="selected"'; } ?>>Normal</option>
258
- <option value="random" <?php if ($wp125settings->ad_order=='random') { echo 'selected="selected"'; } ?>>Random</option>
259
  </select></label>
260
  </td></tr>
261
 
 
 
 
 
 
262
  <tr valign="top">
263
  <th scope="row">Ad Sales Page</th>
264
- <td><input name="salespage" type="text" id="salespage" value="<?php echo $wp125settings->buyad_url; ?>" size="50" /><br/>Do you have a page with statistics and prices? (Leave blank to disable)</td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  </tr>
266
 
267
  </table>
@@ -270,8 +309,17 @@ $wp125settings = $wpdb->get_row("SELECT * FROM $settingtable_name WHERE ad_orien
270
  </form>
271
  <br/>
272
  <p>Your ads can be displayed using either the included widget, or by using the <strong>&lt;?php wp125_write_ads(); ?&gt;</strong> template tag. Also, you can display a single ad, without any formatting, using <strong>&lt;?php wp125_single_ad(<em>num</em>); ?&gt;</strong>, where <em>num</em> is the number of the ad slot you wish to show. This is useful for cases where your theme prevents the default formatting from working properly, or where you wish to display your ads in an unforeseen manner.</p>
 
273
  </div><?php
274
  }
275
 
276
 
 
 
 
 
 
 
 
 
277
  ?>
74
  } else { echo '<tr> <td colspan="8">No ads found.</td> </tr>'; }
75
 
76
  echo '</tbody>
77
+ </table>';
78
+ wp125_admin_page_footer();
79
+ echo '</div>';
80
  }
81
 
82
  function wp125_write_addeditmenu() {
212
  </table>
213
  <p class="submit"><input type="submit" name="Submit" value="Save Ad" /> &nbsp; <?php if ($_GET['editad']!='') { ?><input type="submit" name="deletead" value="Delete Ad" /><?php } ?></p>
214
  </form>
215
+ <?php wp125_admin_page_footer(); ?>
216
  </div><?php
217
  }
218
 
219
  function wp125_write_settingsmenu() {
220
  //DB Data
221
  global $wpdb;
 
222
  //Add settings, if submitted
223
  if ($_POST['issubmitted']=='yes') {
224
  $post_adorient = $wpdb->escape($_POST['adorient']);
225
  $post_numslots = $wpdb->escape($_POST['numads']);
226
  $post_adorder = $wpdb->escape($_POST['adorder']);
227
  $post_salespage = $wpdb->escape($_POST['salespage']);
228
+ $post_widgettitle = $wpdb->escape($_POST['widgettitle']);
229
+ $post_defaultstyle = $wpdb->escape($_POST['defaultstyle']);
230
+ $post_emailonexp = $wpdb->escape($_POST['emailonexp']);
231
+ $post_defaultad = $wpdb->escape($_POST['defaultad']);
232
+ if ($post_defaultstyle!='on') { $post_defaultstyle = 'yes'; } else { $post_defaultstyle = ''; }
233
+ update_option("wp125_ad_orientation", $post_adorient);
234
+ update_option("wp125_num_slots", $post_numslots);
235
+ update_option("wp125_ad_order", $post_adorder);
236
+ update_option("wp125_buyad_url", $post_salespage);
237
+ update_option("wp125_widget_title", $post_widgettitle);
238
+ update_option("wp125_disable_default_style", $post_defaultstyle);
239
+ update_option("wp125_emailonexp", $post_emailonexp);
240
+ update_option("wp125_defaultad", $post_defaultad);
241
  echo '<div id="message" class="updated fade"><p>Settings updated.</p></div>';
242
  }
243
+ //Retrieve settings
244
+ $setting_ad_orientation = get_option("wp125_ad_orientation");
245
+ $setting_num_slots = get_option("wp125_num_slots");
246
+ $setting_ad_order = get_option("wp125_ad_order");
247
+ $setting_buyad_url = get_option("wp125_buyad_url");
248
+ $setting_widget_title = get_option("wp125_widget_title");
249
+ $setting_disable_default_style = get_option("wp125_disable_default_style");
250
+ $setting_emailonexp = get_option("wp125_emailonexp");
251
+ $setting_defaultad = get_option("wp125_defaultad");
252
  ?><div class="wrap">
253
  <h2>Settings</h2>
254
  <form method="post" action="admin.php?page=wp125_settings">
258
  <th scope="row">Ad Orientation</th>
259
  <td><label for="adorient">
260
  <select name="adorient" id="adorient">
261
+ <option <?php if ($setting_ad_orientation=='1c') { echo 'selected="selected"'; } ?> value="1c">One Column</option>
262
+ <option <?php if ($setting_ad_orientation=='2c') { echo 'selected="selected"'; } ?> value="2c">Two Column</option>
263
  </select></label>
264
  <br/>How many columns should the ads be displayed in?
265
  </td></tr>
266
 
267
  <tr valign="top">
268
  <th scope="row">Number of Ad Slots</th>
269
+ <td><input name="numads" type="text" id="numads" value="<?php echo $setting_num_slots; ?>" size="2" /><br/>How many ads should be shown?</td>
270
  </tr>
271
 
272
  <tr valign="top">
273
  <th scope="row">Ad Order</th>
274
  <td><label for="adorder">
275
  <select name="adorder" id="adorder">
276
+ <option selected="selected" value="normal" <?php if ($setting_ad_order=='normal') { echo 'selected="selected"'; } ?>>Normal</option>
277
+ <option value="random" <?php if ($setting_ad_order=='random') { echo 'selected="selected"'; } ?>>Random</option>
278
  </select></label>
279
  </td></tr>
280
 
281
+ <tr valign="top">
282
+ <th scope="row">Widget Title</th>
283
+ <td><input name="widgettitle" type="text" id="widgettitle" value="<?php echo $setting_widget_title; ?>" size="50" /><br/>The title to be displayed in the widget. (Leave blank to disable)</td>
284
+ </tr>
285
+
286
  <tr valign="top">
287
  <th scope="row">Ad Sales Page</th>
288
+ <td><input name="salespage" type="text" id="salespage" value="<?php echo $setting_buyad_url; ?>" size="50" /><br/>Do you have a page with statistics and prices? (Default Ads will link here)</td>
289
+ </tr>
290
+
291
+ <tr valign="top">
292
+ <th scope="row">Default Style</th>
293
+ <td><input type="checkbox" name="defaultstyle" <?php if ($setting_disable_default_style=='') { echo 'checked="checked"'; } ?> /> Include default ad stylesheet? <br/>Leave checked unless you want to use your own CSS to style the ads. Refer to the documentation for further help.</td>
294
+ </tr>
295
+
296
+ <tr valign="top">
297
+ <th scope="row">Expiration Email</th>
298
+ <td><input name="emailonexp" type="text" id="emailonexp" value="<?php echo $setting_emailonexp; ?>" size="50" /><br/>Enter your email address if you would like to be emailed when an ad expires. (Leave blank to disable)</td>
299
+ </tr>
300
+
301
+ <tr valign="top">
302
+ <th scope="row">Default Ad</th>
303
+ <td><input name="defaultad" type="text" id="defaultad" value="<?php echo $setting_defaultad; ?>" size="50" /><br/>Which image should be shown as a placeholder when an ad slot is empty? (<a href="<?php echo wp125_get_plugin_dir('url').'/youradhere.jpg'; ?>">Default</a>)</td>
304
  </tr>
305
 
306
  </table>
309
  </form>
310
  <br/>
311
  <p>Your ads can be displayed using either the included widget, or by using the <strong>&lt;?php wp125_write_ads(); ?&gt;</strong> template tag. Also, you can display a single ad, without any formatting, using <strong>&lt;?php wp125_single_ad(<em>num</em>); ?&gt;</strong>, where <em>num</em> is the number of the ad slot you wish to show. This is useful for cases where your theme prevents the default formatting from working properly, or where you wish to display your ads in an unforeseen manner.</p>
312
+ <?php wp125_admin_page_footer(); ?>
313
  </div><?php
314
  }
315
 
316
 
317
+
318
+ function wp125_admin_page_footer() {
319
+ echo '<div style="margin-top:45px; font-size:0.87em;">';
320
+ echo '<div style="float:right;"><a href="http://www.webmaster-source.com/donate/" title="Why should you donate a few dollars? Click to find out..."><img src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" alt="Donate" /></a></div>';
321
+ echo '<div><a href="'.wp125_get_plugin_dir('url').'/readme.txt">Documentation</a> | <a href="http://www.webmaster-source.com/wp125-ad-plugin-wordpress/">WP125 Homepage</a></div>';
322
+ echo '</div>';
323
+ }
324
+
325
  ?>
installer.php CHANGED
@@ -1,22 +1,13 @@
1
  <?php
2
  //***** Installer *****
3
- function wp125_install () {
4
  require_once(ABSPATH . 'wp-admin/upgrade.php');
5
  //***Installer variables***
6
  global $wpdb;
7
- $table_name = $wpdb->prefix . "wp125_settings";
8
- $table2_name = $wpdb->prefix . "wp125_ads";
9
- $wp125_db_version = "0.8";
10
  //***Installer***
11
  if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
12
  $sql = "CREATE TABLE " . $table_name . " (
13
- ad_orientation varchar(3) NOT NULL,
14
- num_slots int(3) NOT NULL,
15
- ad_order varchar(8) NOT NULL,
16
- buyad_url text NOT NULL
17
- );";
18
- dbDelta($sql);
19
- $sql = "CREATE TABLE " . $table2_name . " (
20
  id int(12) NOT NULL auto_increment,
21
  slot int(2) NOT NULL,
22
  name text NOT NULL,
@@ -30,25 +21,24 @@ $sql = "CREATE TABLE " . $table2_name . " (
30
  );";
31
  dbDelta($sql);
32
 
33
- $def_adorient = "2c";
34
- $def_num_slots = 6;
35
- $def_ad_order = "normal";
36
- $def_buyad_url = '';
37
- $insert = "INSERT INTO " . $table_name . " (ad_orientation, num_slots, ad_order, buyad_url) " . "VALUES ('" . $wpdb->escape($def_adorient) . "','" . $wpdb->escape($def_num_slots) . "','" . $wpdb->escape($def_ad_order) . "','" . $wpdb->escape($def_buyad_url) ."')";
38
- $results = $wpdb->query( $insert );
 
 
 
 
39
  add_option("wp125_db_version", $wp125_db_version);
40
  }
 
41
  //***Upgrader***
42
  $installed_ver = get_option( "wp125_db_version" );
43
  if( $installed_ver != $wp125_db_version ) {
44
- $sql = "CREATE TABLE " . $table_name . " (
45
- ad_orientation varchar(3) NOT NULL,
46
- num_slots int(3) NOT NULL,
47
- ad_order varchar(8) NOT NULL,
48
- buyad_url text NOT NULL
49
- );";
50
  dbDelta($sql);
51
- $sql = "CREATE TABLE " . $table2_name . " (
52
  id int(12) NOT NULL auto_increment,
53
  slot int(2) NOT NULL,
54
  name text NOT NULL,
@@ -61,8 +51,16 @@ $sql = "CREATE TABLE " . $table2_name . " (
61
  PRIMARY KEY (id)
62
  );";
63
  dbDelta($sql);
 
 
 
 
 
 
 
 
 
64
  update_option( "wp125_db_version", $wp125_db_version );
65
  }
66
- }
67
  //***** End Installer *****
68
  ?>
1
  <?php
2
  //***** Installer *****
 
3
  require_once(ABSPATH . 'wp-admin/upgrade.php');
4
  //***Installer variables***
5
  global $wpdb;
6
+ $table_name = $wpdb->prefix . "wp125_ads";
7
+ $wp125_db_version = "1.33667";
 
8
  //***Installer***
9
  if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
10
  $sql = "CREATE TABLE " . $table_name . " (
 
 
 
 
 
 
 
11
  id int(12) NOT NULL auto_increment,
12
  slot int(2) NOT NULL,
13
  name text NOT NULL,
21
  );";
22
  dbDelta($sql);
23
 
24
+ add_option("wp125_ad_orientation", "2c");
25
+ add_option("wp125_num_slots", "6");
26
+ add_option("wp125_ad_order", "normal");
27
+ add_option("wp125_buyad_url", "");
28
+ add_option("wp125_disable_default_style", "");
29
+ add_option("wp125_widget_title", "Ads");
30
+ add_option("wp125_dofollow", "");
31
+ add_option("wp125_emailonexp", "");
32
+ add_option("wp125_defaultad", wp125_get_plugin_dir('url')."/youradhere.jpg");
33
+
34
  add_option("wp125_db_version", $wp125_db_version);
35
  }
36
+
37
  //***Upgrader***
38
  $installed_ver = get_option( "wp125_db_version" );
39
  if( $installed_ver != $wp125_db_version ) {
 
 
 
 
 
 
40
  dbDelta($sql);
41
+ $sql = "CREATE TABLE " . $table_name . " (
42
  id int(12) NOT NULL auto_increment,
43
  slot int(2) NOT NULL,
44
  name text NOT NULL,
51
  PRIMARY KEY (id)
52
  );";
53
  dbDelta($sql);
54
+ add_option("wp125_ad_orientation", "2c");
55
+ add_option("wp125_num_slots", "6");
56
+ add_option("wp125_ad_order", "normal");
57
+ add_option("wp125_buyad_url", "");
58
+ add_option("wp125_disable_default_style", "");
59
+ add_option("wp125_widget_title", "Ads");
60
+ add_option("wp125_dofollow", "");
61
+ add_option("wp125_emailonexp", "");
62
+ add_option("wp125_defaultad", wp125_get_plugin_dir('url')."/youradhere.jpg");
63
  update_option( "wp125_db_version", $wp125_db_version );
64
  }
 
65
  //***** End Installer *****
66
  ?>
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: http://www.webmaster-source.com/donate/
6
  Tags: ads, 125x125, management, advertisement
7
  Requires at least: 2.3
8
  Tested up to: 2.6
9
- Stable tag: 1.0.0
10
 
11
 
12
  Easy management of 125x125 ads on your blog. Ads can be run for a specified number of days, and will automatically be taken down. Track clicks too.
@@ -59,6 +59,17 @@ When an ad's time duration is over, it disappears off your site, and is removed
59
  = What if I don't want an ad to be taken down automatically? =
60
  Just select "I'll remove it manually" for the expiration date when you go to create the ad.
61
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
 
64
  == Screenshots ==
@@ -73,4 +84,10 @@ Just select "I'll remove it manually" for the expiration date when you go to cre
73
 
74
 
75
  == Support ==
76
- If you're having a problem with the plugin, try posting on the official WordPress forum at http://wordpress.org/support/ (be sure to use the tag "WP125"!). I, or another user of the plugin, will hopefully be able to answer your questions. Or send me an email via the contact form on Webmaster-Source.com.
 
 
 
 
 
 
6
  Tags: ads, 125x125, management, advertisement
7
  Requires at least: 2.3
8
  Tested up to: 2.6
9
+ Stable tag: 1.1.1
10
 
11
 
12
  Easy management of 125x125 ads on your blog. Ads can be run for a specified number of days, and will automatically be taken down. Track clicks too.
59
  = What if I don't want an ad to be taken down automatically? =
60
  Just select "I'll remove it manually" for the expiration date when you go to create the ad.
61
 
62
+ = How do I style my ads different than the default? =
63
+ First, uncheck the Default Style box on the Settings page. This will remove the default styling. Next, make use of your mad CSS skills to re-style the ads. Here's what the default CSS looks like:
64
+
65
+ `/* Styles for one-column display */
66
+ #wp125adwrap_1c { width:100%; }
67
+ #wp125adwrap_1c .wp125ad { margin-bottom:10px; }
68
+
69
+ /* Styles for two-column display */
70
+ #wp125adwrap_2c { width:100%; }
71
+ #wp125adwrap_2c .wp125ad { width:125px; float:left; padding:10px; }`
72
+
73
 
74
 
75
  == Screenshots ==
84
 
85
 
86
  == Support ==
87
+ If you're having a problem with the plugin, try posting on the official WordPress forum at http://wordpress.org/support/ (be sure to use the tag "WP125"!). I, or another user of the plugin, will hopefully be able to answer your questions. Or send me an email via the contact form on Webmaster-Source.com.
88
+
89
+
90
+
91
+ == Version History ==
92
+ * 1.0.0 - Initial release
93
+ * 1.1.0 - Some security and performance fixes, adds several new customization options and a few major features.
wp125.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Stylesheet for the WP125 ad management plugin
3
+ URL: http://www.webmaster-source.com/wp125-ad-plugin-wordpress/
4
+ */
5
+
6
+
7
+ /* Styles for one-column display */
8
+ #wp125adwrap_1c { width:100%; }
9
+ #wp125adwrap_1c .wp125ad { margin-bottom:10px; }
10
+
11
+ /* Styles for two-column display */
12
+ #wp125adwrap_2c { width:100%; }
13
+ #wp125adwrap_2c .wp125ad { width:125px; float:left; padding:10px; }
wp125.php CHANGED
@@ -1,18 +1,21 @@
1
  <?php
2
  /*
3
  Plugin Name: WP125
4
- Plugin URI: http://www.webmaster-source.com/wordpress-plugins/
5
  Description: Easily manage 125x125 ads within your WordPress Dashboard.
6
  Author: Matt Harzewski (redwall_hp)
7
  Author URI: http://www.webmaster-source.com
8
- Version: 1.0.0
9
  */
10
 
11
 
 
 
 
12
  //Ad Click Redirect
13
  add_action('init', 'wp125_adclick');
14
  function wp125_adclick() {
15
- if ($_GET['adclick'] != "") {
16
  $theid = $_GET['adclick'];
17
  global $wpdb;
18
  $adtable_name = $wpdb->prefix . "wp125_ads";
@@ -25,8 +28,19 @@ exit;
25
  }
26
 
27
 
 
 
 
 
 
 
 
 
 
28
  //Installer
 
29
  require_once(dirname(__FILE__).'/installer.php');
 
30
  register_activation_hook(__FILE__,'wp125_install');
31
 
32
 
@@ -37,24 +51,28 @@ register_sidebar_widget(__('WP125'), 'wp125_write_ads_widget');
37
  function wp125_write_ads_widget($args) {
38
  extract($args);
39
  echo $before_widget;
40
- echo $before_title;?>Ads<?php echo $after_title;
 
 
41
  wp125_write_ads();
42
  echo $after_widget;
43
  }
44
 
45
 
46
 
 
47
  //Add the Admin Menus
 
48
  function wp125_add_admin_menu() {
49
- add_menu_page("125x125 Ads", "Ads", "edit_themes", __FILE__, "wp125_write_managemenu");
50
- add_submenu_page(__FILE__, "Manage 125x125 Ads", "Manage", "edit_themes", __FILE__, "wp125_write_managemenu");
51
- add_submenu_page(__FILE__, "Add/Edit 125x125 Ads", "Add/Edit", "edit_themes", 'wp125_addedit', "wp125_write_addeditmenu");
52
- add_submenu_page(__FILE__, "125x125 Ad Settings", "Settings", "edit_themes", 'wp125_settings', "wp125_write_settingsmenu");
53
  }
54
 
55
-
56
  //Include menus
57
  require_once(dirname(__FILE__).'/adminmenus.php');
 
58
 
59
 
60
 
@@ -68,6 +86,7 @@ $thedate = strtotime($thedate);
68
  if ($today > $thedate) {
69
  $updatedb = "UPDATE $adtable_name SET status='0' WHERE id='$theid'";
70
  $results = $wpdb->query($updatedb);
 
71
  } else { return; }
72
  } else { return; }
73
  }
@@ -77,33 +96,57 @@ $results = $wpdb->query($updatedb);
77
  //Write the Ads
78
  function wp125_write_ads() {
79
  global $wpdb;
 
 
 
 
 
80
  $adtable_name = $wpdb->prefix . "wp125_ads";
81
- $settingtable_name = $wpdb->prefix . "wp125_settings";
82
- $thesettings = $wpdb->get_row("SELECT * FROM $settingtable_name WHERE ad_orientation != '' ", OBJECT);
83
- if ($thesettings->ad_order == 'random') { $theorder = 'RAND() LIMIT '.$thesettings->num_slots; } else { $theorder = 'slot ASC'; }
84
- $theads = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status = '1' ORDER BY $theorder", OBJECT);
85
  if ($theads) {
86
- if ($thesettings->ad_orientation=='1c') {
87
- echo '<div id="1c125adwrap" style="width:100%;">';
 
88
  foreach ($theads as $thead){
89
- echo '<div class="125ad" style="margin-bottom:10px;">';
90
- wp125_CheckAdDate($thead->end_date, $thead->id);
91
- if ($thead->clicks != -1) { $linkurl = get_option('blogurl').'index.php?adclick='.$thead->id; } else { $linkurl = $thead->target; }
92
- echo '<a href="'.$linkurl.'" rel="nofollow"><img src="'.$thead->image_url.'" alt="'.$thead->name.'" /></a>';
93
- echo '</div>';
 
 
 
 
 
 
 
 
 
94
  }
95
  echo '</div>';
96
  }
97
- if ($thesettings->ad_orientation=='2c') {
98
- echo '<div id="2c125adwrap" style="width:100%;">';
 
99
  foreach ($theads as $thead){
100
- wp125_CheckAdDate($thead->end_date, $thead->id);
101
- if ($thead->clicks != -1) { $linkurl = get_option('blogurl').'index.php?adclick='.$thead->id; } else { $linkurl = $thead->target; }
102
- echo '<div class="125ad" style="width:125px; float:left; padding:10px;"><a href="'.$linkurl.'" rel="nofollow"><img src="'.$thead->image_url.'" alt="'.$thead->name.'" /></a></div>';
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
  echo '</div>';
105
  }
106
- if ($thesettings->buyad_url!='') { echo '<div style="padding:10px; clear:both;"><a href="'.$thesettings->buyad_url.'">Your ad here.</a></div>'; }
107
  }
108
  }
109
 
@@ -116,7 +159,34 @@ if ($thead) {
116
  wp125_CheckAdDate($thead->end_date, $thead->id);
117
  if ($thead->clicks != -1) { $linkurl = get_option('blogurl').'index.php?adclick='.$thead->id; } else { $linkurl = $thead->target; }
118
  echo '<a href="'.$linkurl.'" rel="nofollow"><img src="'.$thead->image_url.'" alt="'.$thead->name.'" /></a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
 
120
  }
121
 
122
 
1
  <?php
2
  /*
3
  Plugin Name: WP125
4
+ Plugin URI: http://www.webmaster-source.com/wp125-ad-plugin-wordpress/
5
  Description: Easily manage 125x125 ads within your WordPress Dashboard.
6
  Author: Matt Harzewski (redwall_hp)
7
  Author URI: http://www.webmaster-source.com
8
+ Version: 1.1.1
9
  */
10
 
11
 
12
+ define("MANAGEMENT_PERMISSION", "edit_themes"); //The minimum privilege required to manage ads. http://tinyurl.com/wpprivs
13
+
14
+
15
  //Ad Click Redirect
16
  add_action('init', 'wp125_adclick');
17
  function wp125_adclick() {
18
+ if ($_GET['adclick'] != "" && ctype_digit($_GET['adclick'])) {
19
  $theid = $_GET['adclick'];
20
  global $wpdb;
21
  $adtable_name = $wpdb->prefix . "wp125_ads";
28
  }
29
 
30
 
31
+ //Stylesheet
32
+ function wp125_stylesheet() {
33
+ if (get_option("wp125_disable_default_style")=='') {
34
+ echo '<link rel="stylesheet" href="'.wp125_get_plugin_dir('url').'/wp125.css" type="text/css" media="screen" />'."\n";
35
+ } else { return; }
36
+ }
37
+ add_action('wp_print_scripts', 'wp125_stylesheet');
38
+
39
+
40
  //Installer
41
+ function wp125_install () {
42
  require_once(dirname(__FILE__).'/installer.php');
43
+ }
44
  register_activation_hook(__FILE__,'wp125_install');
45
 
46
 
51
  function wp125_write_ads_widget($args) {
52
  extract($args);
53
  echo $before_widget;
54
+ if (get_option("wp125_widget_title")!='') {
55
+ echo $before_title; echo get_option("wp125_widget_title"); echo $after_title;
56
+ }
57
  wp125_write_ads();
58
  echo $after_widget;
59
  }
60
 
61
 
62
 
63
+
64
  //Add the Admin Menus
65
+ if (is_admin()) {
66
  function wp125_add_admin_menu() {
67
+ add_menu_page("125x125 Ads", "Ads", MANAGEMENT_PERMISSION, __FILE__, "wp125_write_managemenu");
68
+ add_submenu_page(__FILE__, "Manage 125x125 Ads", "Manage", MANAGEMENT_PERMISSION, __FILE__, "wp125_write_managemenu");
69
+ add_submenu_page(__FILE__, "Add/Edit 125x125 Ads", "Add/Edit", MANAGEMENT_PERMISSION, 'wp125_addedit', "wp125_write_addeditmenu");
70
+ add_submenu_page(__FILE__, "125x125 Ad Settings", "Settings", MANAGEMENT_PERMISSION, 'wp125_settings', "wp125_write_settingsmenu");
71
  }
72
 
 
73
  //Include menus
74
  require_once(dirname(__FILE__).'/adminmenus.php');
75
+ }
76
 
77
 
78
 
86
  if ($today > $thedate) {
87
  $updatedb = "UPDATE $adtable_name SET status='0' WHERE id='$theid'";
88
  $results = $wpdb->query($updatedb);
89
+ sendExpirationEmail($theid);
90
  } else { return; }
91
  } else { return; }
92
  }
96
  //Write the Ads
97
  function wp125_write_ads() {
98
  global $wpdb;
99
+ $setting_ad_orientation = get_option("wp125_ad_orientation");
100
+ $setting_num_slots = get_option("wp125_num_slots");
101
+ $setting_ad_order = get_option("wp125_ad_order");
102
+ $setting_buyad_url = get_option("wp125_buyad_url");
103
+ $setting_defaultad = get_option("wp125_defaultad");
104
  $adtable_name = $wpdb->prefix . "wp125_ads";
105
+ if ($setting_ad_order == 'random') { $theorder = 'RAND() LIMIT '.$setting_num_slots; } else { $theorder = 'slot ASC'; }
106
+ $theads = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status = '1' ORDER BY $theorder", ARRAY_A);
 
 
107
  if ($theads) {
108
+ if ($setting_ad_orientation=='1c') {
109
+ echo '<div id="wp125adwrap_1c">';
110
+ $arraycount = 0;
111
  foreach ($theads as $thead){
112
+ wp125_CheckAdDate($thead['end_date'], $thead['id']);
113
+ $theslot = $thead['slot'];
114
+ $adguidearray[$theslot] = $thead;
115
+ $arraycount++;
116
+ }
117
+ if ($setting_ad_order == 'random') {
118
+ srand((float)microtime() * 1000000);
119
+ shuffle($adguidearray);
120
+ $adguidearray_shufflefix = $adguidearray[0]; $adguidearray[0]=''; $adguidearray[]=$adguidearray_shufflefix;
121
+ }
122
+ for ($curslot=1; $curslot <= $setting_num_slots; $curslot++) {
123
+ if (isset($adguidearray[$curslot])) {
124
+ echo '<div class="wp125ad"><img src="'.$adguidearray[$curslot]['image_url'].'" alt="'.$adguidearray[$curslot]['name'].'" /></div>';
125
+ } else { echo '<div class="wp125ad"><a href="'.$setting_buyad_url.'" rel="nofollow"><img src="'.$setting_defaultad.'" alt="" /></a></div>'; }
126
  }
127
  echo '</div>';
128
  }
129
+ if ($setting_ad_orientation=='2c') {
130
+ echo '<div id="wp125adwrap_2c">';
131
+ $arraycount = 0;
132
  foreach ($theads as $thead){
133
+ wp125_CheckAdDate($thead['end_date'], $thead['id']);
134
+ $theslot = $thead['slot'];
135
+ $adguidearray[$theslot] = $thead;
136
+ $arraycount++;
137
+ }
138
+ if ($setting_ad_order == 'random') {
139
+ srand((float)microtime() * 1000000);
140
+ shuffle($adguidearray);
141
+ $adguidearray_shufflefix = $adguidearray[0]; $adguidearray[0]=''; $adguidearray[]=$adguidearray_shufflefix;
142
+ }
143
+ for ($curslot=1; $curslot <= $setting_num_slots; $curslot++) {
144
+ if (isset($adguidearray[$curslot])) {
145
+ echo '<div class="wp125ad"><img src="'.$adguidearray[$curslot]['image_url'].'" alt="'.$adguidearray[$curslot]['name'].'" /></div>';
146
+ } else { echo '<div class="wp125ad"><a href="'.$setting_buyad_url.'" rel="nofollow"><img src="'.$setting_defaultad.'" alt="" /></a></div>'; }
147
  }
148
  echo '</div>';
149
  }
 
150
  }
151
  }
152
 
159
  wp125_CheckAdDate($thead->end_date, $thead->id);
160
  if ($thead->clicks != -1) { $linkurl = get_option('blogurl').'index.php?adclick='.$thead->id; } else { $linkurl = $thead->target; }
161
  echo '<a href="'.$linkurl.'" rel="nofollow"><img src="'.$thead->image_url.'" alt="'.$thead->name.'" /></a>';
162
+ } else { echo '<a href="'.get_option("wp125_buyad_url").'" rel="nofollow"><img src="'.get_option("wp125_defaultad").'" alt="Your Ad Here" /></a>'; }
163
+ }
164
+
165
+
166
+ //Return path to plugin directory (url/path)
167
+ function wp125_get_plugin_dir($type) {
168
+ if ( !defined('WP_CONTENT_URL') )
169
+ define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
170
+ if ( !defined('WP_CONTENT_DIR') )
171
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
172
+ if ($type=='path') { return WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__)); }
173
+ else { return WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)); }
174
+ }
175
+
176
+
177
+ //Send email alert to admin when an ad expires
178
+ function sendExpirationEmail($theid) {
179
+ global $wpdb;
180
+ $adtable_name = $wpdb->prefix . "wp125_ads";
181
+ $thead = $wpdb->get_row("SELECT * FROM $adtable_name WHERE id='$theid'", OBJECT);
182
+ if (get_option('wp125_emailonexp')!='') {
183
+ $theblog = get_option('blogname');
184
+ $from = get_option('admin_email');
185
+ $message = "One of the advertisements on $theblog has expired.\n\nAD NAME: ".$thead->name."\nAD URL: ".$thead->target."\nSTART DATE: ".$thead->start_date."\nEND DATE: ".$thead->end_date."\n\nFor more information, and to manage your ads, please log in to your WordPress administration.\n\n\n*** Powered by WordPress and WP125 ***";
186
+ $headers = "From: $from\r\nReply-To: $from";
187
+ $mail_sent = @mail(get_option('wp125_emailonexp'), "An ad on your blog has expired", $message, $headers);
188
  }
189
+ return;
190
  }
191
 
192
 
youradhere.jpg ADDED
Binary file