A lot of PHP developers involved with WordPress projects, especially those developing plugins, opt for using Composer. Not only for requiring libraries they can use, but also for autoloading classes and even files inside the plugin. However, some prefer to keep distance from Composer when dealing with WP coding. No problem, if this is your […]
Using the singleton pattern to deal with constraints
Almost any WordPress or PHP programmer, even in his early days, has some contact with the Singleton design pattern. For obvious reasons, this is maybe the first PHP pattern learnt from those who study for developing using this language. Regardless any discussion on the “antipattern” aspect of the Singleton, the reality is that most applications […]
Woocommerce – a much better way of checking if an user has purchases
This week one of our partners needed to implement a simple script for checking whether an user, in a Woocommerce website, had ever purchased anything. Searching the internet forums, he came up with the most bizarre solutions. Some scripts used direct MySQL queries to get such data, while some others relied in a “foreach” to […]
Couldn’t we make wp_insert_post smarter? – Part I
WordPress legacy and functional programming actually makes all websites, those hundreds of millions using this CMS in the world, stay alive. However, for those who use to manage and build a lot of websites, some routines prove to be a pain in the arse. While inserting or updating posts is not complex, it remains laborious. […]
Some WordPress native functions for dealing with arrays
Arrays are one of the most common types used in CMS scripts, which includes WordPress. Data is usually managed through arrays, so any functions that help us deal with them is welcomed. PHP itself has dozens of array-focused functions, but for some operations we still need to combine them and build processes that reach our […]
Creating a custom post type helper class
Custom post types are one of the most crucial feature in WordPress. The way a developer can manipulate the platform’s API is fantastic, and complex systems can be created from developing new types, contents and structures. Having that said, the mechanism for adding and altering post types in WordPress hasn’t changed much over the years. […]
Using Symfony and WP_Query to return multiple formats
It’s not rocket science using WP_Query to return objects from posts in WordPress. Also, it’s relatively simple encoding or normalizing the responses to use data as associative arrays or JSON. However, there are many reasons why we could prefer our queries to return in different formats: JSON itself, XML, CSV our even Yaml. I personally […]
Why using CMB2 over ACF?
Dealing with custom fields and meta fields in WordPress is a daily part of the job for any WordPress developer. Although most devs and that includes some of the houses that sell popular plugins still rely on Advanced Custom Fields to manage custom fields, maybe we should move to CMB2 instead. Don’t take me wrong: […]
WP_List_Util, a WP native class to handle operations on arrays
Sometimes we rely on PHP’s native functions and methods to solve problems in WordPress. In some of those cases, we definitely ask ourselves why there are no WP functions or classes to keep things “home”. Arrays can be managed in uncountable ways. However, sometimes we want just to use the WP core functions and keep […]
Singletons, Multitons – how and why limiting class instances?
If you have been following our posts, you probably noticed that this content is definitely not for those looking for the “best plugins” for WP or trying to find ways to troubleshoot problems not rarely caused by those same plugins. At the same time, we are not targetting experienced and top notch PHP developers or […]