Advertisements

Archive for October, 2012

How to fix mangled HTML in WordPress posts using SQL

There are quite a few ways that source code and other preformatted text can get mangled in WordPress, such as a rich-text editor, or even by the export/import process.

When I speak of ‘mangled’, I mean unnecessarily HTML-encoded. Left and right angle brackets (the < and > signs), quotation marks (the ” symbol), and ampersands (the & symbol) get HTML-encoded to &lt;, &rt;, &quot;, and &amp;. This can seriously mangle sourcecode, as well as making other text seriously ugly.

It can become a huge time waste to try to go back and edit all your affected posts one at a time to fix mangled code, even with search-and-replace.

Instead, there’s an easy and straight-forward way to do it in SQL, that you can execute from phpMyAdmin, MySQL Workbench, or whatever you fancy.

Simply run each of the following queries on your WordPress database, and feel free to edit them as you like.

update wp_posts set post_content = replace(post_content, '&quot;', '"');
update wp_posts set post_content = replace(post_content, '&gt;', '>');
update wp_posts set post_content = replace(post_content, '&lt;', '<');

Have any others to suggest? Please feel free to do so in the comments below. Thanks!

Advertisements

, , ,

Leave a comment

MacBook optical drive dust cover causing stuck CDs

If you have an older MacBook and are having problems with CDs getting stuck in the drive, the drive itself might not be to blame. In the case of one particular MacBook that I’ve worked on, it was the dust cover of the drive itself. It had hardened enough over time from dust and dirt to put resistance on the CDs enough to keep them from ejecting.

The first step is to disassemble the MacBook and get access to the dust cover. Follow this YouTube video for the disassembly, right down to removing the optical drive

Once the optical drive is removed, remove the four screws, and then remove the dust cover assembly.

Carefully pry the dust cover assembly off. It will be stuck to the plastic base with adhesive, so the use of a tool is recommended.

The dust cover itself is little more than fabric glued to the magnesium bracket. You can easily peel it off. This one only left a little reside and I was able to easily clean it with some alcohol.

Now, just reinstall the bracket, and reverse the above.

You’ll notice a small gap where the dust cover used to be, but CDs no longer get stuck! I’m sure it wouldn’t be hard to fabricate a replacement for the dust cover.

Feel free to comment below. 

, ,

Leave a comment