The Ultimate Guide to Responsive Images in WordPress

Websites today are accessed by a variety of devices with different screen sizes and resolutions. Additionally these devices are often connected via low bandwidth connections.

While CSS and JavaScript can adapt designs to work well on small devices with touch screens, the content is still mostly identical. Users on a mobile phone will have to spend time and money downloading a large image meant for the desktop version, that then gets reduced to a much smaller size on their device.

Higher resolution, or retina screens, have also become a common feature among high end phones, tablets, and laptops. These devices need larger images, to account for their higher screen density. Serving content adapted to these devices was up until recently not possible with plain HTML.

The solution to these problems are responsive images.

Read More

Understanding WordPress PHP Unit Test Fixture Setup and Teardown

WordPress PHP Unit Testing When I get started writing unit tests in WordPress, I continuously ran into what seemed to be strange behaviours by the WordPress Unit Testing framework. Strange when comparing to other PHP unit tests anyway.

It wasn’t until I read all the code of the bootstrap and install scripts, as well as the base WordPress unit test case, that I was able to make sense of it all.

So in this article, I’ll detail how WordPress Unit Testing framework handles fixtures. In addition, I’ll touch on a few things to watch out for when writing your own tests.

Read More

WP_UnitTest_Factory: The Missing Documentation

Most WordPress functions interact with data objects like posts, users, or terms. This creates a problem for developers, as every test starts with an empty WordPress installation. The WordPress Unit Test Factory helps to solve this issue.

It provides a set offers a set of helper classes to create these database objects, called database fixtures in a unit testing scenario.

The test framework offers factories for creating:

  • Attachments
  • Comments
  • Posts
  • Categories, Tags, and Terms
  • Users

It also has multisite specific factories for:

  • Networks
  • Blogs

In this article, we’ll see about how you can interact with these factories, and what issues to watch out for.

Read More