Mapping series – Working with Algolia Places address autocompletion api

For a recent mapping project I implemented Algolia Places for address autocompletion┬áto turn an address into latitude and longitude for querying the database. In the past we’ve used Google Maps, but since this project wasn’t using Google Maps for the map display, using the Places API just for Geocoding is against their terms of use.…

Avoiding permissions problems when creating Zip files in PHP

A typical PHP snippet to create a Zip file looks something like this: $zip = new ZipArchive(); $zipname = ‘package_name.zip’; if ( true === $zip->open( $zipname, ZipArchive::CREATE ) ) { $zip->addFromString( ‘file_name.txt’, $file_contents ); $zip->close(); header( ‘Content-Type: application/zip’ ); header( ‘Content-disposition: attachment; filename=’ . $zipname ); header( ‘Content-Length: ‘ . filesize( $zipname ) ); readfile(…

Extending WP CLI – wp config update

One gap in the abilities of WP CLI at the moment is the ability to modify an already existing wp-config.php file. v1.2 introduced the –force flag to overwrite an existing one, but that is the sledgehammer option – so I started working on it myself. I have put a very initial version on GitHub and…

Displaying you WordPress.org favourite plugins

Updated 02 – 05 – 18: plugins object is now returned as an array. On a whim this May bank holiday, tucked up on the sofa watching movies, I decided to create a plugin to display my favourited plugins on WordPress.org. After a bit of digging I found you can use the plugins_api() function and…

Using Garlic.js with TinyMCE WYSIWYG editor

Garlic.js is a great library – it uses localStorage to save the state of forms, so if your users accidentally close the tab or browser before submitting, their entry isn’t lost. This works seemlessly for almost all form elements, however WYSIWYG editors like TinyMCE present problems. Luckily it isn’t hard to fix – there’s a…

Uses of modulus – rows for grids and background colours

There are two things that designers will throw out quite often – box grids with rows, and repeating background colours. Sounds easy – but go and try it within the WordPress loop (or any other). It can get ugly quickly, but the solution is actually simple: Modulus. In PHP it’s the % sign. To see…