WordPress.org

Support

Support » Installation » Ideal location of plugin files

Ideal location of plugin files

  • The wordpress codex indicates that plugins should exist as one file within /wp-content/plugins/ and that extra files should exist inside /wp-content/

    I am writing a plugin that, for clarity, contains user-defined functions in a separate file. Should this be placed in wp-content and, if so, how is it then best to include() the file from the plugin? Using a relative path such as include(../user_funcs.php); ?

    The codex isn’t very clear on what you SHOULD do, just what you shouldn’t do, if someone could clear this up for me it would be greatly appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • From a user point of view, I would say that I don’t care where you put it as long as you document it well. Preferably document the functions and where they can be found in a readme file, not just in the code comments.

    Some plugins have their own directory inside the plugins folder… e.g. there is one main file placed in the /plugins/ folder and below it another folder containing its “subfiles”.

    I’ll agree with tomhanna on this one; documentation is of paramount importance – where files reside is incidental as long as the program can find them. And yes, while some of us are adept at deciphering commented code, a readme is preferable as the primary “line of defense”.

    It’s probably easiest for everyone — the users installing it, and you coding it — if you use a sub-directory inside /wp-content/plugins.

    The only thing to remember is that any translation file used to localize the plugin must live in the /wp-content/plugins/ directory, and not in your plugin’s sub-directory. This is an identified shortcoming with current versions of WordPress, and should be fixed in the next version.

    Thanks all for the responses, that’s cleared the matter up!
    I’ll be putting the I18N files in the ‘top’ level, and the rest of the plugin’s supprting files in a subdirectory.

    And, of course, writing a readme… 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Ideal location of plugin files’ is closed to new replies.
Skip to toolbar