robots-meta.php
author Henryk Gerlach <hgerlach@gmx.de>
Thu, 03 Jul 2008 14:35:05 +0200
changeset 1 a54fe2712ade
parent 0 1cb43ef2edd9
child 2 44a602ed5d39
permissions -rw-r--r--
Added support for the noarchive-tag.
     1 <?php
     2 /*
     3 Plugin Name: Robots Meta
     4 Plugin URI: http://www.joostdevalk.nl/wordpress/robots-meta/
     5 Description: This plugin allows you to add all the appropriate robots meta tags to your pages and feeds, disable unused archives and nofollow unnecessary links.
     6 Author: Joost de Valk
     7 Version: 3.0.2
     8 Author URI: http://www.joostdevalk.nl/
     9 */
    10 
    11 if ( ! class_exists( 'RobotsMeta_Admin' ) ) {
    12 
    13 	class RobotsMeta_Admin {
    14 
    15 		function add_config_page() {
    16 			global $wpdb;
    17 			if ( function_exists('add_submenu_page') ) {
    18 				add_submenu_page('plugins.php','Robots Meta Configuration', 'Robots Meta', 1, basename(__FILE__),array('RobotsMeta_Admin','config_page'));
    19 			}
    20 		} // end add_config_page()
    21 
    22 		function meta_box() {
    23 			if ( function_exists('add_meta_box') ) {
    24 				add_meta_box('robotsmeta','Robots Meta',array('RobotsMeta_Admin','noindex_option_fill'),'post');
    25 				add_meta_box('robotsmeta','Robots Meta',array('RobotsMeta_Admin','noindex_option_fill'),'page');
    26 			} else {
    27 				add_action('dbx_post_sidebar', array('RobotsMeta_Admin','noindex_option'));
    28 				add_action('dbx_page_sidebar', array('RobotsMeta_Admin','noindex_option'));				
    29 			}
    30 		}
    31 		function robotsmeta_insert_post($pID) {
    32 			global $wpdb;
    33 			extract($_POST);
    34 			$wpdb->query("UPDATE $wpdb->posts SET robotsmeta = '$robotsmeta' WHERE ID = $pID");
    35 		}
    36 
    37 		function noindex_option_fill() {
    38 			?>
    39 			<label for="meta_robots_index_follow" class="selectit"><input id="meta_robots_index_follow" name="robotsmeta" type="radio" value="index,follow" <?php if ($robotsmeta == "index,follow") echo 'checked="checked"'?>/> index, follow</label><br/>
    40 			<label for="meta_robots_index_nofollow" class="selectit"><input id="meta_robots_index_nofollow" name="robotsmeta" type="radio" value="index,nofollow" <?php if ($robotsmeta == "index,nofollow") echo 'checked="checked"'?>/> index, nofollow</label><br/>
    41 			<label for="meta_robots_noindex_follow" class="selectit"><input id="meta_robots_noindex_follow" name="robotsmeta" type="radio" value="noindex,follow" <?php if ($robotsmeta == "noindex,follow") echo 'checked="checked"'?>/> noindex, follow</label><br/>
    42 			<label for="meta_robots_noindex_nofollow" class="selectit"><input id="meta_robots_noindex_nofollow" name="robotsmeta" type="radio" value="noindex,nofollow" <?php if ($robotsmeta == "noindex,nofollow") echo 'checked="checked"'?>/> noindex, nofollow</label><br/>
    43 			<?php
    44 		}
    45 
    46 		function noindex_option() {
    47 			global $post;
    48 			$robotsmeta = $post->robotsmeta;
    49 			if (!isset($robotsmeta) || $robotsmeta == "") {
    50 				$robotsmeta = "index,follow";
    51 			}
    52 			if ( current_user_can('edit_posts') ) { ?>
    53 			<fieldset id="robotsmeta-noindexoption" class="dbx-box">
    54 			<h3 class="dbx-handle">Robots Meta</h3>
    55 			<div class="dbx-content">
    56 				<label for="meta_robots_index_follow" class="selectit"><input id="meta_robots_index_follow" name="robotsmeta" type="radio" value="index,follow" <?php if ($robotsmeta == "index,follow") echo 'checked="checked"'?>/> index, follow</label>
    57 				<label for="meta_robots_index_nofollow" class="selectit"><input id="meta_robots_index_nofollow" name="robotsmeta" type="radio" value="index,nofollow" <?php if ($robotsmeta == "index,nofollow") echo 'checked="checked"'?>/> index, nofollow</label>
    58 				<label for="meta_robots_noindex_follow" class="selectit"><input id="meta_robots_noindex_follow" name="robotsmeta" type="radio" value="noindex,follow" <?php if ($robotsmeta == "noindex,follow") echo 'checked="checked"'?>/> noindex, follow</label>
    59 				<label for="meta_robots_noindex_nofollow" class="selectit"><input id="meta_robots_noindex_nofollow" name="robotsmeta" type="radio" value="noindex,nofollow" <?php if ($robotsmeta == "noindex,nofollow") echo 'checked="checked"'?>/> noindex, nofollow</label>
    60 			</div>
    61 			</fieldset>
    62 			<?php 
    63 			}
    64 		}
    65 		
    66 		function config_page() {
    67 			if ( isset($_POST['submitrobots']) ) {
    68 				if (!current_user_can('manage_options')) die(__('You cannot edit the robots.txt file.'));
    69 				check_admin_referer('robots-meta-udpaterobotstxt');
    70 				
    71 				if (file_exists("../robots.txt")) {
    72 					$robots_file = "../robots.txt";
    73 				} else if (file_exists("../../robots.txt")) {
    74 					$robots_file = "../../robots.txt";
    75 				} else {
    76 					$robots_file = false;
    77 				}
    78 				
    79 				$robotsnew = stripslashes($_POST['robotsnew']);
    80 				if ($robots_file != false && is_writeable($robots_file)) {
    81 					$f = fopen($robots_file, 'w+');
    82 					fwrite($f, $robotsnew);
    83 					fclose($f);
    84 				}
    85 			}
    86 			if ( isset($_POST['submithtaccess']) ) {
    87 				if (!current_user_can('manage_options')) die(__('You cannot edit the .htaccess.'));
    88 				check_admin_referer('robots-meta-udpatehtaccesstxt');
    89 
    90 				if (file_exists("../.htaccess")) {
    91 					$htaccess_file = "../.htaccess";
    92 				} else if (file_exists("../../.htaccess")) {
    93 					$htaccess_file = "../../.htaccess";
    94 				} else {
    95 					$htaccess_file = false;
    96 				}
    97 
    98 				$htaccessnew = stripslashes($_POST['htaccessnew']);
    99 				if (is_writeable($htaccess_file)) {
   100 					$f = fopen($htaccess_file, 'w+');
   101 					fwrite($f, $htaccessnew);
   102 					fclose($f);
   103 				}
   104 
   105 			}
   106 			if ( isset($_POST['submit']) ) {
   107 				if (!current_user_can('manage_options')) die(__('You cannot edit the Robots Meta options.'));
   108 				check_admin_referer('robots-meta-udpatesettings');
   109 				
   110 				if (isset($_POST['admin'])) {
   111 					$options['admin'] = true;
   112 				} else {
   113 					$options['admin'] = false;
   114 				}
   115 
   116 				if (isset($_POST['allfeeds'])) {
   117 					$options['commentfeeds'] = true;
   118 					$options['allfeeds'] = true;
   119 				} else {
   120 					$options['allfeeds'] = false;
   121 				}
   122 
   123 				if (isset($_POST['commentfeeds'])) {
   124 					$options['commentfeeds'] = true;
   125 				} else {
   126 					$options['commentfeeds'] = false;
   127 				}
   128 
   129 				if (isset($_POST['disableauthor'])) {
   130 					$options['disableauthor'] = true;
   131 				} else {
   132 					$options['disableauthor'] = false;
   133 				}
   134 
   135 				if (isset($_POST['disabledate'])) {
   136 					$options['disabledate'] = true;
   137 				} else {
   138 					$options['disabledate'] = false;
   139 				}
   140 
   141 				if (isset($_POST['disableexplanation'])) {
   142 					$options['disableexplanation'] = true;
   143 				} else {
   144 					$options['disableexplanation'] = false;
   145 				}
   146 
   147 				if (isset($_POST['login'])) {
   148 					$options['login'] = true;
   149 				} else {
   150 					$options['login'] = false;
   151 				}
   152 
   153 				if (isset($_POST['noindexauthor'])) {
   154 					$options['noindexauthor'] = true;
   155 				} else {
   156 					$options['noindexauthor'] = false;
   157 				}
   158 
   159 				if (isset($_POST['noindexcat'])) {
   160 					$options['noindexcat'] = true;
   161 				} else {
   162 					$options['noindexcat'] = false;
   163 				}
   164 
   165 				if (isset($_POST['noindexdate'])) {
   166 					$options['noindexdate'] = true;
   167 				} else {
   168 					$options['noindexdate'] = false;
   169 				}
   170 				
   171 				if (isset($_POST['noindextag'])) {
   172 					$options['noindextag'] = true;
   173 				} else {
   174 					$options['noindextag'] = false;
   175 				}
   176 
   177 				if (isset($_POST['noarchive'])) {
   178 					$options['noarchive'] = true;
   179 				} else {
   180 					$options['noarchive'] = false;
   181 				}
   182 
   183 				if (isset($_POST['nofollowcatsingle'])) {
   184 					$options['nofollowcatsingle'] = true;
   185 				} else {
   186 					$options['nofollowcatsingle'] = false;
   187 				}
   188 
   189 				if (isset($_POST['nofollowcatpage'])) {
   190 					$options['nofollowcatpage'] = true;
   191 				} else {
   192 					$options['nofollowcatpage'] = false;
   193 				}
   194 
   195 				if (isset($_POST['nofollowindexlinks'])) {
   196 					$options['nofollowindexlinks'] = true;
   197 				} else {
   198 					$options['nofollowindexlinks'] = false;
   199 				}
   200 
   201 				if (isset($_POST['nofollowmeta'])) {
   202 					$options['nofollowmeta'] = true;
   203 				} else {
   204 					$options['nofollowmeta'] = false;
   205 				}
   206 
   207 				if (isset($_POST['nofollowcommentlinks'])) {
   208 					$options['nofollowcommentlinks'] = true;
   209 				} else {
   210 					$options['nofollowcommentlinks'] = false;
   211 				}
   212 
   213 				if (isset($_POST['nofollowtaglinks'])) {
   214 					$options['nofollowtaglinks'] = true;
   215 				} else {
   216 					$options['nofollowtaglinks'] = false;
   217 				}
   218 
   219 				if (isset($_POST['noodp'])) {
   220 					$options['noodp'] = true;
   221 				} else {
   222 					$options['noodp'] = false;
   223 				}
   224 
   225 				if (isset($_POST['noydir'])) {
   226 					$options['noydir'] = true;
   227 				} else {
   228 					$options['noydir'] = false;
   229 				}
   230 				
   231 				if (isset($_POST['pagedhome'])) {
   232 					$options['pagedhome'] = true;
   233 				} else {
   234 					$options['pagedhome'] = false;
   235 				}
   236 
   237 				if (isset($_POST['search'])) {
   238 					$options['search'] = true;
   239 				} else {
   240 					$options['search'] = false;
   241 				}
   242 				
   243 				if (isset($_POST['replacemetawidget'])) {
   244 					$options['replacemetawidget'] = true;
   245 				} else {
   246 					$options['replacemetawidget'] = false;
   247 				}
   248 
   249 				if (isset($_POST['redirectsearch'])) {
   250 					$options['redirectsearch'] = true;
   251 				} else {
   252 					$options['redirectsearch'] = false;
   253 				}
   254 
   255 				if (isset($_POST['trailingslash'])) {
   256 					$options['trailingslash'] = true;
   257 				} else {
   258 					$options['trailingslash'] = false;
   259 				}
   260 				
   261 				if (isset($_POST['googleverify'])) {
   262 					$options['googleverify'] = $_POST['googleverify'];
   263 				}
   264 
   265 				if (isset($_POST['msverify'])) {
   266 					$options['msverify'] = $_POST['msverify'];
   267 				}
   268 
   269 				if (isset($_POST['yahooverify'])) {
   270 					$options['yahooverify'] = $_POST['yahooverify'];
   271 				}
   272 
   273 				if (isset($_POST['version'])) {
   274 					$options['version'] = $_POST['version'];
   275 				}
   276 				$opt = serialize($options);
   277 				update_option('RobotsMeta', $opt);
   278 			}
   279 			
   280 			$opt  = get_option('RobotsMeta');
   281 			$options = unserialize($opt);
   282 			if ($options['allfeeds']) {
   283 				$options['comments'] = true;
   284 			}
   285 
   286 			if (file_exists("../robots.txt")) {
   287 				$robots_file = "../robots.txt";
   288 			} else if (file_exists("../../robots.txt")) {
   289 				$robots_file = "../../robots.txt";
   290 			} else {
   291 				$robots_file = false;
   292 				$error = 1;
   293 			}
   294 			
   295 			if (!$error && filesize($robots_file) > 0) {
   296 				$f = fopen($robots_file, 'r');
   297 				$content = fread($f, filesize($robots_file));
   298 				$content = htmlspecialchars($content);
   299 			}
   300 
   301 			$error = 0;
   302 			if (file_exists("../.htaccess")) {
   303 				$htaccess_file = "../.htaccess";
   304 			} else if (file_exists("../../.htaccess")) {
   305 				$htaccess_file = "../../.htaccess";
   306 			} else {
   307 				$htaccess_file = false;
   308 				$error = 1;
   309 			}
   310 
   311 			if (!$error && filesize($htaccess_file) > 0) {
   312 				$f = fopen($htaccess_file, 'r');
   313 				$contentht = fread($f, filesize($htaccess_file));
   314 				$contentht = htmlspecialchars($contentht);
   315 			}
   316 			
   317 			?>
   318 			<div class="wrap">
   319 				<h2>Robots Meta Configuration</h2>
   320 				<form action="" method="post" id="robotsmeta-conf">
   321 					<span style="border: 0; float: right; margin-top: -35px;" class="submit"><input type="submit" name="submit" value="Save Settings" /></span>
   322 					<table class="form-table">
   323 						<?php if (function_exists('wp_nonce_field')) { wp_nonce_field('robots-meta-udpatesettings'); } ?>
   324 						<input type="hidden" value="<?php echo $options['version']; ?>" name="version"/>
   325 						<tr>
   326 							<th scope="row" valign="top">Plugin settings</th>
   327 							<td>
   328 								<input type="checkbox" id="disableexplanation" name="disableexplanation" <?php if ( $options['disableexplanation'] == true ) echo ' checked="checked" '; ?>/>
   329 								<label for="disableexplanation">Hide verbose explanations of settings</label><br/>
   330 							</td>
   331 						</tr>						
   332 						<tr valign="top">
   333 							<th scope="row" width="20%">RSS Feeds</th>
   334 							<td>
   335 								<input type="checkbox" id="commentfeeds" name="commentfeeds" <?php if ( $options['commentfeeds'] == true ) echo ' checked="checked" '; ?>/>
   336 								<label for="commentfeeds"><code>noindex</code> the comment RSS feeds</label><br/>
   337 								<?php if (!$options['disableexplanation']) { ?>
   338 								<p>
   339 									This will prevent the search engines from indexing your comment feeds.
   340 								</p>
   341 								<?php } ?>
   342 								<input type="checkbox" id="allfeeds" name="allfeeds" <?php if ( $options['allfeeds'] == true ) echo ' checked="checked" '; ?>/> 
   343 								<label for="allfeeds"><code>noindex</code> <strong>all</strong> RSS feeds</label><br/>
   344 								<?php if (!$options['disableexplanation']) { ?>
   345 								<p>
   346 									This will prevent the search engines from indexing <strong>all your</strong> feeds. Highly discouraged.
   347 								</p>
   348 								<?php } ?>
   349 							</td>
   350 						</tr>
   351 						<tr valign="top">
   352 							<th scope="row">Prevent indexing of</th>
   353 							<td>
   354 								<input type="checkbox" id="search" name="search" <?php if ( $options['search'] == true ) echo ' checked="checked" '; ?>/>
   355 								<label for="search">This site's search result pages</label><br/>
   356 								<?php if (!$options['disableexplanation']) { ?>
   357 								<p>
   358 									Prevents the search engines from indexing your search result pages, by a <code>noindex,follow</code> robots tag to them. The <code>follow</code> part means that search engine crawlers <em>will</em> spider the pages listed in the search results.
   359 								</p>
   360 								<?php } ?>								
   361 								<input type="checkbox" id="logininput" name="login" <?php if ( $options['login'] == true ) echo ' checked="checked" '; ?>/>
   362 								<label for="logininput">The login and register pages</label><br/>
   363 								<input type="checkbox" id="admin" name="admin" <?php if ( $options['admin'] == true ) echo ' checked="checked" '; ?>/>
   364 								<label for="admin">All admin pages</label><br/>
   365 								<?php if (!$options['disableexplanation']) { ?>
   366 								<p>
   367 									The above two options prevent the search engines from indexing your login, register and admin pages.
   368 								</p>
   369 								<?php } ?>
   370 								<input type="checkbox" id="pagedhome" name="pagedhome" <?php if ( $options['pagedhome'] == true ) echo ' checked="checked" '; ?>/>
   371 								<label for="pagedhome">Subpages of the homepage</label><br/>
   372 								<?php if (!$options['disableexplanation']) { ?>
   373 								<p>
   374 									Prevent the search engines from indexing your subpages, if you want them to only index your category and / or tag archives.
   375 								</p>
   376 								<?php } ?>
   377 								<input type="checkbox" id="noindexauthor" name="noindexauthor" <?php if ( $options['noindexauthor'] == true ) echo ' checked="checked" '; ?>/>
   378 								<label for="noindexauthor">Author archives</label><br/>								
   379 								<?php if (!$options['disableexplanation']) { ?>
   380 								<p>
   381 									By default, WordPress creates author archives for each user, usually available under <code>/author/username</code>. If you have sufficient other archives, or yours is a one person blog, there's no need and you can best disable them or prevent search engines from indexing them.
   382 								</p>
   383 								<?php } ?>
   384 								<input type="checkbox" id="noindexdate" name="noindexdate" <?php if ( $options['noindexdate'] == true ) echo ' checked="checked" '; ?>/>
   385 								<label for="noindexdate">Date-based archives</label><br/>
   386 								<?php if (!$options['disableexplanation']) { ?>
   387 								<p>
   388 									If you want to offer your users the option of crawling your site by date, but have ample other ways for the search engines to find the content on your site, I highly encourage you to prevent your date-based archives from being indexed.
   389 								</p>
   390 								<?php } ?>
   391 								<input type="checkbox" id="noindexcat" name="noindexcat" <?php if ( $options['noindexcat'] == true ) echo ' checked="checked" '; ?>/>
   392 								<label for="noindexcat">Category archives</label><br/>
   393 								<?php if (!$options['disableexplanation']) { ?>
   394 								<p>
   395 									If you're using tags as your only way of structure on your site, you would probably be better off when you prevent your categories from being indexed.
   396 								</p>
   397 								<?php } ?>
   398 								<input type="checkbox" id="noindextag" name="noindextag" <?php if ( $options['noindextag'] == true ) echo ' checked="checked" '; ?>/>
   399 								<label for="noindextag">Tag archives</label><br/>
   400 								<?php if (!$options['disableexplanation']) { ?>
   401 								<p>
   402 									Read the categories explanation above for categories and switch the words category and tag around ;)
   403 								</p>
   404 								<?php } ?>
   405 								<input type="checkbox" id="noarchive" name="noarchive" <?php if ( $options['noarchive'] == true ) echo ' checked="checked" '; ?>/>
   406 								<label for="noarchive">Add <code>noarchive</code> meta tag</label><br/>
   407 								<?php if (!$options['disableexplanation']) { ?>
   408 								<p>
   409 									Prevents archive.org and google to put copies of your pages into their archive/cache.to put copies of your pages into their archive/cache.
   410 								</p>
   411 								<?php } ?>
   412 							</td>
   413 						</tr>
   414 
   415 						<tr valign="top">
   416 							<th scope="row">DMOZ<br/> and Yahoo! Directory</th>
   417 							<td>
   418 								<input type="checkbox" id="noodp" name="noodp" <?php if ( $options['noodp'] == true ) echo ' checked="checked" '; ?>/>
   419 								<label for="noodp">Add <code>noodp</code> meta tag</label><br/>
   420 								<?php if (!$options['disableexplanation']) { ?>
   421 								<p>
   422 									Prevents all search engines from using the DMOZ description for this site in the search results.
   423 								</p>
   424 								<?php } ?>
   425 								<input type="checkbox" id="noydir" name="noydir" <?php if ( $options['noydir'] == true ) echo ' checked="checked" '; ?>/>
   426 								<label for="noydir">Add <code>noydir</code> meta robots tag</label><br/>
   427 								<?php if (!$options['disableexplanation']) { ?>
   428 								<p>
   429 									Prevents Yahoo! from using the Yahoo! directory description for this site in the search results.
   430 								</p>
   431 								<?php } ?>
   432 							</td>
   433 						</tr>
   434 						<tr>
   435 							<th scope="row" valign="top">Permalink settings</th>
   436 							<td>
   437 								<input type="checkbox" id="trailingslash" name="trailingslash" <?php if ( $options['trailingslash'] == true ) echo ' checked="checked" '; ?>/>
   438 								<label for="trailingslash">Enforce a trailing slash on all category and tag URL's</label><br/>
   439 								<?php if (!$options['disableexplanation']) { ?>
   440 								<p>
   441 									If you choose a permalink for your posts with <code>.html</code>, or anything else but a / on the end, this will force WordPress to add a trailing slash to non-post pages nonetheless.
   442 								</p>
   443 								<?php } ?>
   444 							</td>
   445 						</tr>
   446 						<tr>
   447 							<th scope="row" valign="top">Archive settings</th>
   448 							<td>
   449 								<input type="checkbox" id="disableauthor" name="disableauthor" <?php if ( $options['disableauthor'] == true ) echo ' checked="checked" '; ?>/>
   450 								<label for="disableauthor">Disable the author archives</label><br/>
   451 								<?php if (!$options['disableexplanation']) { ?>
   452 								<p>
   453 									If you're running a one author blog, the author archive will always look exactly the same as your homepage. And even though you may not link to it, others might, to do you harm. Disabling them here will make sure any link to those archives will be 301 redirected to the blog homepage.
   454 								</p>
   455 								<?php } ?>
   456 								<input type="checkbox" id="disabledate" name="disabledate" <?php if ( $options['disabledate'] == true ) echo ' checked="checked" '; ?>/>
   457 								<label for="disabledate">Disable the date-based archives</label><br/>
   458 								<?php if (!$options['disableexplanation']) { ?>
   459 								<p>
   460 									For the date based archives, the same applies: they probably look a lot like your homepage, and could thus be seen as duplicate content.
   461 								</p>
   462 								<?php } ?>
   463 								<input type="checkbox" id="redirectsearch" name="redirectsearch" <?php if ( $options['redirectsearch'] == true ) echo ' checked="checked" '; ?>/>
   464 								<label for="redirectsearch">Redirect search results pages when referrer is external</label><br/>
   465 								<?php if (!$options['disableexplanation']) { ?>
   466 								<p>
   467 									Redirect people coming to a search page on your site from elsewhere to your homepage, prevents people from linking to search results on your site.
   468 								</p>
   469 								<?php } ?>
   470 							</td>
   471 						</tr>
   472 						<tr>
   473 							<th scope="row" valign="top">Internal nofollow settings</th>
   474 							<td>
   475 								<input type="checkbox" id="nofollowcatpage" name="nofollowcatpage" <?php if ( $options['nofollowcatpage'] == true ) echo ' checked="checked" '; ?>/>
   476 								<label for="nofollowcatpage">Nofollow category listings on pages</label><br/>
   477 								<input type="checkbox" id="nofollowcatsingle" name="nofollowcatsingle" <?php if ( $options['nofollowcatsingle'] == true ) echo ' checked="checked" '; ?>/>
   478 								<label for="nofollowcatsingle">Nofollow category listings on single posts</label><br/>
   479 								<?php if (!$options['disableexplanation']) { ?>
   480 								<p>
   481 									If you're showing a category listing on all your single posts and pages, you're "leaking" quite a bit of PageRank towards these pages, whereas you probably want your single posts to rank. To prevent that from happening, check the two boxes above, and you will nofollow all the links to your categories from single posts and/or pages.
   482 								</p>
   483 								<?php } ?>
   484 								<input type="checkbox" id="nofollowindexlinks" name="nofollowindexlinks" <?php if ( $options['nofollowindexlinks'] == true ) echo ' checked="checked" '; ?>/>
   485 								<label for="nofollowindexlinks">Nofollow outbound links on the frontpage</label><br/>
   486 								<?php if (!$options['disableexplanation']) { ?>
   487 								<p>
   488 									If you want to keep the link-juice on your front page to yourself, enable this, and you will only pass link-juice from your post pages.
   489 								</p>
   490 								<?php } ?>
   491 								<input type="checkbox" id="nofollowtaglinks" name="nofollowtaglinks" <?php if ( $options['nofollowtaglinks'] == true ) echo ' checked="checked" '; ?>/>
   492 								<label for="nofollowtaglinks">Nofollow the links to your tag pages</label><br/>
   493 								<?php if (!$options['disableexplanation']) { ?>
   494 								<p>
   495 									If you've decided to keep your tag pages from being indexed, you might as well stop throwing link-juice at them on each post...
   496 								</p>
   497 								<?php } ?>
   498 								<input type="checkbox" id="nofollowmeta" name="nofollowmeta" <?php if ( $options['nofollowmeta'] == true ) echo ' checked="checked" '; ?>/>
   499 								<label for="nofollowmeta">Nofollow login and registration links</label><br/>
   500 								<?php if (!$options['disableexplanation']) { ?>
   501 								<p>
   502 									This might have happened to you: logging in to your admin panel to notice that is has become PR6... Nofollow those admin and login links, there's no use flowing PageRank to those pages!
   503 								</p>
   504 								<?php } ?>
   505 								<input type="checkbox" id="nofollowcommentlinks" name="nofollowcommentlinks" <?php if ( $options['nofollowcommentlinks'] == true ) echo ' checked="checked" '; ?>/>
   506 								<label for="nofollowcommentlinks">Nofollow comments links</label><br/>
   507 								<?php if (!$options['disableexplanation']) { ?>
   508 								<p>
   509 									Simple way to decrease the number of links on your pages: nofollow all the links pointing to comment sections.
   510 								</p>
   511 								<?php } ?>
   512 								<input type="checkbox" id="replacemetawidget" name="replacemetawidget" <?php if ( $options['replacemetawidget'] == true ) echo ' checked="checked" '; ?>/>
   513 								<label for="replacemetawidget">Replace the Meta Widget with a nofollowed one</label><br/>
   514 								<?php if (!$options['disableexplanation']) { ?>
   515 								<p>
   516 									By default the Meta widget links to your RSS feeds and to WordPress.org with a follow link, this will replace that widget by a custom one in which all these links are nofollowed.
   517 								</p>
   518 								<?php } ?>
   519 							</td>
   520 						</tr>
   521 						<tr>
   522 							<th scope="row" valign="top">Webmaster Tools</th>
   523 							<td colspan="2">
   524 								<label for="googleverify">Verify meta value for Google Webmaster Tools:</label><br/>
   525 								<input size="50" type="text" id="googleverify" name="googleverify" <?php echo 'value="'.$options['googleverify'].'" '; ?>/><br/>
   526 								<label for="yahooverify">Verify meta value for Yahoo! Site Explorer:</label><br/>
   527 								<input size="50" type="text" id="yahooverify" name="yahooverify" <?php echo 'value="'.$options['yahooverify'].'" '; ?>/><br/>
   528 								<label for="msverify">Verify meta value for Microsoft Webmaster Portal:</label><br/>
   529 								<input size="50" type="text" id="msverify" name="msverify" <?php echo 'value="'.$options['msverify'].'" '; ?>/>
   530 							</td>
   531 						</tr>
   532 					</table>
   533 					<br/>
   534 					<span class="submit" style="border: 0;"><input type="submit" name="submit" value="Save Settings" /></span>
   535 				</form>
   536 				<br/><br/>
   537 <?php if ($robots_file != false) { ?>
   538 				<h2>Robots.txt</h2>
   539 				<form action="" method="post" id="robotstxt">
   540 					<?php wp_nonce_field('robots-meta-udpaterobotstxt'); ?>
   541 					<?php
   542 						if (!is_writeable($robots_file)) {
   543 							echo "<p><em>If your robots.txt were writable, you could edit it from here.</em></p>";
   544 							$disabled = 'disabled="disabled"';
   545 						} else {
   546 							echo "<p>Edit the content of your robots.txt:</p>";
   547 							$disabled = "";
   548 							?>
   549 							<textarea cols="60" <?php echo $disabled; ?> rows="15" name="robotsnew"><?php echo $content ?></textarea><br/>
   550 							<br/>
   551 							<span class="submit" style="border: 0;"><input type="submit" name="submitrobots" value="Save changes to Robots.txt" /></span>
   552 					<?php } ?>
   553 				</form>
   554 				<br/><br/>
   555 <?php
   556 }
   557 if ($htaccess_file != false) {
   558 ?>
   559 				<h2>.htaccess</h2>
   560 				<form action="" method="post" id="htaccess">
   561 					<?php wp_nonce_field('robots-meta-udpatehtaccesstxt'); ?>
   562 					<?php
   563 						if (! is_writeable($htaccess_file)) {
   564 							echo "<p><em>If your .htaccess were writable, you could edit it from here.</em></p>";
   565 							$disabled = 'disabled="disabled"';
   566 						} else {
   567 							echo "<p>Edit the content of your .htaccess:</p>";
   568 							$disabled = "";
   569 							?>
   570 							<textarea cols="60" <?php echo $disabled; ?> rows="15" name="htaccessnew"><?php echo $contentht ?></textarea><br/>
   571 							<br/>
   572 							<span class="submit" style="border:0;"><input type="submit" name="submithtaccess" value="Save changes to .htaccess" /></span>
   573 					<?php } ?>
   574 				</form>
   575 <?php } ?>
   576 			</div>
   577 			<?php
   578 	}
   579 	} // end class RobotsMeta
   580 }
   581 
   582 function noindex_feed() {
   583 	echo '<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />'."\n";
   584 }
   585 
   586 function noindex_page() {
   587 	echo '<meta name="robots" content="noindex" />'."\n";
   588 }
   589 
   590 function meta_robots() {
   591 	$opt  = get_option('RobotsMeta');
   592 	$options = unserialize($opt);
   593 	
   594 	$meta = "";
   595 	if (is_single() || is_page()) {
   596 		global $post;
   597 		if ($post->robotsmeta != "index,follow") {
   598 			$meta = $post->robotsmeta;	
   599 		}
   600 	} else if ( (is_author() && $options['noindexauthor']) || (is_category() && $options['noindexcat']) || (is_date() && $options['noindexdate']) || (function_exists(is_tag) && is_tag() && $options['noindextag']) || (is_search() && $options['search']) ) {
   601 		$meta .= "noindex,follow";
   602 	} else if (is_home()) {
   603 		if ($options['pagedhome'] && get_query_var('paged') > 1) {
   604 			$meta .= "noindex,follow";
   605 		}
   606 	}
   607 	if ($options['noodp']) {
   608 		if ($meta != "") {
   609 			$meta .= ",";
   610 		}
   611 		$meta .= "noodp";
   612 	} 
   613 	if ($options['noydir']) {
   614 		if ($meta != "") {
   615 			$meta .= ",";
   616 		}
   617 		$meta .= "noydir";
   618 	}
   619 	if ($options['noarchive']) {
   620 		if ($meta != "") {
   621 			$meta .= ",";
   622 		}
   623 		$meta .= "noarchive";
   624 	}
   625 	if ($meta != "" && $meta != "index,follow") {
   626 		echo '<!--Meta tags added by Robots Meta: http://www.joostdevalk.nl/wordpress/meta-robots-wordpress-plugin/ -->'."\n";
   627 		echo '<meta name="robots" content="'.$meta.'" />'."\n";
   628 	}
   629 } 
   630 
   631 function add_trailingslash($url, $type) {
   632 	// trailing slashes for everything except is_single()
   633 	// Thanks to Mark Jaquith for this
   634 	if ( 'single' === $type ) {
   635 		return $url;
   636 	} else {
   637 		return trailingslashit($url);
   638 	}
   639 }
   640 
   641 function search_redirect() {
   642 	if ($_GET['s'] &&  strpos($_SERVER['HTTP_REFERER'], get_bloginfo('url')) === false) {
   643 		wp_redirect(get_bloginfo('url'),301);
   644 		exit;
   645 	}
   646 }
   647 
   648 function archive_redirect() {
   649 	global $wp_query;
   650 	
   651 	$opt  = get_option('RobotsMeta');
   652 	$options = unserialize($opt);
   653 	
   654 	if ($options['disabledate'] && $wp_query->is_date) {
   655 		wp_redirect(get_bloginfo('url'),301);
   656 		exit;
   657 	}
   658 	if ($options['disableauthor'] && $wp_query->is_author) {
   659 		wp_redirect(get_bloginfo('url'),301);
   660 		exit;
   661 	}
   662 }
   663 
   664 function nofollow_link($output) {
   665 	return str_replace('<a ','<a rel="nofollow" ',$output);
   666 }
   667 
   668 function nofollow_category_listing($output) {
   669 	$opt  = get_option('RobotsMeta');
   670 	$options = unserialize($opt);
   671 	
   672 	if ( ($options['nofollowcatsingle'] && (is_single() || is_search()) ) || ($options['nofollowcatpage'] && is_page() || is_category() || is_tag() ) ) {
   673 		$output = nofollow_link($output);
   674 		return $output;
   675 	} else {
   676 		return $output;
   677 	}
   678 }
   679 
   680 function google_verify() {
   681 	if (is_home() || (function_exists('is_frontpage') && is_frontpage()) ) {
   682 		$opt  = get_option('RobotsMeta');
   683 		$options = unserialize($opt);
   684 		echo '<meta name="verify-v1" content="'.$options['googleverify'].'" />'."\n";
   685 	}
   686 }
   687 
   688 function yahoo_verify() {
   689 	if (is_home() || (function_exists('is_frontpage') && is_frontpage()) ) {
   690 		$opt  = get_option('RobotsMeta');
   691 		$options = unserialize($opt);
   692 		echo '<meta name="y_key" content="'.$options['yahooverify'].'" />'."\n";
   693 	}
   694 }
   695 
   696 function ms_verify() {
   697 	if (is_home() || (function_exists('is_frontpage') && is_frontpage()) ) {
   698 		$opt  = get_option('RobotsMeta');
   699 		$options = unserialize($opt);
   700 		echo '<meta name="msvalidate.01" content="'.$options['msverify'].'" />'."\n";
   701 	}
   702 }
   703 
   704 function add_nofollow($matches) {
   705 	$origin = get_bloginfo('wpurl');
   706 	if ((strpos($matches[2],$origin)) === false && ( strpos($matches[1],'rel="nofollow"') === false ) && ( strpos($matches[3],'rel="nofollow"') === false ) ) {
   707 		$nofollow = ' rel="nofollow" ';
   708 	} else {
   709 		$nofollow = '';
   710 	}
   711 	return '<a href="' . $matches[2] . '"' . $nofollow . $matches[1] . $matches[3] . '>' . $matches[4] . '</a>';
   712 }
   713 
   714 function nofollow_index($output) {
   715 	// Loop through the content of each post and add a nofollow when it's on the main page or a category page.
   716 	if (is_home() || is_category()) {
   717 		$anchorPattern = '/<a (.*?)href="(.*?)"(.*?)>(.*?)<\/a>/i';
   718 		$output = preg_replace_callback($anchorPattern,'add_nofollow',$output);
   719 	}
   720 	return $output;
   721 }
   722 
   723 function nofollow_taglinks($output) {
   724 	$output = str_replace('rel="tag"','rel="nofollow tag"',$output);
   725 	return $output;
   726 }
   727 
   728 function widget_jdvmeta_init() {
   729 	if (!function_exists('register_sidebar_widget'))
   730 		return;
   731 
   732 	function wp_jdvwidget_meta($args) {
   733 		extract($args);
   734 		$options = get_option('widget_meta');
   735 		$title = empty($options['title']) ? __('Meta') : $options['title'];
   736 	?>
   737 			<?php echo $before_widget; ?>
   738 				<?php echo $before_title . $title . $after_title; ?>
   739 				<ul>
   740 				<?php wp_register(); ?>
   741 				<li><?php wp_loginout(); ?></li>
   742 				<li><a rel="nofollow" href="<?php bloginfo('rss2_url'); ?>" title="<?php echo attribute_escape(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
   743 				<li><a rel="nofollow"href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo attribute_escape(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
   744 				<li><a rel="nofollow" href="http://wordpress.org/" title="<?php echo attribute_escape(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li>
   745 				<?php wp_meta(); ?>
   746 				</ul>
   747 			<?php echo $after_widget; ?>
   748 	<?php
   749 	}
   750 
   751 	register_sidebar_widget('meta','wp_jdvwidget_meta');
   752 }
   753 
   754 function robotsmeta_update() {
   755 	global $wpdb;
   756 	$opt  = get_option('RobotsMeta');
   757 	$options = unserialize($opt);
   758 	if ($options['version'] < "2.3") {
   759 		echo $wpdb->get_col_info('robotsmeta');
   760 		$wpdb->query("ALTER TABLE $wpdb->posts ADD COLUMN robotsmeta varchar(64)");
   761 		$options['version'] = "2.3";
   762 	}
   763 	if ($options['version'] < "25") {
   764 		$options['version'] = "25";
   765 	}
   766 	$opt = serialize($options);
   767 	update_option('RobotsMeta', $opt);
   768 }
   769 function echo_nofollow() {
   770 	return ' rel="nofollow"';
   771 }
   772 
   773 $opt  = get_option('RobotsMeta');
   774 $options = unserialize($opt);
   775 
   776 global $wp_version;
   777 if ($wp_version >= "2.3") {
   778 	if ($options['allfeeds'] || $options['commentfeeds']) {
   779 		add_action('commentsrss2_head', 'noindex_feed');
   780 	}
   781 	if ($options['trailingslash']) {
   782 		add_filter('user_trailingslashit', 'add_trailingslash', 10, 2);
   783 	}
   784 }
   785 if ($options['allfeeds']) {
   786 	add_action('rss_head', 'noindex_feed');
   787 	add_action('rss2_head', 'noindex_feed');
   788 }
   789 
   790 add_action('wp_head', 'meta_robots');
   791 
   792 if ($options['login']) {
   793 	add_action('login_head', 'noindex_page');
   794 }
   795 if ($options['admin']) {
   796 	add_action('admin_head', 'noindex_page');
   797 }
   798 if ($options['disabledate'] || $options['disableauthor']) {
   799 	add_action('wp', 'archive_redirect');
   800 }
   801 if ($options['redirectsearch']) {
   802 	add_action('init', 'search_redirect');
   803 }
   804 if ($options['nofollowcatsingle'] || $options['nofollowcatpage']) {
   805 	add_filter('wp_list_categories','nofollow_category_listing');
   806 }
   807 if ($options['nofollowmeta']) {
   808 	add_filter('loginout','nofollow_link');
   809 	add_filter('register','nofollow_link');
   810 }
   811 if ($options['nofollowcommentlinks']) {
   812 	add_filter('comments_popup_link_attributes','echo_nofollow');
   813 }
   814 if ($options['nofollowtaglinks']) {
   815 	add_filter('the_tags','nofollow_taglinks');
   816 }
   817 if ($options['googleverify']) {
   818 	add_action('wp_head', 'google_verify');
   819 }
   820 if ($options['yahooverify']) {
   821 	add_action('wp_head', 'yahoo_verify');
   822 }
   823 if ($options['msverify']) {
   824 	add_action('wp_head', 'ms_verify');
   825 }
   826 if ($options['nofollowindexlinks']) {
   827 	add_filter('the_content','nofollow_index');
   828 }
   829 if ($options['replacemetawidget']) {
   830 	add_action('plugins_loaded', 'widget_jdvmeta_init');
   831 }
   832 
   833 add_action('admin_menu', array('RobotsMeta_Admin','add_config_page'));
   834 add_action('admin_menu', array('RobotsMeta_Admin','meta_box'));
   835 
   836 add_action('wp_insert_post', array('RobotsMeta_Admin','robotsmeta_insert_post'));
   837 if ($options['version'] < '25') {
   838 	robotsmeta_update();
   839 }
   840 ?>