17

What is the wordpress wp-includes folder for? That is, whats the fundamental architectural purpose of it, for example why isn't it all in themes or an admin folder?

Can a plugin developer rely in it's contents (e.g. jQuery) and for how long?

I would also like to know, who decides what goes in there and how does it get maintained as Wordpress changes, any is all this documented somewhere as a policy doc?

5 Answers 5

20

wp-includes contains everything needed to run WordPress via the frontend ( and then some ). It is the territory of WordPress Core, and as the adage goes, never modify core under any circumstances.

While wp-content may define plugins and themes, the API itself and the vast majority of the WordPress core sits in that folder. These are depended on by almost the entirety of WordPress. All your standard functions and their dependencies will be found in this folder.

This makes it a valuable resource for research and looking up things.

wp-admin may define additional items but it is not as vital to the running of the frontend

./wp-admin    - Admin code
./wp-content  - User-defined code and content
./wp-includes - Common files

As for how reliable the files are in that folder, you shouldn't rely on the files in that folder. You should never need to include a file or path from wp-includes and if you attempt to or need to, then you have done something horribly wrong and need to stop and go back.

While the files in that folder may change without warning, this should be of no consequence, as the API contained is kept backwards compatible for a significant amount of time.

Outside of updates to WordPress, wp-includes should never be modified and should ideally be read only.

Should you need to add a dependency to your code, rely on the versions in wp-includes rather than adding your own. e.g. don't include a custom jQuery, use the one bundled with WordPress ( don't de-register it and re-register it either ).

Modifications to wp-includes can cause security risks, performance degradation, broken plugins/themes, etc

Changes to the packages and libraries included are announced ahead of releases. Old dependencies no longer required (such as the old colour picker) are kept, but marked deprecated to prevent code breakage

5

The wp-includes directory includes the packages that are included by core. The core team maintains the packages included in wp-includes. Themes and Plugins can rely on those packages being available for any given version of WordPress.

That's a huge reason why it is extremely important to enqueue only core-bundled versions of scripts, using the core-defined script registration, such as: wp_enqueue_script( 'jquery' ), so that your Theme/Plugin will always be using the version bundled with core, no matter what version of WordPress is running.

3

WordPress, as an application, is built of several moving parts. The /wp-includes folder contains common functionality for the WordPress API (which you use in themes/plugins) and the WordPress admin.

So, basically:

./wp-admin    - Admin code
./wp-content  - User-defined code and content
./wp-includes - Common files

The /wp-includes directory is where useful 3rd party libraries (i.e. SimplePie for RSS and IncutioRPC for XML-RPC) are stored. It's also where much of the WordPress API (i.e. WP_Http, WP_Filesystem) is defined.

Can a plugin developer rely in it's contents? and for how long?

Yes. These files are what defines the WordPress API in the first place. The core team goes to great lengths to retain backwards compatibility, so if any changes are ever introduced in WordPress that will break what you're using, you'll know aobut it well beforehand.

I would also like to know, who decides what goes in there and how does it get maintained as Wordpress changes, any is all this documented somewhere as a policy doc?

Decisions for WordPress' API are defined by the development team. You can usually follow changes on http://make.wordpress.org/core. Libraries are always maintained since changing these libraries is what changes WordPress.

1
  • Not the files define the API, the functions and classes in those files do that. The files might move or vanish without any changes to the API.
    – fuxia
    Commented Dec 4, 2012 at 16:25
0

wp-includes is the directory that contains most of WordPress' main functionality. It's where all the major WordPress code lives.

WordPress does an excellent job of maintaining backwards compatibility between versions. You can use the functions included in this folder to build plugins with (that's how you hook into the system).

WordPress Trac is the main area that decides how WordPress moves forward, so if you have opinions/additions, get involved there :)

0

The Make WordPress Core handbook has a handy page titled The WordPress Codebase, which provides a good overview of How Code In WordPress Is Organized, including:

wp-includes

The wp-includes directory consists of the primary core and third-party libraries for WordPress. Many of these files are loaded as the application is bootstrapped.

The files in wp-includes go by a (mostly) standard set of prefixes and suffixes:

  • class-*.php – PHP classes. Some of these are external libraries.
  • ms-*.php – Code specific to WordPress multisite functionality.
  • default-*.php – Code that implements or defines default functionality, namely constants, widgets, and filters.
  • *deprecated.php – Functions which are deprecated.
  • *-template.php – Template functions for the relevant API.

The files in wp-admin/includes follow similar naming conventions.

and

wp-admin/includes

The wp-admin/includes directory consists of the primary core and third-party libraries available and used in the administration area. Some of these are loaded as the admin is bootstrapped; see wp-admin/includes/admin.php for the primary list of files included.

and more... check it out 2022 peoples! :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.