Tom McFarlin
Tom is a self-employed developer who loves writing, building, and sharing WordPress-based projects. He runs Pressware where he provides WordPress goods and services. You can follow him on Twitter.
Tutorials
  • Code
    A Look at the WordPress HTTP API: A Brief Survey of wp_remote_postDiagram http api
    In the first series on the WordPress HTTP API, we took a look at wp_remote_get. Specifically, we took a look at the following aspects of the API: A survey of the function A practical example thereof How to handle the response And understanding the arguments for the function We're going to continue the series on the WordPress HTTP API, but we're going to turn our attention to a second method of the API: wp_remote_post. Throughout the next set of articles, we're going to take a survey of the function to understand what the function offers and why it's useful, a practical example of how to implement it into our work, as well as how to understand the functions and the response that comes from the function. With that said, let's begin our survey of the function.Read More…
  • Code
    A Look at the WordPress HTTP API: wp_remote_get - the ArgumentsDiagram http api
    3 shares
    In the last two posts, we've taken a brief survey of the wp_remote_get function as well as a practical implementation of how to use it. Before moving on to other aspects of the WordPress HTTP API, it's important to know exactly what information is returned from a remote call using wp_remote_get so that you're able to have a full understanding of the data that's returned, to write more defensive code, and to write more complicated requests should the need arise. So in this final article on performing GET requests, we're going to review exactly that.Read More…
  • Code
    A Look at the WordPress HTTP API: wp_remote_get - the ResponseDiagram http api
    2 shares
    In this series, we've been taking a look at the wp_remote_get WordPress HTTP API function in order to understand how it works, how we can use it, and the optional arguments that it accepts. From here, we're able to write detailed requests; however, that's only half of it - there's also the response. In the second article, we took a look at what a basic response would look like, how to evaluate it, and how to display it on the screen, but we didn't actually talk about the response in detail. If you're looking to write more advanced requests and write more defensive code, then it's important to understand the data that's sent as a response. In this final article, we're going to do exactly that.Read More…
  • Code
    A Look at the WordPress HTTP API: A Practical Example of wp_remote_getDiagram http api
    2 shares
    In the last article in this series, we took a look at the PHP functions that are available for making remote requests. Specifically, we reviewed: file_get_contents cURL And we also discussed the WordPress function wp_remote_get. In this article, we're going to put the wp_remote_get to work. This function is part of the HTTP API - to practical use by using it to retrieve the following two things: The number of followers we have on Twitter Our most recent Tweet The nice thing is that we won't need to use any OAuth or authentication mechanisms, and we'll only need to take advantage of Twitter responses and PHP's JSON functionality. So in this article, we're going to take a practical look at how to do exactly this, then we'll end the series reviewing all of the information that wp_remote_get returns so that we'll know how to properly handle it in future work.Read More…
  • Code
    A Look at the WordPress HTTP API: A Brief Survey of wp_remote_getDiagram http api
    3 shares
    When it comes to making remote requests within the context of web sites, web applications, and even WordPress-based projects, the model that we follow is generally the same: Initiate a request on the server-side Handle the response when it's retrieved either by reading the response or catching the error Return the response to the caller This particular format is the same that's used in both synchronous and asynchronous (or Ajax-based) functionality. The thing is, if you're building a standard web application using PHP, Rails, Java, .NET, or any other platform, then they each have their own ways of doing it. The same is true of WordPress; however, if you're working with WordPress, you're also working with PHP which means that you may be leveraging PHP functions rather than specific WordPress API's. In this four part series, we're going to take a look at what it means to make a remote GET request, and in the second part, we're going to take a look at a practical approach to doing so. Then in the last two articles, we're going to look at the arguments that wp_remote_get accepts as well as what you can accept from a response from the server when a request is completed. Ultimately, we should have a full understanding of this method's API as well as how to write quality and defensive code when implementing it in our projects. But first, let's take a survey of what it even means to make a request.Read More…
  • Code
    The WordPress Coding Standards: Bringing It All TogetherThe wordpress coding standards
    5 shares
    When it comes to writing a series of blog posts, one of the most challenging aspects as a reader is actually keeping up with every post that is published. Even if you do manage to try and keep up, posts that are in excess of 1,000 words - especially those that include code - can take time that many of us don't have especially when it comes to juggling our work lives, home lives, hobbies, and other things. So in order to make sure that the information presented throughout this series is still presented in a digestible way, I thought I'd experiment with doing a summary of the entire series. That way, for those of you who have missed an article or haven't had the time to sit down and go through each article, can still get the gist of each point mentioned throughout the articles. With that said, let's take a look at everything we covered when reviewing the WordPress Coding Standards.Read More…
  • Code
    The WordPress Coding Standards: Database Queries and Formatting SQL QueriesThe wordpress coding standards
    37 shares
    Aside from the summary that we're going to be providing as the last article in this series, this is the last explication of the WordPress Coding Standards that we're going to be covering in this series. We're going to be covering the nuances of database queries and how to format SQL within the context of your code. Of course, this wouldn't be without its own set of caveats: Generally speaking, there are APIs that are already available that can prevent us from needing to write SQL on our own; however, these APIs don't catch every single case that we actually need. After all, how can developers implementing APIs know exactly what and how we're going to build something? To that end, we're going to take a look at the APIs that are available for executing database queries, how to use them, and then how to define our own queries when the APIs fall short.Read More…
  • Code
    The WordPress Coding Standards: The Ternary Operator and Yoda ConditionsThe wordpress coding standards
    5 shares
    At this point in the series, we've covered a lot of ground. Up to now, we've discussed the following topics: Naming Conventions and Function Arguments The Use of Single Quotes and Double Quotes Indentation, Space Usage, and Trailing Spaces Brace Style, Regular Expressions, and PHP Tags Lots of stuff, right? In this particular article, I thought we'd take it a bit easier before jumping into the final topic. As such, we're going to cover two really simple topics (that are often either ignored or overcomplicated). Specifically, we're going to talk about the ternary operator and we're going to talk about Yoda conditions.Read More…
  • Code
    The WordPress Coding Standards: Braces, Regular Expressions, and PHP TagsThe wordpress coding standards
    12 shares
    In this series, we've been taking a deep dive into the WordPress Coding Standards in order to get the word out about them, understand them, and begin to practically apply them in our day-to-day work. If you're just joining the series, so far we've covered the following topics: Naming Conventions and Function Arguments Single Quotes and Double Quotes Indentation, Space Usage, and Trailing Spaces In this article, we're going to continue building on top of the content in the previous article: Specifically, we're going to be taking a look at brace style, regular expressions, and nuances of working with PHP tags within the context of building WordPress themes, plugins, and applications.Read More…
  • Code
    The WordPress Coding Standards: Indentation, Space Usage, and Trailing SpacesThe wordpress coding standards
    6 shares
    The entire purpose of this series to help expose the WordPress Coding Standards, why they matter, and how to write quality WordPress code. In order to do this, we're taking an in-depth look at each section of the WordPress Coding Standards. So far, we've covered: Naming Conventions and Function Arguments Single Quotes and Double Quotes Today, we're going to be covering the importance of white space. Specifically, we're going to cover indentation, space usage, and trailing spaces. As easy as it sounds, these are several of the most ignored or misused aspects of the codings standards.Read More…
  • Code
    The WordPress Coding Standards: Single Quotes and Double QuotesThe wordpress coding standards
    10 shares
    In this series, we're taking a look at the WordPress PHP Coding Standards in order further understand how quality WordPress code should be written. Sure, all of this is documented in the WordPress Coding Standards and it's a site that every WordPress developer should have bookmarked and on hand when working on a theme, a plugin, or an application; however, if you're just getting into WordPress development, then it's important to understand the rationale as to why the conventions are the way they are. In this article, we're going to be taking a look at the use of single quotes and double quotes specifically when dealing with strings. This may be the shortest, most straightforward article in the series, but it should cover some important nuances as it relates to working with single quotes, double quotes, and strings in WordPress.Read More…
  • Code
    The WordPress Coding Standards: Naming Conventions and Function ArgumentsThe wordpress coding standards
    8 shares
    In this series, we're taking a deep dive into the WordPress Coding Standards - specifically, the PHP coding standards - in order to evangelize and understand how quality WordPress code should be written. Despite the fact that this is documented within the WordPress Developer Handbook, I think there's something to be said for understanding the rationale behind why some things are the way that they are. Remember: Our ultimate goal is to make sure that we're writing code that conforms to the coding standards so that we, along with other developers, are able to more easily read, understand, and maintain code for themes, plugins, and applications built on top of WordPress. In this post, we're going to be taking a look at how to handle naming conventions and function arguments.Read More…