Skip to main content
1 of 1
shabushabu
  • 952
  • 7
  • 9

All my plugins follow this structure, which seems to be very similar to what most other devs are doing:

plugin-folder/
    admin/
        css/
            images/
        js/
    core/
    css/
        images/
    js/
    languages/
    library/
    templates/
    plugin-folder.php
    readme.txt
    changelog.txt
    license.txt

plugin-folder.php is then usually a class that loads all required files from the core/ folder. Most often on the init or plugins_loaded hook.

I used to prefix all my files as well, but as @kaiser noted above, it's really redundant and I've recently decided to remove it from any future plugins.

The library/ folder holds all external helper libraries that the plugin might depend on.

Depending on the plugin, there might be an uninstall.php file in the plugin root as well. Most of the time this is being handled via register_uninstall_hook(), though.

Obviously, some plugins might not require any admin files or templates, etc, but the structure above works for me. In the end you just have to find a structure that works for you and then stick with it.

I also have a starter plugin, based on the structure above that I use as a starting point for all my plugins. All I need to do then is do a search/replace for function/class prefixes and off I go. When I was still prefixing my files that was an extra step I had to do (and quite annoying at that), but now I just have to rename the plugin folder and the main plugin file.

shabushabu
  • 952
  • 7
  • 9