Category 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

How I use MindNode to help craft blog posts

I wanted to write a quick post about how I plan out my blog posts, which I will admit is a little meta – but with so many people writing their thoughts on things in a blog format I thought it would be interesting to start up a conversation on how different people do it.

I use a brain storming tool called MindNode to plan out my posts. It lets you quickly get down what you are thinking into small nodes, which you can attach sub nodes to.

The best way to explain this is of a screenshot, and I figured the best way to do this would be to screenshot the MindNode I made for this post!

As you can see I can quickly map out what I think an article might end up containing, this is a really quick way to decide if there are enough talking points to continue writing the full article or not, most of the time I have found you can easily get 20-50 words out of an individual node.

You might also have noticed that each child node is to the left of its parent node, this is by design. After I have created the MindNode I use it as a todo list, this makes everything really easy to track as I can just move the completed nodes to the right, like so.

If you have paid attention to the images you will know what I am going to talk about next!

I like using MindNode because:

  • It makes you focus the points of your blog post – this can help you to avoid waffle or repeating yourself.
  • It can exhaust the points you wish to explore – if you just start writing the article you could find yourself getting to the conclusion by skipping a few steps.
  • It is quick to do – It is almost as quick as jotting them down your ideas on a notebook, only your notebook can’t be synced with Dropbox!

Once I have moved everything over to the right hand side I know I am pretty much done with the article.

If you write content in a blog format I would love to know what you do to prepare it and what tools you use, please leave a comment here or on Hacker News, or on Reddit.

And for completeness, here is my final MindNode!

Thanks for reading!

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

Gotta love the google font API

I had read some tweets earlier today about the Google Font API and thought I would check it out.

Normally the way these things go down is I view the demos and have every intention of trying it myself but there are usually just a couple too many steps involved for the time I have allotted to dicking around the interwebs but this was so quick and so straight forward that I have eliminated cufon from this site in about 5 minutes.

Here are the steps I used;

  1. Follow the link above.
  2. Click on the font you want.
  3. Click get the code.
  4. Copy and paste the link into the head of your page.
  5. Update your CSS with a copy/paste.
  6. Done! (well, I also had to jump onto WordPress and turn off Cufon in a settings page, but that is specific to my template.)

I am not a designer so I don’t really know if those fonts are any good or not from a design point of view, but the potential for breaking away from the standard websafe fonts is huge!

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