Posts in Category: WordPress

Shashin 3.0.2

Tonight I pushed a set of updates to Shashin that should address most of the issues people have reported in the last 24 hours. I tried to be thorough in the development and beta testing, so I’m glad to see most of the issues are minor. Thanks everyone for the detailed reports. Note you will also need to update Toppa Plugin Libraries for WordPress. Here’s the list of updates in Shashin 3.0.2 (from the readme file):

  • Album photos table now inherits position from parent album thumbnail table
  • Now handles Shashin 2 shashin_album_key query string arg, for old links
  • Bug fix: numeric fields (like photo count, pub date) were getting cleared when updating ‘include in random’ settings for albums
  • Bug fix: now checks for ‘include in random’ flag on albums and photos when generating random thumbnail display
  • Bug fix: fixed size for album thumbnails using old shortcode format
  • Aligned ‘update include in random’ button on Tools menu with radio button column
  • Updated explanation on Settings menu for photo thumbnails
  • Added .pot translation file

Shashin 3.0 now at wordpress.org

Over the past year I’ve worked on Shashin 3 in 20 minute pomodoro-like sessions, to give myself something interesting to do on my daily train commute back and forth to work. I’ve used it to teach myself clean code practices. How to apply clean code practices to WordPress plugin development will be the subject of my talk next weekend at Philly WordCamp.

If you haven’t seen the posts I’ve been writing while I’ve been working on it, see the Post to Post Links II error: No post found with slug "shashin-wordpress-plugin" and Post to Post Links II error: No post found with slug "shashin-3-development-progress" to see the new features. It’s been a lot of work, and a lot of fun. Many thanks to everyone who helped with testing of the alpha and beta versions.

Please use the comments section of this post for any questions or bug reports. Note if you overlook the notice that tells you to install Post to Post Links II error: No post found with slug "toppa-plugin-libraries-for-wordpress" before upgrading Shashin, and you use WordPress’ automatic plugin upgrade feature, you won’t see Shashin’s warning telling you that Toppa Libraries is missing. So you will need to install the Toppa Libraries, and then de-activate and re-activate Shashin in order to complete the upgrade.

Twitpic and Youtube with Shashin

A dragonfly in the Imperial Palace GardensA dragonfly in the Imperial Palace Gardens
A dragonfly in the Imperial Palace Gardens07-Jul-2010 23:14, SONY DSC-W55, 5.2, 18.9mm, 0.005 sec, ISO 100
 
NoMeansNo - Bumbershoot 2011 - Slave (half of song only)NoMeansNo - Bumbershoot 2011 - Slave (half of song only)
NoMeansNo - Bumbershoot 2011 - Slave (half of song only)04-Sep-2011 00:00
 
Last meal in Tokyo :-( some delicious ramenLast meal in Tokyo 🙁 some delicious ramen
Last meal in Tokyo 🙁 some delicious ramen08-Jul-2010 14:56
 

I just did something that’s a no-no with beta software – I added new features. I just couldn’t resist 🙂 . Shashin 3 now works with Twitpic and Youtube. To your right are a photo from Picasa, a photo from my Twitpic account, and a Youtube video I uploaded, all shown using a single Shashin shortcode. Here’s the shortcode:

[shashin type="photo" id="2655,1507,1453" size="small" columns="1" order="user" crop="y" caption="y" position="right"]

If you go to my Post to Post Links II error: No post found with slug "photo-albums", you can see my Twitpic and YouTube feeds now appear as albums, right alongside my Picasa albums.

Albums, photos, and videos from Twitpic, Picasa, and Youtube will all show up in the WordPress post editor’s Shashin media browser, so you can find and add them by point and click (so you don’t need to look up their ID numbers or even type the shortcode).

In your WordPress admin, on the Shashin Tools page, expand the “Examples” section to see how to add Twitpic and Youtube feeds. Youtube doesn’t advertise the existence of their feeds, but they’re there! In addition to a feed for your own account, you can get feeds for their most popular videos, trending videos, top rated, etc and have Shashin automatically update itself daily. So you can do things like feature the current most popular Youtube videos on your site.

Another change I made is photos will now scale to the size you indicate. So if you want the size to be, say, 213 pixels, it’ll be 213 pixels (if it’s not a size available from the photo hosting service, Shashin will find the next largest size available and scale it down). I did this to accommodate showing photos from different services side by side, since they don’t all make their photos available in the same sizes. This also means you can now show album thumbnails in any size, cropped or not cropped (note I changed the size labels to reflect this, so a “large” album thumbnail is now the same size as a “large” photo thumbnail).

You can download the latest version from GitHub. If you already have Shashin 3 beta installed, please 1. deactivate it, 2. delete your current files, 3. upload the new files, and then 4. reactivate (you don’t need to uninstall the plugin – I renamed several files, so this is just to cleanup your Shashin files).

Assuming no major bugs come up in the next few days, I’ll push Shashin 3 to wordpress.org this weekend, and officially retire Shashin 2.

Shashin Documentation and Examples

Writing good documentation is hard work 🙂

  • Post to Post Links II error: No post found with slug "shashin-wordpress-plugin" now contains detailed documentation for installing and using Shashin 3 (the beta version is currently available at GitHub).
  • I modified the Shashin 3 progress status page so it is now a demo page, with Post to Post Links II error: No post found with slug "shashin-3-development-progress".
  • I created a new, temporary page for Post to Post Links II error: No post found with slug "shashin-2-documentation", since it is still available for download at wordpress.org (I’ll replace it with Shashin 3 when beta testing is complete, in about a week).

Shashin 3 Beta is Here

I just uploaded the beta release of Shashin 3 to GitHub. All the features are done, so this is the version I will upload to wordpress.org after all you nice people help me test it (what would be especially helpful is if someone tried it on a Windows server, which I do not have). If you find bugs, please submit issue tickets on GitHub, or leave a comment here.

I am working on a major re-write of my Post to Post Links II error: No post found with slug "shashin-wordpress-plugin", so that it documents how to use Shashin 3, as there are several major differences from Shashin 2. I intend to finish this weekend.

A key thing to note for those who’ve been using the alpha version is that it will now upgrade and replace an existing Shashin 2 installation (you can no longer run Shashin 2 and Shashin 3 side-by-side). It will update your Shashin 2 database and there’s an option now on the Shashin Settings menu to turn on support for the old shortcode format.

If you are upgrading from Shashin 2, please follow these upgrade instructions:

  1. Deactivate and delete your Shashin 3 Alpha installation if you have one
  2. Deactivate your Shashin 2 installation
  3. Backup and remove the “shashin” folder from your plugin directory
  4. Download Shashin 3 from GitHub, and rename its folder to “shashin”
  5. Upload it to your plugin folder
  6. Click “Plugins” in the WordPress admin sidebar, to reload the main plugin panel (this is important, so that WordPress will be aware of the underlying code change before activating)
  7. Activate Shashin. This will trigger the creation of backup copies of your existing Shashin 2 database tables, and then a series of transformations on the live tables to make them Shashin 3 compatible.
  8. You’ll see an upgrade nag message telling you to go to the Shashin Tools menu to complete the upgrade – follow the instructions you see there

WordPress Plugin Updates

I’ve committed updates to the following WordPress plugins:

  • Shashin 3 (dev): added support for image viewers other than Highslide. See the Post to Post Links II error: No post found with slug "shashin-3-development-progress" for more details. Currently available at GitHub (I’m not going to replace Shashin 2 at the wordpress.org plugin repository until Shashin 3 is done).
  • Post to Post Links II error: No post found with slug "deko-boko-wordpress-plugin": fixed the language translation configuration and updated the .pot file
  • Post to Post Links II error: No post found with slug "toppa-plugin-libraries-for-wordpress": added language translation support, improved the form building widgets (especially for checkboxes), and added a bunch of functions to the WordPress facade (see the readme file).
  • Post to Post Links II error: No post found with slug "simpletest-for-wordpress": also added language translation support.
  • All of the above: handling of any plugin activation errors is now much more user friendly.
    • My other two plugins – Post to Post Links II error: No post found with slug "post-to-post-links-wordpress-plugin" and Post to Post Links II error: No post found with slug "koumpounophobia-wordpress-plugin" – are on the back-burner for now. For now I’m focused on getting Shashin 3 done. I have plans for these 2 plugins as well. It’s all just a matter of finding enough time…

Shashin 3 Progress Update

Last week I finished the last complex task remaining for Shashin 3, which is using jQuery so you can page through large album photos sets without the whole page having to refresh. Click the thumbnail on your right for my Seattle trip photos to give it a try.

Tonight I pushed an update to GitHub which makes the settings page fully functional. Note you need to update Toppa-Libs as well. Keep in mind not all the features related to the settings are implemented yet (specifically, automated album syncing and support for viewers other than Highslide).

At this point, you can put Shashin 3 into use on your site, as long as you don’t need backwards compatibility with Shashin 2, and you don’t need the features still on the to-do list. Shashin 2 backwards compatibility and the other features are coming!

I am speaking at WordCampPhilly on Nov 5th, to talk about the Agile coding practices I’ve applied to Shashin 3, so my goal is to be done before then.

Shashin 3 Progress and Examples

I’ve created Post to Post Links II error: No post found with slug "shashin-3-development-progress". It lists features which are completed, and those that are on the to-do list. It also documents the new shortcode syntax and has working examples.

I just uploaded revisions to GitHub. If you are working with a version that’s more than a few days old, you will need to delete your previous installation and reinstall, in order to get the database changes (hey, it’s still an alpha version!).

Please make sure to follow the instructions in the README file when installing, and report any problems with Shashin 3 using the GitHub issue tracker.

Agile Programming for WordPress Plugins: The Joy of Output Buffering

A standard practice of Agile programming, and good programming in general, is to separate your display code from your application logic. Bob Martin:

Today’s modern programming environments make it possible to put many different languages into a single source file. For example, a Java source file might contain snippets of XML, HTML, YAML, JavaDoc, English, JavaScript, and so on… This is confusing at best and carelessly sloppy at worst.

The ideal is for a source file to contain one, and only one, language. Realistically, we will probably have to use more than one. But we should take pains to minimize both the number and extent of extra languages in our source files.

Separating display code is central to the MVC pattern, which underlies almost all PHP frameworks (and frameworks in many other languages as well). WordPress is a blogging platform and arguably a CMS, but for plugin authors, it does not provide the typical tools of a development framework. If you want to separate out your display layer, you’re on your own.

As a result, very few plugin developers do. A common style for WordPress plugins is a single file, sometime running thousands of lines, that consists of cryptically named functions (often in no discernible order), which have the display code scattered around within the core application logic. This style might be acceptable for something small and simple. But once the functionality becomes complex, this style makes the code very difficult to understand for anyone other than the author (and the author is likely to find it hard to understand six months after finishing work on it). It also makes extending the functionality difficult. For example, adding support for a mobile UI would entail a major rewrite.

For a WordPress plugin, you can use output buffering to solve this problem. You can see an example in my ShashinMenuDisplayerAlbum class. The run() method triggers the display of the menu, and its HTML is in a separate file:

ob_start(); // start the output buffer
require_once($this->relativePathToTemplate); // get the HTML template
$toolsMenu = ob_get_contents(); // store it in a variable
ob_end_clean(); // empty the buffer and turn it off

Normally a require_once call would include the file, evaluate any PHP code, and immediately output the HTML. Including the file with output buffering turned on allows you to instead store all the output in a variable. You can then control when it is displayed. With this approach you do not have to write all your HTML inline with your application logic.

The template file being included in my example does have PHP as well as HTML in it, so I am not meeting the ideal of complete separation. But as Bob Martin points out, such total separation isn’t always possible. In this case, the PHP code used in the template is the minimum necessary for the purpose of rendering the page (for example, it contains a foreach loop to display rows of data in a table).

Deko Boko 1.3 Now Available

Update 6/26: Please download version 1.3.1, as it contains an important bug fix. Also, for GitHub fans, I now also have Deko Boko on GitHub.


It’s been almost two years since I last updated my Deko Boko contact form plugin. The new version is now available at wordpress.org. It started as a fix to a minor bug that was recently reported, and grew into a significant overhaul. This version updates the reCAPTCHA library code, as the reCAPTCHA project is now managed through Google. It includes several other minor enhancements and bug fixes (see the change log if you’re really curious). Note you will need to install Toppa Plugin Libraries for WordPress to use it.

This is the first round of refactoring Deko Boko. It has exactly one unit test now! Hey, it’s a start. I’ll turn my attention back to finishing work on Shashin before I do more with it (Deko Boko is much less complex than Shashin, so updating it was not nearly as involved).