Читать книгу Professional WordPress Plugin Development - Brad Williams - Страница 59

Naming Variables and Functions

Оглавление

Variables and functions should always be written in snake case. All characters should be written in lowercase, and multiple words should be separated with an underscore. Functions and variables in the global namespace should also be preceded with a unique prefix for your plugin, such as pdev_. The following example is the correct way to write a function:

<?php function pdev_function( $param_a ) { // Do stuff. }

$param_a isn't in the global scope there, so it doesn't need a prefix. While it's considered bad practice to use global variables, if you do use them, make sure to prefix.

Professional WordPress Plugin Development

Подняться наверх