Version Description
Download this release
Release Info
Developer | redwallhp |
Plugin | WP125 |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- adminmenus.php +277 -0
- installer.php +68 -0
- readme.txt +76 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- wp125.php +146 -0
adminmenus.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//Write Manage Menu
|
4 |
+
function wp125_write_managemenu() {
|
5 |
+
echo '<div class="wrap">
|
6 |
+
<h2>Manage Ads</h2>';
|
7 |
+
|
8 |
+
//Handle deactivations
|
9 |
+
if ($_GET['wp125action'] == "deactivate") {
|
10 |
+
$theid = $_GET['theid'];
|
11 |
+
echo '<div id="message" class="updated fade"><p>Are you sure you want to deactivate the ad? <a href="admin.php?page=wp125/wp125.php&wp125action=deactivateconf&theid='.$theid.'">Yes</a> <a href="admin.php?page=wp125/wp125.php">No!</a></p></div>';
|
12 |
+
}
|
13 |
+
if ($_GET['wp125action'] == "deactivateconf") {
|
14 |
+
$theid = $_GET['theid'];
|
15 |
+
global $wpdb, $table_prefix;
|
16 |
+
$adtable_name = $wpdb->prefix . "wp125_ads";
|
17 |
+
$wpdb->query("UPDATE $adtable_name SET status = '0' WHERE id = '$theid'");
|
18 |
+
echo '<div id="message" class="updated fade"><p>Ad deactivated.</p></div>';
|
19 |
+
}
|
20 |
+
|
21 |
+
//Handle REactivations
|
22 |
+
if ($_GET['wp125action'] == "activate") {
|
23 |
+
$theid = $_GET['theid'];
|
24 |
+
echo '<div id="message" class="updated fade"><p>Are you sure you want to reactivate the ad? <a href="admin.php?page=wp125/wp125.php&showmanage=inactive&wp125action=activateconf&theid='.$theid.'">Yes</a> <a href="admin.php?page=wp125/wp125.php&showmanage=inactive">No!</a></p></div>';
|
25 |
+
}
|
26 |
+
if ($_GET['wp125action'] == "activateconf") {
|
27 |
+
$theid = $_GET['theid'];
|
28 |
+
global $wpdb, $table_prefix;
|
29 |
+
$adtable_name = $wpdb->prefix . "wp125_ads";
|
30 |
+
$wpdb->query("UPDATE $adtable_name SET status = '1' WHERE id = '$theid'");
|
31 |
+
echo '<div id="message" class="updated fade"><p>Ad activated.</p></div>';
|
32 |
+
}
|
33 |
+
|
34 |
+
echo '<ul class="subsubsub">'; ?>
|
35 |
+
<li><a href="admin.php?page=wp125/wp125.php" <?php if ($_GET['showmanage'] != 'inactive') { echo 'class="current"'; } ?>>Active Ads</a> |</li><li><a href="admin.php?page=wp125/wp125.php&showmanage=inactive" <?php if ($_GET['showmanage'] == 'inactive') { echo 'class="current"'; } ?>>Inactive Ads</a></li>
|
36 |
+
<?php echo '</ul>
|
37 |
+
<table class="widefat">
|
38 |
+
<thead><tr>
|
39 |
+
<th scope="col">Slot</th>
|
40 |
+
<th scope="col">Name</th>
|
41 |
+
<th scope="col" class="num">Clicks</th>
|
42 |
+
<th scope="col">Start Date</th>
|
43 |
+
<th scope="col">End Date</th>
|
44 |
+
<th scope="col"></th>
|
45 |
+
<th scope="col"></th>
|
46 |
+
</tr></thead>
|
47 |
+
<tbody>';
|
48 |
+
|
49 |
+
global $wpdb;
|
50 |
+
$adtable_name = $wpdb->prefix . "wp125_ads";
|
51 |
+
if ($_GET['showmanage'] == 'inactive') {
|
52 |
+
$wp125db = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status = '0' ORDER BY id DESC", OBJECT);
|
53 |
+
} else {
|
54 |
+
$wp125db = $wpdb->get_results("SELECT * FROM $adtable_name WHERE status != '0' ORDER BY id DESC", OBJECT);
|
55 |
+
}
|
56 |
+
if ($wp125db) {
|
57 |
+
foreach ($wp125db as $wp125db){
|
58 |
+
|
59 |
+
echo '<tr>';
|
60 |
+
echo '<td>'.$wp125db->slot.'</td>';
|
61 |
+
echo '<td><strong>'.$wp125db->name.'</strong></td>';
|
62 |
+
if ($wp125db->clicks!='-1') { echo '<td class="num">'.$wp125db->clicks.'</td>'; } else { echo '<td class="num">N/A</td>'; }
|
63 |
+
echo '<td>'.$wp125db->start_date.'</td>';
|
64 |
+
echo '<td>'.$wp125db->end_date.'</td>';
|
65 |
+
echo '<td><a href="admin.php?page=wp125_addedit&editad='.$wp125db->id.'">Edit</a></td>';
|
66 |
+
if ($_GET['showmanage'] == 'inactive') {
|
67 |
+
echo '<td><a href="admin.php?page=wp125/wp125.php&showmanage=inactive&wp125action=activate&theid='.$wp125db->id.'">Activate</a></td>';
|
68 |
+
} else {
|
69 |
+
echo '<td><a href="admin.php?page=wp125/wp125.php&wp125action=deactivate&theid='.$wp125db->id.'">Deactivate</a></td>';
|
70 |
+
}
|
71 |
+
echo '</tr>';
|
72 |
+
|
73 |
+
}
|
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() {
|
82 |
+
//DB Data
|
83 |
+
global $wpdb;
|
84 |
+
$settingtable_name = $wpdb->prefix . "wp125_settings";
|
85 |
+
$adtable_name = $wpdb->prefix . "wp125_ads";
|
86 |
+
// Retrieve settings
|
87 |
+
$wp125settings = $wpdb->get_row("SELECT * FROM $settingtable_name WHERE ad_orientation != '' ", OBJECT);
|
88 |
+
//If post is being edited, grab current info
|
89 |
+
if ($_GET['editad']!='') {
|
90 |
+
$theid = $_GET['editad'];
|
91 |
+
$editingad = $wpdb->get_row("SELECT * FROM $adtable_name WHERE id = '$theid'", OBJECT);
|
92 |
+
}
|
93 |
+
?><div class="wrap">
|
94 |
+
|
95 |
+
<?php
|
96 |
+
if ($_POST['Submit']) {
|
97 |
+
$post_editedad = $wpdb->escape($_POST['editedad']);
|
98 |
+
$post_adname = $wpdb->escape($_POST['adname']);
|
99 |
+
$post_adslot = $wpdb->escape($_POST['adslot']);
|
100 |
+
$post_adtarget = $wpdb->escape($_POST['adtarget']);
|
101 |
+
$post_adexp = $wpdb->escape($_POST['adexp']);
|
102 |
+
$post_adexpmo = $wpdb->escape($_POST['adexp-mo']);
|
103 |
+
$post_adexpday = $wpdb->escape($_POST['adexp-day']);
|
104 |
+
$post_adexpyr = $wpdb->escape($_POST['adexp-yr']);
|
105 |
+
$post_countclicks = $wpdb->escape($_POST['countclicks']);
|
106 |
+
$post_adimage = $wpdb->escape($_POST['adimage']);
|
107 |
+
if ($post_countclicks=='on') { $post_countclicks = '0'; } else { $post_countclicks = '-1'; }
|
108 |
+
$today = date('m').'/'.date('d').'/'.date('Y');
|
109 |
+
if ($post_adexp=='manual') { $theenddate = '00/00/0000'; }
|
110 |
+
if ($post_adexp=='other') { $theenddate = $post_adexpmo.'/'.$post_adexpday.'/'.$post_adexpyr; }
|
111 |
+
if ($post_adexp=='30') { $expiry = time() + 30 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
|
112 |
+
if ($post_adexp=='60') { $expiry = time() + 60 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
|
113 |
+
if ($post_adexp=='90') { $expiry = time() + 90 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
|
114 |
+
if ($post_adexp=='120') { $expiry = time() + 120 * 24 * 60 * 60; $expiry = strftime('%m/%d/%Y', $expiry); $theenddate = $expiry; }
|
115 |
+
if ($post_editedad!='') { $theenddate = $post_adexpmo.'/'.$post_adexpday.'/'.$post_adexpyr; }
|
116 |
+
if ($post_editedad=='') {
|
117 |
+
$updatedb = "INSERT INTO $adtable_name (slot, name, start_date, end_date, clicks, status, target, image_url) VALUES ('$post_adslot', '$post_adname', '$today','$theenddate','$post_countclicks', '1', '$post_adtarget','$post_adimage')";
|
118 |
+
$results = $wpdb->query($updatedb);
|
119 |
+
echo '<div id="message" class="updated fade"><p>Ad "'.$post_adname.'" created.</p></div>';
|
120 |
+
} else {
|
121 |
+
$updatedb = "UPDATE $adtable_name SET slot = '$post_adslot', name = '$post_adname', end_date = '$theenddate', target = '$post_adtarget', image_url = '$post_adimage' WHERE id='$post_editedad'";
|
122 |
+
$results = $wpdb->query($updatedb);
|
123 |
+
echo '<div id="message" class="updated fade"><p>Ad "'.$post_adname.'" updated.</p></div>';
|
124 |
+
}
|
125 |
+
}
|
126 |
+
if ($_POST['deletead']) {
|
127 |
+
$post_editedad = $wpdb->escape($_POST['editedad']);
|
128 |
+
echo '<div id="message" class="updated fade"><p>Do you really want to delete this ad record? This action cannot be undone. <a href="admin.php?page=wp125_addedit&deletead='.$post_editedad.'">Yes</a> <a href="admin.php?page=wp125_addedit&editad='.$post_editedad.'">No!</a></p></div>';
|
129 |
+
}
|
130 |
+
if ($_GET['deletead']!='') {
|
131 |
+
$thead=$_GET['deletead'];
|
132 |
+
$updatedb = "DELETE FROM $adtable_name WHERE id='$thead'";
|
133 |
+
$results = $wpdb->query($updatedb);
|
134 |
+
echo '<div id="message" class="updated fade"><p>Ad deleted.</p></div>';
|
135 |
+
}
|
136 |
+
?>
|
137 |
+
|
138 |
+
<h2>Add/Edit Ads</h2>
|
139 |
+
|
140 |
+
<form method="post" action="admin.php?page=wp125_addedit">
|
141 |
+
<table class="form-table">
|
142 |
+
|
143 |
+
<?php if ($_GET['editad']!='') { echo '<input name="editedad" type="hidden" value="'.$_GET['editad'].'" />'; } ?>
|
144 |
+
|
145 |
+
<tr valign="top">
|
146 |
+
<th scope="row">Name</th>
|
147 |
+
<td><input name="adname" type="text" id="adname" value="<?php echo $editingad->name; ?>" size="40" /><br/>Whose ad is this?</td>
|
148 |
+
</tr>
|
149 |
+
|
150 |
+
<tr valign="top">
|
151 |
+
<th scope="row">Slot</th>
|
152 |
+
<td><label for="adslot">
|
153 |
+
<select name="adslot" id="adslot">
|
154 |
+
<?php for ($count = 1; $count <= $wp125settings->num_slots; $count += 1) { ?>
|
155 |
+
<option value="<?php echo $count; ?>" <?php if ($count == $editingad->slot) { echo 'selected="selected"'; } ?>>#<?php echo $count; ?></option>
|
156 |
+
<?php } ?>
|
157 |
+
</select></label>
|
158 |
+
</td></tr>
|
159 |
+
|
160 |
+
<tr valign="top">
|
161 |
+
<th scope="row">Target URL</th>
|
162 |
+
<td><input name="adtarget" type="text" id="adtarget" value="<?php if ($editingad->target!='') { echo $editingad->target; } else { echo 'http://'; } ?>" size="40" /><br/>Where should the ad link to?</td>
|
163 |
+
</tr>
|
164 |
+
|
165 |
+
<?php if ($_GET['editad']!='') {
|
166 |
+
$enddate = $editingad->end_date;
|
167 |
+
if ($enddate != '00/00/0000') {
|
168 |
+
$enddate = strtotime($enddate);
|
169 |
+
$endmonth = date('m', $enddate);
|
170 |
+
$endday = date('d', $enddate);
|
171 |
+
$endyear = date('Y', $enddate);
|
172 |
+
} else { $endmonth='00'; $endday='00'; $endyear='0000'; }
|
173 |
+
} ?>
|
174 |
+
<tr valign="top">
|
175 |
+
<th scope="row">Expiration</th>
|
176 |
+
<td><label for="adexp">
|
177 |
+
<?php if ($_GET['editad']=='') { ?><select name="adexp" id="adexp" onChange="isOtherDate(this.value)">
|
178 |
+
<option value="manual">I'll remove it manually</option>
|
179 |
+
<option selected="selected" value="30">30 Days</option>
|
180 |
+
<option value="60">60 Days</option>
|
181 |
+
<option value="90">90 Days</option>
|
182 |
+
<option value="120">120 Days</option>
|
183 |
+
<option value="other">Other</option>
|
184 |
+
</select><?php } ?></label>
|
185 |
+
<span id="adexp-date"> Month: <input type="text" name="adexp-mo" id="adexp-mo" size="2" value="<?php if ($endmonth!='') { echo $endmonth; } else { echo date('m'); } ?>" /> Day: <input type="text" name="adexp-day" id="adexp-day" size="2" value="<?php if ($endday!='') { echo $endday; } else { echo date('d'); } ?>" /> Year: <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 /> Use 00/00/0000 for manual removal.<?php } ?></span>
|
186 |
+
</td></tr>
|
187 |
+
|
188 |
+
<?php if ($_GET['editad']=='') { ?><script type="text/javascript">
|
189 |
+
document.getElementById("adexp-date").style.display = "none";
|
190 |
+
function isOtherDate(obj) {
|
191 |
+
if (obj=="other") {
|
192 |
+
document.getElementById("adexp-date").style.display = "inline";
|
193 |
+
} else {
|
194 |
+
document.getElementById("adexp-date").style.display = "none";
|
195 |
+
}
|
196 |
+
}
|
197 |
+
</script><?php } ?>
|
198 |
+
|
199 |
+
<?php if ($_GET['editad']=='') { ?>
|
200 |
+
<tr valign="top">
|
201 |
+
<th scope="row">Click Tracking</th>
|
202 |
+
<td><input type="checkbox" name="countclicks" checked="checked" /> Count the number of times this ad is clicked</td>
|
203 |
+
</tr>
|
204 |
+
<?php } ?>
|
205 |
+
|
206 |
+
<tr valign="top">
|
207 |
+
<th scope="row">Ad Image</th>
|
208 |
+
<td><input name="adimage" type="text" id="adimage" value="<?php if ($editingad->image_url!='') { echo $editingad->image_url; } else { echo 'http://'; } ?>" size="40" /></td>
|
209 |
+
</tr>
|
210 |
+
|
211 |
+
</table>
|
212 |
+
<p class="submit"><input type="submit" name="Submit" value="Save Ad" /> <?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">
|
236 |
+
<table class="form-table">
|
237 |
+
|
238 |
+
<tr valign="top">
|
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>
|
268 |
+
<input name="issubmitted" type="hidden" value="yes" />
|
269 |
+
<p class="submit"><input type="submit" name="Submit" value="Save Changes" /></p>
|
270 |
+
</form>
|
271 |
+
<br/>
|
272 |
+
<p>Your ads can be displayed using either the included widget, or by using the <strong><?php wp125_write_ads(); ?></strong> template tag. Also, you can display a single ad, without any formatting, using <strong><?php wp125_single_ad(<em>num</em>); ?></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 |
+
?>
|
installer.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
23 |
+
clicks int(7) NOT NULL,
|
24 |
+
start_date varchar(12) NOT NULL,
|
25 |
+
end_date varchar(12) NOT NULL,
|
26 |
+
status int(1) NOT NULL,
|
27 |
+
target text NOT NULL,
|
28 |
+
image_url text NOT NULL,
|
29 |
+
PRIMARY KEY (id)
|
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,
|
55 |
+
clicks int(7) NOT NULL,
|
56 |
+
start_date varchar(12) NOT NULL,
|
57 |
+
end_date varchar(12) NOT NULL,
|
58 |
+
status int(1) NOT NULL,
|
59 |
+
target text NOT NULL,
|
60 |
+
image_url text NOT NULL,
|
61 |
+
PRIMARY KEY (id)
|
62 |
+
);";
|
63 |
+
dbDelta($sql);
|
64 |
+
update_option( "wp125_db_version", $wp125_db_version );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
//***** End Installer *****
|
68 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: redwall_hp
|
3 |
+
Plugin URI: http://www.webmaster-source.com/wp125-ad-plugin-wordpress/
|
4 |
+
Author URI: http://www.webmaster-source.com
|
5 |
+
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.
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
== Description ==
|
17 |
+
|
18 |
+
If you've given up the low-paying and slightly obtrusive ad networks used by many new bloggers, in favor of selling ads directly, you may have been frustrated with the excessive time involved managing your ads. Not only do you have to find advertisers to sponsor your blog, you have to manually edit your template to put the ad in, and then head over to your favorite calendar app to set an alert to remind you when to take the ad down.
|
19 |
+
|
20 |
+
Time consuming practices like those are a thing of the past. The WP125 plugin can help you manage your ads more efficiently, leaving you with more time to write new posts. The plugin adds a new "Ads" menu to the WordPress admin, featuring submenus for tweaking display settings and adding and removing ads.
|
21 |
+
|
22 |
+
Features include:
|
23 |
+
|
24 |
+
* One or two column ad display, and support through template tags to implement your own unconventional design.
|
25 |
+
* Show as many ads as you want, and in either manual or random order
|
26 |
+
* Keep track of how many times an ad is clicked
|
27 |
+
* When creating a new ad, you don't have to calculate the end date yourself. Just input how many days you wish the ad to run for, and the correct date will be applied. The ad will be automatically taken down when the time comes.
|
28 |
+
* When an ad run is over, the record is archived on the Inactive ads screen, so you can check on the final click count, or revive the ad for another run.
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
== Installation ==
|
33 |
+
|
34 |
+
1. Download and unzip the package.
|
35 |
+
2. FTP the entire "wp125" directory to your /wp-content/plugins/ directory on your blog.
|
36 |
+
3. Activate the plugin on the "Plugins" tab of the administartion panel.
|
37 |
+
4. Either use the included "WP125: Ads" widget, or place the <?php wp125_write_ads(); ?> template tag where you wish your ads to appear.
|
38 |
+
5. Go to the new "Ads" section of the WordPress admin, where you can tweak settings, such as the maximum number of ads to be shown at once (the default is 6), and how they should be displayed.
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
== Upgrading ==
|
43 |
+
|
44 |
+
You may upgrade the plugin via the automated system in WordPress 2.5 or greater, or "old-style" by downloading the new one and then
|
45 |
+
1. Deactivating plugin
|
46 |
+
2. Uploading the updated files
|
47 |
+
3. Reactivating plugin
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
== Frequently Asked Questions ==
|
52 |
+
|
53 |
+
= What if I don't want to arrange my ads in one OR two columns? =
|
54 |
+
If you want to arrange your ads in an unconventional manner, you can use the <?php wp125_single_ad(num); ?> template tag (replace "num" with the number of an ad slot). The tag will return one ad with minimal formatting (simply <a><img /></a>). You can use multiple instances of the tag in your template to set lay your ad slots out in whatever way you choose.
|
55 |
+
|
56 |
+
= One of my ads hit it's expiration date. Where did it go? =
|
57 |
+
When an ad's time duration is over, it disappears off your site, and is removed from the Active ads page in the WordPress admin. To access the record, just click the "Inactive" link on the Manage screen. The page should update to show all of your inactive ads.
|
58 |
+
|
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 ==
|
65 |
+
1. A few 125x125 ads, in two-column format.
|
66 |
+
2. The Add/Edit ads screen.
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
== Known Issues ==
|
71 |
+
* If you have WP Super Cache installed on your blog, it may conflict with WP125's click tracking feature. To fix this, add "index.php" on a new line in the "Rejected URLs" field of the WP Super Cache options page. This will disable caching for yourblog.com/index.php. If someone goes to yourblog.com, they will still get the cached version, but since WP125's click tracker URLs look like "/index.php?adclick=1," they will avoid the cache.
|
72 |
+
|
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.
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|
wp125.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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";
|
19 |
+
$thead = $wpdb->get_row("SELECT target FROM $adtable_name WHERE id = '$theid'", OBJECT);
|
20 |
+
$update = "UPDATE ". $adtable_name ." SET clicks=clicks+1 WHERE id='$theid'";
|
21 |
+
$results = $wpdb->query( $update );
|
22 |
+
header("Location: $thead->target");
|
23 |
+
exit;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
//Installer
|
29 |
+
require_once(dirname(__FILE__).'/installer.php');
|
30 |
+
register_activation_hook(__FILE__,'wp125_install');
|
31 |
+
|
32 |
+
|
33 |
+
//Create Widget
|
34 |
+
function wp125_create_ad_widget() {
|
35 |
+
register_sidebar_widget(__('WP125'), 'wp125_write_ads_widget');
|
36 |
+
}
|
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 |
+
|
61 |
+
//Check Ad Date, and deactivate if the time is up
|
62 |
+
function wp125_CheckAdDate($thedate, $theid) {
|
63 |
+
global $wpdb;
|
64 |
+
$adtable_name = $wpdb->prefix . "wp125_ads";
|
65 |
+
if ($thedate!='00/00/0000') {
|
66 |
+
$today = strtotime(date('m').'/'.date('d').'/'.date('Y'));
|
67 |
+
$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 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
|
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 |
+
|
110 |
+
|
111 |
+
function wp125_single_ad($theslot) {
|
112 |
+
global $wpdb;
|
113 |
+
$adtable_name = $wpdb->prefix . "wp125_ads";
|
114 |
+
$thead = $wpdb->get_row("SELECT * FROM $adtable_name WHERE slot = '$theslot' AND status = '1' ORDER BY id DESC", OBJECT);
|
115 |
+
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 |
+
|
123 |
+
//Hooks
|
124 |
+
add_action("plugins_loaded", "wp125_create_ad_widget"); //Create the Widget
|
125 |
+
add_action('admin_menu', 'wp125_add_admin_menu'); //Admin pages
|
126 |
+
|
127 |
+
|
128 |
+
|
129 |
+
/*
|
130 |
+
Copyright 2008 Matt Harzewski
|
131 |
+
|
132 |
+
This program is free software: you can redistribute it and/or modify
|
133 |
+
it under the terms of the GNU General Public License as published by
|
134 |
+
the Free Software Foundation, either version 3 of the License, or
|
135 |
+
(at your option) any later version.
|
136 |
+
|
137 |
+
This program is distributed in the hope that it will be useful,
|
138 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
139 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
140 |
+
GNU General Public License for more details.
|
141 |
+
|
142 |
+
You should have received a copy of the GNU General Public License
|
143 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
144 |
+
*/
|
145 |
+
|
146 |
+
?>
|