BuddyPress Notifications

Today, with a little help from my friends, the first new component to BuddyPress in several years saw it’s first commit into trunk this morning.

BuddyPress Notifications

First pass UI for BuddyPress Notifications

BuddyPress’s new Notifications component is something I’ve had in my imagination since BuddyPress 1.0. It works identically to the previous core notifications functionality, and offers key features I’ve always wanted in our notifications:

  • The notifications component can now be deactivated.
  • Individual notifications can be marked as read/unread.
  • A user interface for previously read notifications.
  • A solid foundation for future notifications improvements (notification meta!).

For the curious, you can follow along with Notifications development on ticket #5148. This feature is slated for BuddyPress 1.9, coming near the end of November.

Contributing to WordPress, BuddyPress, & bbPress

Siobhan McKeown recently authored an amazing post at Smashing Magazine about contributing to WordPress. I was fortunate enough to have the opportunity to share some of my own thoughts, mostly surrounding BuddyPress and bbPress.

If you’re a part of the WordPress community, this is a great read, with ideas and suggestions from a few of the most iconic WordPress contributors. I’ll leave you with my two favorite snippets from my pals Matt and Mark:

The number one skill you need for just about any job, but specifically working on open source, is communication skills. You need to have clarity, consistency, compassion, relatability, a little bit of a thick skin and a decent sense of humor. — Mark Jaquith

You can’t knock on the door at Google and say, “Hey, do you mind if I help you out with your home page? I have some ideas for you.” But you could come to us and say, “Hey, I have some ideas for your dashboard, and here are some patches.” — Matt Mullenweg

SLASH Architecture – My approach to building WordPress plugins

I’ve fallen into a routine when building WordPress plugins; a few general rules are:

  • Avoid creating new PHP globals.
  • Avoid executing PHP code in the global scope.
  • Generous use of Actions and Filters.

I’ve decided to name the pattern I use Slash, which stands for:

  • Singletons
  • Loaders
  • Actions
  • Screens
  • Handlers

Singletons

I didn’t love singletons in PHP at first, and I’m still not convinced they are ideal, but they work well at avoiding yet-another-WordPress-related Global variable. bbPress is a good example.

The benefit of using PHP singleton’s in WordPress is they don’t create an additional PHP global to worry about getting stomped. They also allow your plugin to always exist in memory, without another plugin being able to unset it, while still working like a traditional PHP class.

Loaders

These are basically bootstrap functions. Their only responsibility is to jumpstart a singleton, and put it in a place for easy access. See the bbpress() function in the above bbPress link. Loaders allow you to reference your Singleton without needing to use a global variable, or pass an instance around into functions and method calls. Used like: bbpress()->foo = 'bar';

Actions

By hooking everything into WordPress core actions, bbPress never runs any code inline in the global scope, other than the above loader function. Also, bbPress comes with it’s own sub-actions to piggyback WordPress’s, making writing bbPress specific plugins safe and simple.

This also includes WordPress Filters. The major difference with Filters is that they are generally more risky to use; you have to assume other plugins are already using them, and those same plugins aren’t designed to handle whatever you’re trying to do too.

Screens

Derived from BuddyPress, screens are basically “Views” if you’re familiar with MVC. They are how we output markup to the browser from inside PHP, WordPress, and our plugins. Screens can be modular (again, see bbPress) allowing them to work with shortcodes, widgets, and template parts. Screens typically contain all of the translatable strings and HTML markup, and sanitize any variables for output.

Handlers

Handlers are the equivalent of controllers in MVC. They are responsible for containing the logic that comes from requests like forms, AJAX, JSON, XML-RPC, etc… They “handle” whatever the request is, performing capability checks, validating input data, and also checking for nonces.

Why not use MVC?

Honestly? No reason. Slash isn’t intended to compete or replace anything, and like anything else it’s constantly evolved over time to become what it is today, and will likely change tomorrow too. MVC and other architectures work really well, and Slash is just an approach that’s worked well for me. Putting a name on the routine should help it grow, or educate me on better approaches.

It’s also worth noting that Slash isn’t really anything new, but rather an assembly of separate methodologies combined into a single process that helps me translate my thoughts into code.

The best way to see the Slash approach in action is to browse through the BuddyPress and bbPress codebases. If you’re an experienced developer, I’m always looking for feedback. If you’re just starting out, maybe give the Slash approach a try. Take what’s in bbPress and remix it for your own use, and let me know how it goes.

Custom Plugin Header Image Label

Back in December of 2011, Matt and friends added the ability for WordPress plugins to have really pretty header images. For BuddyPress, I went through a few design iterations before settling on the header image pictured at the bottom of this post. I wanted it to be minimalistic and unique, so I took an hour to extend the label area with the buddies at the end. Below is the basic approach to make that happen:

  • Take a screen shot of the header image without the extended icon area.
  • Open that screen shot in Photoshop or your favorite image editor.
  • Make a new layer.
  • Fill the new layer with a black close to whatever the primary color of the label is. (#181818)
  • Hide that layer, select the background layer.
  • Magic wand the label.
  • Extend the selection to the size you want it to be (Usually 50px or so.)
  • Switch to your all black layer.
  • Right click; Select inverse; Delete.
  • Tweak the opacity of your black layer to match as closely as possible. Take your time with this; even if it’s the slightest bit off, it’s pretty noticeable.

Confessions of an Open Source Workaholic

Hi, my name is John, and I’m an Open Source Software workaholic. I touched on it a bit in my WPCandy interview, and I thought I’d finish the story here with a few added thoughts.

I live in a great neighborhood on the east side of Providence, RI. I work from home, rarely drive my car (ignore the frequent road trips), and enjoy the luxury of being walking distance from food, laundry, spirits, and anything else I might need to live a happy and comfortable life.

By day, I work for Automattic. I love my job. I love my colleagues. I love everything about what I do. To say it’s a dream job is an understatement. I work on some really awesome stuff going on around WordPress.com, Jetpack, Gravatar, and try to poke my head into other interesting social bits as much as possible.

By night, I’m the lead developer of bbPress, BuddyPress, and maintain both of the bbPress.org and BuddyPress.org sites. I believe both projects are two of the strongest spokes attached to the WordPress hub, and it’s my pleasure and privilege to be so closely involved with them. I am passionate about their success and enjoy iterating and improving them both equally, and love to help their users whenever I can.

That said, I’m in a unique and misunderstood position.

I work 40+ hours at a job that I love. Most days when I’m done with work I switch gears to my hobbies; usually that’s bbPress and BuddyPress. Other days, I enjoy going to the park with my dog Paul, watching Netflix, or enjoying a nice meal with friends.

In 2010 and 2011, I had the pleasure of mentoring some really bright individuals as part of the Google Summer of Code and the Google Code In projects. Gautam Gupta, a 15 year-old student from India, placed 6th by working closely with me contributing to the first major release of bbPress in two years; helping to totally refactor bbPress into a plugin for WordPress, skyrocket its popularity, and reinvigorate something great that hadn’t had much attention in a while.

My point, is that working on the bb’s is not something I am directly paid by Automattic to do. Instead, my job at Automattic enables me the means to keep my skills sharp *and* work on the software that I love, at the same time; it allows me to spend my free time giving as much back to the community as I am willing and able to. I choose to concentrate on bbPress and BuddyPress.

While Automattic does donate the time of several full-time people directly back into WordPress, and while it benefits Automattic as a business to be coupled so closely to its active development, it is not Automattic’s responsibility to staff anyone to contribute back to any open source project anymore than it is your own to do the same.

WordPress is free and open for anyone to build off of and dedicate resources towards. The bb’s are both free and open like WordPress is, with a lower barrier of entry to make a a much larger impact. If you’ve ever been intimidated by the amount of activity happening around the development of WordPress, or have been afraid your contributions aren’t good enough: 1. you’re wrong; 2. use the bb’s as your training ground.

If you choose to stick around and help work on the bb’s, your influence carries more weight because there are fewer people contributing. Dedicated contributors walk up the ranks quickly, earning core commit access like Boone Gorges, Paul Gibbs, and I with both BuddyPress and bbPress. We’re not the founding developers, we’re the currently active ones, and we would love to have your help. From code to codex, everything is an iterative work-in-progress.

Who knows, maybe eventually you’ll be an open source workaholic, too.

BuddyPress 1.5 “Lombardi” released

Could not have said it better myself. Reblogged from Boone @ Teleogistic:

It’s finally here! After many, many months of bug squashing, refactoring, and general bloodsweatntears, BuddyPress 1.5 has been released!

This long development cycle has been frustrating in some ways and extremely rewarding in others. On balance, I’m quite proud of the work that’s been done, and quite pleased to have worked so closely and so well with JohnPaul, and all the other contributors to BuddyPress. My sincere thanks to all the users and developers who have been supportive during this dev cycle.

Most importantly, BuddyPress 1.5 itself kicks ass. The bp-default theme has seen some serious improvements, some much-needed features have been added, and the codebase has been overhauled in terms of additional internal APIs, documentation, style, and so on. If you’ve done development with BuddyPress in the past, do yourself a favor and check out BP 1.5 – you are in for an extremely pleasant surprise.

Here’s to 1.6 and beyond!

Boone and Paul, thank you both for your hard work and dedication. You are great developers and outstanding friends, and I’m excited at what we will accomplish in future versions!

I Spoke at WordCamp San Francisco!

This year I had the privilege of speaking a total of three times at WordCamp San Francisco and MC’ing the dev track all day on Friday.

The footage and slides below are from my first talk on Friday morning about BuddyPress 1.5.

Overall I’m happy with the way things turned out. I’ve always been comfortable on stage but have fallen out of practice in recent years. I love being able to use footage like this to improve each presentation that I give, and am excited to apply what I learned this time around.