How to setup tab completions for WP-CLI commands

WP-CLI is the command line interface for WordPress. If you have not setup WP-CLI yet, see steps to setup WP-CLI.

There is tab completions feature which is generally missed in the installation process. Here are the easy few steps to add tab completions for the WP-CLI. I am using Ubuntu here for example. But it would be similar for UNIX environment.

You need to have bash file for setting up autocomplete in the terminal. WP-CLI has already provided bash file. You can download it from Github repo of WP-CLI.

Put that downloaded wp-completion.bash file under the folder you like. Say you keep under completions in your Home directory.
/home/nilambar/completions/wp-completion.bash

Now, open your .bashrc file with your favorite text editor.
vi ~/.bashrc

In that file, put code to source your completion file. Syntax will be similar to:
source /FULL/PATH/TO/wp-completion.bash

In our example, it would be:
source /home/nilambar/completions/wp-completion.bash

Save your file and close it. Now you need to source your bashrc file to activate your new code for the terminal. source ~/.bashrc

Then restart the terminal.

Its that simple, no? But it will be very handy to use WP-CLI. I am sure you will love it.

Custom Logo Implementation in WordPress 4.5

Custom Logo is one of the awesome features of WordPress 4.5. You can see release detail of WordPress 4.5 “Coleman” here. Detail of Custom Logo is here. This link gives you detailed explanation of declaring support for Custom Logo and parameters available.

I needed to update my theme to use Custom Logo. But my all themes has logo option available. Image field was provided in the Customizer for logo. In the implementation of this new feature, existing logo was not supposed to be lost. So, I had to add new update script which will import old logo if set by use in existing theme.

Earlier, logo was displayed like following. Logo was saved in theme mod with key site_logo.

Update script I used is given below. I have tried to comment each step as much as possible as inline comments. Continue reading

Making Theme Accessibility Ready in WordPress

accessibility-keyboard-mac-windows

Accessibility means access generally. Accessibility in web design means creating web pages that everyone can use, regardless of disability or special needs, use and benefit from everything within their environment.

According to Wikipedia:

Accessibility refers to the design of products, devices, services, or environments for people with disabilities. The concept of accessible design ensures both “direct access” (i.e. unassisted) and “indirect access” meaning compatibility with a person’s assistive technology (for example, computer screen readers).

In WordPress, there is a mission to make WordPress accessible to everyone including the more than one billion humans with disabilities. And regular progress shows that this mission will be achieved in near future.

After hearing so much about Accessibility in WordPress, I wanted to try it in my theme also. So I decided to make my free theme Simple Life accessible. I was new and I did not know anything about making theme accessible. After spending few hours learning about key elements under Accessibility, I started modifying my theme. Honestly speaking, it took some iterations to finally make my theme fully accessible but I learned a lot in the process and I am happy about that. I want to share some points which are important while developing accessible WordPress theme or plugin. Continue reading