It means I am an idiot

As a hobby, I build a content management system. I build it at night. I am aware of what it means to write a content management system in my spare time. If you are not aware of what that means, it means I am an idiot.

Paul Ford, my favourite writer of things online

Passing PHP variables to Javascript with wp_localize_script()

I’ve been using jQuery Backstretch in projects for a long time now. I love it. It’s so simple to use, and works perfectly. To use it on your site, you just:

1. Download the file—regular version or minified version, doesn’t matter which—and put it in your theme files’ /assets folder or /js folder, or wherever you put your scripts

2. Enqueue the Backstretch file in functions.php, like so:


function waterstreet_scripts() {
 wp_enqueue_script( 'backstretch', get_template_directory_uri() . '/js/jquery.backstretch.min.js', array( 'jquery' ), '', true );
}
add_action( 'wp_enqueue_scripts', 'waterstreet_scripts' );

Have a look at the Codex if those parameters don’t make sense to you.

3. Now that Backstretch is properly included in our theme, we can write our own scripts.js file and set a background image for stretchin’. That file might look something like this:

jQuery(function($) {
   $.backstretch("http://waterstreetgm.org/wp-content/themes/waterstreet/assets/background.jpg");
});
 

Ok, so all that’s cool. We’ve added Backstretch and called it with our own scripts file and told it about the background image we want to use. But have you noticed the problem? I’ve hardcoded the path to the file. I develop locally, so that line in my local file will look lit this:

 $.backstretch("http://localhost:8888/waterstreetgm/wp-content/themes/waterstreet/assets/background.jpg");

It’s happened to me about 10,000 times now that I will send a client a first draft of a site and they’ll say — Hey! I though we were going to put an image in the background? So then, I’d need to go in and remove the link to my localhost site and add the the live site url—again, by hardcoding it. It should be easier than this. Good news is that it doesn’t need to be this way!

wp_localize_script() to the rescue!

To make a long story short, I just want to be able to use something like site_url(); in my Javascript file so I don’t have to hardcode the url every time—but, of course, I can’t. What I can do, however, is set site_url as a parameter in PHP that I can use in my Javascript via wp_localize_script().

Now, that enqueue file will look something like this:

function waterstreet_scripts() {
	wp_enqueue_script( 'backstretch', get_template_directory_uri() . '/js/jquery.backstretch.min.js', array( 'jquery' ), '', true );
}

/* Make site url available to JS scripts */

$site_parameters = array(
	'site_url' => get_site_url(),
	'theme_directory' => get_template_directory_uri()
	);
wp_localize_script( 'scripts', 'SiteParameters', $site_parameters );

add_action( 'wp_enqueue_scripts', 'waterstreet_scripts' );
 

And hence, instead of hardcoding the path to the file in the Backstretch file, I can now simply use the parameter I just setup:

 $.backstretch(SiteParameters.theme_directory+"/assets/background.jpg"); 

wp_localize_script() is extremely handy for this. Any time you need to reference a PHP variable in a Javascript, you can just go back and add it to the $site_parameters array. You will hardcode no more!

How much am I worth?

I was listening to episode #82 of the ShopTalk show today when an answer to a question about salary vs creativity caught me completely by surprise. The guy was basically asking: should he stay at his current job with lots of creative freedom and less money or move to a more “corporate” job for more money and less creative latitude.

Now to the part that caught me by surprise — Chris answered the question by suggesting that this guy could probably have both if he lived somewhere like San Francisco:

Just in my experience in living in the San Francisco area for a while. […] I feel like that’s the base level out there [$100, 000]

That’s a terrible quote, but it captures what Chris was saying. You can listen to the whole answer for better context. Still, Chris was suggesting that $100,000 was pretty-well a base salary for a normal (“non-rockstar”) developer. Does this sound absurd to anyone else? Can a front-end developer make $100,000 doing front-endy things in SF? I recognize that $100k doesn’t get you all that far in a city with enormous living costs, but still.

So it raised the question for me.

How much am I worth?

I’ve developed lots of client sites over the years. I try and stay current, I’m at probably an intermediate-level with PHP/WordPress and Javascript, I’m a reasonably good designer, I do the whole responsive thing. I use Git. Etc. I’m no “full-stack engineer” by any stretch, but I can certainly take a fairly complex project and turn it into a fully-functioning WordPress site.

Is there some upside-down universe out there (SF maybe?) that would pay me $100,000 dollars a year to do this? In less crazy cities, this figure would obviously be reduced, but what are they paying? What does this person make in Chicago? Toronto? Vancouver? Dallas?

Is San Francisco upside-down, or are people actually making similar money out there in normal cities? Just curious. Send me a note on Twitter if you have any thoughts.

 

Rethinking Mail with SmartMail

Photo:William Selman

We’ve lived in our house for five years now. In that time, we’ve had all sorts of things come in the mail: boots, jeans, coffee makers, cameras, computers, watches, Christmas gifts from mom and dad, etc. Lots of stuff.

I suspect that we’ve had at least 40-50 packages delivered to our door in the last five years — that’s roughly ten per year or one per month or so. Of course, when I say “delivered” I don’t actually mean delivered. Only maybe 5 of the 50 packages were actually delivered. For all the rest, I’d receive a notification on the door that someone came by and tried and failed to deliver the package because we weren’t home, and we’d eventually go to the depot across town and pick it up.

This happens to you too. I don’t even know you, but I’m certain this happens to you. You’re at work all day, and the delivery people are out delivering your packages all day—of course you’re not home to receive them! You couldn’t think of a more absurd way of delivering mail than the system we have now. Trucks full of packages go around to homes with no one in them, dropping off stickers to tell the homeowner that their package was here earlier, but is now available at an inconvenient location across town. Just completely absurd!

A Better Mail System

Let’s rethink the mail system for a second. Not cable bills and birthday cards from you mom—that’s separate. Let’s just think about packages for a moment:

Imagine you order a new alarm clock online from Amazon. When you go through the checkout process, Amazon collects your email address. When they hand off the package to SmartMail, they hand off that email address as well. When your package arrives in your city, it gets delivered to a central depot where you can pick it up, and you get an email telling you it’s there. No more silly trucks driving around knocking on the doors of empty houses.

SmartMail, of course, has a few pros and cons:

Pros:
Mail should be cheaper. SmartMail should be able to cut out door-to-door delivery trucks completely. This will save money on the trucks, the salaries of the people driving them, auto insurance, maintenance, etc.

It would just make sense. Email me when my package arrives, and I’ll pick it up. If I wanted the package delivered to the door, I could still select UPS or Canada Post or similar in the checkout options, but if I’m 100% sure I won’t be home when they try and deliver, it would be great to be able to choose the cheaper SmartMail.

Cons:
Urban centres only. To avoid getting into the issue of having to deal with local carriers, SmartMail would probably have to be urban centre only. But not everyone lives in a big city!  I know. That’s why I’ve clearly listed this in the “Con” category.

Logistics

Please note: I know nothing about the mail system. Literally nothing. The only thing I know is that I find the current system a bit silly and inefficient. That said, I think this could actually work. Just imagine a much, much smaller version of Canada Post that only sent packages, and only served urban centres. Each city would need a few depots, a few delivery trucks and a few staff in each depot. Compare that with the army of people required to run the current mail systems that exist, and I think you’ll agree that a new system could work.

Given the trouble that traditional mail companies are in right now, I think SmartMail could really work.

Update: Minutes after posting this, I was told about BufferBox. Oh well. Just when you think you’ve had an original idea.

If users leave they’re just doing what the design told them to do

What are our designs telling users to do when we bury a 12px font-sized river of text in a sea of animated banner ads, sensationalist flat belly links, and fixed positioned social sharing widgets? In my mind, if users leave they’re just doing what the design told them to do because all the crufty noise linking elsewhere is the most engaging thing on the page.

—Trent Walton, Human Interest

A small list of the things that I want to do

I want to write a cookbook. A beautiful cookbook, with nice paper and a nice cover on it, and with lots of black & white pictures and colour pictures with lots of nice muted texture like the ones from VSCO like this amazing one here. I want to make this cookbook because I want to go through the process of buying the food so that I can make the meals so that I can have the people around to eat them with and finally open one of those special-event-wines that I keep sitting in the cupboard. I also just want to just have the photos. I want to look at them and feel them printed on that nice paper. I want the cookbook to be like Tartine’s or Donna Hay’s. I want it to make people want to rush home from work and cook supper and drink wine and not eat until 9pm on a work night. I want it to make me do that.

Besides food, I want to take more pictures in general. I want to take more pictures of just being outside. Early in the morning and late in the night and in the late evening when the sun is just about to go down and everything looks perfect and new and fresh. I want to take pictures of and on the beach, which is great because that’s something else I want to do. I want to go to the beach more, and throw rocks and sit down and watch the waves and see the tide coming in. When I’m not doing that, I want to be eating an ice cream, or stopping at a roadside stand to buy vegetables, or waiting for the barbeque to warm up to put a thick steak on. I might even take a picture of the steak too.

When I’m not eating ice cream, cooking steaks or buying vegetables, I want to run the Tely10. I just want to do it once. I just want to do it and feel happy about my time and feel good as I cross the finish line and feel like I’ve done something. I want all of those 6:30am runs to mean something—to accumulate to something. I want all those mornings I ran in the rain and the snow and the wind and the cold and the pain and the frustration and the joy and the sun and the warm summer breeze to all just add up already. I just want to do that once. I also want to do another century ride — 100km — on my bike like I did about 10 years ago with a best friend. I want to sit on my bike and feel strong for hours and push up the hills and through the wind and ride with a group and take a turn at the front. It’ll be harder and harder to do all that with some of my other competing wants—like the huge one to finally get my house in shape. To finally finish some of the dozens of half-finished projects I’ve got going on like the basement or the attic or the entire outside or get the hardwood laid or get the bathroom finally painted and put in that fan.

Then there’s all this work stuff. Will I ever actually, truly learn to program? Will I ever be satisfied if I don’t? Do I even want to actually learn, or do I just want to continue to skim the surface of it all. The way I skim the surface of everything else. Am I actually, deep-down ‘just’ a designer? Am I actually ‘just’ a teacher? A something else?  Is this where I should be putting all my energy? Should I be out there writing cookbooks and taking pictures and going to the beach and eating ice cream and feeling connected to something all day? Does anyone out there feel connected to anything? Anyone? Do you people have this level of noise go on in your heads all day? This unending doubt and self-doubt and distraction and constant stream of questions? Will I actually publish this? Will I leave it published or will I delete it?

Airmail

I’ve been using Apple’s native Mail app for as long as I’ve been using Macs. I got wind of a new email client last week and I wanted to share. I’ve really been liking Airmail. It’s just $1.99 in the App Store, which I think is the perfect price for large-scale adoption.

airmail

The one thing about Mail that always bugged me was the poor Gmail integration. I couldn’t label things with my Gmail labels and I never knew if things were deleted or not.

If these issues bug you too, it’s worth the $1.99.