Prefixes
In the framework everything is prefixed to prevent naming conflicts and to give a meaning to functions, classes and methods names.
Core
-
Public functions and classes should be prefixed with:
fw_for functionsFW_for classes
function 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');
Theme
-
Public functions and classes should be prefixed with:
fw_theme_for functionsFW_Theme_for classes
function fw_theme_head() {// ...}class FW_Theme_Pagination{// ...} -
Private functions and classes should be prefixed with:
_fw_theme_for functions_FW_Theme_for classes
/*** @internal*/function _fw_theme_private_function() {// ...}/*** @internal*/class _FW_Theme_Private_Class{// ...} -
Functions used for hooks should be prefixed with:
_action_theme_foradd_action()_filter_theme_foradd_filter()
/*** @internal*/function _filter_theme_the_content($content) {// ...return $content;}add_filter('the_content', '_filter_theme_the_content');/*** @internal*/function _action_theme_init() {// ...}add_action('init', '_action_theme_init'); -
Filters and actions should be prefixed with
fw_theme_.$data = apply_filters('fw_theme_whatever', $data);do_action('fw_theme_whatever');
Extensions
-
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 with:
_fw_ext_<extension-name>_for functions_FW_Ext_<extension-name>_for classes
-
Functions used for hooks should be prefixed with:
_action_fw_ext_<extension-name>_foradd_action()_filter_fw_ext_<extension-name>_foradd_filter()
For e.g. if extension name is
demo:/*** @internal*/function _filter_fw_ext_demo_the_content($content) {// ...return $content;}add_filter('the_content', '_filter_fw_ext_demo_the_content');/*** @internal*/function _action_fw_ext_demo_init() {// ...}add_action('init', '_action_fw_ext_demo_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');