Changeset 449619
- Timestamp:
- 10/10/2011 08:03:54 PM (13 years ago)
- Location:
- comments-cleaner/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
comments-cleaner/trunk/comments-cleaner.php
r443013 r449619 5 5 Description: This plugin removes all HTML tags, BBCode tags and links from added comments. 6 6 Author: Daniel Frużyński 7 Version: 1. 27 Version: 1.3 8 8 Author URI: http://www.poradnik-webmastera.com/ 9 9 Text Domain: comments-cleaner … … 95 95 get_option( 'comcln_remove_bbcode_old' ), 96 96 get_option( 'comcln_remove_links_old' ) ); 97 } 98 99 // These functions are modified copies of WP's make_clickable() and its helper functions 100 // Callback to remove URI match. 101 function _remove_url_cb( $matches ) { 102 $url = $matches[2]; 103 $suffix = ''; 104 105 /** Include parentheses in the URL only if paired **/ 106 while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { 107 $suffix = strrchr( $url, ')' ) . $suffix; 108 $url = substr( $url, 0, strrpos( $url, ')' ) ); 109 } 110 111 $url = esc_url($url); 112 if ( empty($url) ) 113 return $matches[0]; 114 115 return $matches[1] . $suffix; 116 } 117 // Callback to remove URL match. 118 function _remove_web_ftp_cb( $matches ) { 119 $ret = ''; 120 $dest = $matches[2]; 121 $dest = 'http://' . $dest; 122 $dest = esc_url($dest); 123 if ( empty($dest) ) 124 return $matches[0]; 125 126 // removed trailing [.,;:)] from URL 127 if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) { 128 $ret = substr($dest, -1); 129 $dest = substr($dest, 0, strlen($dest)-1); 130 } 131 return $matches[1] . $ret; 132 } 133 // Callback to remove email address match. 134 function _remove_email_cb( $matches ) { 135 return $matches[1]; 136 } 137 // Remove plaintext URIs. 138 function remove_plaintext_links( $ret ) { 139 $ret = ' ' . $ret; 140 // in testing, using arrays here was found to be faster 141 $save = @ini_set('pcre.recursion_limit', 10000); 142 $retval = preg_replace_callback('#(?<!=[\'"])(?<=[*\')+.,;:!&$\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]{1,2000}|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', array( &$this, '_remove_url_cb' ), $ret); 143 if ( !is_null( $retval ) ) 144 $ret = $retval; 145 @ini_set('pcre.recursion_limit', $save); 146 $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', array( &$this, '_remove_web_ftp_cb' ), $ret); 147 $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', array( &$this, '_remove_email_cb' ), $ret); 148 // this one is not in an array because we need it to run last, for cleanup of accidental links within links 149 $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret); 150 $ret = trim($ret); 151 return $ret; 97 152 } 98 153 … … 113 168 // Remove plain text links 114 169 if ( $remove_links ) { 115 $text = preg_replace( '#https?://[^\s]+#i', '',$text );170 $text = $this->remove_plaintext_links( $text ); 116 171 } 117 172 } while ( $text_ori != $text ); -
comments-cleaner/trunk/readme.html
r443015 r449619 3 3 <head> 4 4 <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 5 <title>Comments Cleaner 1. 2Readme</title>5 <title>Comments Cleaner 1.3 Readme</title> 6 6 </head> 7 7 <body> 8 <h1>Comments Cleaner 1. 2Readme</h1>8 <h1>Comments Cleaner 1.3 Readme</h1> 9 9 <p>This plugin removes all HTML tags, BBCode tags and links from added comments.</p> 10 10 <p><b>Plugin Homepage:</b> <a href="http://www.poradnik-webmastera.com/projekty/comments_cleaner/">Comments Cleaner</a></p> … … 33 33 34 34 <h2>Changelog</h2> 35 <p>1.3</p> 36 <ul> 37 <li>Fix: WP makes clickable URLs which starts from "www" - remove them too</li> 38 </ul> 35 39 <p>1.2</p> 36 40 <ul> -
comments-cleaner/trunk/readme.txt
r443015 r449619 4 4 Requires at least: 2.7 5 5 Tested up to: 3.2.9 6 Stable tag: 1. 26 Stable tag: 1.3 7 7 8 8 This plugin removes all HTML tags, BBCode tags and links from added comments (including link to author's website) … … 32 32 33 33 == Changelog == 34 35 = 1.3 = 36 * Fix: WP makes clickable URLs which starts from "www" - remove them too 34 37 35 38 = 1.2 =
Note: See TracChangeset
for help on using the changeset viewer.