Mark Meta widget with "nofollow"

Due SEO considerations it is not recommended (e.g. by Matt Cutts) to spend precious page rank on links like log-in, register formulars, rss pages and other meta stuff. One thould mark them as nofollow and that is one example where nofollow attribute can be turned in something useful.

Nearly every Worpdress blog would have something like Meta section in the sidebar, every link there should be marked as nofollow. Unfortunately there are not coded in one widget, they are distributed over two files in the standard wordpress installation.

Yo need also update two files:

  1. /wp-includes/widges.php
  2. /wp-includes/general-template.php

In the widgets.php you need to ad rel=nofollow inside of the function wpwidgetmeta(), so that result of this looks like this:

function wpwidgetmeta($args) {  
 extract($args); 
 $options = getoption('widgetmeta'); 
 $title = empty($options['title']) ? ('Meta') :   $options['title']; ?> 
  <?php echo $beforewidget; ?>
  <?php echo $beforetitle . $title . $aftertitle; ?> 
<ul>  
  <?php wpregister(); ?> <li><?php wploginout(); ?></li> 
<li>  
  <a href="<?php bloginfo('rss2url'); ?>" rel="nofollow" title="<?php echo  attributeescape(('Syndicate this site using RSS 2.0')); ?>">
 <?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a>
 </li> 
 <li>

<a href="<?php bloginfo('commentsrss2url'); ?>" rel="nofollow" title="<?php echo attributeescape(_('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>  
<?php wpmeta(); ?>  
</ul>  
<?php echo $after_widget; ?>  
<?php }  

As you see, wp_register() function is called here, and therefore we need to modify general-template.php file. Exactly the mentioned method, so that it looks like this:

 function wp_register( $before = '<li>', $after = '</li>' ) {

if ( ! isuserloggedin() ) {  
if ( getoption('userscanregister') )  
$link = $before . '<a href="' . getoption('siteurl') . '/wp-login.php?action=register" rel="nofollow">' . _('Register') . '</a>' . $after; else 
$link = ''; } else { $link = $before . '<a href="' . getoption('siteurl') . '/wp-admin/" rel="nofollow">' . _('Site Admin') . '</a>' . $after; }

echo apply_filters('register', $link);  
}

Notice that I have added only nofollow relation and nothing more.

However that is not the best solution cause, when these files have been changed in new version you have to patch them all manually. unfortunately, there is no mechanism to preserve standard widgets to be not be updated as i think unless of creating own meta-widget plugin, but this is to much for this purpose. What do you think about?

Update: There is already a plugin for it. :)