In my experience, the way we first interact with the repository design pattern often influences how we think about the pattern. (The whole first impressions are lasting impressions, right?)
The purpose of this post is to show how it can be implemented in WordPress specifically when writing object-oriented plugins to read data (writing data may be covered in another post), but before doing that I tried to think of a few consistencies among the variations of the pattern that I’ve seen.
Generally speaking, this is what I think a repository pattern should do:
- provide a single place to read data,
- abstract the details of how the data is accessed,
- and have a consistent interface for doing so.
This means that whatever it is you need to retrieve from the application can be retrieved from the database. But how its retrieved can be considered a black box. That’s up to the developer implementing the pattern.
And in the case for those who read this post, that’s most likely us.
Continue reading “A General Example of the Repository Pattern in WordPress The repository pattern provides a consistent way for how data can be retrieved. Here’s how it can be implemented in a WordPress plugin.“
Although I think the title of this series and the articles for each are clear enough, there are other things I’m aiming to do with this series in contrast to the other series I’ve written up to this point, too.
Specifically, two of the things that I’m trying to do is to two:
- keep each article relatively succinct (in comparison to how previous articles have been),
- focus on one thing at a time and keep the description of it short.
Since this is membership content, I don’t mind it being a bit longer than usual, but I also don’t want it to be so long that it’s hard to follow. I’d rather it be a short read with something practical that you can implement after reading each post.
And one of the things that greatly helps with writing better WordPress code is Composer.
Continue reading “Tools for Writing Better WordPress Code: Composer A very basic introduction to Composer explaining its purpose and how you can use it to take advantage of autoloading.“
Recently, I was working on a project that was communicating with a third-party API that, like many APIs, sends back a lot of data part of which includes a URL for the product associated with the API.
The thing about the API that was being returned was not the proper destination URL. Instead, it was a URL that ultimately redirected to another URL.
So imagine hitting, say, acme.site-info.com and having it direct to acme.com. We do this manually all the time, but I needed to get the actual – or the final – destination of the direct from the URL.
And finding the destination of a redirect with PHP is easy; however, this does assume there’s only a single redirect.
Nonetheless, here’s how to do it.
Continue reading “Finding the Destination of a Redirect with PHP This solution for finding the destination of a redirect with PHP is easy but it assumes a single redirect.“
It’s been a while since I’ve published anything on a Monday (I don’t know if that’s notable or not but, as I’m writing this, it came to mind 🙃).
But since today officially starts the second quarter of the year it’s that time in which I also opt-out of social media, for the most part, and recap some of the things I’ve done and plan to do over the next month.
For those who haven’t read about this stuff before, you can see what I did last year in the following posts:
- The First Social Media Sabbatical of 2018
- The Second Social Media Sabbatical of 2018
- The Third Social Media Sabbatical of 2018
Every time I end up taking time off of social media in general, I never regret it. At the same time, I also find new things I want to do during that time.
And, this time, one of the things (among others I’ll discuss in a moment) is I want to work on really slimming down on the number of applications I have installed on my mobile device.
I’m already pretty good with managing my time (thanks to Screen Time and turning off notifications), but I have a good friend who said it like this:
I’m trying to Marie Kondo the number of apps on my phone.
And I liked that. So that’s part of what I’m planning to do over the coming month.
But that’s not all.
Continue reading “Time Off 2019: Part 1 of 4 of Social Media Sabbaticals Since I won’t have my usual social channels to talk about what’s up, I’m going to do so in this post.“
Two weeks ago, I started talking a bit about my concerns regarding privacy – which may be the same as yours – and decided I’d start running down a list of things that I’m trying, using, and doing to adhere more to privacy-centric software and services.
Here’s the thing though:
- what I’m comfortable with using may not be the same for you (and vice versa),
- and privacy and security are not terms that I use interchangeably.
Going into this series, I want to make sure I’m working off of a consistent definition of privacy. You can see the whole definition here but for the purpose of these articles, I’m going to be using the following:
Privacy grants us freedom from the public; concealed.
So any service that compromises that definition on any level would be something that violates privacy. Furthermore, it’s hard to find things that are purely private is near impossible so we have to make tradeoffs.
And I’m going to lead with that.
Continue reading “Privacy is Hard: Web Browsing Because private web browsing is related to development, then why not discuss it?“