PHP has long had a problem of naming collisions. Because older versions of PHP had no way of declaring methods outside the global space, developers came up with several different ways of preventing and checking for namespace collisions, none of which treated the underlying condition. These many and varied solutions begged for a unifying standard as they made things like autoloading and package management increasingly difficult. PHP 5.3 introduced a feature called ‘namespacing’ to solve this problem and WordPress developers should begin adopting. With proper namespacing, WordPress plugin and themes will become clearer, more stable, and more portable.
(more…)Category: Blog
-
Writing Unit Tests for WordPress
This post and others like it still get a strange amount of traffic. It’s worth noting the details here are out of date and I won’t be keeping it up. Use at your own risk!
In my last post I wrote about two testing libraries for WordPress and briefly discussed the difference between integration tests and unit tests. I also mentioned a concept called test driven development (TDD) and breifly explained how it might help write better code from the start. This post will expand on that and show how to write a simple WordPress plugin from a test-first approach. Since we’re writing unit tests, we’re going to use WP-Mock to create a test double for us and we’ll use PHPunit for our test runner.
TDD starts with a problem you want to solve—the same problem your plugin wants to solve. In this case, let’s say we have a plugin that will add some metadata to a post with the title “Test”. Since that’s going to require us to mock some WordPress core functionality, make sure WP-Mock is configured in your working environment. We’ll start by writing a test that verifies the metadata was attached to the post.
(more…) -
Why Unit Testing in WordPress Matters
Testing WordPress has become a favorite topic of mine lately: moving away from hitting refresh and toward something more holistic, reliable, and automatable. I’ve written before about a testing method called called browser testing, which verifies a webpage has some expected behavior. These kinds of tests are great but they’re not perfect. They require a lot o dependencies and that someone else would need to verify your code. There is a better way, one that doesn’t require any of those dependencies and verfies the code down to the exact lines you wrote—it can even be independent of WordPress. It’s called unit testing and it will make you a better developer.
-
How can I use Feature Switches in WordPress
While a colleague and I were discussing the rollout of a new feature to our public facing website, he asked me if it would be possible to “hide” the new content behind a toggle. Effectively, he was asking me to write a feature switch, a best practice of continuous integration that allows you to push some source code while hiding future features. WordPress has some of this idea built into it’s core: plugins, for example, can be activated and deactivated to turn things on and off. Within plugins and themes, options pages can be used to turn on different features. SEO plugins, for example, let users turn on and off different optimizaiton tools. Feature switches are a little different, and in our case leverage the power of Apache environment variables to show and hide different parts of our site.
-
How to Maybe Flush WordPress’s Rewrite Rules
Custom post types and taxonomies are one of the most powerful tools to transform WordPress from a blogging platform to a full CMS. One of the most common problems beginning developers have when starting to use them is understanding how they work. It’s easy to think that calling
register_post_typeis all it takes only to discover that their new post type archives are not working. This likely leads to a long dive into first (hopefully) the code to see if something was written incorrectly and then to the WordPress support forums to figure out what the problem is. 99% percent of the time I wager it’s because the developer forgot to flush WordPress’s rewrite rules. -
How can I do Browser Testing With WordPress
Browser testing is a basic component of a concept called behavior driven development (BDD), and one that has helped me become a better WordPress developer in the last few months. The concept of BDD is simple: test and develop around your software’s expected behavior. I recently wrote about BDD for Excella’s company blog, and this post will go a bit more technical than that. The upshot of behavior testing is you can find problems with both your code and your requirements. Before we get into that, a bit of background on the tools.
-
How to Explain Git to Non-Developers
Since starting with Excella in January I’ve found myself explaining
gitand the underlying concept of version control to a lot of non-developers. People like to ask me what I’m doing at my job, what I’m learning, and git was a big one I had to learn early on. What I usually focus on when explaining git is how it is fundamentally different from revision history tools like those included with Google Documents and other word processors. -
A week into Octopress
About a week ago I successfully migrated some of my posts from harmsboone.org to this blog, I also wrote a post about some things I learned about git that week. WordPress is great. I wouldn’t recommend it (and I almost always do) if it weren’t. For someone who wants to spin up a blog and maybe some day more in a pinch, WordPress is the go-to platform. In fact, the rest of harmsboone.org still runs it. Earlier this year, though, Danielle and I started talking about ditching the one-blog-for-both solution. When we were both living and teaching abroad sharing one blog made sense but now with the both of us starting different careers, we have different things to say.
We decided to keep HarmsBoone.org as an archive of the last four years and also create new blogs for the both of us. Since I was starting from scratch anyway, might as well strike out with something new.
-
What I learned about git this week
I love hidden features in software. Whether it’s finding a konami code in unexpected places or that I can add or remove all the dots and underscores to my gmail address I want and I’ll still get the emails, something about them are great. That was what made Zach Holman’s presentation ‘More Git & GitHub Secrets’ such an enjoyable read this week.
-
Tussle over Technology: Controversy & the Patent Act
Abstract
(more…)The United States Constitution instructed the First Congress of the United States to enact laws “securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries.” This instruction, commonly referred to as the Intellectual Property Clause, demanded a set of laws based on the broad idea that inventors are best incentivized and remunerated for their works through a system of guaranteed exclusive rights. What exactly the scope of those rights were, who had authority to hand them out, and under what conditions they would be given, were all left to Congress to sort out; it was among the earliest controversies over science and technology in the United States of America.
-
20 Years of Gustavus: A bird’s eye view
Inspired by the Google Earth Time Machine blog highlighted by Kottke.org a few days ago, I decided to see how far back the imagery over my college campus reached. I figured it being in rural area, there was probably a lot of agricultural aerial photography going on, but I was wrong, the imagery only went back as far as 1992. Perhaps if I paid for some extra features it would stretch back further, but who knows. Those familiar with Gustavus Adolphus College will recall the infamous 1998 Tornado, the ten-year anniversary of which was commemorated while I was a student. The big thing I remember hearing about the campus was tree loss. The big takeaway watching the recruitment video from the 90s they were still using when I was a freshman was ‘where did all those giant trees on the quad go? What I did not think about, and what never really got talked about, was how many more trees there are now, and this was immediately evident comparing the 92 aerial imagery with the photographs taken 20 years later.

One thing that was especially interesting was where there were more trees in 2012, where the trees were smaller, and where they were actually larger. The Linnaeus Arboretum sort of hugs the Westernmost part of the campus. In 2012 the Arb, as we affectionately knew it, is densely populated with trees on the North side, strikingly so compared to the same image in 1992. The South side is a bit more dense, but, since there’s more prairie on that end of the Arb, it’s not as noticeable. What’s strange here is that all the trees actually look a lot bigger, 20 years bigger, in fact. Did the Arb somehow survive the tornado, or was it replanted with really big trees? On the South-Southeast side of the campus, headed down the hill from (the old) Old Main the tree cover is definitely sparser in ‘92, but the trees much larger. There are also more paved paths headed up the hill from Rundstrom Hall, something I would have welcomed when I lived there.
Apart from trees, the campus was busy constructing, moving, or demolishing campus facilities in the last twenty years. The facilities are highlighted on the 2012 map supra and color-coded according to whether they are sports (blue), academic (yellow), housing (green), public spaces (orange), and parking (red). I also made some notes in white. One thing is clear straight away, housing at Gustavus has changed a lot in the last twenty years. On the Southern edge of the campus were added the Arbor View Apartments, on the Western edge before the Arb, Southwest and Prairie View halls (the latter meant to be temporary after the tornado) and the International Center. On the South-Southeast side of campus (a barren patch of grass circled in green) was Wahlstrom Hall, a building demolished the summer before I enrolled. Gusties have also changed the way they play sports, with the football field moved to behind Lund Center on the North End of campus. The new stadium, built in the summer of 2007, is right next to a soccer field, and is across Ring Rd. from a baseball field and a multi-purpose field for practices (and other things? My golf class met there, I imagine that’s not all). All of these fields are either new or have moved since 1992. The 2012 stadium is directly atop the 1992 baseball field, and the 2012 baseball and multi-purpose fields appear to be atop 1992’s farmland. It’s not clear whether the rugby pitch behind Southwest Hall is new, or if it was so used in 1992. The 1992 football stadium is now covered by a mall stretching NE from Christ Chapel, one of two new public spaces. The others were an expansion of the campus center that happened after the tornado to include the Marketplace, and the creation of the Big Hill Farm West of the Arb.

The last thing I noted was how little the campus expanded its academic buildings. The three buildings in yellow are Mattson Hall, housing the Nursing and Education Departments; Old Main, renovated in 2005; and Beck Academic Hall completed about one year ago. This illustration of how the campus has changed is by no means scientific. Certainly academics can expand without constructing new buildings unlike, say, housing, and it’s possible some of these buildings were renovated internally, or that departments were moved around campus as they outgrew their homes. The old library, better known as the SSC in my day or A. H. Anderson Hall officially, is currently not occupied by any department, though I believe is still used for its classrooms (correct me if I’m wrong). The departments that were once there have all moved to Beck Hall now. It is nevertheless interesting to think about this aerial transformation in terms of a college’s priorities.
I’m far from the first to note that college costs are on the rise, and I’m far from the first to wonder why colleges seem to spend more on fancy athletic and housing facilities than the academic program (and whether that even matters), and what drives spending by college administrators. Nevertheless, it is hard to argue that, at least from a bird’s eye view, my college seems to have its priorities in two key areas: athletics, and student facilities.
Edited for grammar and spelling, 8/15 at 7:37pm.
-
The Soft Power of Online Diplomacy
Abstract
(more…)The age of the state is not over. Though some have written about the power of web 2.0 to topple regimes and destroy state sovereignty, the picture is a little more complicated. The Republic of Korea in the last two decades has taken on a major cultural export campaign. Led by television dramas and pop music, the “Korean Wave,” as it’s called, has strengthened the ROK’s position as a regional power. More recently, the Republic of Korea started a comprehensive online public diplomacy campaign targeted specifically outside Korea’s ordinary sphere of influence with the goal of developing soft power abroad. Through an examination of tourism statistics, public opinion polls, and Google search trends, this paper ask the question: what if any soft power was generated by these online efforts? The results, though not immediately obvious, provide an early model for a state successfully taking on the new challenges posed by information and communication technologies to generate soft power online.
Download this article as a PDF. This paper was prepared as part of a course taught by Shanthi Kalathil at Georgetown University.