My two new WordPress plugins are now available at wordpress.org.
If you’re wondering why I’m releasing new plugins before finishing Shashin 3, it’s because these plugins are key building blocks for the new version of Shashin (they give me autoloading, unit testing, a WordPress functions facade, and more).
I’ve updated the dev version of Shashin 3 on GitHub. If you installed it before, you’ll need to do a fresh installation with this release, as there are database changes. Note you can install Shashin 3 side-by-side with an existing Shashin 2 installation – they will not interfere with each other. The functionality is still limited to the Album management screen. The changes are to internal structure (the dependency injection container is more robust, and I straightened out some issues with the overall object model). Please see the installation steps in my earlier post about Shashin 3.
I won’t be making further changes to Shashin 2 on wordpress.org. I know that many people have been experiencing seemingly random problems synchronizing albums since Picasa switched to using https earlier this year. Fixing this is not practical in Shashin 2. Shashin 3 does its album synchronizing in a different and more robust way. I do my work on Shashin in 20 minutes batches as I ride back and forth to work on the subway (that’s when I have time), so I’m focusing on the new version only.
Please use the comments section for questions, feedback, and feature requests for Shashin 3.
Only a year overdue, I have a development version of Shashin 3 available for download. That’s the good news. The bad news is that all you can do with it right now is use its Tools Menu to sync albums. The Shashin tags and Highslide are not implemented yet. So it may not seem like much, but it’s been probably 80 hours of work so far. This is a complete rewrite, as I found myself unable to provide adequate support for the previous version, given the way I wrote it.
Over the past six months I have immersed myself in Clean Code, Agile Software Development, Refactoring, Growing Object-Oriented Software, Guided by Tests, and more. I’ve been programming since I was 12 (which was a long time ago…) and in recent years thought I had become darn good at it. What I’ve been learning in recent months has been both humbling and exciting. Although the Shashin 3 menus look almost the same as before, if you look under the hood you will see something very different from the old Shashin. I hope to have the time to say more about it later.
But for now, I’m hoping those who’ve had the patience to wait this long for the next version of Shashin will be willing to test this development version. I’m especially looking for feedback from people who have had difficulty syncing albums in Shashin 2, as the new version does syncing in a completely new way, which I expect will be faster and more reliable. It’s designed to be extremely flexible, so after I get the Picasa functionality completed, I intend to add support for Flickr, Youtube, etc. The one limitation right now is that it supports public albums only.
Here’s what you need to do:
What I’m hoping to do from now on is add a new piece of functionality to it roughly once a week, and upload it to github. I’ll tweet any major updates. Once all the basic functionality is in place, I’ll update the plugin repository at wordpress.org
If you’re developing a WordPress plugin, any initial, one-time setup work your plugin needs is done through a call to register_activation_hook()
(such as registering settings, or creating a database table). Debugging problems with code you call through this hook is notoriously difficult. I think I’ve pulled my hair out over each one of the many things that can go wrong, so I thought I’d share my hard-earned solutions (these all apply to the current version of WordPress, 3.0.4):
if function_exists()
wrapper around your function (or if class_exists()
around your class). But don’t waste your time – all it really means is that there was an error of some kind. Any kind of logic error within your function (such as an incorrect number of arguments to a function call) will result in this error being displayed. Don’t be fooled.echo
or print
to debug, but never see any output: normal output isn’t shown during plugin activation. If you want to see some debugging output, call trigger_error()
instead. This will force your message to be displayed in the plugin activation status box.register_activation_hook
, and it just fails silently. The first argument must be the path to your main plugin file (i.e. the file with the plugin comments at the top – __FILE__
will do fine), which is where your activation function must be. The existence of this argument is deceptive, as it suggests you could put the function in another file (you could, I suppose, put your call to register_activation_hook
in another file, and then put your callback function in the main file, but I can’t think of a good reason to do that). The second argument is the function name – if you want to get fancy, it’s fine to use callback pseudo-types.Two general guidelines I recommend are:
register_activation_hook
. This is a good way to expose errors that are otherwise hidden behind the “cannot redeclare” error.UPDATE 3/13: Shashin is not working properly with private albums, since Picasa introduced https support. Also, for public albums, enter their urls with “http” for now (not “https”). I have a major rewrite of Shashin underway, so I will address these problems in the upcoming version. I’m still putting in overtime at my job, so a new version is likely at least one month away. Thanks for your patience.
2010 was the year I worked too much. I have one job, but I was doing the work of two. That’s why my blog was mostly quiet last year, and I didn’t have time to update my WordPress plugins. But I remind myself this is a “nice to have” problem, as there are many people in need of any job these days. I’m happy to report that we are hiring for a new position, which means I can go back to doing one job in a few months (if you’re interested in being an Agile Product Owner for the U Penn SOMIS Web Team, you can apply here – look for reference number 110129833).
I still have too much to do for the next few months, but I’m freed up enough at this point that I can start responding to support questions again for my plugins. I’ve started work on a rewrite of Shashin, but at this point I can’t say when it’ll be done. Please use the comments section of this post for questions (I’ve closed comments on the previous support post).
I’ve added threaded comments to my site’s theme (keep an eye out for the “reply” links under each comment). This will help make different support discussions easier to follow.
I need to temporarily discontinue offering personal support for my WordPress plugins. I sincerely apologize for this. I’m putting in time nights and weekend at my job – that and my family have to come first. I don’t expect my situation at work to be like this for more than a few more months. In the meantime, please use the comments thread on this post if you have questions, and I’m hoping you can support each other (there are at least a few savvy users of my plugins who have posted helpful comments in the past). I will try to jump in if I can to offer help, but I can’t promise it right now.
A couple years ago I wrote a post describing how to limit posts on your WordPress home page to ones in specific categories. A limitation of this approach is that it can only show recent posts that are in The Loop. Others have solved this problem as well, but all the solutions I’ve seen have this same limitation. What if posts in the categories you specify aren’t among your recent posts? Your home page would show no posts!
This was a problem for my new home page design. I’ve divided my site’s content into 3 major topics, and I show hyperlinked titles for the 3 most recent posts in each topic. But it’s possible that a topic may not have any posts among the most recent 10 posts, which is all The Loop knows about (10 is WordPress’ default setting for how many posts to show on your home page). So I want to get the most recent 3 posts for each topic, regardless of whether they happen to be in The Loop.
To do this, I created the following function and put it in my theme’s functions.php file. Note that I’m using a straight SQL query, which means this is not guaranteed to work in future versions of WordPress (the WP coders do a good job of maintaining a consistent programming API across versions, but they do change the database sometimes).
function get_top_category_posts ($term_ids) { global $wpdb; $top_3 = ''; $results = $wpdb->get_results("select ID, post_title, post_date from wp_posts p inner join wp_term_relationships r on p.ID = r.object_id inner join wp_term_taxonomy t on t.term_taxonomy_id = r.term_taxonomy_id where t.term_id in ($term_ids) and p.post_type = 'post' order by post_date desc limit 3", ARRAY_A); foreach ($results as $result) { $top_3 .= "<li>" . date("M d", strtotime($result['post_date'])) . " - " . '<a href="' . get_permalink($result['ID']) . '">' . $result['post_title'] . "</a></li>\n"; } return $top_3; }
I then call it like this from my custom home page (where I’m not using The Loop at all):
<ul> <?php echo get_top_category_posts('6,12,89,90,98,105,106,115'); ?> </ul>
I’m passing the IDs for the categories I want. The easiest way to get a category ID is to go to its edit screen and note the cat_ID in the URL. This works for tag IDs also.
There are 3 database tables involved in the query: wp_posts contains your posts, wp_term_taxonomy contains the term IDs for categories (and tags), and wp_term_relationships connects the posts to their categories. Note that a cat_ID or tag_ID you see in an edit screen URL is actually called a term_id within the database. In this case I’m only retrieving the date and title of each post, but you could retrieve the entire post if you want (see the description of the wp_posts table).
If you want to simplify the query to improve performance, you can eliminate one of the table joins if you manually look up the term_taxonomy_id that corresponds to each category’s term_id, and pass those instead:
select ID, post_title, post_date from wp_posts inner join wp_term_relationships on ID = object_id where term_taxonomy_id in ($taxonomy_ids) and post_type = 'post' order by post_date desc limit 3
The downside of doing this is that every time you add a new category or tag, you’ll have to go into your database and look up its term_taxonomy_id. So I don’t recommend doing it this way unless you’re comfortable poking around in mySQL.
(Note to fellow cranky programmers: I know this is poorly abstracted – the need here is simple enough that, to me, abstraction didn’t seem worth the trouble).
Shashin’s popularity has recently spiked, which makes me happy, but it’s also caused a spike in support requests (my last Shashin post has 127 comments). Until the start of this year, I had been diligent in providing support, but my day job recently has been seeping into my nights and weekends, significantly reducing my availability. It’s likely to stay that way for the next several months.
I started on some major enhancements to Shashin early in the winter – most notably flickr and twitpic support – but it’s been on hold for a while now. At this point, my guess is that it’ll be summer before I can get back to it.
Please use the comment section on this post for support questions. I will do my best to provide responses twice per week. I will most likely not be able to delve into problems that involve the particulars of your server configuration, such as problems with connecting to Picasa via curl for unlisted albums (as those kinds of issues can sometimes take hours to work through). But general usage questions and Highslide issues are usually easier to address, and I’ll do what I can to help out.
Thanks everyone for your patience, and please remember I’m doing this for free 🙂 (donations come in very rarely).
UPDATE: I just posted a minor update, version 2.6.3:
Shashin 2.6 is now available for download at wordpress.org. I figure the end of the world is a good time to release a new version. Here’s what’s new:
Also, I’ve installed the Subscribe to Comments plugin, so if you have a support question, you can get an email notification when I reply, instead of having to remember to check back.
UPDATE: I’ve made a couple bug fixes: v2.6.1 fixed another bug related to Windows servers, and v2.6.2 fixed a bug related to Google servers outside the US (see this comment for details).
Shashin 2.5 is now available for download at wordpress.org. This actually isn’t the major release I’ve been working on – it doesn’t include Flickr and Twitpic support (that’s still a work in progress). But it does include one very cool new feature: a jQuery based WYSIWYG browser for adding Shashin photos to your posts. You can now browse albums from within the editor, and click on photos to add them to your post (it will write [simage] and [sthumbs] tags for you). To use it, click the Picasa icon in the editor’s media button bar. This great feature was contributed by Sune Pedersen.
A couple usability items to point out with it:
The other important new feature is that automatic album syncing is now done every 10 hours instead of once daily. This is because Picasa video URLs now expire every 11 hours, as I described previously. If you have any videos in your albums, then you will want to turn on this feature in the Shashin Settings menu.
There are also two bug fixes:
Now back to work on version 3.0…