If you’ve read this blog for any length of time, specifically in the last two or three years, then you know I’m a fan of object-oriented programming especially so in the context of WordPress.
And if you’ve followed me on Twitter, you know that – like many of you – I’ve met many people who I consider to be legitimate friends (versus the bastardization of the phrase by sites such as Facebook)
On top of that, you know one of my favorite past times on Twitter is trolling said friends. So far, though, this entire post is all about my friends and me and, ahem, trolling.
So what’s the point?
Ultimately, it’s to give you a heads up something that’s been released today, that’s been a long time in the making, that’s finally available, and that’s going to help anyone who wants to be a better WordPress developer.
Continue reading “Discover Object-Oriented Programming Using WordPress Discover Object-Oriented Programming Using WordPress is something that should be in any WordPress developer’s library.“
Because of the open-source nature of WordPress, one of the luxuries that many of us are used to having is complete control over the environment in which we’re working. Given that, you might even say that we take certain aspects of WordPress for granted.
And I’d say that for the majority of projects on which we work, this is true.
By that, I mean we’re not only able to customize, extend, and even limit the software (for certain types of users), we’re also able to change certain aspects of its configuration.
But if you’re in the business of doing work for others – an employer, as part of a contractor, or in some other situation – you may be limited in just how much customization you’re able to make.
Continue reading “Taking Aspects of WordPress for Granted When you’re used to having complete control over an environment and it’s revoked, what then?“
The Pods Framework for WordPress, a specific utility that’s been around for a long time, offers a lot of functionality that can make working with advanced content types, custom settings, and so on.
I mention this because Pods is a popular utility and there are some features available that provide some nice functionality.
Through the use of shortcodes, it’s possible to perform some powerful database queries to retrieve information to populate forms dynamically.
One use case that I see showing up in a few results is how to populate a shortcode with the current user’s ID. There’s a forum post about it here and a continued discussion about it on Stack Overflow, too.
But if you’re looking for a way to filter the content to do this without reworking some of the existing shortcodes, there’s another way to do it.
Continue reading “Use the Current User ID with Pods for WordPress One way to filter the post content to get the current user ID with Pods for WordPress.“
If you’re used to working with models (in any foundation or framework, but specifically WordPress), then there’s a chance that you may need to serialize an instance of the model at some point.
Sure, writing the class to a database using PHP’s built-in functions is easy enough; however, introducing a bit of flexibility especially as it relates to making it available on other platforms is important.
For example, let’s say you’re building an application on WordPress that’s going to have some type of unique piece of information represented in a model. The model will then be accessible via a mobile application through the REST API.
Arguably, one of the easiest ways to get this done is to use JSON. It’s a format that works across various languages and platforms, can be easily serialized and de-serialized by said platforms, and sent across the wire as needed.
And it’s incredibly easy to implement this in PHP. You just need to make sure your class implements the JsonSerializable interface.
From the documentation, the interface does the following:
Objects implementing JsonSerializable can customize their JSON representation when encoded with json_encode().
The only method a class needs to provide is jsonSerialize, and though it’s likely you will want to serialize all of the properties of an object (as well as its state whenever its called), you can customize the implementation however you’d like.
Continue reading “WordPress Class Serialization with PHP Using the JsonSerializable Interface, adding WordPress class serialization is really easy.“
Generally speaking, whenever I work with custom post type pagination, it’s done so by writing a custom query using WP_Query and then calling wp_reset_postdata() at the end of The Loop.
I still think this has its place, but there is a simpler solution that you may be able to implement using a specific hook that WordPress provides.
Continue reading “WordPress Custom Post Type Pagination If you’re working with custom post type pagination and don’t want to deal with a custom query, this may work.“