When you’re developing a WordPress plugin, there are certain patterns and practices that are extremely useful to know and apply in order to get a better fit with the platform as a whole.
One of these things it’s what’s the better way to initialize a class on a plugin, which this answer on the WordPress StackExchange covers in great detail, while also explaining other interesting topics and recommendations such as using an autoloader and global access, registry and service locator patterns.
While you’re at it, you might also want to check these posts from Tom McFarlin:
Design superhero John Maeda is now working at Automattic as Global Head, Computational Design and Inclusion because he believes in the open web…
The fact that so many people are commenting about it on Facebook, just proves how hard his new mission is… And how easy is to just not “get” why it’s so important.
Basic Authentication it’s often used as a simple security measure or as a temporary authentication method while developing with certain APIs.
While the WordPress HTTP API doesn’t have explicit support for basic authentication, it’s still possible to use it as a header:
$request = wp_remote_post(
'body' => array( 'foo' => 'bar' ),
'headers' => array(
'Authorization' => 'Basic '. base64_encode( $username .':'. $password )
Remember that if you’re sending an unencrypted request, all the headers will be sent in plain text, so you should only use it over HTTPS.
Many people (by which I mean “many Windows users”) don’t realize the huge difference between “the Windows way of doing things” and, basically, everyone elses’ way, i.e: the POSIX world which comprises all of the Unices, Linux, BSD and even OS X.
Hugo Landau writes:
From the perspective of POSIX, Windows is “alien technology” […] Windows and POSIX are fundamentally different in many ways, and lead to further “cultural” differences in how software is developed on these platforms. Windows and POSIX, then, are two “cultures”, the technical differences of the core technology itself being only a small part of that.
Read the entire piece at: The Cultural Defeat of Microsoft
Envoy is a task runner originally developed for Laravel, but that you can also use on any other kind of project.
It’s a very easy way to define tasks with Blade syntax and simple terminal commands, which you can run on remote servers via SSH (including parallel execution) or locally.
Thanks to its simplicity, it’s great to quickly automate repetitive tasks. For instance, this is something I use for importing a replica of the production DB of a site:
@servers(['production' => 'foobar.com', 'local' => 'localhost'])
@task('dump-production-db', ['on' => 'production'])
echo 'Creating production DB dump';
mysqldump --no-autocommit --skip-extended-insert --single-transaction --ignore-table=foobar.wp_simple_history_contexts --ignore-table=foobar.wp_simple_history_history foobar_production | gzip > foobar.production.sql.gz
@task('get-production-db', ['on' => 'local'])
echo 'Copying DB dump from production server';
rsync -P foobar:~/ddbb/foobar.production.sql.gz .
@task('import-production-db', ['on' => 'local', 'confirm' => true])
gzip -d -f foobar.production.sql.gz
sed 's/www.foobar.com/www.foobar.lo/g' -i foobar.production.sql
echo 'Importing production DB replica';
mysql -v foobar_development < foobar.production.sql
Jared Friedman from Scribd explains why he wouldn’t use Rails for a new company.
His main reasons are:
- Ruby is slow — yup, even PHP with HHVM it’s faster
- Rails is static while others have caught up
- There are better new alternatives
The Unicode Common Locale Data Repository it’s “the largest and most extensive repository of locale data available”, so it’s pretty much the perfect solution when you need information such as:
- Currency values, with ISO codes and visualization formats
- Dates and times patterns, including timezones
- List of “territories”, countries, continents, etc. with their corresponding languages, currencies
- Translations of all of the above
You can get their data from their Downloads page in XML format (follow the links in the Data column) or, if you prefer JSON, you may the Releases on their GitHub repository.
The JSON data it’s also available for use with NPM or bower.