In both theme and plugin everything is prefixed to prevent naming conflicts and to give a meaning to functions, classes and methods names. See the guidelines below.
Important
Prefix everything! Lack of proper prefixes is a frequent theme reject reason. Read more: Reject Reasons
In theme development, a unique and more than 2 letters prefix is required by ThemeForest reviewers, therefore the prefix to use in a theme is fw_ct_bee_
for variables, functions, classes, and fw-ct-bee-
for styles, image sizes, db options etc.
Functions and classes should be prefixed with:
fw_ct_bee_
for functionsFW_Ct_Bee
for classesfunction fw_ct_bee_head() { // ... } class FW_Ct_Bee_Pagination { // ... }
Private functions and classes should be prefixed the same way due to ThemeForest standards
Functions used for hooks should be prefixed with:
fw_ct_bee_action_
foradd_action()
fw_ct_bee_filter_
foradd_filter()
/** * @internal */ function fw_ct_bee_filter_the_content($content) { // ... return $content; } add_filter('the_content', 'fw_ct_bee_filter_the_content'); /** * @internal */ function fw_ct_bee_action_init() { // ... } add_action('init', 'fw_ct_bee_action_init');
Filters and actions should be prefixed with fw_ct_bee_
.
$data = apply_filters('fw_ct_bee_whatever', $data); do_action('fw_ct_bee_whatever');
Public functions and classes should be prefixed with:
fw_ext_<extension-name>_
for functionsFW_Ext_<extension-name>_
for classes
Private functions and classes should be prefixed the same way due to ThemeForest standards
Functions used for hooks should be prefixed with:
fw_ext_<extension-name>_action_
foradd_action()
fw_ext_<extension-name>_filter_
foradd_filter()
For e.g. if extension name is
demo
:/** * @internal */ function fw_ext_demo_filter_the_content($content) { // ... return $content; } add_filter('the_content', 'fw_ext_demo_filter_the_content'); /** * @internal */ function fw_ext_demo_action_init() { // ... } add_action('init', 'fw_ext_demo_action_init');
Filters and actions should be prefixed with 'fw_ext_<extension-name>_'
.
For e.g. if extension name is
demo
:$data = apply_filters('fw_ext_demo_whatever', $data); do_action('fw_ext_demo_whatever');
Public functions and classes should be prefixed with:
fw_
for functionsFW_
for classesfunction fw_useful_function() { // ... } class FW_Useful_Class { // ... }Note
A Public function is meant to be used by anyone. Usually it’s a helper function that does something useful.
Private functions and classes should be prefixed with:
_fw_
for functions_FW_
for classes/** * @internal */ function _fw_private_function() { // ... } /** * @internal */ class _FW_Private_Class { // ... }Note
A private function is used somewhere internally. Don’t forget to use the @internal tag in your PhpDoc in order to make it clear to other developers that this is a private function. It will also remove the function from your documentation (if you are using an automatic documentation generator)
Functions and methods used for hooks should be prefixed with:
_action_
foradd_action()
_filter_
foradd_filter()
/** * @internal */ function _action_init_something() { // ... } add_action('init', '_action_init_something');Important
Be sure the function name is unique enough in order to minimize the chances to be defined by someone else. Do not use too simple function names like
_action_init
.class FW_Example { public function __construct() { add_filter('the_content', array($this, '_filter_the_content')); } /** * @internal */ public function _filter_the_content($content) { // ... return $content; } }
Filters and actions should be prefixed with 'fw_'
.
$data = apply_filters('fw_whatever', $data); do_action('fw_whatever');