Changeset 45331
- Timestamp:
- 05/12/08 03:26:35 (2 months ago)
- Files:
-
- smart-ads/trunk/readme.txt (modified) (3 diffs)
- smart-ads/trunk/smartads.php (modified) (18 diffs)
- smart-ads/trunk/yourads.php.txt (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
smart-ads/trunk/readme.txt
r40979 r45331 4 4 Tags: ads, advertisements, insert 5 5 Requires at least: 2.3 6 Tested up to: 2.5 7 Stable tag: 1. 1.26 Tested up to: 2.5.1 7 Stable tag: 1.2 8 8 9 This plugin allows you to intelligently insert ads (like Adsense) before and after your post content based on post wordcount, post date, or other .9 This plugin allows you to intelligently insert ads (like Adsense) before and after your post content based on post wordcount, post date, or other features. 10 10 11 11 == Description == … … 17 17 == Installation == 18 18 19 1. Before uploading the folder, open "yourads.php" and paste your desired advertising code into the three indicated areas. yourads.php contains three variables which house your code data: $topad, $bottomad, and $customad. Sample data is provided as an example of how to paste your code. Replace the sample data by simply highlighting it and pasting your advertising code over it. Enter your ad code into the the other two variables to match. 19 First Installation: 20 21 1. Before uploading the folder, change "yourads.php.txt" to "yourads.php." This feature prevents automatic upgrades from overwriting your file. Then, open your newly renamed "yourads.php" and paste your desired advertising code into the three indicated areas. yourads.php contains three variables which house your code data: $topad, $bottomad, and $customad. Sample data is provided as an example of how to paste your code. Replace the sample data by simply highlighting it and pasting your advertising code over it. Enter your ad code into the the other two variables to match. 20 22 21 23 2. Because we're working with PHP data, you may have to "escape" your advertising code if it contains any single quotes (like ' ). Escaping means simply placing a forward slash before the single quote. So if the original sentence was: "Hello, I'm "hungry" didn't you know?" You would escape it to look like the following: "Hello, I\'m "hungry" didn\'t you know?". If your code doesn't contain single quotes then this isn't necessary. … … 23 25 3. Upload the plugin folder containing both files to wp-content/plugins/ and activate from the Plugin administrative menu. 24 26 27 Upgrade: 28 29 Use the automatic upgrade feature. Your advertising code will not be overwritten. Otherwise, upload "smartads.php" to your current smartads folder. 30 25 31 == Frequently Asked Questions == 26 32 smart-ads/trunk/smartads.php
r40979 r45331 5 5 Description: Automatically adds advertisements before and after your post's single page content based on word count or post age. You can also ad custom ads wherever you like by typing <!-smartads- > into your posts! 6 6 Author: John Kolbert 7 Version: 1. 1.27 Version: 1.2 8 8 Author URI: http://simply-basic.com/ 9 9 … … 48 48 49 49 function smartads_options_page(){ 50 include 'yourads.php'; 50 $changefile = ABSPATH . 'wp-content/plugins/' . dirname(plugin_basename(__FILE__)) . '/yourads.php'; 51 echo $changefile; 52 if (file_exists($changefile)){ 53 include 'yourads.php'; 54 } 51 55 global $wpdb; 56 if (!file_exists($changefile)){ 57 echo '<div class="updated" style="color: red; font-size: 14px; height: 20px; padding: 5px; border: 1px solid #E6DB55;"><strong><center>"yourads.php" was not found. Did you change "yourads.php.txt" to "yourads.php"?</strong></center></div>'; 58 } 59 52 60 if (isset($_POST['update_options'])) { 53 61 $options['smart_ads_showindexcust'] = trim($_POST['smart_ads_showindexcust'],'{}'); 62 $options['smart_ads_custcomment'] = trim($_POST['smart_ads_custcomment'],'{}'); 54 63 $options['smart_ads_wordcount'] = trim($_POST['smart_ads_wordcount'],'{}'); 55 64 $options['smart_ads_days'] = trim($_POST['smart_ads_days'],'{}'); 56 65 $options['smart_ads_catex'] = trim($_POST['smart_ads_catex'],'{}'); 57 66 $options['smart_ads_regsuser'] = trim($_POST['smart_ads_regsuser'],'{}'); 58 update_option('smart_ads_insert', $options); 67 $options['smart_ads_imgex'] = trim($_POST['smart_ads_imgex'],'{}'); 68 $options['smart_ads_imgchar'] = trim($_POST['smart_ads_imgchar'],'{}'); 69 $options['smart_ads_postbox'] = trim($_POST['smart_ads_postbox'],'{}'); 70 update_option('smart_ads_insert', $options); 59 71 // Show a message to say we've done something 60 72 echo '<div class="updated"><p>' . __('Options saved') . '</p></div>'; … … 75 87 <tr valign="top"> 76 88 <th scope="row">Show Custom ads on Homepage?</th> 77 <td><input type="checkbox" name="smart_ads_showindexcust" id="smart_ads_showindexcust" <?php if ($options['smart_ads_showindexcust'] == 1) {echo "checked";} ?> value="1" > Yes <br /> If selected, Custom ads will be displayed on the main blog page. Otherwise they will only be displayed on the single post or page view. </td>89 <td><input type="checkbox" name="smart_ads_showindexcust" id="smart_ads_showindexcust" <?php if ($options['smart_ads_showindexcust'] == 1) {echo "checked";} ?> value="1" > Yes <br /> If selected, Custom ads will be displayed on the main blog page. Otherwise they will only be displayed on the single post or page view.<br /><strong>Note</strong>: <a href="https://www.google.com/adsense/support/bin/answer.py?answer=48182&sourceid=aso&subid=ww-ww-et-asui&medium=link&gsessionid=DERvyq807mw">Google policies state</a> that only three ad units may be displayed on a single page, so be careful using this option.</td> 78 90 </tr> 91 <tr valign="top"> 92 <th scope="row">Custom ads notation:</th> 93 <td><input name="smart_ads_custcomment" type="radio" id="smart_ads_custcomment" value="comment" <?php if (($options['smart_ads_custcomment'] !== "bracket") ) {echo 'checked';} ?> /> <?php $data = '<!-smartads->'; echo htmlentities($data); ?> (<em>Default</em>, an HTML comment)<br /> 94 <input name="smart_ads_custcomment" type="radio" id="smart_ads_custcomment" value="bracket" <?php if ($options['smart_ads_custcomment'] == "bracket") {echo 'checked';} ?> />{smartads}<br /> Use the HTML comment unless you use the WordPress' visual editor and are having problems getting your ads to appear. 95 </tr> 79 96 <tr valign="top"> 80 97 <th scope="row">Minimum Post <br /> Word Count:</th> … … 87 104 <tr valign="top"> 88 105 <th scope="row">Category Exclusions:</th> 89 <td><input name="smart_ads_catex" type="text" id="smart_ads_catex" value="<?php echo $options['smart_ads_catex']; ?>" size="10" /> List category IDs seperated by a comma and a single space (such as 15, 2, 19)<br />This does not affect Custom Ads.</td> 106 <td><input name="smart_ads_catex" type="text" id="smart_ads_catex" value="<?php echo $options['smart_ads_catex']; ?>" size="10" /> List category IDs seperated by a comma and a single space (such as 15, 2, 19)<br />These categories will not have ads placed in them. This does not affect Custom Ads.</td> 107 </tr> 108 <tr valign="top"> 109 <th scope="row">Disable Top Ad if Post Begins with an Image:</th> 110 <td><input type="checkbox" name="smart_ads_imgex" id="smart_ads_imgex" <?php if ($options['smart_ads_imgex'] == 1) {echo "checked";} ?> value="1" > Yes, if an image tag is found within the first 111 <input name="smart_ads_imgchar" type="text" id="smart_ads_imgchar" value="<?php echo $options['smart_ads_imgchar']; ?>" size="3" /> characters (including HTML characters). Recommended value: 200<br /> This does not affect the Bottom Ad or Custom Ads.</td> 90 112 </tr> 91 113 <tr valign="top"> … … 93 115 <td><input type="checkbox" name="smart_ads_regsuser" id="smart_ads_regsuser" <?php if ($options['smart_ads_regsuser'] == 1) {echo "checked";} ?> value="1" > Yes <br /> If selected, registered members of your blog will not see any ads, even custom ads.</td> 94 116 </tr> 95 </table> 117 <tr valign="top"> 118 <th scope="row">Hide per-post options box:</th> 119 <td><input type="checkbox" name="smart_ads_postbox" id="smart_ads_postbox" <?php if ($options['smart_ads_postbox'] == 1) {echo "checked";} ?> value="1" > Yes <br /> This allows you to hide the Smart Ads options box that appears while writing a post.<br />No post settings will be lost.</td> 120 </tr> 121 </table> 96 122 97 123 <div class="postbox"> 98 124 <h3>Your Code</h3> 125 <?php 126 127 if (!file_exists($changefile)){ 128 echo '<div style="background: #FFFBCC; color: red; font-size: 14px; height: 20px; padding: 5px; border: 1px solid #E6DB55;"><strong><center>"yourads.php" was not found. Did you change "yourads.php.txt" to "yourads.php"?</strong></center></div>'; 129 } 130 ?> 99 131 <p>The following is shown for your information only. To edit the Top, Bottom, and Custom Ads code please edit "wp-content/plugins/smartads/yourads.php".</p> 100 132 <div class="inside"> … … 110 142 <tr valign="top"> 111 143 <th scope="row">Custom Ad:</th> 112 <td>This code can be inserted anywhere in your posts or pages by typing <strong><?php $data = '<!-smartads-> '; echo htmlentities($data); ?></strong> where you want your ad to appear. To change this code edit "...wp-content/plugins/smartads/yourads.php"<div style="background: #eee; padding: 5px; border: 1px solid #ddd; margin-top: 5px; margin-bottom: 5px;"><?php if(trim($customad) != null) {echo(stripslashes (htmlspecialchars ($customad)));} else {echo '<strong>Custom ad not set. Please edit <em>$customad</em> in "...wp-content/plugins/smartads/yourads.php"</strong>';} ?></div></td>144 <td>This code can be inserted anywhere in your posts or pages by typing <strong><?php $data = '<!-smartads-> or {smartads}'; echo htmlentities($data); ?></strong> where you want your ad to appear. To change this code edit "...wp-content/plugins/smartads/yourads.php"<div style="background: #eee; padding: 5px; border: 1px solid #ddd; margin-top: 5px; margin-bottom: 5px;"><?php if(trim($customad) != null) {echo(stripslashes (htmlspecialchars ($customad)));} else {echo '<strong>Custom ad not set. Please edit <em>$customad</em> in "...wp-content/plugins/smartads/yourads.php"</strong>';} ?></div></td> 113 145 </tr> 114 146 </table> … … 136 168 137 169 function smartads_write_box() { 170 138 171 global $post; 139 172 $options = get_option('smart_ads_insert'); 173 140 174 if (function_exists('current_user_can')) { 141 175 if (!current_user_can('manage_options')) return; … … 150 184 151 185 ?> 152 <div class="postbox"> 153 <h3>Smart Ads <small>by <a title="John Kolbert" href="http://simply-basic.com/smart-ads-plugin" target="_blank">John Kolbert</a></small></h3> 154 <div class="inside"> 155 <p></p> 186 <div class="side-info"> 187 <h5><a style="color: #000; text-decoration: none;" href="http://simply-basic.com/smart-ads-plugin" target="_blank">Smart Ads</a></h5> 188 156 189 <input value="smartads_post" type="hidden" name="smartads_post" /> 157 <table class="form-table" style="text-align: left;"> 158 <tr valign="top"><th scope="row" >Disable ads for this post:</th> 159 <td><input type="checkbox" name="smart_ads_disable" id="smart_ads_disable" <?php if ($disable == 1) {echo "checked";} ?> value="1" > Yes <br /> If selected, Top and Bottom ads will not be shown on this post, regardless of the word count or post date. This does not affect Custom Ads.</td> 160 </tr> 161 <tr valign="top"><th scope="row" >Minimum Word Count:</th> 162 <td><big><?php if (isset($options['smart_ads_wordcount']) && ($options['smart_ads_wordcount'] != 0)) {echo $options['smart_ads_wordcount'] . '</big><br /> This is the minimum number of words your post must have before Top and Bottom ads will be displayed. This can be changed in the plugin options menu.';} else{ echo "Wordcount limit not set";} ?></td></tr> 163 <tr valign="top"><th scope="row" >Ads Delayed For:</th> 164 <td><?php if(isset($options['smart_ads_days']) && ($options['smart_ads_days'] != 0)) { echo 'Ads will not be shown until this post is <big>' . $options['smart_ads_days'] . '</big> days old. This does not include Custom Ads.'; } else { echo "<big>Ad date restrictions not set.</big>"; } ?></td> 165 190 <table style="text-align: left; font-size: 10px;"> 191 <tr valign="top"> 192 <td><input type="checkbox" name="smart_ads_disable" id="smart_ads_disable" <?php if ($disable == 1) {echo "checked";} ?> value="1" ></td><td style="font-size: 11px;">Disable ads for this post. This does not affect Custom Ads.</td> 193 </tr> 166 194 </table> 167 </div></div> 195 <p>Custom ads may be added by entering <?php 196 if ($options['smart_ads_custcomment'] == "bracket"){ 197 echo '{smartads}'; 198 } 199 200 else {$toecho = '<!-smartads->'; 201 echo htmlentities($toecho);}?> 202 anywhere in your post</p> 203 </div> 168 204 <?php 169 205 … … 171 207 172 208 function add_smartads_custom_field($id){ 209 if ($options['smart_ads_postbox'] != 1){ 173 210 $smartdisable = $_POST["smart_ads_disable"]; 174 211 … … 180 217 add_post_meta($id, 'smartadsdisable', $smartdisable); 181 218 } 219 } 182 220 } 183 221 … … 195 233 $options = get_option('smart_ads_insert'); 196 234 197 $catex = trim($options[ smart_ads_catex]);235 $catex = trim($options['smart_ads_catex']); 198 236 $catex = explode(", ", $catex); 199 237 … … 207 245 208 246 247 function smartads_imgexclude($content){ //exclude posts that start with images 248 $options = get_option('smart_ads_insert'); 249 250 if(($options['smart_ads_imgex'] == 1) && (stristr(substr($content, 0, $options['smart_ads_imgchar']), '<img') == true)){ 251 return 1; 252 } 253 else{ 254 return 0; 255 } 256 } 257 258 209 259 210 260 function smartads_insert($content){ //adds the ads … … 212 262 global $post; 213 263 $options = get_option('smart_ads_insert'); 264 265 if ($options['smart_ads_custcomment'] == "bracket"){ 266 $custtype = '{smartads}'; 267 } 268 else{ 269 $custtype = '<!-smartads->'; 270 } 214 271 get_currentuserinfo(); 215 272 global $user_level; … … 223 280 if (is_page()) { 224 281 $replace = stripslashes($customad); 225 $content = ereg_replace( '<!-smartads->', $replace, $content);282 $content = ereg_replace($custtype, $replace, $content); 226 283 return $content; 227 284 } … … 231 288 if ($options['smart_ads_showindexcust'] == 1){ 232 289 $replace = stripslashes($customad); 233 $content = ereg_replace( '<!-smartads->', $replace, $content);290 $content = ereg_replace($custtype, $replace, $content); 234 291 return $content; 235 292 } 236 293 else { 294 $replace = ""; 295 $content = ereg_replace($custtype, $replace, $content); 237 296 return $content; 238 297 } … … 247 306 $lastad = stripslashes($bottomad); 248 307 249 $content = ereg_replace('<!-smartads->', $replace, $content); 308 $content = ereg_replace($custtype, $replace, $content); 309 310 if (smartads_imgexclude($content) == 1) { 311 $content = $content . $lastad; 312 return $content; 313 } 314 else { 250 315 $content = $firstad . $content . $lastad; 251 return $content; 252 } 316 return $content; 317 } 318 } 253 319 else { 254 320 $replace = stripslashes($customad); 255 $content = ereg_replace('<!-smartads->', $replace, $content); 256 return $content; 257 } 258 } 259 321 $content = ereg_replace($custtype, $replace, $content); 322 return $content; 323 } 324 } 260 325 else{ 261 326 return $content; … … 264 329 } 265 330 } 266 return $content; 267 } 268 331 332 return $content; //if it's the RSS, just return the content 333 } 334 269 335 add_filter('the_content', 'smartads_insert'); 270 336 337 $options = get_option('smart_ads_insert'); 338 339 if (($wp_version >= "2.5") && ($options['smart_ads_postbox'] != 1)){ 340 341 add_filter('submitpost_box', 'smartads_write_box'); 342 343 add_action('edit_post', 'add_smartads_custom_field'); 344 add_action('publish_post', 'add_smartads_custom_field'); 345 add_action('save_post', 'add_smartads_custom_field'); 346 } 347 348 elseif (($wp_version < "2.5") && $options['smart_ads_postbox'] != 1){ 271 349 add_action('simple_edit_form', 'smartads_write_box'); 272 350 add_action('edit_form_advanced', 'smartads_write_box'); 273 add_action('edit_page_form', 'smartads_write_box');274 351 275 352 add_action('edit_post', 'add_smartads_custom_field'); … … 277 354 add_action('save_post', 'add_smartads_custom_field'); 278 355 add_action('edit_page_form', 'add_smartads_custom_field'); 279 356 } 280 357 281 358 ?>
