Prefix Everything in WordPress Coding

Simple but very important rule in the WordPress development practices is to Prefix Everything. It means,
  • Suppose your project i.e. theme or plugin name is WPGear
  • You should prefix everything with wpgear_ in WordPress coding.

Examples

Functions:

function wpgear_featured_content() {
  // ...
}

Classes:

class WPGear_Counter {
  // ...
}

Variables:

$wpgear_color = '';

It is very simple concept that you should prefix everything with your project. It will be helpful in avoiding any possible conflict with the coding of other plugins or themes.

Why Prefix Everything:

WordPress is a masterpiece open source software. Many developers release and maintain awesome plugins or themes daily. So, in the global namespace it is very easy to have a conflict with other codes if you fail to prefix your code.

You can read an excellent article on prefix everything here.

Comments

Popular posts from this blog

Top 7 Reasons to Switch to WordPress

Best Free Minimalist WordPress Themes 2017