why we contribute, part eleventy

I can (and sometimes do) talk at great and boring length about this whole crazy project to contribute more to Open Source – how much faster I’ve increased my own skills than ever before, how much I learn from the genius developers around me, how my paid business benefits from unpaid work I do building connections within the community, how helping people in the forums feeds directly into empowering them to make cooler things. But some days, it’s because OH HOLY CARP stuff I worked on is being used by like A BAJILLION PEOPLE

http://en.blog.wordpress.com/2012/05/18/look-before-you-leap/

On theme typography and language detection

As both a font geek and a theme geek, I was of course happy to see Drew’s update on typography in Twenty Twelve. But the part that really made me happy was this bit:

I had some concerns about the default web font settings. What about non-western languages? Those users would be out of luck if we had Open Sans turned on by default. They would see a bunch of empty space and garbled characters when they switched to Twenty Twelve. Not a very accessible or friendly experience.

So what to do? I proposed turning Open Sans off by default, and allowing users to switch it back on from the Theme Options menu. Nacin jumped in and suggested we use language detection to turn the font on or off. Non-supported languages would have the font turned off by default and supported languages would have it turned on. Nacin’s idea represented the best of both worlds — awesome!

I spent an entire past career worrying a whole lot about multi-language computing: encoding conflicts, crappy character rendering, input methods, and everything else that comes with it. And as much as I love the brave new world of web fonts and play with them on any project where I can find a reasonable excuse, it distresses me to see how many widely-used web fonts don’t even bother to support the extended-latin range, let alone any other alphabets.

(Open sans has extensive Greek and Cyrillic — not just Russian — support, in the condensed variant as well as the text. I’m such a hopeless sucker for a good condensed.)

The detection/default trick is even cooler, and I’d love to see a similar approach to smart default-setting become a common practice. The option to change it is there, even if the average English-speaking user never stops to think that it’s for anything other than aesthetics or load time: but the theme is making a reasonably intelligent stab at rendering the site without ugly mystery characters from the very first load.

We are all noobs

Michael reminded me of this:

https://twitter.com/#!/tw2113/status/201006820070920193

but as you can see if you go follow the ensuing twitter conversation, it’s a rant that I can go on about for way more than 140 characters. So I will.

It’s incredibly common for people in any kind of support environment, or really any kind of tech learning space, to start off a completely reasonable and intelligent question with “hey, so I’m a total n00b, but…” and end even even a perfectly successful interaction with “oh god I’m such an idiot”. And I’m pretty sure that it’s all down to one really, really bad assumption and the consequences that follow from it:

  • The world is divided into two kinds of people, which for now I’ll call noobs and rockstars1.
  • Since there’s nothing in between the two, there must be some kind of infinite gap.
  • So a noob must obviously be a horrible thing to be.
  • Therefore, ohmygodohmygod I suck.
  • If I have a totally reasonable question, I need to crawl in to the channel/forum/classroom and immediately show my belly like a puppy afraid of being savaged.

And they have some very good reasons to do so. People can be real assholes, and nerd spaces have a longstanding rep for being incredibly unforgiving about any perceived stupidity. So playing submissive puppy is an understandable response: after all, why would you want to expose yourself to getting ripped apart by the pack?

It’s not just in support venues, either. If it weren’t for this kind of attitude, we wouldn’t have huge-selling book series on “… for Dummies” and “… for Complete Idiots”. (No offense to friends who have published in both series!) We certainly wouldn’t fall back on tired old tropes like “so simple your mom can do it” — aside from the nasty sexism, it assumes that there’s a whole class of non-technical people out there who are just fundamentally  incapable of getting anything hard.

And so if I think (or just secretly fear) that I’m on that side? Yeah, you bet I’m going to feel like the mere fact of having a question is something deeply shameful 2.

Meanwhile, for rockstars, the whole noob vs. rockstar thing is just as destructive (if not quite as obviously so at first: after all, they’re on the winning side of the equation). If it’s only the noobs who need to ask questions, then if I admit my ignorance on anything, I must secretly be a noob! Oh the shame! Better just not ask and admit weakness… And that way lies a nice self-defeating case of impostor syndrome, for the less confident among us; or the kind of junior dev arrogance that Garann talks about, for the otherwise inclined.

The fact is, learning doesn’t happen without a lot of painful and embarrassing bumping up against the stuff we don’t know, and it’s neither easy nor comfortable to be in that position. I’d even go so far as to say that’s why we learn: the sense of accomplishment that comes from mastering something you couldn’t handle an hour or a decade ago is a powerful driver to get through a painful process, but on an even more basic level, no longer having that awful pit-of-the-stomach feeling is even more so. Unless we’ve convinced ourselves that it’s impossible; in that case, most people just give up and avoid whatever it is that’s making them feel this way.

You’re a noob. I’m a noob. Hell, I’m a noob about all the things that people sometimes try to call me a rockstar about. We need to stop dividing up the world this way. And don’t let me catch you saying things like that about your mother.

  1. I have just as much of a problem with the “rockstar” side of the equation, but that’s a different rant
  2. The flip side is the bully who fronts expertise by calling other people noobs. If you haven’t figured it out yet, don’t do that.

Backwards compatibility for WordPress 3.4 headers and backgrounds

As I mentioned in the previous post, the new versions of WordPress custom headers and backgrounds have some great new features, but they require WordPress 3.4. That’s no problem if you’re already steering your custom development towards 3.4 (and you should be), but if you’re building themes for distribution, you can’t be sure that all your users are going to upgrade on the first day or even month.

Michael Fields, Automattic Theme Wrangler and all-around smart theme guy, pointed me toward the latest version of P2, which has a rather nice way of handling the backwards compatibility issue for just this case: (This function is called within theme setup)

function p2_setup_custom_header() {
	$args = array(
		'width'               => 980,
		'height'              => 120,
		'default-image'       => '',
		'default-text-color'  => '3478e3',
		'wp-head-callback'    => 'p2_header_style',
		'admin-head-callback' => 'p2_admin_header_style',
	);

	$args = apply_filters( 'p2_custom_header_args', $args );

	if ( function_exists( 'get_custom_header' ) ) {
		add_theme_support( 'custom-header', $args );
	} else {
		// Compat: Versions of WordPress prior to 3.4.
		define( 'HEADER_TEXTCOLOR',    $args['default-text-color'] );
		define( 'HEADER_IMAGE',        $args['default-image'] );
		define( 'HEADER_IMAGE_WIDTH',  $args['width'] );
		define( 'HEADER_IMAGE_HEIGHT', $args['height'] );
		add_custom_image_header( $args['wp-head-callback'], $args['admin-head-callback'] );
	}
}

Elsewhere in the theme setup function, P2 also uses:

	$args = apply_filters( 'p2_custom_background_args', array( 'default-color' => 'f1f1f1' ) );
	if ( function_exists( 'get_custom_header' ) ) {
		add_theme_support( 'custom-background', $args );
	} else {
		// Compat: Versions of WordPress prior to 3.4.
		define( 'BACKGROUND_COLOR', $args['default-color'] );
		add_custom_background();
	}

That’s taken direct from P2 — you’ll have to make adjustments for your own themes: change the slugs, set up the options you want to use, etc.

I can’t think of any reason you couldn’t wrap both function_exists() checks into one conditional, but I’m inclined to keep them separate — it’s easier to read, easier to override in child themes, and if one extra check is a performance concern, it’s time to add a second hamster to your hamster wheel…

(On the other hand, I’m not a fan of holding on to backward compatibility beyond a couple of core versions back. There are a lot of themes out there still checking if widgets are supported, and at that point it’s just cruft. Be nice to your code.)

Flexible headers in WordPress 3.4 themes

As of WordPress 3.4 Beta1, theme authors can allow custom header images with flexible heights, widths, or both.

In other words, instead of being limited to a fixed size determined by the designer, as you’re already familiar with:

With flexible headers, you can allow users to upload smaller or larger headers without having to make a child theme or (worse) hack your theme, like so:

How to do it:

Image header support in 3.4 no longer uses all the constants that had to be defined in previous versions — HEADER_IMAGE_HEIGHT, HEADER_IMAGE_WIDTH, HEADER_TEXT_COLOR and the like are now gone. Instead, all the header support options are included in a single array, and enabled with a call to add_theme_support() in your theme’s functions.php file.

This is how the array looks in the theme I used for the screenshots above:

// Add support for flexible headers
 $header_args = array(
 'flex-height' => true,
 'height' => 200,
 'flex-width' => true,
 'width' => 950,
 'default-image' => '%s/images/headers/path.jpg',
 'admin-head-callback' => 'mytheme_admin_header_style',
 );

 add_theme_support( 'custom-header', $header_args );

If flex-height or flex-width are not included in the array, height and width will be fixed sizes, replacing the old HEADER_IMAGE_HEIGHT and HEADER_IMAGE_WIDTH. If flex-height and flex-width are included, height and width will be used as suggested dimensions instead.

Don’t forget to remove any references to the old constants in your template files — in my header.php, I simply replaced.

<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />

with:

<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />

For reference, here’s the full set of options and their default values, as found in /wp-includes/theme.php. Note that the other header image options like text, text color, and randomization are available in the same add_theme_support() call by setting only the options you need:

$defaults = array(
'default-image' => '',
'random-default' => false,
'width' => 0,
'height' => 0,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => '',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);

A few important notes:

  • Flexible header support has to be built into each theme – it will not work automatically with your pre-existing themes.
  • This functionality requires WordPress 3.4, which is currently in beta. You can grab the latest here (.zip file). Please use it for testing and development, but don’t run it in production unless you know what you’re doing and have some risk tolerance.
  • Design-wise, flexible heights are relatively easy; flexible widths are much trickier to work into a layout while still looking good. Experiment!

https://twitter.com/#!/Malarkey/status/175366107786522624

As a quick followup to the previous licensing post, and in light of the current discussions on WordPress plugin licensing, I’ve decided to use MIT license for packaged code and Public Domain for code samples in posts from now on. None of this invalidates my previous argument, of course — pick a license, understand what it does, and unless you’re developing a whole new license for some excellent reason, don’t make up your own weird terms that downstream projects can’t easily work with.

WPTRT Review-a-thon tomorrow

The Review Team has been playing around with ideas to get through our backlog of themes to be reviewed, so I’ve proposed an IRC meetup in #wordpress-themes on Freenode, tomorrow at 1700 UTC / noon US Eastern.

The model I have in mind is http://codex.wordpress.org/WordPress_Bug_Hunts

In particular, I want to invite any new or wanna-be reviewers to join in; this would be a great chance to get started with reviewing, get your test environment set up and work through your first few reviews with help on hand to understand how the guidelines work.

We have just a few ground rules:

  • This isn’t a meeting with an agenda: it’s a group work day. Drop in for as long as you’re available, and get as many reviews done as you can during that time.
  • The goal is to crunch through as much of the queue as possible while helping and learning from our peers.
  • All reviewers, however new or experienced, can bring questions about how to handle particular issues. Absolutely no penalties for admitting you’re stuck ;)
  • Themers, you’re welcome to join in the discussion, try your hand at reviewing, or just lurk and learn the process. However, please don’t use this time to ask about when your own theme will be done — we’re taking everything in queue order, and we’d most likely just encourage you to sign on to review a few themes.
  • For new or potential reviewers, more experienced people will try to help out as much as we can with getting started, working with trac, setting up your test environment and the like.

 

So, that happened

I’ve never seen a day like yesterday online. Yeah, Wikipedia being out got most of the focus, and a lot of that was jokes at the expense of people who were kind of terminally clueless. People will forget about it over time, or take away the wrong message (already, I heard a BBC commenter say, “So, this is a blow against intellectual property?”… no, just against the use of it as an excuse to stifle completely unrelated areas.) It’ll be easy to forget the feeling of watching history change in front of our eyes, as the day went on. So consider:

Until the internet spoke up, SOPA and PIPA were considered to be a sure thing, with overwhelming majorities in both houses. Even worse, they were considered to be sure to pass because nobody would even bother to learn what was in them. 

According to SOPAstrike.org, over 75,000 sites, large and small, took part in the protest. It was more than that, really: that’s only the people who added their names to the list.

Over 7 million people signed Google’s petition. It’s still up, if you didn’t get to it yesterday.

Thousands of people showed up in person in New York for the NY Tech Meetup’s protest at their Senators’ offices.

Dozens of legislators announced their opposition to the two bills. Some of them were previously unaligned, but the list includes several who were previously in favor, even co-sponsors of the bills.

We — the internet, the meme fields, the digital wild west — did a thing. Don’t forget it. But above, don’t stop until it’s done:

ACTION: If you couldn’t get through to your congress members because their phone and fax lines were slammed and their websites went down, contact them now. Even if you did get through, contact them again.

ACTION: VOTE.