Tag Archives: Wordpress

If you store WordPress code on Github think about your wp-config.php

If you store WordPress code on Github inside of a public repository all your code is public. Most people know and accept this, but people either don’t realise that their database credentials get stored inside the php file wp-config.php or they do and forget to exclude it from their repository.

This means that if you do a simple Google search for site:github.com master/wp_config.php password blob DB_PASSWORD you will find a whole rake of folk with their passwords on display.

Obviously it is impossible to tell if they are just sample details or real details, but it is still crumby practice and if you do it you really need to stop now.

I will be contacting people I find to let them know, but please pass this message on to any WordPress/GitHub users you know.

Share this on

I just made an affiliate program.

It is amazing what a few hours of concentrated work can do for you.

Months ago me and my buddy who work together on TFT were talking about the idea of an affiliate program for our users – to try and encourage them to promote the site amongst friends and family, and to maybe entice some of the bigger websites to send some traffic our way.

At the time I thought it would be a neat little project, but once I started listing the edge cases I noticed that this would be a bit of a slog to get right.

A combination of work and family issues stopped me from looking or even thinking about the affiliate program until recently, when my friend brought it up again.

This time instead of thinking about all the edge cases and worrying about replicating what some of the bigger affiliate systems do I brought it right back to basics.

I asked myself two questions.

  1. What is an affiliate system at its most basic form.
  2. What is the least amount of effort I can put in (both long and short term) in order to achieve this.

After spending maybe an hour mulling these questions over I had come up with a solution that would work.

5 hours later I had written, tested, debugged and deployed a solution that will work and will only need minor time investment to scale should we need to.

It won’t win any awards for being the most complete affiliate program in the world, but it will allow my users to make some money from the site and ultimately put more money into my pocket.

Normally I would love to go into the technical details of what I done, but how I have had to work it is such an edge case that I couldn’t possibly see it being useful to anyone. The short version is that it speaks to a couple of WordPress plugins and PayPal and to be honest will never win me a programmer of the year award.

Share this on

Useful WordPress Links

Here is a collection of articles I have found useful for various WordPress development issues.

I will add to the list over time to be sure to bookmark the post.

(Last Edited 01/04/12)

Getting custom menus into your theme – A nice introductory article by the guys at Think Vitamin.

Adding sub-page information into a parent page – This handy little code sippet comes straight from the Codex and allows you to add child page information into the layout for your parent page.

Customise the WordPress Admin Area – A guide on customising the WordPress Admin Area, useful when removing things useless to the client you are developing for.

Useful WordPress Themes, Tools and Plugins – A really big list from Smashing Magazine with links to various WordPress related content.

5 Ways to including templates in WordPress – A nice quick rundown of ways you can include template files.

Cheers to Paul for proving some of the links.

Share this on

Accessing PHP variables from within JavaScript under WordPress

Accessing PHP variables from within JavaScript under WordPress is so easy it is almost trivial.  Having said that, I didn’t know there was a way to do it until I asked on the WordPress StackExchange site.

I will show you what you need to do by way of an example.  Let us suppose we need the site URL in our JavaScript code.

It is a two step process, the first step is in your PHP;

wp_enqueue_script('my_script');
$data = array('site_url' => __(site_url()));
wp_localize_script('my_script', 'php_data', $data);

So what we have done there is enqueued our script (named here, my_script) and once we have done that we set up our data array. In our case the property is site_url and it’s contents are going to be the result of site_url(). Once we have that we can call wp_localize_script, into it we pass the name of our script, the name we want to give our JavaScript object and the data we want to pass in.

Next we want to be able to access the data, so in your JavaScript file you can simply call the following (if you wanted to alert out the site URL!)

alert(php_data.site_url);

Really, really easy and really, really handy!

For more information please see the official reference.

Share this on

WordPress Cheat Sheet

I found this sheet last night and have already made use of it.  This PDF document lists all of the common WordPress functions and whilst it isn’t as comprehensive as it could be it is certainly a handy thing to have about when a function name is on the tip of your tongue!

Download the cheat sheet from Ekin Ertac.

Share this on