Debug Bar Slow Actions

If a typical WordPress page load takes more than one second, chances are there’s something terribly wrong with your site, a theme or a plugin is probably doing something it shouldn’t. Obviously you don’t have time to review every single line in your codebase, so Debug Bar Slow Actions might help you out.

Debug Bar Slow Actions is an extension for the popular Debug Bar plugin. It adds a new panel with a list of the top 100 slowest actions (and filters) during the current page request.

Debug Bar Slow Actions

It’s fairly lightweight (as opposed to xdebug and other profiling tools), but I wouldn’t recommend running it on a production environment, or at least not for long. It does hook to each and every action and filter (twice!) to time it, though timing is pretty fast and it’s highly unlikely that it’ll ever become a performance bottleneck.

After you’ve found out which action is the slowest, you can easily lookup the callback functions hooked to that action, perhaps using tools like Query Monitor, or a simple var_dump:

add_action( 'init', 'whats_at_init', 9999 );
function whats_at_init() {
	var_dump( $GLOBALS['wp_filter']['init'] );
}

Update: version 0.8.1 and above will show you the number of callbacks hooked to each action, and it’s also possible to expand the callbacks list.

You can get Debug Bar Slow Actions from WordPress.org or GitHub.

Happy profiling!

Publish up to 170% more posts with Color Schemes Roulette for WordPress

You know WordPress 3.8 has arrived, right? It’s got a total of eight new and beautiful color schemes for you to choose from, and another eight (at the time of writing) in an official plugin called Admin Color Schemes, so sixteen total. How do you pick one? Easy.

Meet Color Schemes Roulette — a brand new WordPress plugin, that will randomly change your admin color scheme every time you hit that Publish button. It’s also a great motivator, proven to increase blogging frequency up to 170% right after activation!

WordPress Color Schemes

Yup, this is my way to celebrate the 3.8 release. Although I haven’t contributed much this time, I’m still super excited to see it all come together. Thanks to Matt and the whole team behind 3.8, for making such a beautiful WordPress.

Columns for WordPress

Sometimes you need to split your content into two or more columns, perhaps for a list of features on your front page. Unfortunately the standard WordPress editor does not support that out of the box (yet) so you turn to plugins.

With quite a few options available, it’s not easy to make the right choice, plus, there’s almost always a learning curve involved, especially with shortcodes like:

[fourcol_two_last]

I crafted an experimental columns plugin quite a while ago, which hopefully simplifies the shortcodes to a bare minimum, and makes them look slightly more like HTML. Put as much columns as you want into a column group, and it can figure out the rest:

[column-group]
    [column]This is my first column[/column]
    [column]This is my second column[/column]
[/column-group]

Hopefully this is much easier than memorizing cryptic shortcode names, and even if you end up deactivating the plugin in the future, you can always run a (fairly) simple regex search and replace to “lock yourself out.”

I recently released the plugin for public use. It’s called Columns (duh!) and it’s available at the WordPress.org plugins directory. Give it a spin and let me know what you think!

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.

WordPress Plugin Review Discussion

Otto, Brian Krogsgard, Ben Lobaugh, Erick Hitter, Jake Goldman, Kailey Lampert, Shane Pearlman, John Hawkins, Patrick Garman, Ryan Frankel, Andrew Norcross. Google Hangouts seemed to work pretty well!

I don’t have a strong opinion about any of the points they discussed, but I would love to see an option to flag a particular plugin with a security issue, and obviously, write what the issue is, and how it could (or should) be resolved.

Convert NextGen Galleries to WordPress Galleries

I was using NextGen Gallery for quite some time here on my blog, and it was all going well until WordPress introduced its own gallery shortcode, custom post types and more, which NextGen never adapted to. After migrating the blog a couple of times I was tired of all the conflicts, so I stopped using galleries, disable the plugin and lived happily even after, until…

Until Jetpack Carousel came along and because it’s so cool an sexy, it made me wanna use galleries again, so I (finally) decided to write a script to migrate my old NextGen Galleries to native WordPress galleries, so they can be used with Jetpack Carousel, or any other carousel or lightbox plugins, which:

  • Don’t create their own shortcode
  • Don’t create their own file structure
  • Don’t create their own database tables

Unfortunately NextGen Gallery does all the above, making it quite tricky to escape, or “lock yourself out.” My script started as a simple Gist on GitHub, but finally made it into its own repo, which I called Escape NextGen Gallery.

It’s far from a complete migration plugin, but it worked for moving my galleries over, and finally getting rid of the database tables and file structure I always hated. Your setup might differ from mine, so you’ll probably have to fine-tune that script, and if you do, don’t hesitate to submit a pull request or fork if you wish.

WordPress as an Issue Tracker

With the recently updated P2 Resolved Posts plugin, your WordPress blog can now be a full-blown issue tracker, given that it’s running the awesome P2 Theme.

You can see it in action on make.wordpress.org/systems, where red posts are unresolved issues, and green posts are resolved. Sidebar widgets can also help list all your current unresolved posts as well as recently resolved ones, filterable by tags. And don’t forget about the already existing features in P2, like @mentions and to-do lists!

How to Network Deactivate a WordPress Plugin

Duh! Hit “Network Deactivate” in the Network Admin, right? Yeah….

Next time, think twice before you Network Activate a WordPress plugin. It’s not too easy to deactivate it, while keeping it activated on blogs that actually use it. I wrote a little CLI script to activate a plugin of your choice on all blogs in a network:

define( 'ABSPATH', '/path/to/wordpress/' );
require( '/path/to/wp-config.php' );
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
global $wpdb;

$blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs;" );
foreach ( $blogs as $id ) {
    switch_to_blog( $id );
    activate_plugin( 'your-plugin/your-plugin.php' );
    restore_current_blog();
}

printf( "Plugin has been activated on %d blogs.", count( $blogs ) );

You can use it before you network deactivate a plugin, to make sure it’s still activated on all blogs that (might) use it, but newly created ones will not have it active by default. You can then go through all the blogs with that plugin activate, and deactivate on the ones that are not using it, either manually or with a script similar to the above, depending on the plugin.

For example, you can do a check for an option that a plugin uses with get_option and if it’s empty use deactivate_plugins to deactivate it for that blog. The above trick helped me deactivate three plugins, which were barely used in a network.

What about you? How many plugins have you network activated some day, and not really using them on each and every site in the network?