Oh, as an Aside: Tag Management for WordPress 2.3 (From the 22nd of October)

Now that you have gotten used to WP 2.3 and had time to fiddle around with all those tags, you are probably finding that you need to edit, rename or delete tags. While I was going to write my own Plugins for this for a while, I found the perfect Plugins to do the work for me — and by perfect I mean really good, so I take no responsibility if they eat your dog.

The Simple Tags has been around for a long time, but now it works perfectly with WordPress tagging. What does it do? Most everything you could want (I could retype the list, but I’m going to borrow it straight from the Simple Tags website):

  • type-ahead input tags
  • auto suggestion of tags
  • tags management (rename, delete, amalgamate, search and add tags, edit tags ID)
  • List of non tagged contents
  • Edit mass tags
  • Possibility to tag pages (not only posts) and include them inside the tags results
  • Related content since common tags
  • Possibility to add related posts inside RSS
  • Dynamic Tag Clouds with colors with Widgets
  • Tags inside your header’s blog
  • Embedded tags ([tags]tag1, tag2[/tags]) for retro compatibility

I use a lot of Plugins and write a lot of Plugins, so the fact that I even use one usually means it is really well made or very useful, but this one is one of the very few that I thought was good enough to promote.

Continue reading. »

Oh, as an Aside: Mysql Search and Replace. (From the 31st of August)

I’ve been getting ready for WordPress 2.3, so in preparation I’ve started cleaning up my database. My first order of business was to clean up the tags database. Over time I’ve used several different methods of separating words: all spaces, hyphens and underscores have all been used which really makes the nice names ugly. Fixing this was easy, I just used the MYSQL replace command:

UPDATE `table` SET `field` = REPLACE(Field,'change_me','to_me');

Or specifically for the tags:

UPDATE `wp_tags` SET `tag` = REPLACE(tag,'_',' ');

Designing flexible WordPress themes.

The average WordPress theme has different files for pages, single posts, archives and the front page; however, most of them are almost exactly the same except for inside the_loop. This is a quick tutorial on how to do the most with the fewest files, and includes a few methods to have custom templates by separating content display from structural elements.

WordPress looks first for special files and then defaults to the index.php file (as shown in this diagram). We can take advantage of this by using only an index.php file and then using conditionals to modify it. While it seems that this method would render the code less readable, it is actually far more readable, and far easier to modify.

Your theme should start off a header.php, footer.php, sidebar.php and an index.php. These files are the “code” files and are fairly self-explanatory, and at this point the only question should be whether you add just the header portion of the file to the header.php or everything including the calls to get_sidebar()—the same goes for the footer.php depending on your theme.

Continue reading. »

Trapping WordPress errors with output buffering.

If you have tried to use AJAX with WordPress, most likely you have stumbled upon the wp_die() function which completely kills the response you expect to get. However, we can trap the wp_die() by using PHP’s output buffering and the ob_start callback function to process the output of wp_die() even though a die() is called. This is a very special case, and will only work when you are able to ensure output buffering can be called before the die is called.

The easiest way to get a non-fatal wp_die() error (an error that shouldn’t cause the entire application to stop) is when submitting comments: non-fatal errors occur whenever someone posts too quickly or submits a duplicate comment, so this can be a problem when creating an AJAX app to submit comments (I ran into this problem with INAP.)

Since AJAX makes the entire submit process very quick, so it is easy to trigger the “Posting too quickly” error if the user make short comments, and when this happens an entire page –complete with CSS and headers– is returned as the AJAX response.

Continue reading. »

Oh, as an Aside: Victory over GMail–Inline Images. (From the 25th of July)

I’ve wanted to be able to add images to my emails inline (one that appears with the text, not as a separate attachment) for a long time, and today, thanks to WordPress I finally figured out how to do it.

  1. Open GMail, go to compose mail, select the “Rich Formatting” if it isn’t your default.
  2. Open your WordPress Admin Panel, go to a new post, select the Visual Editor (you may have to turn it on under your user preferences)
  3. Write your email in the WordPress Visual Editor, and embed the image into the new post (or just embed the image).
  4. Copy and paste the “email” from your WordPress Visual Editor to your GMail “Rich Formatting” textbox.
  5. Send your email, don’t save your post.

Easy as π, I would probably figured this out sooner if I didn’t have a hate-fest with visual editors related to the web. (Oh and this works perfectly in Firefox on Linux, so it isn’t a Windows/IE only trick.)

Mommy, he hit me. Yah, well you bit me.

Drama, drama, drama. Sometimes you are amazed at the internet and its ability to bring the word together and coalesce the sum of humanities accomplishments into a single information source. Other times you start to wonder if the internet is filled with pre-pubescent children running around whacking each other over the head with inflatable hammers. Yet again, we have another of the latter. This time the wounded parties are theme designers who sell links to websites, embed them into their themes, and distributed freely across the internet–sometimes, according to Matt, these links are even sold to the same people who spam blogs. Like many of you have heard, these “sponsored” themes are now banned from several central theme distribution sources; thus, minimizing the ability of these themes to spread which, as a result, will keep them from making money for their authors.

Well words have started flying, on one side you have the people losing money and on the other side nearly everyone else.

Continue reading. »