Posts in Category: WordPress

Deko Boko 1.2 Available

Post to Post Links II error: No post found with slug "deko-boko-wordpress-plugin". You can add any optional or required fields you want to the contact form, simply using HTML. It includes a “CC Me” option, it uses reCAPTCHA for handling spam, and it protects against XSS and email header injection attacks.

New in version 1.2:

  • You can have Deko Boko load its stylesheet only on pages where you use the Deko Boko contact form, so it won’t be loaded unnecessarily on other pages.
  • Localization support: a dekoboko.pot file is included to enable translations to other languages.
  • If you want to make a custom contact form, a template is included to get you started.
  • If you want to customize the dekoboko.css stylesheet, you can place it in your active theme folder, and Deko Boko will find it there (that way you won’t lose your stylesheet customizations when upgrading Deko Boko).
  • Uninstall option.
  • Uses a nonce field for additional security.

You can download Deko Boko from wordpress.org.

Important note to upgraders: you will need to deactivate and then reactivate Deko Boko after you upload the new files. Also, the contact form now uses a nonce field for additional security. If you have made your own contact form template, you will need to add a nonce hidden input field, like this:

<?php wp_nonce_field('dekoboko_nonce', 'dekoboko_nonce'); ?>

Update 5/12: I’ve released a bug fix, version 1.2.1. It fixes an installation bug: Deko Boko wasn’t installing properly if you didn’t already have the WP-reCAPTCHA plugin installed. It will now install correctly with or without WP-reCAPTCHA already installed.

Koumpounophobia 0.4 Now Available

Post to Post Links II error: No post found with slug "koumpounophobia-wordpress-plugin" is a WordPress plugin that enhances the HTML Editor in several ways, giving you new buttons, modal dialogs, and the ability to add your own buttons.

The new version 0.4 is compatible with Internet Explorer 7 and 8. It also fixes the “scroll position” bug in Firefox 3 (the editor no longer scrolls to the top after you use a Koumpounophobia modal dialog). It’s available for download at wordpress.org.

Getting it to work with Internet Explorer took a lot of research, but in the end it required only a few additional lines of code. The problem was that IE would forget the cursor position in the editor when you used a modal dialog, causing your tag to always be inserted at the beginning of your post. If you do a search for “textarea cursor position” you’ll see a lot of electrons being spilled by others trying to solve this problem for their own projects. I’ll write a separate post on this, as the solution in many cases doesn’t require the dozens and dozens of lines of code that a lot of people are using.

Post-to-Post Links II Now at WordPress.org

Post-to-Post Links II is a plugin for creating links to other posts, pages, tags, or categories on your WordPress site, and it’s now available for download at wordpress.org. I also created Post to Post Links II error: No post found with slug "post-to-post-links-wordpress-plugin".

There are a couple improvements with this version:

  • Now you can use it with tag slugs and tag IDs too
  • Fixed a bug with using category slugs

As explained in the readme file, it unfortunately can’t interpret the tags from Scott Reilly’s old “Easy Post-to-Post Links” plugin. I used his plugin heavily, and if you want to convert your old tags for use with my new plugin, you can. Doing so requires 1. you to be comfortable running a SQL query and 2. that you consistently used only post slugs or only IDs with Scott’s plugin. If you used IDs in some tags and slugs in others, then you can’t make the conversion (as there’s nothing in the syntax of Scott’s tag itself that indicates whether you’re linking by ID or slug).

These are the steps:

  1. Make a backup of your WordPress database, or at least the wp_posts table. This is very important, in case you make a mistake in the SQL.
  2. Run this SQL statement if you always used slugs for your links:
    update wp_posts set post_content = replace(post_content,'[post=','[p2p type="slug" value=');

    Or run this SQL statement if you always used IDs for your links:

    update wp_posts set post_content = replace(post_content,'[post=','[p2p type="id" value=');

I use the “text” attribute the same way Scott did, so that portion of the tag will carry over seamlessly in the conversion.

Koumpounophobia Now at WordPress.org

Koumpounophobia is a plugin for adding custom buttons to the WordPress HTML Editor, and it’s now available for download at wordpress.org. I also created a Post to Post Links II error: No post found with slug "koumpounophobia-wordpress-plugin".

I’ve made a few improvements with this version:

  • Now uses the jQuery plugin UI Dialog for controlling the modal input dialogs
  • Fixed bug with buttons for self closing tags that don’t use an input dialog (the button mistakenly tried to add a closing tag)
  • Simplified the HTML and CSS for the form input dialogs

If you made your own input dialogs based on the initial release, the HTML needed is now simpler. Please see the dialogs.html in the new version.

If you were using the initial release in conjunction with Post-to-Post Links II, you’ll want download a fresh copy of Post-to-Post Links II as well (not at wordpress.org yet, but it’ll be there soon now also at wordpress.org).

It still doesn’t work correctly in Internet Explorer 🙁 But I haven’t given up…

Two New WordPress Plugins: Koumpounophobia and Post-to-Post Links II

Update: Koumpounophobia is now at wordpress.org and so is Post-to-Post Links II. I’ve updated the download links below.

I’m releasing beta versions of two new WordPress plugins: Koumpounophobia and Post-to-Post Links II. I’ll create documentation pages for them soon. In the meantime please see the readme.txt files that come with them for details. Here’s the overview:

Koumpounophobia

Koumpounophobia is powered by jQuery, and enhances the WordPress HTML Editor button bar in 5 ways:

  1. It replaces the anchor and image buttons with new versions that provide input dialogs with more options (image width, height, etc.)
  2. It adds two new buttons: div and span, each with their own input dialogs (for class, style, etc. attributes)
  3. It lets you add your own buttons and create custom input dialogs for them
  4. It provides an API for other plugins to add buttons and custom input dialogs
  5. You have total control over which Koumpounophobia-based buttons will appear in the button bar

This is a beta release, and since it involves some fairly intricate JavaScript code, browser compatibility is an issue. In my testing so far it works beautifully in Firefox 3 and Google Chrome. It does not work well in IE 6, 7, or 8 (even without Koumpounophobia installed, the HTML Editor has some problems in IE8). I’d appreciate feedback on how it works in other browsers (please leave a comment on this post – let me know your operating system too).

If you’re wondering about the name, Koumpounophobia is a phobia of buttons. I learned about it because my 3 year old has a mild case of it (he won’t wear anything with buttons, and he won’t let you hold him if you’re wearing buttons). I thought the name was appropriate since there haven’t been any improvements to the WordPress HTML Editor in years – someone must be afraid of the buttons 😉

This plugin was a real challenge to create because the WordPress “quicktags” code that creates the HTML Editor’s button bar was not written with customization in mind. It has no hooks for runtime access. This is why so few plugins add buttons to the HTML Editor, while the Visual Editor, with its well documented API, is lavished with attention. Those of us who like to work directly with the HTML deserve some nice buttons too!

Download Koumpounophobia

Post-to-Post Links II

Using the Post-to-Post Links II shortcode in your posts and pages, you can create links to other posts, pages, or categories on your WordPress site. You use the ID number or the slug to identify the post, page, or category for your link. The link will use its title as the link text, or you can supply your own link text. See the readme.txt file for examples of the shortcode syntax.

It makes linking within your site more convenient, and it means your links won’t break if you ever change your permalink structure or re-arrange your categories.

This plugin was inspired by the Easy Post-to-Post Links plugin written (but no longer maintained by) Scott Reilly. Unfortunately though, it cannot interpret the old Easy Post-to-Post Links tags. Post-to-Post Links II uses WordPress’ robust Shortcode API, which is not compatible with the syntax Scott used in Easy Post-to-Post Links. (Update: but you can convert them – see here)

I’m releasing it at the same time as Koumpounophobia because it uses the Koumpounophobia API to register a new button for the HTML Editor. So if you want a handy button for its shortcode, install Koumpounophobia too. Or if you’re a plugin developer, it’s a good working example of how to add buttons to the HTML Editor using Koumpounophobia.

Download Post-to-Post Links II

Shashin 2.3.5 Now Available

I had hoped to finish version 2.4 by now, but I’ve been busy with other projects and haven’t had enough time for it. So I’m releasing 2.3.5, which will be the final patch for version 2.3. There were a few bugs that people discovered since the last patch, and I don’t want to delay getting the fixes out. You can download it from wordpress.org, or if you already have a previous version installed, your plugin menu should give you a link within the next 24 hours to automatically upgrade.

Patches aren’t supposed to have new features, but this has a couple small ones, since I had already finished working on them.

  1. In addition to floating left or right, you can use “center” as an option for positioning your shashin tags and widgets. For example:
    [simage=600,576,y,center]

    This gives the picture with key 600 a width of 576, shows the caption, and centers the picture. Shashin uses the CSS “margin-left: auto; margin-right: auto;” technique to center the picture. This means you can leave out the “clear” argument if you’re centering, as the subsequent content will be automatically pushed below the picture.

  2. The simage tag has a new, optional 6th argument, which lets you specify an alternate thumbnail image. This is particularly useful for videos, as sometimes Picasa is unable to generate a thumbnail (I’ve run into this with a couple of mp4 videos, where the Picasa-generated thumbnail is just a solid black image). You can see it in Post to Post Links II error: No post found with slug "takanawa-yochien-kindergarten-video". The thumbnail is a still frame from the middle of the video. The syntax looks like this:
    [simage=432,288,y,left,none,433]

    The number at the end is the photo key for the thumbnail image to use. Note this option is available only for the simage tag.

These are the bug fixes:

  • Fixed incomplete localization code for widget menus
  • In the album photo admin menu, now correctly saves whether photos should be included in random display
  • The salbumphotos tag can now handle sort order options with spaces (e.g. “pub_date desc”)
  • The salbumphotos tag no longer shows a “go back” link, as there’s nothing to go back to

Making Unrelated WordPress Posts Look Like They Are In The Same Category

In my page header you’ll see there’s the linked photo for “Japan and Other Travel.” I recently decided to separate my “Japan” category from my “Travel” category, since I’ve been writing a fair number of posts about Japan that aren’t directly related to my travel there. But I still have plenty of posts that are about my time in Japan. So supporting that link in my header became a problem since WordPress doesn’t have the concept of multiple category parents (that is, WordPress can only display posts together on a page if they are in the same category, or have a common category parent).

One solution would be to use tags – to give all my “Travel” and “Japan” posts a common tag, and then link to the tag. That’s a perfectly good solution, but I decided against it because I’m lazy. I’m not currently using tags at all, and I don’t want to go back and update something like 150 posts with the new tag. Even if I wrote a database query to take care of the old posts in a single batch, I’d still have to always remember to put any new posts under the right category and the right tag. In addition to being lazy, I’m also forgetful.

Instead, I did the following:

  1. I created a new top-level category named “Japan and Other Travel,” and I made a note of the category ID number assigned to it. This category will be an empty shell. I won’t ever assign any posts to it.
  2. I created a new template in my theme named category-96.php. That number in the filename is the ID number that was assigned to the category. When displaying a category page, WordPress will automatically first look for a template specific to that category before moving on to a catch-all template.
  3. category-96.php consists of nothing more than the following lines of code:
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=42,92&paged=$paged");
    require_once(TEMPLATEPATH . '/index.php');
    ?>

    This uses some of the same code that’s in a post I wrote last year, about how to limit the categories that appear on your home page. Normally this category page would have nothing on it, since I don’t have any posts assigned to it. The call to query_posts() overrides that, and instead gets posts from the two category ID numbers that I passed to it. The $paged variable keeps track of which page someone is on if they click links to see older entries in the category. The require_once() call pulls in the index.php file for my theme to display the posts (if my theme had a category.php file, I would have used that instead).

And that’s it! The empty category doesn’t show up in my category list in the sidebar, because by default wp_list_categories() excludes categories with no posts in them.

I like this solution because now that I’ve set it up, I can go back to being lazy and forgetful.

Shashin 2.3 Now Available at wordpress.org

Beta testing is now done, and Shashin 2.3 is available for download from wordpress.org. If you have the beta version, go get the final version from wordpress.org. Thanks very much to everyone who helped with testing – you found bugs that I had missed and provided helpful feedback on the new features.

Update 2/10: …even more bug fixes – version 2.3.4 is now available. A few people using Shashin with WordPress on Windows were having problems adding certain photos. This is fixed now (the problem had to do with photos that had no date indicating when they were taken – mySQL on Windows insists on having a date). Also, the [salbumlist] tag is now working again (I overlooked it in my previous testing). Lastly, you can now put more than one [salbumthumbs] or [salbumlist] tag on a page (it never occurred to me to try this, but someone wanted to, and now it’ll work).

Update 1/30: Yet another minor release is now available – version 2.3.3. I rewrote the album syncing method for faster performance. There should be a noticeable improvement when clicking “sync all,” especially if you have a lot of albums (or a lot of photos in your albums). I also fixed a bug – Shashin wasn’t correctly updating its photo data when an album was moved from one Picasa album to another. Shashin can now also handle a # character at the end of album URLs when adding an album (the # appears in certain Picasa links – it’s not actually part of the album URL, and it was tripping up the RSS feed).

Update 1/25: Another bug fix release is now available at wordpress.org – version 2.3.2. This is an important one, so please upgrade. You’ll need to deactivate and then reactivate Shashin after uploading the new version. It fixes a problem with albums getting added multiple times when you try to sync albums. It also fixes a problem with the album thumbnail widget – it now automatically links the album thumbnails to Picasa, instead of trying to load all your photos in the sidebar. And it includes the first localization file contribution – Shashin in Dutch!

Update 1/23: I just updated Shashin at wordpress.org with a couple of bug fixes (version 2.3.1). It wasn’t loading language localization files correctly, and in certain situations it was reporting a database error when there wasn’t one. Both problems are fixed.

Workaround for Using Unlisted Picasa Albums in Shashin

Update 2/14/2010: As of version 2.6, Shashin now has support for unlisted albums, so you no longer need the workaround described in this post.


There’s still no support for unlisted albums in the new version of Shashin, but there is a workaround. If you temporarily make your unlisted album public, then add it to Shashin, and then make it unlisted again, it will work in Shashin. If you later add photos to the album, you’ll need to briefly make it public again to sync it with Shashin. I was actually surprised this worked. Shashin is able to display the photos even without the authkey for the unlisted album. It seems that Picasa requires an authkey to access the Picasa pages that display the unlisted photos, but doesn’t require an authkey for the images themselves.

The reason I haven’t added better unlisted album support yet is that it’s more difficult to do than it might seem. I could use an album’s authkey to give Shashin access to an unlisted album’s RSS feed. However, Shashin also needs to access your Picasa user feed, which contains important metadata about all your albums. Unlisted albums don’t show up in the public version of that feed, even if an authkey is available.

To access that feed, I’ll need to give Shashin the ability to log in to your Picasa account. This is possible with the Picasa Web Album API. There’s an officially supported PHP library for interacting with it, but the problem is that the library is over 3MB in size, and I don’t want to bundle something that enormous with Shashin.

I wrote my own authentication routine using Google’s ClientLogin method for another project, but that approach isn’t appropriate for a distributed web application like Shashin. I’ll have to figure out their AuthSub method instead, which is intended for web applications. So… look for better unlisted album support in a future version of Shashin, and hopefully the workaround described here will get you by in the meantime.

Shashin 2.3 Beta is Here

Shashin 2.3 is a complete rewrite, with more robust error handling, improved security, and several new features. I’m initially releasing it on my site only, as a beta release. Update: The final version is now available for download at wordpress.org:

Download Shashin 2.3 Now.

I’ve done a fair amount of testing myself, but since it’s a rewrite, there’s the possibility of new bugs where there weren’t any before, so I’m looking for help testing it before I make it more widely available on wordpress.org. Please use the comments section on this post to let me know if you run into any problems.

If you’d like to see an overview of the code, here’s the Shashin 2.3 phpdoc documentation.

Important installation instructions if you’re upgrading:

  1. Make a backup copy of your current Shashin files
  2. Deactivate Shashin
  3. Delete Shashin from your plugins directory (this will not harm your Shashin photo data)
  4. Unzip and upload the new version
  5. Reactivate Shashin
  6. Go to the Shashin settings page. You will need to reset your options (they’re stored in a different way in Shashin 2.3, and it doesn’t inherit from previous versions)

New features and how to use them:

  • Automatic daily synchronization of all your Shashin albums with Picasa. This is turned off by default – you can go to the Shashin settings page to turn it on. This was the last feature I added and I haven’t tested it thoroughly, so I’d especially appreciate feedback on this.
  • Internationalization: Shashin now comes with a shashin.pot file and will work with localization files you create. If you create a translation for Shashin, please send me your localization files and I’ll include them with the Shashin distribution.
  • Simplified use of the [salbumthumbs] tag. If you’re using Highslide with Shashin, you no longer need a second page with the salbumphotos tag to display an album’s photos. Just click an album thumbnail, and the page will reload showing thumbnails of the album’s photos. On the Shashin settings page you’ll see a new set of options for specifying the thumbnail size, sort order, etc.
  • Repurposed [salbumphotos] tag: you can now use it to show all the photos for an album, without having to first click an album thumbnail. This means the syntax has changed slightly – the first argument is now an album key:
    [salbumphotos=album_key,max_size,max_cols,caption_yn,description_yn,order_by,float,clear]
  • Improved usability for the Shashin admin menus. You can sort your albums and photos by clicking on different column headers. Also, Shashin makes use of the new styling options in WordPress 2.7 to make the album list easier on the eyes.
  • The [srandom] and [snewest] tags used to require either a single album key or the word “any” as its first argument. You can now also provide multiple album keys. Here’s an example:
    [srandom=3|7|2,288,2,6,n,none,both]
  • For each of the Shashin widgets, you can now specify CSS “float” and “clear” values.
  • Uninstall option: this will delete the Shashin database tables and delete all the Shashin options from the WordPress options table. You can never get your photo key and album key numbers back if you do this, so only uninstall if you really don’t like Shashin 🙁

Bug fixes, security fixes, and error handling:

  • If you list multiple album keys or photo keys in a Shashin tag, they’ll now always display in the order you listed them.
  • There were a number of minor bugs with Shashin widgets. I won’t list them all here, but it’s probably safe to say that if you noticed something that wasn’t quite right with one of the widgets, it’s fixed now.
  • Better protection against SQL injection (this is a very low risk for Shashin anyway, since it doesn’t take user inputs through public-facing pages, but the extra protection can’t hurt).
  • Removed an XSS (cross site scripting) vulnerability.
  • In the admin panels, Shashin used to report the same error message regardless of what really went wrong. Now the error reporting is much more specific, which will make debugging much easier.

Acknowledgements

Update 1/21: the official release is now available at wordpress.org. Thanks to everyone who helped with testing! The download link above now points to wordpress.org.
Update 1/18: I’ve uploaded another revised version, thanks to a couple bug reports I received. You’ll need to deactivate and reactive Shashin for one of the fixes to go into effect (there was a datatype problem with the date fields, resulting in albums and photos not always sorting in the right order).
Update 1/16: Post to Post Links II error: No post found with slug "shashin-wordpress-plugin" for the Shashin 2.3 beta. Also, I found and fixed two very minor bugs. The download link below includes the fixes.