![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F04%2Fshutterstock_517228426-1.jpg&w=1080&q=75)
In my last article, in this series on advanced object-oriented programming (OOP) for PHP WordPress development, I showed how to setup the WordPress test suite for integration tests. Previously, I had written about unit tests, which I showed how to run in an isolated environment. These tests were not dependent on WordPress at all, so they could just run on the system’s PHP. On the other hand, integration tests cover the interaction of the plugin and WordPress, so they need a complete WordPress. I showed how to setup those tests using VVV or Docker. In the example plugin, I set […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F05%2Fshutterstock_1044298795.jpg&w=1080&q=75)
In my previous articles in this series, I showed how to structure a WordPress plugin using object-oriented PHP. Then I covered unit testing. Unit tests cover each component, totally isolated from all other parts of the system. Unit tests should not be concerned with how the object interacts with any dependencies including the database and WordPress. Instead, once we have unit tests, we use integration tests to cover the effects of our code on the environment it is in. In general, we use phpunit for both types of tests. We just use them differently. We can think of phpunit as […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F04%2Fshutterstock_654072133.jpg&w=1080&q=75)
This post is part of a series of posts on extending the WordPress REST API using advanced object-oriented PHP. In the first post, I showed you how to use three filters to modify the schema of any post type route. Using an object-oriented approach is more complex, and takes more work than using functional programming styles or using some object-oriented code but not following the SOLID principles closely as I am attempting to do in these posts. That code we’ve been working with uses three WordPress filters and interacts with multiple WordPress APIs. The goal of these posts is to […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F04%2Fshutterstock_557615488.jpg&w=1080&q=75)
In my last post, I showed how to modify the WordPress content endpoints using WordPress hooks — aka the WordPress plugins API — during REST API requests. The practical example changed the underlying query to improve search. Now I need to test that code isolated from the WordPress plugins API. For this article, we will assume the Plugins API is working as documented. This, however, isn’t a safe assumption, so we need to be ready if it isn’t working as planned. This post is really about how we can control for that problem. I’ll be walking you through setting up […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F03%2Fshutterstock_747099091.jpg&w=1080&q=75)
I’ve written a lot about object-oriented PHP and the WordPress REST API for Torque over the past few years. I’ve also touched on using Composer for dependency management and to provide an autoloader, as well as covered unit testing. The basic message of everything I’ve written is that by applying the established best practices of software development to how we develop for WordPress, we can create better plugins. This is the first of a series of articles, that will pull together these concepts in a practical, functional example. I’ll be walking through creating a WordPress plugin to modify the capabilities […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2017%2F12%2Fshutterstock_518049721.jpg&w=1080&q=75)
A few months ago I wrote on Quora, in response to a question if it’s better to learn Vue or React first. I said, “Learn VueJS first. I’d say that even if I knew there was a 100% chance you’d be using React in a year.” I’ve learned a lot more about React since then and I still stand by that. I’ve been using React more recently. Because WordPress is integrating a lot of React concepts as part of the new “Gutenberg” system, the question of which framework you should use with WordPress has changed. This is a topic that’s […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F03%2Fshutterstock_505601602.jpg&w=1080&q=75)
I’ve written a lot about object-oriented PHP and more specifically dependency injection and using classes to encapsulate functionality with a simple public API. By using the object-oriented programming features of PHP this way, you can write unit and integration tests so that you whenever you make changes to the class, you know that given the same inputs, the output of the class is consistent. That all sounds great, but dealing with inputs is tricky. This is especially true when taking an object-oriented approach to working with WordPress. In this article, we’ll look at a common problem when writing WordPress code […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F02%2Fshutterstock_602578109.jpg&w=1080&q=75)
Since the WordPress REST API was first proposed, we’ve talked a lot about how it will be involved in the future of wp-admin. Gutenberg, the new WordPress UI system that will be used for the new post editor in WordPress 5.0 is the first example we have of the REST API being used to communicate data between the server and a JavaScript-driven interface. A JavaScript-driven interface communicating with WordPress via the REST API or GraphQL inside of wp-admin is something that’s been talked about and written about a lot. Many plugins do this already. But Gutenberg is the most expansive […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F02%2Fshutterstock_302793251.jpg&w=1080&q=75)
Getting emails through your WordPress site is important. Whether someone is informing you there’s something wrong with your products, or just dropping by to say you’re doing a great job, you need to make sure you receive those emails. Too often, our tests for if emails work on a WordPress site or in a WordPress plugin involve filling out a form, checking our email and seeing if it looks right. That’s not efficient and requires a proactive investment of human time. Let’s write a program to do it better and more consistently instead. This article is about using testing emails. […]
![[object Object]](/_next/image?url=https%3A%2F%2Ftorquemag.io%2Fwp-content%2Fuploads%2F2018%2F02%2Fshutterstock_59191027.jpg&w=1080&q=75)
WordPress is a global platform. With over 29 percent of the Internet, a lot of those users aren’t in English speaking countries. In fact, since 2014, there are more downloads not in English than in English. While WordPress defaults to English, it supports many languages and there are many great ways to translate WordPress post content. WordPress’ translation-friendliness is not just necessary for global growth, but it fits with our community’s values of inclusivity and accessibility. One of the many prospective changes in accessibility I’ve had as a result of being involved in this community was that I need to […]