WordPress.org

Ready to get started?Download WordPress

Forums

Ideal location of plugin files (6 posts)

  1. denyerec
    Member
    Posted 8 years ago #

    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!

  2. tomhanna
    Member
    Posted 8 years ago #

    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.

  3. moshu
    Member
    Posted 8 years ago #

    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".

  4. vkaryl
    Member
    Posted 8 years ago #

    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".

  5. skippy
    Member
    Posted 8 years ago #

    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.

  6. denyerec
    Member
    Posted 8 years ago #

    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... :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.