Each new version of WordPress brings enhanced features and bug fixes to improve the Web’s most-used blogging platform. The upcoming release of WordPress, version 4.4, is slated for sometime in early December 2015 with some interesting changes.
The 4.4 codex page has already been created and is awaiting full details. But some release info has already been put out and should excite all fans of the WordPress platform.
WordPress will now add additional attributes to the img tag when adding images to aid in responsive images in your WordPress theme. At the moment when you add an image to your editor it will automatically add HTML attributes for class to align the image on the left, center or right. The new update will add two new attributes for srcset and size.
Using these attributes will allow the browser to download the correct size images for the viewport.
This comes with a number of new filters allowing you to customise the default sizes by using the filter wp_calculate_image_sizes.
- wp_get_attachment_image_srcset() – Retrieves the value for an image attachment’s srcset attribute.
- wp_calculate_image_srcset() – A helper function to calculate the image sources to include in a srcset attribute.
- wp_get_attachment_image_sizes() – Creates a sizes attribute value for an image.
- wp_calculate_image_sizes() – A helper function to create the sizes attribute for an image.
- wp_make_content_images_responsive() – Filters img elements in post content to add srcset and sizes attributes. For more information about the use of a display filter, read this post.
- wp_image_add_srcset_and_sizes() – Adds srcset and sizes attributes to an existing img element. Used by wp_make_content_images_responsive().
Greater oEmbed support
WordPress 4.4 will include expanded support for oEmbed websites beyond just YouTube and Twitter.
The concept behind oEmbed is to allow for easy embedding of content based on a single URL. This means you can copy/paste a YouTube video directly into a post and WordPress will auto-generate the required embed code.
Even better, WordPress 4.4 will fully support oEmbed for all blogs that wish to use it. So now WordPress posts can be embedded directly into other websites using this same technology.
Many of these features were previously available via plugins but starting with v4.4 all oEmbed features will be added right into the WordPress core.
For developers this means when you create the site you will need to think about how you style the site when it’s embedded. Any content that is publicly available will be able to be used in the oEmbed system. Using pretty links your embed content will be displayed in an iframe accessing through the URL of example.com/your-post/embed/.
There are a number of new functions you can use with this new feature
- get_post_embed_url() — Retrieves the URL to embed a specific post in an iframe
- get_post_embed_html() — Retrieves the full embed code for a specific post.
- get_oembed_endpoint_url() — Retrieves the oEmbed endpoint URL for a given permalink, e.g. https://example.com/?oembed=true&url=. This is used to add the oEmbed discovery links to the HTML for single posts.
- get_oembed_response_data() — Retrieves the oEmbed response data for a given post, according to the oEmbed specification.
If you don’t like the sound of people being able to embed your content you can install the following plugin to turn off this feature: Disable Embeds
Default Twenty Sixteen theme
Heralding the new year is WordPress’ official theme release packaged as the default theme with WordPress 4.4. The Twenty Sixteen theme has been out for a few months and can be downloaded from GitHub or straight from the WordPress theme repo.
Twenty Sixteen is very minimal and relies primarily on typography. It’s fully responsive and perfect as a customizable template for WP theme developers. The entire layout can be restyled with various colors and offers custom sidebar positioning.
Twenty Sixteen was designed by Takashi Irie who also created the previous two themes for Twenty Fifteen and Twenty Fourteen.
Here are some of Twenty Sixteen’s major features:
- Five color schemes: Default, Dark, Grey, Red, and Yellow
- Optional sidebar with two menu locations
- Fully responsive and designed for mobile first
- Custom features like excerpts and header styles
WordPress core REST API
Developers will be excited to know the WP REST API is being worked in as a core feature.
This API is not fully merged yet, but the REST API infrastructure will be apart of the 4.4 core. API endpoints still require the WP API plugin, but these endpoints are an expected addition to the core in a future release.
Anyone who develops with APIs and knows about RESTful API practices will be thrilled. WordPress has grown so quickly over the years and this marks a truly exciting time for WP developers.
Changes to WP_Title
Another code-based change is the move away from WordPress’ well-known wp_title()method. This change has been in the works since WordPress 4.1 but now has much more detail moving into v4.4.
It seems the initial plan was to completely deprecate wp_title(), but this would cause a lot of confusion. The WP team has instead chosen to maintain support while encouraging devs to move onto the newer title tag feature.
There’s bound to be many other small changes but these larger points should get developers excited for the full v4.4 release.
Users who want to play around with the 4.4 beta can install WordPress Beta Tester to see the upcoming changes for themselves.
Ever since the release of WordPress 4.1 it has been recommended to use the function.
add_theme_support( 'title-tag' );
To auto generate the title tag in your WordPress theme, this is done by adding the HTML into the wp_head() output.
Originally the wp_title() function was going to deprecated or removed from the core, but this is not the case anymore and has been kept in the core functionality but is classed as deprecated. This means you can still use the function but it is recommended that you don’t, therefore all developers should not use this function moving forward and try to update your previous themes to not use this anymore.
Term Taxonomy Meta
With each release of WordPress the developers are slowly moving to a more OOP structure you can see this with the addition of a new object for handling terms and taxonomies with the object WP_Term.
The biggest improvement to this is the use of term meta, allowing you to add custom field content to a taxonomy object just like you do on posts and pages by using the following functions add_term_meta(), update_term_meta(), delete_term_meta(), and get_term_meta().
Before if you would want to create term meta you would have to create site_option data explained in this tutorial
Now you can do all this by using the WP_Term object, I will update the above tutorial with information on how to achieve the samething using the WP_Term object.
Along with terms, comments has had a small update with the WP_Comment object, allowing you to manage the output of the comments in a more OOP way.
The default comment form has also had a little rearrange with the comment form now appearing first before the name and email fields.
Multisite WP_Network Object
In keeping with the OOP changes there is a new object for multisite being the WP_Network object. This makes it easier to customise the the data used across a network of sites, with the addition of new functions add_network_option(), update_network_option(), get_network_option(), and delete_network_option() are all new functions in 4.4.
Single Post Template File
One neat little feature of WordPress 4.4 is the creation of the single post – post name template file included in the theme file hierarchy.
This template file will allow you to have a new design for an individual post, can be a nice feature to use if you have an eCommerce shop and want to display this page differently to the others, or have an offer on something you can make this page different to anything else on your site.
These are some of my favourite features with WordPress 4.4 I’m looking forward seeing what can be created with the RESTful API or what hybrid sites can be created with it. 4.4 is still in testing you can download the beta right now and have a play but I wouldn’t recommend using it on a live site until it has been released.