Custom Plugin Refuses to Play Nice (I am going crazy!)
-
I am trying to write a very basic plugin, but something is going wrong and I don’t quite know where to begin hunting this problem down.
The code
function xalign_filter_code($content){
$bad_code = array('<p align="left">','<p align="center">','<p align="right">');
$good_code = array('<p style="text-align:left">','<p style="text-align:center">','<p style="text-align:right">');
for($x=0;$x<3;++$x){
$content = str_replace($bad_code[$x],$good_code[$x],$content);
}
return $content;
}add_filter('content_save_pre', 'xalign_filter_code', 10);
add_filter('pre_comment_content', 'xalign_filter_code', 10);The problem is that nothing happens to the “align” attributes, but the bigger problem is that if I add something else to the arrays that I know is in the post text it is replaced!
The plugin is meant to clean up the invalid align attribute that the rich text editor (tinyMCE) uses. Is it the hook I am using? Does tinyMCE do something weird that avoids being hooked into?
Any help big or small would be appreciated.
- The topic ‘Custom Plugin Refuses to Play Nice (I am going crazy!)’ is closed to new replies.