WordPress 3.7 “Basie” is out!

So, where should we start after upgrading? There are so many things going on with the new WordPress version that it is hard to go through everything in a post. For sure, this version is a quantum leap into the vision of making WordPress upgrades as silent as Chrome browser does. It also introduces a better meter when choosing passwords, which is awesome. And I’m not forgetting the new language packs, integrated with WordPress.org, for a seamless experience on distributing the right translations to the users.

But for us, wannabe-developers, there are so many tiny changes under the hood that it will take time to notice all of them.

The improved search

One of the small changes I am interested about is the new improved search mechanism.

It was a well known issue on the community: WordPress search mechanism was poor and was only returning results ordered by date. WordPress 3.7 introduces the concept of stop words in the core, thus improving the search results quality, and it will order them by relevance, giving special attention to the search terms found in the title. It is a small change but important for those of you who don’t want to install plugins to improve the search functionality. For those who still need more than what core offers: try geeSearch Plus!

I’ll cover the search changes in deep on a future post about the new version of geeSearch Plus.

New filters: more control over Insert Links box on editor

I’ve been working on a plugin which requires some changes on the Insert/edit Link dialog box at posts editor. WordPress 3.7 introduces two brand new filters to allow some query manipulation on the internal links (shown when toggling  Or link to existing content link).

Insert - edit Link dialog box
Insert Link dialog box

So, if you need to customise the internal links suggestions at this box there are two new filters:

  • wp_link_query_args
  • wp_link_query

The first,  wp_link_query_args, allows you to filter the query args before WP runs a WP_Query query. This can be useful to show/hide some custom post types posts, as in the following example:

// Show only links for 'books' post type
add_filter( 'wp_link_query_args', 'my_custom_links_query_arg', 1, 1 );
function my_custom_links_query_arg( $query ) {
    $query['post_type'] = array( 'books' );
    return $query;
}

As per the wp_link_query, it allows you to filter the query results before they are sent to the screen. The results array only contains the post ‘ID’, ‘title’, ‘permalink’ and an ‘info’ label, which by default shows the post date (for Posts) or the post type name for custom post types.

// Change the 'info' label for all the results
add_filter( 'wp_link_query', 'my_custom_links_results', 1, 2 );
function my_custom_links_results( $results, $query ) {
    foreach( $results as $key => $result ) {
        $results[ $key ]['info'] = __('Unicorn Links');
    }
    return $results;
}

This is just a tiny fragment of all the unleashed potential of WordPress 3.7 version. Be sure to check out the release notes full article.