Three Good Things

Three Good Things: Building and deploying a project with Laravel

David Nash laravel, linux, mysql, php 1 Comment

What do developers do in their spare time? Code! Three Good Things is a little app that I started over the holidays, and have been working on in my spare time. During the Christmas/New Year holiday period I read Flourish: A Visionary New Understanding of Happiness and Well-being, by Dr Martin Seligman. In it he describes an exercise called “What-Went-Well” (or “Three Blessings”). The idea is, every night you write three good things that happened in the last 24 hours, and why they happened. I thought it would be a good idea for an app, so I set to work. It was a …

How to create a select element option (drop-down) menu in the WordPress Theme Customizer

David Nash css, php, wordpress 2 Comments

I’m working on a project that requires the same basic theme for two companies that are both under the same group. The only real difference is the logo and theme colours. Instead of creating two separate themes and having to maintain them separately I used WordPress “customize_register” action in the theme’s functions.php. The official docs are here and very long and confusing. https://codex.wordpress.org/Theme_Customization_API WordPress provides some basic types like a text field, image upload and colour picker, but no select menu: https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control Here’s the code I’m using to create a select element with two options (in the theme’s functions.php file): …

Disable WordPress Theme “Update Available” Notification

David Nash wordpress 17 Comments

I’ve been customising a theme that had a new version, getting the message “There is a new version of … available”. I didn’t want the end-user to update the theme, because I’d customised it so heavily. I know that any updates are going to need to be done by a WordPress theme developer. After a while of searching through code, looking for add_action and add_filter hooks, and even delving into the database, I realised I could just edit the theme’s style.css and remove the “Version:” line from the WordPress specific CSS header right at the top. And the notification (and …

Pixel Perfect Firefox Extension

David Nash css, xhtml 0 Comments

When I write HTML and CSS I’ll usually create a mockup – I take a high quality JPG of the design and put it into a very simple page that shows the JPG, centered on the screen. Then in Firefox I switch back and forth between the page I’m working on and the mockup so that I can get the design pixel-perfect. Well today all that will change. I’ve discovered the Pixel Perfect Firefox Extension which allows me to overlay the mockup over what I’m designing.  You can set the opacity and quickly toggle the overlay on and off. I’m …

Dynamic Font/Image Replacement in Silverstripe

David Nash silverstripe, What I'm Working On Today 15 Comments

I’ve recently started creating sites with SilverStripe CMS, and I’m loving it. My client wants nicely rendered non-standard font titles that fade in and out, without using javascript. Here’s how I’m going to accomplish it: In Silverstripe’s mysite/code/Page.php I overload the onBeforeWrite() call in my Page class. This intercepts the data before it is written to the database. I can get the title of the updated page from $this->Title I will then use PHP’s GD (graphics) library to create a PNG with a transparent background. I’ll use imagettftext() to load a font from a TTF file and write it to …