Based on some advice I read[1], I have meticulously named all my plugin php files with my adopted plugin prefix, being ‘wpsm-‘ in this case. All my class files have the additional ‘class’ qualifier, making their prefix ‘wpsm-class-‘.

Now, while doing some early morning housekeeping, trying to get zoned into serious coding, I realised that as long as all my php files stay in my plugin’s folder, there is no reason to prefix them all, and removing the prefix actually improves readability. Further, if I place all my class files in a ‘code’ or ‘class’ folder, I don’t need the additional ‘class’ prefix.

What do readers of this question suggest for my naming conventions, in the context I describe above?

[1] Professional WordPress Plugin Development:

“When building a custom plugin, it’s essential that you prefix
everything with a unique prefix. This means all plugins files,
function names, variable names, and everything included with your
plugin.”

2 s
2

There’s certainly no need to name plugin files with prefixes (although some plugin authors like to do this). I suspect the advice you read was referring to functions within your plugin files. Structuring you plugin folders as you suggest (using a class folder) is fine.

See this link for more information on writing plugins:

http://codex.wordpress.org/Writing_a_Plugin

Specifically the section “Plugin Development Suggestions” towards the end where it says:

All the functions in your Plugin need to have unique names that are different from functions in the WordPress core, other Plugins, and themes. For that reason, it is a good idea to use a unique function name prefix on all of your Plugin’s functions. A far superior possibility is to define your Plugin functions inside a class (which also needs to have a unique name).

Leave a Reply

Your email address will not be published. Required fields are marked *