One-liners: Stopping all your docker containers

Let’s say you have multiple docker projects on your laptop and in the course of a day you bounce around between them. It’s easy to forget which ones have been shut down and which haven’t. If you’re using docker-compose this could mean several containers are running and eating your battery. Here’s a simple one-liner to shut them all down.

docker ps -q | xargs docker stop

Obfuscate Your Code at Your Own Risk

Looks like ZippyKid no longer supports WishList Member. I think it raises a good point about obfuscating code. Hiding your code behind some sort of encryption like Base64 may prevent your code from being ripped off, but it also prevents it from being improved and supported. If WLM made it’s code transparent it could share the burden of support and innovation with other services and developers. ZippyKid/WP Engine/WPMU/ and on and on. But the obfuscation instead guarantees this vast community of resources can be of no benefit to WLM at all. I hope it’s worth it.

WordPress Portable Database Caching Class

So here’s a little library/class that I wrote to make caching a little easier from project to project. WordPress requires a plugin like W3 Total Cache to be in place for “persistent” caching to be available … that is, caches of data that survive longer than the current page view. But sometimes when you’re building a complex custom project there are some queries you know could be safely cached regardless of the global caching setup. With this class you can build it right into your theme or plugin.

Why WordPress?

I assume other developers often ponder this question. In a practical sense, the answer is “because it’s what you know”. But I’m pondering a bigger question. As a developer with a keen interest in PHP should I waste my time with WordPress? Can you ever get “respect” as a PHP developer when your tool of choice is WordPress?

WordPress is a dinosaur compared to most of the popular custom PHP frameworks. Frameworks like Codeigniter,Kohana and others are very light weight and scalable. They generally focus on concepts like OOP (object-oriented programming) and MVC (model-view-controller). Code reusability and encapsulation are priorities not luxuries.

WordPress is a vestige of  PHP before PHP had a robust object-oriented structure. As such it is mostly a collection of libraries of functions. Of course, with every new release these function are streamlined and improved. But ultimately WordPress is always going to be a procedural framework.

So if you’re interested in PHP why waste your time with a code base that will never be the vangard of PHP development?

Well, for one, just because WordPress core is less than impressive from a PHP point of view, does not mean that cutting edge approaches to coding are not implemented via plugins. Plugins are essentially little custom apps that tie into the WordPress API. But as such there are lots of plugins that exemplify flexible and cutting edge approaches to code development.

For instance, there’s a plugin out there the integrates Doctrine ORM with WordPress. Doctrine is a “Object-Relational-Mapping” interface that aims to cleanup how PHP interacts with Databases. Sure WordPress core doesn’t have a Database Abstraction layer, but if your interested you can use Doctrine in your plugins!

PodsCMS, one of my favorite plugins, is another one that pushes better code into WordPress. Pods is capable of managing massive complexity in WordPress content, but itself is a very light-weight, Object-Oriented framework. Moreover, PodsCMS, while not entirely MVC, at least separates code from markup which is a feature sorely lacking in WordPress core.

Other plugins, among them Shopp (an e-commerce plugin) and GravityForms, take very Object-Oriented approaches to coding. So just because there are limitations to WordPress core, does not mean developers passionate about PHP cannot excel and flourish. If anything, the lack of cutting edge PHP in WordPress creates a tremendous opportunity for hard core PHP developers.

But why? Why drive a station wagon when you could be driving a sport car? Well, because you have places to go and things to do … and people to take with you. The simple reality is that there’s a huge market for WordPress development. A bigger market than just about any other out-of-the-box CMS. And that means an opportunity develop good code for good projects.

So if you’re a WordPress developer and want to branch out into custom PHP, my advice is first, learn the WordPress way of doing things. Then forget the WordPress way of doing things. Experiment with custom frameworks and try to find ways to incorporate the innovations into the WordPress projects you’re working on.

And most importantly, don’t be afraid to NOT use WordPress for a project or two. Getting outside your comfort zone is what gets your  creative juices flowing.

Jmapping : Jquery plugin for Google Maps

Need to quickly integrate Google Maps with a series of posts? Try using JMapping. The easy part of this Jquery plugin is that you really don’t have to know much Jquery. Just loop through your posts with the right html syntax and POW! it happens. There are other jquery approaches that are more flexible … but they require considerably more knowledge.