Encrypting links for WP-NoExternalLinks
Warning! I no longer support this plugin after version 3.5.9.9! Please ask questions on wordpress support page.
This article is based on this one and the latest version of plugin. Now you can easily encrypt your links without changing plugin code.
- Ensure that you have php-mcrypt installed:
For CentOS, type
sudo yum install php-mcrypt
For ubuntu, type
sudo apt-get install php5-mcrypt
For windows, enable this extension in php.ini:
extension=php_mcrypt.dll
- Create file wp-content/uploads/custom-parser.php and add here the following:
salt ='ms8-sRt-kBs5-s1wQ';
$this->iv=mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
}
function encode_link($url)
{
if(!$this->salt)
$this->init_crypt();
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->salt, $url, MCRYPT_MODE_ECB, $this->iv)));
}
function decode_link($url)
{
if(!$this->salt)
$this->init_crypt();
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->salt, base64_decode($url), MCRYPT_MODE_ECB, $this->iv));
}
}
?>
Do not forget to change $salt to any custom value! Also, add statistic handling from the original function if you use statistics.