Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

adminmenus.php for WP125 1.4.9

By: samuelaguilera on Mar 14th, 2013  |  syntax: PHP  |  size: 21.35 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. // fixed file for WP125 1.4.9
  4.  
  5. if (function_exists('wp_enqueue_style') ) {
  6.  
  7.         function wp125_admin_styles ($hook) { // this function insert required js/css ONLY if we are in the correct page
  8.  
  9.                 global $wp125_edit;
  10.  
  11.                 if( $wp125_edit != $hook ) {
  12.  
  13.                         return;
  14.  
  15.                 } else {
  16.  
  17.                         wp_enqueue_script('jquery');
  18.                         wp_enqueue_script('thickbox');
  19.                         wp_enqueue_style('thickbox');
  20.                         wp_enqueue_script('media-upload');
  21.  
  22.  
  23.                 }
  24.         }
  25.  
  26. add_action( 'admin_enqueue_scripts', 'wp125_admin_styles' );
  27.  
  28. }
  29.  
  30.  
  31. //Write Manage Menu
  32. function wp125_write_managemenu() {
  33. echo '<div class="wrap">
  34. <h2>'.__('Manage Ads', 'wp125').'</h2>';
  35.  
  36. //Handle deactivations
  37. if ($_GET['wp125action'] == "deactivate") {
  38. $theid = intval($_GET['theid']);
  39. echo '<div id="message" class="updated fade"><p>'.__('Are you sure you want to deactivate the ad?', 'wp125').' <a href="admin.php?page=wp125/wp125.php&wp125action=deactivateconf&theid='.$theid.'">'.__('Yes', 'wp125').'</a> &nbsp; <a href="admin.php?page=wp125/wp125.php">'.__('No!', 'wp125').'</a></p></div>';
  40. }
  41. if ($_GET['wp125action'] == "deactivateconf") {
  42. $theid = intval($_GET['theid']);
  43. global $wpdb, $table_prefix;
  44. $adtable_name = $wpdb->prefix . "wp125_ads";
  45. $wpdb->update(
  46.         $adtable_name,
  47.         array('status' => '0'),
  48.         array('id' => $theid)
  49. );
  50. echo '<div id="message" class="updated fade"><p>'.__('Ad deactivated.', 'wp125').'</p></div>';
  51. }
  52.  
  53. //Handle REactivations
  54. if ($_GET['wp125action'] == "activate") {
  55. $theid = intval($_GET['theid']);
  56. echo '<div id="message" class="updated fade"><p>'.__('Are you sure you want to reactivate the ad?', 'wp125').' <a href="admin.php?page=wp125/wp125.php&showmanage=inactive&wp125action=activateconf&theid='.$theid.'">'.__('Yes', 'wp125').'</a> &nbsp; <a href="admin.php?page=wp125/wp125.php&showmanage=inactive">'.__('No!', 'wp125').'</a></p></div>';
  57. }
  58. if ($_GET['wp125action'] == "activateconf") {
  59. $theid = intval($_GET['theid']);
  60. global $wpdb, $table_prefix;
  61. $adtable_name = $wpdb->prefix . "wp125_ads";
  62. $wpdb->update(
  63.         $adtable_name,
  64.         array('status' => '1', 'pre_exp_email' => '0'),
  65.         array('id' => $theid)
  66. );
  67. echo '<div id="message" class="updated fade"><p>'.__('Ad activated.', 'wp125').'</p></div>';
  68. }
  69.  
  70. echo '<ul class="subsubsub">'; ?>
  71. <li><a href="admin.php?page=wp125/wp125.php"  <?php if ($_GET['showmanage'] != 'inactive') { echo 'class="current"'; } ?>><?php _e('Active Ads', 'wp125'); ?></a> | </li><li><a href="admin.php?page=wp125/wp125.php&showmanage=inactive" <?php if ($_GET['showmanage'] == 'inactive') { echo 'class="current"'; } ?>><?php _e('Inactive Ads', 'wp125'); ?></a></li>
  72. <?php echo '</ul>
  73. <table class="widefat">
  74. <thead><tr>
  75. <th scope="col">'.__('Slot', 'wp125').'</th>
  76. <th scope="col">'.__('Name', 'wp125').'</th>
  77. <th scope="col" class="num">'.__('Clicks', 'wp125').'</th>
  78. <th scope="col">'.__('Start Date', 'wp125').'</th>
  79. <th scope="col">'.__('End Date', 'wp125').'</th>
  80. <th scope="col"></th>
  81. <th scope="col" style="text-align:right;"><a href="admin.php?page=wp125_addedit" class="button rbutton">'.__('Add New', 'wp125').'</a></th>
  82. </tr></thead>
  83. <tbody>';
  84.  
  85. global $wpdb;
  86. $adtable_name = $wpdb->prefix . "wp125_ads";
  87. if ($_GET['showmanage'] == 'inactive') {
  88. $wp125db = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status = '0' ORDER BY id DESC", OBJECT);
  89. } else {
  90. $wp125db = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status != '0' ORDER BY id DESC", OBJECT);
  91. }
  92. if ($wp125db) {
  93. foreach ($wp125db as $wp125db){
  94.  
  95. echo '<tr>';
  96. echo '<td>'.$wp125db->slot.'</td>';
  97. echo '<td><strong>'.$wp125db->name.'</strong></td>';
  98. if ($wp125db->clicks!='-1') { echo '<td class="num">'.$wp125db->clicks.'</td>'; } else { echo '<td class="num">'.__('N/A', 'wp125').'</td>'; }
  99. echo '<td>'.$wp125db->start_date.'</td>';
  100. echo '<td>'.$wp125db->end_date.'</td>';
  101. echo '<td><a href="admin.php?page=wp125_addedit&editad='.$wp125db->id.'">'.__('Edit', 'wp125').'</a></td>';
  102. if ($_GET['showmanage'] == 'inactive') {
  103. echo '<td><a href="admin.php?page=wp125/wp125.php&showmanage=inactive&wp125action=activate&theid='.$wp125db->id.'">'.__('Activate', 'wp125').'</a></td>';
  104. } else {
  105. echo '<td><a href="admin.php?page=wp125/wp125.php&wp125action=deactivate&theid='.$wp125db->id.'">'.__('Deactivate', 'wp125').'</a></td>';
  106. }
  107. echo '</tr>';
  108.  
  109. }
  110. } else { echo '<tr> <td colspan="8">'.__('No ads found.', 'wp125').'</td> </tr>'; }
  111.  
  112. echo '</tbody>
  113. </table>';
  114. echo '<br /><a href="'.wp125_get_plugin_dir('url').'/calendar.php" title="Subscribe with your calendaring software..."><img src="'.wp125_get_plugin_dir('url').'/ical.gif" alt="iCalendar" /></a>';
  115. wp125_admin_page_footer();
  116. echo '</div>';
  117. }
  118.  
  119. function wp125_write_addeditmenu() {
  120. //DB Data
  121. global $wpdb;
  122. $adtable_name = $wpdb->prefix . "wp125_ads";
  123. // Retrieve settings
  124. $setting_ad_orientation = get_option("wp125_ad_orientation");
  125. $setting_num_slots = get_option("wp125_num_slots");
  126. $setting_ad_order = get_option("wp125_ad_order");
  127. $setting_buyad_url = get_option("wp125_buyad_url");
  128. $setting_widget_title = get_option("wp125_widget_title");
  129. $setting_disable_default_style = get_option("wp125_disable_default_style");
  130. $setting_emailonexp = get_option("wp125_emailonexp");
  131. $setting_defaultad = get_option("wp125_defaultad");
  132. //If post is being edited, grab current info
  133. if ($_GET['editad']!='') {
  134. $theid = intval($_GET['editad']);
  135. $editingad = $wpdb->get_row($wpdb->prepare(
  136.         "SELECT * FROM {$adtable_name} WHERE id = %d",
  137.         $theid
  138. ));
  139. }
  140. ?><div class="wrap">
  141.  
  142. <?php
  143. if ($_POST['Submit']) {
  144. $post_editedad = $wpdb->escape($_POST['editedad']);
  145. $post_adname = $wpdb->escape($_POST['adname']);
  146. $post_adslot = $wpdb->escape($_POST['adslot']);
  147. $post_adtarget = $wpdb->escape($_POST['adtarget']);
  148. $post_adexp = $wpdb->escape($_POST['adexp']);
  149. $post_adexpmo = $wpdb->escape($_POST['adexp-mo']);
  150. $post_adexpday = $wpdb->escape($_POST['adexp-day']);
  151. $post_adexpyr = $wpdb->escape($_POST['adexp-yr']);
  152. $post_countclicks = $wpdb->escape($_POST['countclicks']);
  153. $post_adimage = $wpdb->escape($_POST['adimage']);
  154. if ($post_countclicks=='on') { $post_countclicks = '0'; } else { $post_countclicks = '-1'; }
  155. $today = date('m').'/'.date('d').'/'.date('Y');
  156. if ($post_adexp=='manual') { $theenddate = '00/00/0000'; }
  157. if ($post_adexp=='other') { $theenddate = $post_adexpmo.'/'.$post_adexpday.'/'.$post_adexpyr; }
  158. if ($post_adexp=='30') { $expiry = time() + 30 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
  159. if ($post_adexp=='60') { $expiry = time() + 60 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
  160. if ($post_adexp=='90') { $expiry = time() + 90 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
  161. if ($post_adexp=='120') { $expiry = time() + 120 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
  162. if ($post_editedad!='') { $theenddate = $post_adexpmo.'/'.$post_adexpday.'/'.$post_adexpyr; }
  163. if ($post_editedad=='') {
  164. $updatedb = "INSERT INTO $adtable_name (slot, name, start_date, end_date, clicks, status, target, image_url, pre_exp_email) VALUES ('$post_adslot', '$post_adname', '$today','$theenddate','$post_countclicks', '1', '$post_adtarget','$post_adimage', '0')";
  165. $results = $wpdb->query($updatedb);
  166. echo '<div id="message" class="updated fade"><p>Ad &quot;'.$post_adname.'&quot; created.</p></div>';
  167. } else {
  168. $updatedb = "UPDATE $adtable_name SET slot = '$post_adslot', name = '$post_adname', end_date = '$theenddate', target = '$post_adtarget', image_url = '$post_adimage', pre_exp_email = '0' WHERE id='$post_editedad'";
  169. $results = $wpdb->query($updatedb);
  170. echo '<div id="message" class="updated fade"><p>'.__('Ad', 'wp125').' &quot;'.$post_adname.'&quot; '.__('updated.', 'wp125').'</p></div>';
  171. }
  172. }
  173. if ($_POST['deletead']) {
  174. $post_editedad = $wpdb->escape($_POST['editedad']);
  175. echo '<div id="message" class="updated fade"><p>'.__('Do you really want to delete this ad record? This action cannot be undone.', 'wp125').' <a href="admin.php?page=wp125_addedit&deletead='.$post_editedad.'">'.__('Yes', 'wp125').'</a> &nbsp; <a href="admin.php?page=wp125_addedit&editad='.$post_editedad.'">'.__('No!', 'wp125').'</a></p></div>';
  176. }
  177. if ($_GET['deletead']!='') {
  178. $thead = intval($_GET['deletead']);
  179. $updatedb = "DELETE FROM $adtable_name WHERE id='$thead'";
  180. $results = $wpdb->query($updatedb);
  181. echo '<div id="message" class="updated fade"><p>'.__('Ad deleted.', 'wp125').'</p></div>';
  182. }
  183. ?>
  184.  
  185. <h2><?php _e('Add/Edit Ads', 'wp125'); ?></h2>
  186.  
  187. <form method="post" action="admin.php?page=wp125_addedit">
  188. <table class="form-table">
  189.  
  190. <?php if ($_GET['editad']!='') { echo '<input name="editedad" type="hidden" value="'.intval($_GET['editad']).'" />'; } ?>
  191.  
  192. <tr valign="top">
  193. <th scope="row"><?php _e('Name', 'wp125'); ?></th>
  194. <td><input name="adname" type="text" id="adname" value="<?php echo $editingad->name; ?>" size="40" /><br/><?php _e('Whose ad is this?', 'wp125'); ?></td>
  195. </tr>
  196.  
  197. <tr valign="top">
  198. <th scope="row"><?php _e('Slot', 'wp125'); ?></th>
  199. <td><label for="adslot">
  200. <select name="adslot" id="adslot">
  201. <?php for ($count = 1; $count <= $setting_num_slots; $count += 1) { ?>
  202. <option value="<?php echo $count; ?>" <?php if ($count == $editingad->slot) { echo 'selected="selected"'; } ?>>#<?php echo $count; ?></option>
  203. <?php } ?>
  204. </select></label>
  205. </td></tr>
  206.  
  207. <tr valign="top">
  208. <th scope="row"><?php _e('Target URL', 'wp125'); ?></th>
  209. <td><input name="adtarget" type="text" id="adtarget" value="<?php if ($editingad->target!='') { echo $editingad->target; } else { echo 'http://'; } ?>" size="40" /><br/><?php _e('Where should the ad link to?', 'wp125'); ?></td>
  210. </tr>
  211.  
  212. <?php if ($_GET['editad']!='') {
  213. $enddate = $editingad->end_date;
  214. if ($enddate != '00/00/0000') {
  215. $enddate = strtotime($enddate);
  216. $endmonth = date('m', $enddate);
  217. $endday = date('d', $enddate);
  218. $endyear = date('Y', $enddate);
  219. } else { $endmonth='00'; $endday='00'; $endyear='0000'; }
  220. } ?>
  221. <tr valign="top">
  222. <th scope="row"><?php _e('Expiration', 'wp125'); ?></th>
  223. <td><label for="adexp">
  224. <?php if ($_GET['editad']=='') { ?><select name="adexp" id="adexp" onChange="isOtherDate(this.value)">
  225. <option value="manual"><?php _e("I'll remove it manually", 'wp125'); ?></option>
  226. <option selected="selected" value="30">30 <?php _e('Days', 'wp125'); ?></option>
  227. <option value="60">60 <?php _e('Days', 'wp125'); ?></option>
  228. <option value="90">90 <?php _e('Days', 'wp125'); ?></option>
  229. <option value="120">120 <?php _e('Days', 'wp125'); ?></option>
  230. <option value="other"><?php _e('Other', 'wp125'); ?></option>
  231. </select><?php } ?></label>
  232.  <span id="adexp-date">&nbsp;&nbsp; <?php _e('Month:', 'wp125'); ?> <input type="text" name="adexp-mo" id="adexp-mo" size="2" value="<?php if ($endmonth!='') { echo $endmonth; } else { echo date('m'); } ?>" /> <?php _e('Day:', 'wp125'); ?> <input type="text" name="adexp-day" id="adexp-day" size="2" value="<?php if ($endday!='') { echo $endday; } else {  echo date('d'); } ?>" /> <?php _e('Year:', 'wp125'); ?> <input type="text" name="adexp-yr" id="adexp-yr" size="4" value="<?php if ($endyear!='') { echo $endyear; } else {  echo date('Y'); } ?>" /> <?php if ($_GET['editad']!='') { ?><br /> &nbsp;&nbsp; <?php _e('Use 00/00/0000 for manual removal.', 'wp125'); ?><?php } ?></span>
  233. </td></tr>
  234.  
  235. <?php if ($_GET['editad']=='') { ?><script type="text/javascript">
  236. document.getElementById("adexp-date").style.display = "none";
  237. function isOtherDate(obj) {
  238. if (obj=="other") {
  239. document.getElementById("adexp-date").style.display = "inline";
  240. } else {
  241. document.getElementById("adexp-date").style.display = "none";
  242. }
  243. }
  244. </script><?php } ?>
  245.  
  246. <?php if ($_GET['editad']=='') { ?>
  247. <tr valign="top">
  248. <th scope="row"><?php _e('Click Tracking', 'wp125'); ?></th>
  249. <td><input type="checkbox" name="countclicks" checked="checked" /> <?php _e('Count the number of times this ad is clicked', 'wp125'); ?></td>
  250. </tr>
  251. <?php } ?>
  252.  
  253. <tr valign="top">
  254. <th scope="row"><?php _e('Ad Image', 'wp125'); ?></th>
  255. <td><input name="adimage" type="text" id="adimage" value="<?php if ($editingad->image_url!='') { echo $editingad->image_url; } else { echo 'http://'; } ?>" size="40" /> <input id="upload_image_button" type="button" class="button" value="Upload Image" /></td>
  256. </tr>
  257.  
  258. <script type="text/javascript">
  259. jQuery(document).ready(function() {
  260.         jQuery('#upload_image_button').click(function() {
  261.                 formfield = jQuery('#adimage').attr('name');
  262.                 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
  263.                 return false;
  264.         });
  265.  
  266.         window.send_to_editor = function(html) {
  267.                 imgurl = jQuery('img',html).attr('src');
  268.                 jQuery('#adimage').val(imgurl);
  269.                 tb_remove();
  270.         }
  271. });
  272. </script>
  273.  
  274. </table>
  275. <p class="submit"><input type="submit" name="Submit" class="button" value="<?php _e('Save Ad', 'wp125'); ?>" /> &nbsp; <?php if ($_GET['editad']!='') { ?><input type="submit" name="deletead" value="<?php _e('Delete Ad', 'wp125'); ?>" /><?php } ?></p>
  276. </form>
  277. <?php wp125_admin_page_footer(); ?>
  278. </div><?php
  279. }
  280.  
  281. function wp125_write_settingsmenu() {
  282. //DB Data
  283. global $wpdb;
  284. //Add settings, if submitted
  285. if ($_POST['issubmitted']=='yes') {
  286. $post_adorient = $wpdb->escape($_POST['adorient']);
  287. $post_numslots = $wpdb->escape($_POST['numads']);
  288. $post_adorder = $wpdb->escape($_POST['adorder']);
  289. $post_salespage = $wpdb->escape($_POST['salespage']);
  290. $post_widgettitle = $wpdb->escape($_POST['widgettitle']);
  291. $post_defaultstyle = $wpdb->escape($_POST['defaultstyle']);
  292. $post_emailonexp = $wpdb->escape($_POST['emailonexp']);
  293. $post_daysbeforeexp = $wpdb->escape($_POST['daysbeforeexp']);
  294. $post_defaultad = $wpdb->escape($_POST['defaultad']);
  295. if ($post_defaultstyle!='on') { $post_defaultstyle = 'yes'; } else { $post_defaultstyle = ''; }
  296. update_option("wp125_ad_orientation", $post_adorient);
  297. update_option("wp125_num_slots", $post_numslots);
  298. update_option("wp125_ad_order", $post_adorder);
  299. update_option("wp125_buyad_url", $post_salespage);
  300. update_option("wp125_widget_title", $post_widgettitle);
  301. update_option("wp125_disable_default_style", $post_defaultstyle);
  302. update_option("wp125_emailonexp", $post_emailonexp);
  303. update_option("wp125_daysbeforeexp", $post_daysbeforeexp);
  304. update_option("wp125_defaultad", $post_defaultad);
  305. echo '<div id="message" class="updated fade"><p>Settings updated.</p></div>';
  306. }
  307. //Retrieve settings
  308. $setting_ad_orientation = get_option("wp125_ad_orientation");
  309. $setting_num_slots = get_option("wp125_num_slots");
  310. $setting_ad_order = get_option("wp125_ad_order");
  311. $setting_buyad_url = get_option("wp125_buyad_url");
  312. $setting_widget_title = get_option("wp125_widget_title");
  313. $setting_disable_default_style = get_option("wp125_disable_default_style");
  314. $setting_emailonexp = get_option("wp125_emailonexp");
  315. $setting_defaultad = get_option("wp125_defaultad");
  316. $setting_daysbeforeexp = get_option("wp125_daysbeforeexp");
  317. ?><div class="wrap">
  318. <h2><?php _e('Settings', 'wp125'); ?></h2>
  319. <form method="post" action="admin.php?page=wp125_settings">
  320. <table class="form-table">
  321.  
  322. <tr valign="top">
  323. <th scope="row"><?php _e('Ad Orientation', 'wp125'); ?></th>
  324. <td><label for="adorient">
  325. <select name="adorient" id="adorient">
  326. <option <?php if ($setting_ad_orientation=='1c') { echo 'selected="selected"'; } ?> value="1c"><?php _e('One Column', 'wp125'); ?></option>
  327. <option <?php if ($setting_ad_orientation=='2c') { echo 'selected="selected"'; } ?> value="2c"><?php _e('Two Column', 'wp125'); ?></option>
  328. </select></label>
  329. <br/><?php _e('How many columns should the ads be displayed in?', 'wp125'); ?>
  330. </td></tr>
  331.  
  332. <tr valign="top">
  333. <th scope="row"><?php _e('Number of Ad Slots', 'wp125'); ?></th>
  334. <td><input name="numads" type="text" id="numads" value="<?php echo $setting_num_slots; ?>" size="2" /><br/><?php _e('How many ads should be shown?', 'wp125'); ?></td>
  335. </tr>
  336.  
  337. <tr valign="top">
  338. <th scope="row"><?php _e('Ad Order', 'wp125'); ?></th>
  339. <td><label for="adorder">
  340. <select name="adorder" id="adorder">
  341. <option selected="selected" value="normal" <?php if ($setting_ad_order=='normal') { echo 'selected="selected"'; } ?>><?php _e('Normal', 'wp125'); ?></option>
  342. <option value="random" <?php if ($setting_ad_order=='random') { echo 'selected="selected"'; } ?>><?php _e('Random', 'wp125'); ?></option>
  343. </select></label>
  344. </td></tr>
  345.  
  346. <tr valign="top">
  347. <th scope="row"><?php _e('Widget Title', 'wp125'); ?></th>
  348. <td><input name="widgettitle" type="text" id="widgettitle" value="<?php echo $setting_widget_title; ?>" size="50" /><br/><?php _e('The title to be displayed in the widget.', 'wp125'); ?> <em><?php _e('(Leave blank to disable.)', 'wp125'); ?></em></td>
  349. </tr>
  350.  
  351. <tr valign="top">
  352. <th scope="row"><?php _e('Ad Sales Page', 'wp125'); ?></th>
  353. <td><input name="salespage" type="text" id="salespage" value="<?php echo $setting_buyad_url; ?>" size="50" /><br/><?php _e('Do you have a page with statistics and prices?', 'wp125'); ?> <em><?php _e('(Default Ads will link here.)', 'wp125'); ?></em></td>
  354. </tr>
  355.  
  356. <tr valign="top">
  357. <th scope="row"><?php _e('Default Style', 'wp125'); ?></th>
  358. <td><input type="checkbox" name="defaultstyle" <?php if ($setting_disable_default_style=='') { echo 'checked="checked"'; } ?> /> <?php _e('Include default ad stylesheet?', 'wp125'); ?> <br/><?php _e('Leave checked unless you want to use your own CSS to style the ads. Refer to the documentation for further help.', 'wp125'); ?></td>
  359. </tr>
  360.  
  361. <tr valign="top">
  362. <th scope="row"><?php _e('Expiration Email', 'wp125'); ?></th>
  363. <td><input name="emailonexp" type="text" id="emailonexp" value="<?php echo $setting_emailonexp; ?>" size="50" /><br/><?php _e('Enter your email address if you would like to be emailed when an ad expires.', 'wp125'); ?> <em><?php _e('(Leave blank to disable.)', 'wp125'); ?></em></td>
  364. </tr>
  365.  
  366. <tr valign="top">
  367. <th scope="row"><?php _e('Pre-Expiration Email', 'wp125'); ?></th>
  368. <td><?php _e('Remind me', 'wp125'); ?> <input name="daysbeforeexp" type="text" id="daysbeforeexp" value="<?php echo $setting_daysbeforeexp; ?>" size="2" /> <?php _e('days before an ad expires.', 'wp125'); ?> <em><?php _e('(Emails will be sent to the address specified above.)', 'wp125'); ?></em></td>
  369. </tr>
  370.  
  371. <tr valign="top">
  372. <th scope="row"><?php _e('Default Ad', 'wp125'); ?></th>
  373. <td><input name="defaultad" type="text" id="defaultad" value="<?php echo $setting_defaultad; ?>" size="50" /><br/><?php _e('Which image should be shown as a placeholder when an ad slot is empty?', 'wp125'); ?> (<a href="<?php echo wp125_get_plugin_dir('url').'/youradhere.jpg'; ?>"><?php _e('Default', 'wp125'); ?></a>)</td>
  374. </tr>
  375.  
  376. </table>
  377. <input name="issubmitted" type="hidden" value="yes" />
  378. <p class="submit"><input type="submit" class="button" name="Submit" value="<?php _e('Save Changes', 'wp125'); ?>" /></p>
  379. </form>
  380. <br/>
  381. <p><?php _e("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.", 'wp125'); ?></p>
  382. <?php wp125_admin_page_footer(); ?>
  383. </div><?php
  384. }
  385.  
  386.  
  387.  
  388. //Add Dashboard Widget
  389. function wp125_dashboard_widget() {
  390.         echo '<table class="widefat">
  391.         <thead><tr>
  392.         <th scope="col">'.__('Slot', 'wp125').'</th>
  393.         <th scope="col">'.__('Name', 'wp125').'</th>
  394.         <th scope="col" class="num">'.__('Clicks', 'wp125').'</th>
  395.         <th scope="col">'.__('Start Date', 'wp125').'</th>
  396.         <th scope="col">'.__('End Date', 'wp125').'</th>
  397.         </tr></thead>
  398.         <tbody>';
  399.         global $wpdb;
  400.         $adtable_name = $wpdb->prefix . "wp125_ads";
  401.         $wp125db = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status != '0' ORDER BY id DESC", OBJECT);
  402.         if ($wp125db) {
  403.         foreach ($wp125db as $wp125db){
  404.         ?>
  405.         <tr><td><?php echo $wp125db->slot; ?></td><td><strong><?php echo $wp125db->name; ?></strong></td><td class="num"><?php echo $wp125db->clicks; ?></td><td><?php echo $wp125db->start_date; ?></td><td><?php echo $wp125db->end_date; ?></td></tr>
  406.         <?php
  407.         }
  408.         } else { echo '<tr> <td colspan="8">'.__('No ads found.', 'wp125').'</td> </tr>'; }
  409.         echo '</tbody>
  410.         </table>
  411.         <br />';
  412.         echo '<a href="admin.php?page=wp125_addedit" class="button rbutton">'.__('Add New', 'wp125').'</a> &nbsp; <a href="admin.php?page=wp125/wp125.php" class="button rbutton">'.__('Manage', 'wp125').'</a> &nbsp; <a href="admin.php?page=wp125_settings" class="button rbutton">'.__('Settings', 'wp125').'</a>';
  413. }
  414. function wp125_dashboard_add_widget() {
  415.         if (current_user_can(MANAGEMENT_PERMISSION)) {
  416.                 if (function_exists('wp_add_dashboard_widget')) {
  417.                         wp_add_dashboard_widget('wp125_widget', __('125x125 Ads', 'wp125'), 'wp125_dashboard_widget');
  418.                 }
  419.         }
  420. }
  421. add_action('wp_dashboard_setup', 'wp125_dashboard_add_widget' );
  422.  
  423.  
  424.  
  425. function wp125_admin_page_footer() {
  426. echo '<div style="margin-top:45px; font-size:0.87em;">';
  427. echo '<div style="float:right;"><a href="http://www.webmaster-source.com/static/donate_plugin.php?plugin=wp125&amp;KeepThis=true&amp;TB_iframe=true&amp;height=250&amp;width=550" class="thickbox" title="Donate"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" alt="Donate" /></a></div>';
  428. echo '<div><a href="'.wp125_get_plugin_dir('url').'/readme.txt?KeepThis=true&amp;TB_iframe=true&amp;height=450&amp;width=680" class="thickbox" title="Documentation">'.__('Documentation', 'wp125').'</a> | <a href="http://www.webmaster-source.com/wp125-ad-plugin-wordpress/">'.__('WP125 Homepage', 'wp125').'</a></div>';
  429. echo '</div>';
  430. }
  431.  
  432. ?>