what does this code do? (preg_replace)

Mutikasa

Power Member
Joined
May 23, 2011
Messages
589
Reaction score
216
This code is from like dislike counter plugin for wordpress. I wanna know what does it do exactly
Code:
$changedDir='';
if (!$changedDir)$changedDir = preg_replace('|wp-content.*$|','',__FILE__);

thanks
 
The first line and the if statement is useless there. $changedDir is empty and if statement would always turn to true since $changedDir is empty.
PHP Code:
$changedDir = preg_replace('|wp-content.*$|','',__FILE__);

The above statement seems like its trying to get the root path / Wordpress directory where wp-contents folder is located (incase this is stored in a theme file or plugin). Its removing everything after and including wp-content in __FILE__ (which gives the current file path)
 
Last edited:
Back
Top