docs/best-practices/coding-standards/naming-conventions.md
WooCommerce core generally follows WordPress PHP naming conventions.
There are some additional conventions that apply, depending on the location of the code.
/srcClasses defined inside /src follow the PSR-4 standard. See the README for /src for more information.
The following conventions apply to this directory:
Automattic\WooCommerce namespace.CamelCase convention.snake_case convention.class- prefix.woocommerce_.snake_case convention.For example, the class defined in src/Util/StringUtil.php should be named StringUtil and should be in the Automattic\WooCommerce\Util namespace.
/includesThe /includes directory contains legacy code that does not follow the PSR-4 standard. See the README for /includes for more information.
The following conventions apply to this directory:
WC_.Upper_Snake_Case convention.wc_.snake_case convention.woocommerce_.snake_case convention.Class name examples:
WC_Cache_HelperWC_CartFunction name examples:
wc_get_product()wc_is_active_theme()Hook name examples (actions or filters):
woocommerce_after_checkout_validationwoocommerce_get_formatted_order_totalWooCommerce core follows WordPress JS naming conventions.
As with PHP, function, class, and hook names should be prefixed, but the convention for JS is slightly different.
WC. Class names exported from modules are not prefixed.UpperCamelCase convention.wc. Function names exported from modules are not prefixed.camelCase convention.woocommerce.camelCase convention.Global class name example:
WCOrdersTableGlobal function name example:
wcSettings()Hook name example (actions or filters):
woocommerceTracksEventProperties