Читать книгу Professional WordPress Plugin Development - Brad Williams - Страница 61
Naming Files
ОглавлениеWordPress has a strict guideline on how it names files. The standard is to write each character in lowercase and separate multiple words with hyphens. For example, you might have a group of user‐related functions in your plugin. You'd want to name that file something like functions‐users.php
.
WordPress also prefixes class filenames with class‐
. The PDEVSetup
or PDEV_Setup
class from the previous section in this chapter would be named class‐pdev‐setup.php
following the WordPress standard.
Again, this is where WordPress deviates from the standards within the PHP community. At some point, you'll likely want to use an autoloader, such as the one provided by Composer (https://getcomposer.org
). Once you do that, you'll quickly realize that the best method of naming class files is for the filename to match the class name exactly because it simplifies the autoloader code and keeps you from having to write a custom implementation. In this case, you should name the file for the PDEVSetup
class as PDEVSetup.php
.