Tip: wp_cron() runs during init

Pro tip: wp_cron() runs during the init action at the default priority, i.e. 10. If you’d like things to be available during your cron tasks, make sure you initialize them earlier: the init action at priority 9 and less, or other actions that run before init — beware of these, since other things might not be available at that time.

Also, Core Control is a good plugin to test and debug cron tasks.

Happy Holidays

Santamattic

Santamattic came early this year. I was surprised FedEx could ship a package to Russia in only one week. It would have been faster if their Russian partners didn’t go knocking at the wrong door for two days in a row, but that’s okay since I was expecting this to arrive in January.

Unfortunately I can’t disclose the contents of the box, because some of my coworkers haven’t received theirs yet.

WordPress 3.5

WordPress 3.5 is here and it’s awesome. Media’s lovely, hyphens in shortcodes now work, and switch_to_blog() is so fast, your dog will never catch it, unless your database is down, in which case you should try HyperDB.

Always nice to see your own name in the list of contributors, which makes 3.5 the fourth major version I contributed to with at least one patch. The feeling is good, but I hope to do much more for 3.6.

Have you contributed a patch that landed in 3.5? If not, head over to the Core Contributor Handbook to find out how you can help!

Theme Publish is now on WordPress.com

I released a WordPress theme called Publish earlier this month, and today, thanks to the awesome Theme Team of Automattic, Publish has been made available to all WordPress.com users.

WordPress Theme Publish

Publish is a clean and minimal WordPress theme, perfect for (but not limited to) single-author blogs. While working on shipping Publish to WordPress.com customers, a bunch of improvements have been made to the theme itself, like support for uploading a custom logo (vs using Gravatar), better compatibility with many sidebar widgets and more.

I’m excited to see how Publish does on WordPress.com, and looking forward to launching more themes. You can start a new blog on WordPress.com with Publish or head over to WordPress.org for the downloadable version. Enjoy!

Reminder: Don’t Use the Short PHP Open Tag

Jetpack 2.0.1 was released last night, immediately followed by 2.0.2, which fixed a fatal error on some hosts, caused by a short PHP open tag. So here’s a reminder: never use the short form of the PHP opening tag:

<? _doing_it_wrong(); ?>

Always use the long form:

<?php _doing_it_right(); ?>

If your grep can do Perl regular expressions, you can search your entire codebase with a negative lookahead like this:

grep --include=*.php -rP '<\?(?!php|xml)' *

Joseph Scott has a simpler example that works without the -P flag. If you’re building WordPress themes, the Theme Check plugin will scan your theme for short tags automatically. Plugin Check will do the same thing for your plugins.

Stay safe.

Double Titles when Sharing on Google+

If you’ve got double titles when sharing your WordPress posts on Google+, it’s probably due to duplicate OpenGraph tags, which might have been caused by the latest update to Jetpack, which added OpenGraph tags in version 2.0. If you’re already running a plugin that outputs the “og:” tags in your document head, you’ll have to disable one or the other.

For example, to have WordPress SEO by Yoast not output the OpenGraph tags, go to SEO – Social and disable Facebook OpenGraph. If you’d like to disable Jetpack’s OpenGraph support, you’ll have to write some code, preferably in a plugin file:

add_filter( 'jetpack_enable_open_graph', '__return_false' );

Other plugins might be different, but you get the idea.