I made a small update to the ComLuv API so it will show the info panel properly when a user has special characters like © in their bio description or post titles.
Replace it with nothing!
I did have some rather complex search and replace code in the api to try and prevent special characters from killing the returned data but it wasn’t always working. It’s been there for quite some time and I’d almost forgotten about it until I saw a tutorial on regular expressions.
I’ve now come up with this to replace all instances of characters that shouldn’t be there..
function clean_it($string){ $text = preg_replace("/[^a-zA-Z0-9\s\"\'<>\/=\.:\-]/", "",$string); return $text; }
call it with $clean_string = clean_it($dirty_string);
All it does is replace any characters that aren’t alphanumeric or quotes,equals,dots,hyphens colons and forward slashes with nothing. This means you can have your description contain a link but nothing too fancy.
More code?
Now that guest blogging is open for all subjects, I will be putting up code snippets when I get the chance or when I discover something new. It helps me keep a record of what I’ve done and it might just help someone out there.
Are you ok with an occasional geeky php post or two? Let me know in the comments…
Twitter: BasicBlogTips
says:
Hi Andy, thanks for the update. PHP posts are fine with me, as long as you explain the outcome in plain English for us semi geeky folks too.
Cheers on overcoming another coding hurdle.
Ileane Smith´s recent blog post ..Your Blog Is Your Baby Treat It Like One
Twitter: commentluv
says:
Thanks Ileane, maybe I need to do a video guest post on your site with some simple php snippets that anyone can try on their wordpress blog?
Twitter: CoachNotesBlog
says:
Hi Andy, I don’t mind geeky php posts. I’m not a programmer, but I can usually find my way around code if it is well commented. I haven’t run into the issue you describe, but glad to see you’re always on the lookout for how to make ComLuv even better.
CoachNotes´s recent blog post ..Quick Fix: Special Text Boxes Plugin Stopped Working
Twitter: commentluv
says:
I’ll be sure to leave plenty of comments in my code if I make more php posts in the future then! thanks for coming by
Twitter: BlazingMinds
says:
Hey Andy you’re blinding us with science Seriously though, congrats on sorting out the PHP, I wouldn’t know where to start
BlazingMinds´s recent blog post ..Is This Really A Time Traveler Caught On Film
Twitter: commentluv
says:
I fixed one thing and it broke another! the thing i fixed caused a problem with something else so I had to rush in a quick code change. I have it all sorted now I hope
Twitter: lavenderuses
says:
Thanks for working so tirelessly for commentluv community Andy. I know nothing about code but I’m sure whatever you have done will just make things run even better.
Patricia Perth Australia
Patricia´s recent blog post ..Lavender Products:cheap but not so cheerful
Twitter: commentluv
says:
I hope so! thanks
Hi Andy, thanks for the update.