Customizing the WordPress meta widget

Jump to the code if you’re not interested in the backstory.

I recently had to investigate how to customize the “meta” widget provided by WordPress.

I maintain the Wikimedia Blog, and we wanted to include a link to our posting guidelines to the “meta” section of our sidebar.

There is no straightforward way to do this; the widget can’t be edited from within the admin area.

One possibility was to replace the standard meta widget by a custom text widget, with the same content and links, and to add our guidelines to the mix. But this meant losing the nice context-aware links (e.g. “Register” vs. “Site admin”, and “Log in” vs. “Log out”, respectively for logged-out and logged-in users) provided by built-in WordPress functions (wp_register and wp_loginout): widget text can’t embed PHP code.

Another possibility was to install a third-party plugin to customize the meta widget (or allow PHP code in widget text). I’m usually reluctant to using plugins for simple changes like the one we wanted to do. Both our Operations staff and I prefer to keep the amount of third-party plugins installed on the blog to a minimum, for various reasons (security, maintenance, maintainability, etc.)

Because there are no hooks to plug into the widget’s behavior, most of the solutions I’ve seen online consist either of using a third-party plugin, or messing with WordPress core files, which is a no-go for me.

The third possibility, which is the one I went for, was to create our own meta widget. This is what the code below does.

WMBlog meta widget Customizing the WordPress meta widget

Result: Our blog guidelines inserted into the meta widget.

I used the WordPress widgets API to create a widget, as well as the content of the standard meta widget, located in wp-includes/default-widgets.php. The code is located in our WMBlog plugin, a set of customizations specific to our blog that work independently of the theme.

The custom widget replicates the functionality of the standard meta widget (with the handy context-aware links) and also includes the link to our guidelines. It was a bit more work, but it’s cleaner and more robust that way. Once the widget is available, an admin can replace the standard widget with the custom one.

If you want to add stuff to the meta widget, or remove some of its standard content, this is probably the Right™ Way to do it. You’ll want to look at lines 42 to 51 in the code below.

Note: The code hasn’t been deployed to production yet; it’ll appear on the Wikimedia blog in a few days.

Code

/* =========================================================
   Replicate the default meta widget and extend it to include
   a link to the Wikimedia blog guidelines */

class WMBlog_meta_widget extends WP_Widget {

	function WMBlog_meta_widget() {
		// (constructor) Instantiate the parent object
		parent::WP_Widget( /* Base ID */'WMBlog_meta_widget', /* Name */'WMBlog_meta_widget', array( 'description' => 'The default meta widget plus Wikimedia-specific stuff' ) );
	}

	function form( $instance ) {
		// output the options form on admin
		// i.e. for now only the widget's title
		if ( $instance ) {
			$title = esc_attr( $instance[ 'title' ] );
		}
		else {
			$title = __( 'New title', 'text_domain' );
		}
		?>
		<p>
		<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
		</p>
		<?php
	}

	function update( $new_instance, $old_instance ) {
		// process widget options to be saved
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		return $instance;
	}

	function widget( $args, $instance ) {
		// output the content of the widget
		extract( $args );
		$title = apply_filters( 'widget_title', $instance['title'] );
		echo $before_widget;
		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
			<ul>
			<?php wp_register(); ?>
			<li><?php wp_loginout(); ?></li>
			// Link to our own posting guidelines
			<li><a href="//meta.wikimedia.org/wiki/Wikimedia_Blog/Guidelines" title="General contribution guidelines for the Wikimedia blog">Blog guidelines</a></li>
			<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
			<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
			<li><a href="http://wordpress.org/" title="<?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li>
			<?php wp_meta(); ?>
			</ul>
		<?php echo $after_widget;
	}

}

function WMBlog_register_widgets() {
	// register the plugin's available widgets
	register_widget( 'WMBlog_meta_widget' );
}

// plug in the widgets registration
add_action( 'widgets_init', 'WMBlog_register_widgets' );
Posted in Coding, Wikimedia Technology | Tagged , , | Leave a comment

Service announcement

This site has been dormant for the past year or so.

Because I’m currently working on a new version, I was reluctant to spend a lot of time to fix this one. The downside is that I couldn’t really post new content in the meantime.

Because I still want to have a space to post articles, I’ve done a bunch of upgrades and cleanup, and reverted this site to a working state. There are still quirks, but for the time being it’ll be good enough.

Posted in General | Leave a comment

Wikimedia Commons gets user galleries

myuploads3c 590x230 Wikimedia Commons gets user galleries

User gallery example

I just found out by chance that a long-awaited feature for Wikimedia Commons had been enabled a few weeks ago. I’m talking about user galleries, i.e. the ability to list recent uploads by a user to a MediaWiki-powered wiki.

As if often happens, such a tool has been available on the toolserver for years (see an example), and a link to this tool was added to the default Commons interface for user pages.

Nonetheless, a “user gallery” feature built in MediaWiki, similar to the list of one’s edits, was still missing. We touched the subject during the Multimedia usability project, but we had to focus on the uploader.

A feature request was opened in our bug tracker back in 2005. This morning, while reading my bugmail, I saw a notification about this bug, saying the feature had been added in 2010 and deployed recently.

It turns out it was added by Bryan Tong Minh, a MediaWiki developer particularly active in multimedia features; he’s also the one who wrote the GlobalUsage extension a few years ago, which provides a list of all the pages around Wikimedia sites where a file is included.

It was already possible, in MediaWiki, to list files (in reverse-chronological order) through the Special:ListFiles special page. Bryan added the ability to filter this list by user, effectively creating a user gallery (r65013). He then added thumbnails to the page (r75582). The feature was enabled on Wikimedia sites (including Commons) as part of the deployment of MediaWiki 1.17.

So, it is now possible to see the gallery of uploads by a certain user (see an example). Want to see your gallery? Go to Special:MyUploads. Neat, heh?

The gallery is also accessible through the small “uploads” link at the top of your contributions list.

This feature is a huge step forward in terms of usability. During our interviews & testing, most people were wondering where their uploads had gone once the upload was completed. I’d like to thank Bryan, and all our awesome volunteers, for their work in making MediaWiki better.

The next step will probably be to add a shortcut to the gallery in the user’s top-right menu, as well as in the “Toolbox” menu in the sidebar. Maybe not on all wikis, but it would definitely be useful on Commons.

Further improvement could include the prettification of the page, perhaps à la Flickr, and the possibility to get the code to insert the image in a wiki page, as we do at the last step of the Upload wizard.

Actually, once that is done, we could pretty much replace the last step of the upload wizard by the gallery page, only with a thank-you message at the top. What do you think?

Posted in Featured, Wikimedia Commons, Wikimedia Technology | Tagged , | 4 Comments

Wikimania 2010 notes

Gdansk 0359 590x344 Wikimania 2010 notes

Boats on the Motława river seen from Most Stągiewny

It’s been a few months since Wikimania 2010 in Gdańsk. I had a few notes I wanted to share, but I was waiting for the Wikimania videos, which were never delivered. I’ll just go ahead and publish my notes now.

I went to Wikimania with my staff hat on, mainly to present and discuss the Multimedia usability project. I briefly presented the results of our research, then went on to demo the Upload wizard and play videos from our UX study.

The supporting slides are available on Wikimedia Commons; you can also download the PDF directly (2.36 MB).

I also submitted and coordinated a UX panel to provide a venue for users to ask their questions to the UX team. During this session, both the panel and the audience took notes collaboratively, which we found was a pretty effective means to maintain audience engagement!

The venue for the event was lovely; after WikiSym, hosted at the Music Academy in Gdańsk, having Wikimania in the Polish Baltic Philharmonic was awesome. Then again, I’m biased towards concert halls.

Program & Sessions

I wasn’t necessarily a big fan of the “Wikimania madness” concept at first: I personally hate to be rushed through something. But if you prepare your 30-second intro, the idea actually works quite well — provided everybody plays by the rules and speaks for only 30 seconds.

The overall program was awesome; with all due respect to the previous Wikimania conferences I attended, whose program was great too, I feel this year’s Wikimania was the best in terms of quality of talks. Huge props to the Program team!

The downside of it, obviously, was that it was extremely difficult to choose between concurrent sessions. For example, I missed the sessions about Talk pages and LiquidThreads, Semantic MediaWiki and Semantic Result Formats. I have some thoughts on how to solve this dilemma that I’ll publish later.

On Friday evening, we had the opportunity of attending a gala concert performed by the Gdańsk Baltic Philarmonic, directed by Felix Reolon. I’m hoping the recording will be made available, but in the meantime there’s an extract of the concert on YouTube. The concert was lovely, even though the audience didn’t necessarily measure up.

Many Wikimania sessions were better than the ones I attended at WikiSym. Harel’s talk about Conflicts between chapters and communities was both painfully accurate and delightfully funny. I feel a large part of the audience recognized themselves in both groups.

Another highlight was the presentation of the German mentoring program, by Tim Moritz Hector and his friends from the German-language Wikipedia. Their system seems to be fairly effective, and this talk was particularly relevant in a context where many criticize the unfriendliness of established editors towards inexperienced participants, but few act on it.

I was eager to watch the world premiere of Truth in Numbers, the documentary about Wikipedia, whose early cuts I had had the opportunity to see at Wikimania 2007 in Taipei. I ended up being quite disappointed, and the audience had mixed feelings about it overall.

Staff are people, too

The thing I like most about Wikimania is obviously the Wikimedians. Many of them interact a lot online, and sometimes become friends. Yet, most of them never get to see each other in person except once a year at Wikimania. This gives the event a rare intensity that I was looking forward to.

Unfortunately, I didn’t have too many opportunities to catch up with Wikimedians I know, or to meet new ones. When I talked to some of my Wikimedian friends online afterwards, they told me they had been reluctant to “using my time” for “just socializing” because it had become “more precious”  since I was an employee, and not “just” a volunteer.

While it was very nice of them to have that concern, I was still a tad disappointed. Wikimania is about meeting people, socializing and catching up with friends, more than attending presentations. Employees are not different than volunteers in that regard, especially when they’ve been long-time Wikimedians.

In a nutshell: Don’t hesitate to hang out with me (and other employees) at Wikimania next year!

Posted in Featured, Wikimania | Tagged , | Leave a comment

Wikimedia Commons licensing tutorial: the making-of

Puzzly shooting and sharing 590x153 Wikimedia Commons licensing tutorial: the making of

Extract from the licensing tutorial. All graphics CC-by-sa, Wikimedia Foundation.

A few days ago, I announced the publication of the English version of an illustrated licensing tutorial for Wikimedia Commons. The tutorial was developed as part of the Multimedia usability project I’ve been working on for the past year. This article invites you on a behind-the-scenes tour of the licensing tutorial project.

Context

Because all Wikimedia projects are based on free licenses, Wikimedians have developed a particular expertise in this field, and in copyright in general. One of my favorite quotes about Wikimedians is from Sue Gardner’s keynote session at Wikimania 2009 in Buenos Aires:

You all know more about copyright law than any sane, sensible human being.

We do. And it’s hard to remember how little we knew about copyright a few years ago, when we had just started to edit. Back then, most of us had never heard about the GFDL, or about Creative Commons. Back then, we had never heard of Bridgeman Art Library v. Corel Corp. or the Place des Terreaux case1.

Copyright is an incredibly complicated topic, especially in an international context. We’ve grown accustomed to it, but the learning curve is very steep for new users.

Puzzly puzzled Wikimedia Commons licensing tutorial: the making of

Copyright and free licenses are a complicated topic, and confuse many new participants.

Wikimedians generally like to be thorough, but we can’t expect new participants to read dozens of documentation pages before uploading a picture2. We needed to create a high-level introduction that presented the basics without misrepresenting the complexity of copyright. No jargon, no legal precedents, no country-specific idiosyncrasies. There would be no “freedom of panorama” or “threshold of originality” here.

During the early stages of the licensing tutorial project, we even decided to ban the words “copyright” and “free licenses” altogether: they’re misunderstood and misinterpreted so often that we chose to explain these concepts in plain English, using practical examples. It was also consistent with our wish to provide plain-English descriptions of licenses in the upload wizard.

I started with a purposely short list of main points that we wanted to cover in the tutorial, and asked experienced participants to review them. The list was effectively a summary based on my own experience and a review of the existing instructions and documentation available on Commons. Then, we met with our illustrator to discuss the general approach and to agree on the rough content.

A collaborative effort

Finding an illustrator wasn’t an easy task. We had several non-negotiable requirements, listed in our Call for proposals. For example, we needed to find an artist willing to release their final artwork under a free license. We also had time and budget constraints.

With the help of Jay Walsh (our Head of Communications), we were able to find a talented illustrator who aligned with our values and met our requirements: Michael Bartalos, an illustrator from San Francisco, who had notably done some pretty awesome work for the California Academy of Sciences.

Puzzly Wikimedia Commons licensing tutorial: the making of

Puzzly is a character developed by Michael Bartalos in collaboration with experienced Wikimedians.

Michael was extremely accommodating with our hands-on, iterative and open process. Wikimedians are used to completely open, very inclusive processes, but it isn’t as natural in other fields, particularly in art-related disciplines. In the world of illustration, in particular, you usually try to keep all your preliminary and in-progress artwork secret to prevent other people from stealing your still-rough ideas.

Luckily, Michael and I were able to find a middle ground. We agreed not to publish the in-progress designs, and he agreed to let us share them privately with members of our community interested in providing feedback.

I explained the context and reasons honestly on the Commons mailing list and Village pump, and the participants were very sympathetic to these constraints. I invited people to sign up if they were interested in providing feedback, so they could receive a link to the artwork. Most of the people who signed up did write useful comments, and all of them respected our request not to republish it. The feedback they provided was very constructive and of high quality.

We went through this process a few times, first to comment on the general approach and content, then to focus on specific details of wording and graphics.

I found that it helped immensely to ask specific questions to commenters. I structured the page into specific sections and most commenters naturally added their feedback in the appropriate place. I initiated the sections with my own comments, in order to save other people’s time.

Some comments were similar, while others were in disagreement. The preparation made it easier to provide the illustrator with a consolidated summary to help him work on the next version without having to deal with long discussions and contradictory statements.

Translation and localization

Licensing tutorial ar Wikimedia Commons licensing tutorial: the making of

The tutorial has been translated and localized into many languages, such as Arabic.

Once the English version was ready, the translation process started. Casey Brown and I prepared the translation framework and provided detailed pieces of advice, in order to inform translators and help them with this particular translation request.

I used to be a Wikimedia translator myself, and I knew how effective they were. Still, I was amazed to discover that, after only three days, about 20 translations of the text had been completed. Furthermore, they had already integrated the translations in about a dozen localized versions of the artwork.

As it turns out, the coordination page containing advice and instructions proved to be very helpful to translators, and well worth the time I had invested in it. About eighteen localized versions are available now, and more are underway.

What next?

The real test, of course, will be when new participants are presented with the tutorial. Will they like it? Will they read it, or jump directly to the next step? Will the tutorial be successful in helping them learn what we want to teach?

So far, we haven’t formally tested it. We were hoping to conduct a study on the tutorial and the latest version of our upload wizard prototype, but we had to postpone it. I do hope we’ll be able to measure the impact of the tutorial at a later point. Still, the enthusiasm with which the tutorial has been welcomed is, it seems, a good sign.

I hope this summary will be helpful to people conducting similar projects. I feel the interaction with the rest of the community has been quite smooth during the whole project. It would be presumptuous to think it was only because I’ve been a long-time community member myself, but it sure helped to speak the same language as the users’.

More generally, the Multimedia usability project was the first engineering project of the Wikimedia Foundation with a Product Manager on its team. I feel this role has played a critical bridging role between the users and the rest of the team, to everyone’s benefit. I’d love to see this happening more regularly in WMF-driven projects.

My own lessons learned, in a nutshell:

  • Trust the Power of The Crowd.
  • Collaboration is worth the effort.

Notes

  1. If you know the first one, you earn 50 Wikipediholism points. If you know the second one, you earn 1000. Except if you’re French, in which case you earn only 500.
  2. Some new users actually do read many documentation and policy pages before their first edit (sometimes in print version). I say they’re very likely to become some of our best and most committed Wikimedians.
Posted in Featured, Multimedia Usability | Tagged , , , , , , | 2 Comments