WordPress: Quick Steps to Setup a Child Theme

WordPress has this neat feature called “Child theme” for a while now. I’m a big fan of this feature. It is important to use this when you are using a theme that you like but want some changes to it. If you work on the theme files directly, chances are you will overwrite the changes when new updates are pushed. I’ve done it before and since the child theme came out I’ve not had any issue with it anymore.

So, here I would show how to setup a child theme quick and easy. Say you are using “twentytwelve” theme as your primary theme. Now you (like me) want to make a change to the header file to add your own code – for example, some Google code to show translation bar. Here are the steps:

1. under your-wp-root/wp-content/themes/ create the directory you want to place the child theme files in

2. now go into your-wp-root/wp-content/themes/your-child-theme/ and create a file named style.css

3. in style.css you will need to put the following piece of comment:

/*
* Theme Name: YOUR CHILD THEME NAME
* Description: Modified 2012 Theme
* Author: Your Name
* Template: twentytwelve
* */

Line 5 is very important here. It tells WP which parent theme directory to use.

4. After the comment you will need to import the parent theme’s stylesheet in. You can either copy paste the entire style.css from twentytwelve directory, or put the following import code:

@import url(../twentytwelve/style.css);

5. Now you can copy header.php from your-wp-root/wp-content/themes/twentytwelve to your-wp-root/wp-content/themes/your-child-theme/. Make necessary changes to the file and you are good to go.

6. Last step (which you could have done before changing header.php file) is to activate the child theme. In WP admin, under Appearance > Themes look for the theme you’ve just created. Click on “Activate” to use it.

Only the modified files (like header.php) will be used from your child theme’s directory. You can always do these on your local machine, upload the directory via FTP and activate the theme; the steps above are just the way I do it – i.e. login via SSH and do these from command line.

For further reading you can click here.

 

Bangladeshi IT Professionals in Canada

Today I started a group with a fellow Bangladeshi IT professional in Canada, Junal Rahman, on Facebook called Bangladeshi IT Professionals in Canada (https://www.facebook.com/groups/bdpca/). We are trying to bring as many Bangladeshi IT Professionals in Canada as possible under one roof. The goal is to have members help each other, share their views, thoughts, and ideas.

By sharing – we believe – members will be able to collaborate and possibly start something new, exciting and productive. By doing so, we hope we can stand out of the crowd and proudly say we are from Bangladesh, and we are making changes.

We believe there is no shortage of talents from Bangladesh in the field of IT in Canada, and we can definitely get together to think big, and do even bigger things. Please spread the word, and invite your Bangladeshi friends, peers, family members who are IT professionals and living in Canada.

Thank you.

My two WordPress plugins

I’ve been using WordPress since 2005 when I decided to move away from my custom made blog. I’ve – since then – modified and created bunch of themes and plugins. Customized many plugins/themes to work the way I want it to work.

I’ve also published two WordPress plugins. I wrote both of them for my own purpose, but later decided to publish them on WordPress.org (visit my profile page on WP to download the plugins).

1. Recently Updated Pages

This plugin will let users add a sidebar widget where you can list WP pages you’ve recently modified. The sole purpose of this plugin was to list ONLY the pages, but after some requests from the users I’ve also added feature to list posts. I’ve couple of more features in works right now, one is to exclude pages/posts from listing under this widget. So far I’ve added an option in the post/page editor where user can opt-in/out of listing it under RUP widget. These features will be published soon.

2. Feedback Extended

I’ve recently published this plugin. Downloads for this plugin isn’t as aggressive as the RUP plugin but today it reached 100 downloads (woohoo!!).

This plugin only works with the Contact Form enabled under Jetpack 1.3 or higher. FE will add an extra option to reply from within the administrative area of WP to any contact received via the Jetpack Contact Form. These contact messages are stored under Feedback section in WP and FE will allow you to reply to the emails sent to you via WP site right from the admin area as long as WP installation can send emails using the server’s send mail service. There is no further feature I’ve in mind for this plugin.

Do you’ve any idea for a new plugin? Do you want someone to help you build a plugin? Please drop a line here and let’s have a chat about it. 

jQuery: Select Multiple Dropdown Items

Back in 2006 I posted a simple piece of Javascript code that would let you select multiple items from a dropdown (or multiselect box) to a textarea. This code has been very popular and people liked it as I can see from different forums being linked to this post.

Here is the same code, but it uses jQuery to do the job. Smaller piece of code than what I’d before. HTML piece remains same and here is the example:

 
 

HTML Code:

<form method=POST name='testing'>  
  <select name='testsel' multiple id='testsel'>  
    <option value="one">one</option>
    <option value="two">two</option>
    <option value="three">three</option>  
  </select>  
  <textarea id="txtEditions"></textarea>
</form>

jQuery Code:

<script type="text/javascript">
var glue = '+';
try {
	$('#testsel').change(function() {
		$('#txtEditions').val(($('#testsel').val()).join(glue));
	});
} catch(e) {
	console.log(e);
}
</script>

Rotate Logs for Apache on Linux using logrotate

Using Apache’s access_log and error_log files are useful. Not only a system administrator should use it, but also a developer should grow habit of using these log files for debugging purpose. But sometimes for high traffic web site/applications these files can grow HUGE and real fast.

In real life, you probably need log file up to a certain point. If anything goes wrong and you know about it immediately you will probably need the current log file plus few from past to compare. In case if you find out about an issue with the site/application a week later – then you should really think about how to fix that problem.

Anyhow, this article is to show you how you can tune pre-configured logrotate on linux system for apache (HTTPD) to meet your needs. Every path I’m going to refer here are based on CentOS 5.6 OS.

Usually the logrotate configuration file is located under /etc/logrotate.conf. But logroate also has individual configuration for different linux processed. One of them is Apache. By default the configuration looks like this:

/var/log/httpd/*log {
missingok
 notifempty
 sharedscripts
 postrotate
 /sbin/service httpd reload > /dev/null 2>/dev/null || true
 endscript
}

To understand what each of the items mean please refer to http://tinyurl.com/ansqol

For my purpose I just added two lines to have this:

/var/log/httpd/*log {
size=1024M
rotate 5
missingok
notifempty
sharedscripts
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}

size=1024M – The logs should be rotated when it is 1G in size.

rotate 5 – The logs are rotated 5 times before it is removed.

Thanks!