Plugin Update: Fun with Sidebar Tabs
Monday
Mar 31, 2008
I have made a few changes to the Sidebar Tabs plugin. Version 0.4 was uploaded tonight.
The most important change was a switch from Prototype to JQuery. This should make it less of a burden on load times and prevent the plugin from being compromised by plugins that bypass WordPress’s inbuilt script scheduling.
I have also added the facility to deal with sidebars where there are more tabs than the width of the sidebar can accommodate. It show now offer the option to ‘page’ the tabs where there is more than one row instead of simply wrapping around.
Finally, I have added a fade effect to the tab switchover.
You can read more about the plugin at the main plugin page here: http://www.wp-fun.co.uk/fun-with-sidebar-tabs/
- Comments Off
- Read Entire Post
A few days ago I wrote, in response to Ian at Theme Shaper’s question, about my thoughts for a new default theme for WordPress. It seems that my ideas were well received as I have won first prize in the contest. What this means is that I now have access to a number of Premium WordPress Themes provided by iThemes that I can try and review.
I have often wondered how easy premium themes are to use and work with, and I imagine that a lot of people have considered this before buying. To help anyone who is considering buying a premium theme I intend to try each theme, live with it for a week or so, and blog my experiences.
I will begin over the weekend with the first posts on Monday. If you have any particular thoughts or questions about the experience of using and living with a Premium theme let me know and I will pay particular attention to it.
Authors in Comments
Thursday
Mar 27, 2008
Earlier today Miriam at WordPress Garage posted a quick challenge: how to display a list of authors who had posted in a particular category. I had an idea at the time but I wasn’t in a position to test the idea, so now I am home I have written a quick function to do just that.
The function
These two functions are best placed in your functions.php file or can be added loose to the category template file, either would be fine.
function get_authors_by_cat($cat_id, $sort = true){ $author_id_array = array(); $author_details_array = array(); $cat_posts = get_posts('category='.(int) $cat_id); foreach ($cat_posts as $cat_post){ if (!in_array($cat_post->post_author , $author_id_array)){ $author_id_array[] = $cat_post->post_author; $author_details_array[] = get_userdata($cat_post->post_author); } } if ($sort === true ){ usort($author_details_array , 'author_by_cat_sort'); } return $author_details_array; } function author_by_cat_sort($a, $b){ $al = strtolower($a->display_name); $bl = strtolower($b->display_name); if ($al == $bl) { return 0; } return ($al > $bl) ? +1 : -1; }
There are two functions here, the first retrieves all the posts from the category and loops through them to make sure. The second function is a callback for the usort function. This allows the list to be sorted by the display name of the authors.
This could be done more efficiently by querying the database directly but I wanted to avoid that option as a lot of people are not comfortable doing that themselves.
Using the Function
To use the function in your theme you need to include the following in your where you want the list to appear (replacing the number 18 with the ID of the category that you want to list authors for.
<?php $authordata_array = get_authors_by_cat(18, $sort = true); foreach ($authordata_array as $authordata){ ?> <?php the_author(); ?> <?php the_author_posts_link (); ?> <?php } ?>
Notice that in the foreach loop you should be able to use the normal author based template tags. You can find a list at http://codex.wordpress.org/Template_Tags
I was, and am, doing a theme. I have been quite on the theme front for a few weeks because I have been working on the details and there wasn’t much to say. Unfortunately that is still the case so I have decided to elicit comments on it so far.
My other, tumbleweed infested, blog is now running the minimalist theme I have been working on and it will continue to use it. You can see it at http://www.arickmann.co.uk.
There is some back end stuff that has taken longer than I expected to get the way I wanted it and so you won’t see this side of it yet, but I would be really interested to hear any thoughts on it from a readers perspective.
I have already noticed that the next and back post buttons need to behave differently depending on the page the person has come from; for example, if you find the page from a category or tag archive the next and back link should be restricted to the category, but if you come from a data based archive or link directly then it should be entirely chroniloligcal. I am not sure exactly how I will deal with this, but I want it to be seamless. So that is the next thing I need to work on.
Not going to WordCamp Dallas? Well Jeffro is and he wants to ask your questions to the people in the know.
What do you want to ask, and who do you want to ask? Tell Jeffro.
New Plugin: Fun with Microformat Pingbacks
Tuesday
Mar 25, 2008
I have released the initial version of my plugin: Fun with Microformat Pingbacks. A plugin that parses the posts that ping WordPress looking for an hReview Microformat and uses the summary as the comment text.
This page has more about Fun with Microformat Pingbacks.
- Comments Off
- Read Entire Post
Controlling Archives
Sunday
Mar 23, 2008
If you want to display a list of archive links in WordPress the way you do it is with the template tag: wp_get_archives. But what if you want a little more control?
Unlike bookmarks and categories there doesn’t seem to be a quick and easy way to retrieve an array of archive links as an array for later use. So what do you do if you want a list of archives exactly the same as that generated from the code below, but you want to insert something else into that list?
<?php wp_get_archives('type=monthly&limit=12'); ?>
WordPress has three functions that make it much easier to generate lists of archives manually:
- get_day_link( $day , $month , $year );
- get_month_link( $month , $year );
- get_year_link( $year );
These functions each return the appropriate permalink for the date provided to them. All you need to do is to calculate the dates you want to include.
The code snippet below shows the links for this and the previous 11 months and adds a class (selected) to the list item if the page it is displayed on is an archive from the month and year selected.
for ($i = 0; $i < 12; $i++){ $the_date = mktime(0, 0, 0, date("m")-$i, date("d"), date("Y")); $year = date("Y", $the_date ); $month = date("m", $the_date); $selected_class = ''; if ( $wp_query->get('monthnum') == $month && $wp_query->get('year') == $year ){ $selected_class = ' class="selected" '; } echo '<li'.$selected_class.'>'; echo '<a href="'.get_month_link($year, $month).'">'.date('F Y',$the_date).'</a>'; echo '</li>'; }
This can be amended in a variety of ways to add extra functionality to a theme, including paging, listing posts inline, and even combining with Javascript to produce a dynamic menu of years, months and days.
Microformat Pingbacks
Tuesday
Mar 18, 2008
If you’ve been reading this blog, or Reader Appreciation Project for the last few months you may have noticed an ongoing discussion in posts and comments about the usefulness and potential replacements for trackbacks / pingbacks. Put simply I believe that trackbacks and pingbacks are almost useless right now, and I want to change that.
The key problem is that the text that ends up on the page is, honestly, useless. The text is taken out from around the link based on characters with no context or semantics. Most of the time the result looks something like this:
[...]Person X has written a post about thing y, here is a link.[...]
This tells us nothing except that a link exists, and often interrupts the conversation.
To find a solution I decided that it would be necessary to identify the meaning of the link. A, ‘Go look at this’ link has no business being tracked, it is meaningless to every visitor to the page being linked to. There is no reason for the visitor to move in the opposite direction to the link. These then can be ignored.
This leaves posts that not only link, but also comment on the content. These are useful, add to the conversation, and should be tracked.
It seems clear to me that what we are talking about is semantics. We are trying to identify the meaning behind the content, and this is what Microformats were made for.
I think that the hReview Microformat is perfect for marking up offsite comments (posts with pingbacks). What is a comment if not a review? Better yet the format already features a summary class that can be used to quick and simply summarise the points for readers of the original post.
Is this a good idea? I want to test it out and that is what this post is all about.
I have written a rough plugin to parse hReview review pingbacks, based on the hkit Microformat parser, It hasn’t had much testing, and so I am hoping that you will help me by writing a post using the html below, an hReview.
If you are using WordPress it will ping me automatically as there is a link to this post, and the plugin will parse your post looking for an hReview, hopefully including your full summary as the comment text. I hope the html is fairly self explanatory.
<div class="hreview"> <p class="item">Andrew at wp-fun has asked bloggers to help him test out his <a class="fn url" href="http://www.wp-fun.co.uk/2008/03/18/microformat-pingbacks/">Plugin that uses Microformats as part of the pingback process</a>.</p> <p class="summary">this is where you summarise the content, this will appear in the comments of wp-fun</p> <div class="description"> <p>This is where you say what you think in full</p> </div> </div>
To help things along a little I have removed the normal comment option from this post so it is pings only. I appreciate any help you can provide.
Update: I have found a problem with the implementation that I don’t really understand. It seems that there is a problem with XPath when it uses normalize-space in that it sometimes treats spaces between words as whitepace nodes and deletes them. I need to research this a bit more as this is all contained within HKIT and isn’t something I have ever used, but for the time being it means the odd space may be missing from pingbacked comments.
Update: The problem with the spaces is actually nothing do to with XPath so, thankfully, I don’t need to get into that. The problem was actually caused by a combination of Tidy wrapping content, and removing spaces in the process, and hkit then removing the line breaks.
Where Next for the Default Theme?
Monday
Mar 17, 2008
Ian Stewart at Themeshaper is asking the question, how should the default theme in WordPress change?. It is clear that Kubrick just aint gonna cut it any more, this is true as much for its ubiquity as it is for the style and features it contains; but what comes next?
Theming has moved on a great deal since Kubrick became the default, so what is it that a default theme needs in the 2.5 era?
The key problem with Kubrick is that, despite the configurable options, Kubrick always looks like Kubrick. That is requirement number one: You must be able to change it sufficiently for it not to look like the default theme.
The theme should come with a set number of pre-defined layouts using accepted CSS techniques. These themes don’t need to be amazing, just variable enough to allow individuality.
This shouldn’t be too difficult.
Minimal processing
Speed should be a priority. This is going to be the storefront for WordPress so it needs to be as fast as possible while achieving the aims. This means as little extra processing as possible.
I have no problem with extra content and layout processing, my own theme features it up the wazoo, but the default needs to make WordPress shine so the less that can go into functions.php the better, and the more files that can be changed once and cached till the next change the better.
Simple HTML
This is the theme that people will learn from. The HTML should be clean, straightforward, and semantic. The HTML should not rely on any processing as this will make it harder to follow.
If at all possible the html should be a container for the standard theme tags. This means not using PHP for classes or IDs unless it is absolutely necessary.
Fully configurable
There should be no changes necessary that cannot be accomplished through the admin panel. Inevitably there will be some that cannot be forseen or are edge cases, but in general, the aim should be that the underlying HTML and CSS is never touched.
We need widgetised sidebars that collapse if there are no widgets included, on both the left and right of the content. We need menus that appear only when there are links in appropriate bookmark / blogroll categories. We need colour changes, transparent gradient overlays, alterable header images and admin pages to change typefaces, colours, line-heights etc. All thing that are relatively easy to achieve, with a little work.
Ian has suggested The Sandbox. He has hopes of CSS only themes, I personally don’t agree; The Sandbox theme doesn’t meet my requirements.
The Idea of one underlying HTML structure to rule them all is not a bad idea, but I don’t think it is appropriate for the default theme. It isn’t something that I would ever use, or design for, because I see HTML as part of the art.
When it comes to HTML, less is more. I think a default theme should follow best practice, because we need to instill best practice in the next generation of themers who are only now starting to learn.
Ian’s suggestion, while interesting, seems to be a suggestion for a replacement theme system as much as a default theme. WordPress has a theme system, a good and flexible one, and I think it would be wise to avoid creating a two tiered theme system by default.
The default needs to be written specifically for that purpose. It should feature a finite set of requirements to do the job that the default needs to do. It should not try to compete for any other position and should not aim to be the theme to end all themes.
Silence is golden
Tuesday
Mar 11, 2008
Things will be a little quiet here this week. I am working to get my theme finished off but also have some other, non-WordPress-related stuff to do so I probably won’t get time to post. To bide over the time here are a few questions I have been mulling over for a few days.
Time limited content
Over at Reader Appreciation Project a little while back I posted about weekend blogging. About the fact that I don’t but am disappointed when others do.
That sparked a discussion about how to educate readers to expect content on the weekends and time limited content is something that has since occurred to me as a way to do that.
Here’s the idea:
A post is published. Unlike regular posts the feed contains only a brief introduction and a statement that the post will be available to read for 24 hours.
If you click through and read it within those 24 hours you get to read the post, and you get a cookie which means that you can keep viewing it. So any conversations in the comments can keep going.
If you click through outside of 24 hours the post content is not available to you. You can register to get it when it is released, which could be in a week, (presumably the e-mail notification will also arrive on a Saturday), but you can’t view until then.
My question to readers here is: would this just piss you off? or would you get it and run with it? would it make you unsubscribe?
Plugin Architecture
The second question relates to my Fun with WordPress Plugins tool.
I have in mind a major overhaul for the next version, lots of UI changes, much more integration with filters and actions; however, there is one thing I have in mind for the actual back end code, but I am not sure if there is a demand for it.
I have it in mind to develop some objects for widgets, admin pages, and possible even actions and filters and keep these outside the main plugin class. The idea would be that these would function as a limited form of MVC, with each object including pages in specific foldersl; for example:
Your plugin creates a new admin page object, sets the parent, and registers it. It looks for a specified file within the html folder to get the content of the page, and within the code folder to get the processing instructions.
This invariably makes the plugin more complex, possibly even more complicated, but I like the idea of keeping the plugin itself as empty as possible.
My question on this is, what do you think? good? bad? do you have a better solution? Do you think there is a best practice for WordPress plugin architecture irrespective of its function?
I appreciate any comments you have on any points.
P.s. I am also on Twitter now.

