Warning! I no longer support this plugin after version 3.5.9.9! Please ask questions on wordpress support page.
Recently I added a new feature to this plugin. Now you can extend it yourself without danger of plugin update which could remove all your changes in plugin code.
In this sample, we will overwrite function check_follow, which checks if link is posted by admin and has rel=”follow” attribute.
Let’s imagine we want all our authors to have the same options. How can we accomplish it? Easily!
Just create file custom-parser.php in directory wp-content/uploads and replace
user_can($author,'manage_options' );
from original function with
user_can($author,'publish_posts' );
- voila!
Here is the full code of our new modified class which will be loaded instead of basic one:
<?php if(!defined('DB_NAME')) die('Error: Plugin "wp-noexternallinks" does not support standalone calls, damned hacker.'); #include base parser include_once(ABSPATH . 'wp-content/plugins/wp-noexternallinks/wp-noexternallinks-parser.php'); classcustom_parserextendswp_noexternallinks_parser { functioncheck_follow($matches) { #support of "meta=follow" option for admins. disabled by default to minify processing. if(!$this->options['dont_mask_admin_follow']) returnfalse; $id=array(get_comment_ID(),get_the_ID());//it is either page or post if($id[0]) $this->debug_info('It is a comment. id '.$id[0]); elseif($id[1]) $this->debug_info('It is a page. id '.$id[1]); $author=false; if($id[0]) $author=get_comment_author($id[0]); elseif($id[1]) $author=get_the_author_meta('ID'); if(!$author) $this->debug_info('it is neither post or page, applying usual rules'); elseif(user_can($author,'publish_posts' )&&(stripos($matches[0],'rel="follow"')!==FALSE || stripos($matches[0],"rel='follow'")!==FALSE)) { $this->debug_info('This link has a follow atribute and is posted by author, not masking it.'); #wordpress adds rel="nofollow" by itself when posting new link in comments. get rid of it! Also, remove our follow attibute - it is unneccesary. returnstr_ireplace(array('rel="follow"',"rel='follow'",'rel="nofollow"'),'',$matches[0]); } else $this->debug_info('it does not have rel follow or is not posted by author, masking it'); returnfalse; } } ?>