I’ve Joined Automattic

This is big news, and words can’t explain my feelings. Today’s my first day at Automattic, the company behing WordPress.com, Akismet, Gravatar, Polldaddy, VaultPress, and a whole lot more. As you know, Automattic also contributes to a number of Open Source projects, including BuddyPress, bbPress, Browse Happy, WordCamp.org and of course WordPress itself.

So… Starting today, I’ll be working on some really cool stuff with some of the most talented minds on earth. I’ve already met with some of the folks online and the energy is incredible, they got me even more excited, and now I can’t wait for my first meetup and of course WordCamp to meet everybody in real life.

This is a dream come true for me, thank you so much Automattic! Looking forward to “make the web a better place.” :)



Hey WordPress, How About a WP_Plugin Class?

Okay January is my month of ideas :) Let’s talk about plugins for a moment, shall we? Actions and filters are no secret to WordPress developers, right? Say, how many times do you type something like this in your plugins or theme files:

class Some_Plugin {
    function __construct() {
        add_action( 'admin_init', array( $this, 'admin_init' ) );
    }

    function admin_init() {
        // Whatever
    }
}

If you don’t, then you can stop reading now :) I’m addressing the naming technique here, the fact that admin_init is both an action tag, and a method that you assign to that action tag. So if I’m naming all my methods after actions and filters tags in WordPress, isn’t there a way to cut down the burden of having to add_action and add_filter all the time?

I’ve been thinking of an approach that could solve this problem in both, an easy to understand way, and a compatible way. Perhaps we’re lacking a WP_Plugin class in WordPress that would take care of this (along with a bunch of other things) for us, so that we can focus on writing our plugin, and not spend time matching tags to methods.

Here’s a concept that first popped into my mind, experimental and buggy, but something to get our heads thinking about it. If your class extends the WP_Plugin class, and your method’s name starts with a double-underscore prefix (or any other convention we may choose), and matches an existing action or filter, why not run the action or filter automatically without having to add_action or add_filter?

class Some_Plugin extends WP_Plugin {
    function __admin_init() {
        // Will run during admin_init
    }

    function __the_content( $content ) {
        // Will filter the_content
        return $content;
    }
}

Again, it’s just a thought and a lot of decisions should be made before implementing something like this. I went ahead and drafted a plugin file which works well to some extent. You can change the method name convention on line 18.

So my questions to you, dear reader are: is will this make things easier for the WordPress developers? Will this mess things up? What do you think of the prefix convention? How would you propose to handle the priority dilemma? What else could go into a WP_Plugin class?

Update! It seems like Reflection is a better approach at what I’m trying to do, and separating actions from filters logic too. Thanks so much for the heads up Ryan McCue, Kaiser and Daniel Dvorkin. Here’s Ryan’s improvement over my first Gist.

Thanks for stopping by and subscribing!



WordPress Multisite with Wildcard Subdomains

If you’re working with WordPress Multisite in your local environment, you might have noticed that dealing with a subdomain install is a pain, because your hosts file doesn’t support wildcard entries for hosts, i.e. you cannot do something like this:

127.0.0.1 *.multisite.lo # will not work!

There are quite a few solutions though, first and easiest of which is to run multisite with a subdirectories setup. The second solution would be to manage you hosts file manually and create an entry for each subdomain in you installation. This could be a pain if you’re working with quite a large amount of subdomains, in fact you can end up spending most of your time editing you hosts file and flushing DNS cache.

I wrote a little snippet that you can use in a plugin file or functions.php which prints out a string you can copy and paste into your /etc/hosts file. It generates an entry out of all the existing domains in your WordPress multisite install and maps them to the IP address you specify.

add_action( 'wp_footer', 'print_entry_for_hosts_file' );
function print_entry_for_hosts_file() {
    global $wpdb;
    $domains = $wpdb->get_col( "SELECT domain FROM $wpdb->blogs;" );
    echo "127.0.0.1 " . implode( ' ', $domains );
}

The wp_footer hook will get it to print the entry in your theme’s footer but you can attach it to any other hook if you like. When actually pasting the generated entry into your hosts file, make sure you remove the previous entry for your domain to keep the file clean and shiny. Comment out the add_action line to hide the mess until you add a few more sites to the network and need to update you hosts file again.

I agree it’s still a bit of a pain but it really helps! The third and probably most correct way of handling wildcard domains working locally would be to set up a DNS server. It’s not always worth the trouble though.

If you had experience dealing with wildcard domains in WordPress multisite, please share your thoughts in the comments section below. If you installed a local DNS server, feel free to link to any guide or tutorial on how to do that on your operating system. Thanks!



I turned 23 today, it doesn’t feel too much different from last year. I have gone through a lot of (mostly) good things, the most wonderful of which was my marriage in December. Let’s see what happens next, I’m quite excited!



Dear WordPress, I Want to “Drop Files Here” in the Visual Editor!

Wouldn’t in be great if we could drag and drop to upload files directly into the visual editor? WordPress 3.3 very well handles drag and drop uploads into the Add Media modal box, in a special area that says “drop files here”:

WordPress 3.3 Drop Files Here

And thank you so much for that, WordPress, but I’m tired of constantly having to open the media manager to insert an image into my post or page. Having the visual editor carry out the “drop files here” role would be awesome, it would save at least one click every time I need to insert an image.

Two clicks if we can get it to upload and insert the image into the editor without even showing the Add Media screen! But that might be a little more complicated because of positioning and sizing. A simple upload is where we should start.

Continue reading



Installing WordPress with MAMP on Mac OS X

This is an absolute beginners tutorial on how to get yourself a local WordPress development environment set up on your Mac OS X with MAMP. Step by step (and with screenshots,) we’ll go through each part of the process — downloading and installing MAMP, basic MAMP configuration, creating a MySQL user and database, getting WordPress up and running, and in the end I’ll share some tips you might find useful in your WordPress journey.

Continue reading



Stop SOPA Ribbon for your WordPress site or network. A plugin I made in a few minutes to show my support. It works with Multisite if you need a ribbon throughout the whole network. Learn more about SOPA on the Stop American Censorship website or read the Help Stop SOPA/PIPA in the WordPress news section.



Andy Stratton gave a presentation called “Diet Pills, SEO, and Theme Frameworks” at WordCamp Chicago 2011. He talked about WordPress themes, frameworks, marketplaces and a lot of related misconceptions, and some of the many problems with commercial themes including SEO, customization, child themes. Here’s a quote if you haven’t got time to watch the whole video.

There are no shortcuts to awesome!

So if your clients think that $30 themes are flexible, customizable and awesome products that will solve all their business problems, they might be wrong. Thank you Andy for clearing that out! Andy’s presentation is on SlideShare too!



About the “Lock in Effect” in WordPress Themes and Plugins

The WordPress themes and plugins market is huge these days. With all that wide range of products available, we sometimes stumble into situations where we’d like to change our mind, i.e. use a different plugin or theme instead of the one we’re currently using.

Eventually we figure out that it’s incredibly tough to replace some of the themes and plugins, because as soon as they’re deactivated, all (or part) of our data is lost, and the new theme or plugin that was supposed to replace the old ones, doesn’t see the data we previously had. So we say that we’re locked in.

This post describes the lock in effect, shows you some methods to identify such themes and plugins. Plus, if you really do have to use one such theme or plugin, we’ll cover some tips on escaping or locking yourself out.

Continue reading



Akismet Spam Stats

I turned commenting off on articles older than 14 days a copule of months ago and here’s the impact shown by Akismet’s stats page. No wonder why I stopped receiving a bunch of “please moderate” e-mails every day.