The WordPress coreCoreCore is the set of software required to run WordPress. The Core Development Team builds WordPress. development team builds WordPress! Follow this site for general updates, status reports, and the occasional code debate. There’s lots of ways to contribute:
Found a bugbugA bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority.?Create a ticket in our bug tracker.
Warning: This page has been moved here Please do not edit this page, use edit on the new page.
WordPress follows the JSDoc 3 standard for inline JavaScriptJavaScriptJavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. documentation.
Short descriptions should be clear, simple, and brief. Document “what” and “when” – “why” should rarely need to be included. The “why” can go in the long description if needed. For example:
Functions and closures are third-person singular elements, meaning third-person singular verbs should be used to describe what each does.
Tip: Need help remembering how to conjugate for third-person singular verbs? Imagine prefixing the function, hook, class, or method summary with “It”:
Good: “(It) Does something.”
Bad: “(It) Do something.”
Functions: What does the function do?
Good: Handles a click on X element.
Bad: Included for back-compat for X element.
@since: The recommended tool to use when searching for the version something was added to WordPress is svn blame.
If, after using these tools, the version number cannot be determined, use @since Unknown.
Code Refactoring: Do not refactor code in the file when changes to the documentation.
Descriptive elements should be written as complete sentences. The one exception to this standard is file header summaries, which are intended as file “titles” more than sentences.
The serial (Oxford) comma should be used when listing elements in summaries, descriptions, and parameter or return descriptions.
The following guidelines should be followed to ensure that the content of the doc blocks can be parsed properly for inclusion in the code reference.
Short descriptions:
Short descriptions should be a single sentence and contain no markup of any kind. If the description refers to an HTML element or tag, then it should be written as “link tag”, not “<a>”. For example: “Fires when printing the link tag in the header”.
Long descriptions:
Markdown can be used, if needed, in a long description.
@param and @return tags:
No HTML or markdown is permitted in the descriptions for these tags. HTML elements and tags should be written as “audio element” or “link tag”.
DocBlock text should wrap to the next line after 80 characters of text. If the DocBlock itself is indented on the left 20 character positions, the wrap could occur at position 100, but should not extend beyond a total of 120 characters wide.
Summary: A brief, one line explanation of the purpose of the function. Use a period at the end.
Description: A supplement to the summary, providing a more detailed description. Use a period at the end.
@deprecated x.x.x: Only use for deprecated functions, and provide the version the function was deprecated which should always be 3-digit (e.g. @since 3.6.0), and the function to use instead.
@since x.x.x: Should be 3-digit for initial introduction (e.g. @since 3.6.0). If significant changes are made, additional @since tags, versions, and descriptions should be added to serve as a changelog.
@access: Only use for functions if private. If the function is private, it is intended for internal use only, and there will be no documentation for it in the code reference.
@class: Use for class constructors.
@augments: For class constuctors, list direct parents.
@mixes: List mixins that are mixed into the object.
@alias: If this function is first assigned to a temporary variable this allows you to change the name it’s documented under.
@memberof: Namespace that this function is contained within if JSDoc is unable to resolve this automatically.
@static: For classes, used to mark that a function is a static method on the class constructor.
@see: A function or class relied on.
@link: URL that provides more information.
@fires: Event fired by the function. Events tied to a specific class should list the class name.
@listens: Events this function listens for. An event must be prefixed with the event namespace. Events tied to a specific class should list the class name.
@global: Marks this function as a global function to be included in the global namespace.
@param: Give a brief description of the variable; denote particulars (e.g. if the variable is optional, its default) with JSDoc @param syntax. Use a period at the end.
@yield: For generator functions, a description of the values expected to be yielded from this function. As with other descriptions, include a period at the end.
@return: Note the period after the description.
/**
* Summary. (use period)
*
* Description. (use period)
*
* @since x.x.x
* @deprecated x.x.x Use new_function_name() instead.
* @access private
*
* @class
* @augments parent
* @mixes mixin
*
* @alias realName
* @memberof namespace
*
* @see Function/class relied on
* @link URL
* @global
*
* @fires eventName
* @fires className#eventName
* @listens event:eventName
* @listens className~event:eventName
*
* @param {type} var Description.
* @param {type} [var] Description of optional variable.
* @param {type} [var=default] Description of optional variable with default variable.
* @param {Object} objectVar Description.
* @param {type} objectVar.key Description of a key in the objectVar parameter.
*
* @yield {type} Yielded value description.
*
* @return {type} Return value description.
*/
Backbone’s extend calls should be formatted as follows:
@lends This tag will allow JSDoc to recognize the extend function from Backbone as a class definition. This should be placed right before the Object that contains the class definition.
Backbone’s initialize functions should be formatted as follows:
Summary: A brief, one line explanation of the purpose of the function. Use a period at the end.
Description: A supplement to the summary, providing a more detailed description. Use a period at the end.
@deprecated x.x.x: Only use for deprecated classes, and provide the version the class was deprecated which should always be 3-digit (e.g. @since 3.6.0), and the class to use instead.
@since x.x.x: Should be 3-digit for initial introduction (e.g. @since 3.6.0). If significant changes are made, additional @since tags, versions, and descriptions should be added to serve as a changelog.
@constructs Marks this function as the constructor of this class.
@augments: List direct parents.
@mixes: List mixins that are mixed into the class.
@requires: Lists modules that this class requires. Multiple @requires tags can be used.
@alias: If this class is first assigned to a temporary variable this allows you to change the name it’s documented under.
@memberof: Namespace that this class is contained within if JSDoc is unable to resolve this automatically.
@static: For classes, used to mark that a function is a static method on the class constructor.
@see: A function or class relied on.
@link: URL that provides more information.
@fires: Event fired by the constructor. Should list the class name.
@param: Document the arguments passed to the constructor even if not explicitly listed in initialize. Use a period at the end.
Backbone Models are passed attributes and options parameters.
Backbone Views are passed an options parameter.
Class = Parent.extend( /** @lends namespace.Class.prototype */{
/**
* Summary. (use period)
*
* Description. (use period)
*
* @since x.x.x
* @deprecated x.x.x Use new_function_name() instead.
* @access private
*
* @constructs namespace.Class
* @augments Parent
* @mixes mixin
*
* @alias realName
* @memberof namespace
*
* @see Function/class relied on
* @link URL
* @fires Class#eventName
*
* @param {Object} attributes The model's attributes.
* @param {type} attributes.key One of the model's attributes.
* @param {Object} [options] The model's options.
* @param {type} attributes.key One of the model's options.
*/
initialize: function() {
//Do stuff.
}
} );
If a Backbone class does not have an initialize function it should be documented by using @inheritDoc as follows:
At times functions will be assigned to a local variable before being assigned as a class member.
Such functions should be marked as inner functions of the namespace that uses them using ~.
The functions should be formatted as follows:
/**
* Function description, you can use any JSDoc here as long as the function remains private.
*
* @alias namespace~doStuff
*/
var doStuff = function () {
// Do stuff.
};
Class = Parent.extend( /** @lends namespace.Class.prototype */{
/**
* Class description
*
* @constructs namespace.Class
*
* @borrows namespace~doStuff as prototype.doStuff
*/
initialize: function() {
//Do stuff.
},
/*
* This function will automatically have it's documentation copied from above.
* You should make a comment ( not a DocBlock using /**, instead use /* or // )
* noting that you're describing this function using @borrows.
*/
doStuff: doStuff,
} );
At times classes will have Ancestors that are only assigned to a local variable. Such classes should be assigned to the namespace their children are and be made inner classes using ~.
@since x.x.x: Should be 3-digit for initial introduction (e.g. @since 3.6.0). If significant changes are made, additional @since tags, versions, and descriptions should be added to serve as a changelog.
@access: If the members is private, protected or public. Private members are intended for internal use only.
@type: List the type of the class member.
@property List all properties this object has in case it’s an Object. Use a period at the end.
@member: Optionally use this to override JSDoc’s member detection in place of @type to force a class member.
@memberof: Optionally use this to override what class this is a member of.
@namespace: Marks this symbol as a namespace, optionally provide a name as an override.
@since x.x.x: Should be 3-digit for initial introduction (e.g. @since 3.6.0). If significant changes are made, additional @since tags, versions, and descriptions should be added to serve as a changelog.
@memberof: Namespace that this namespace is contained in.
@property: Properties that this namespace exposes. Use a period at the end.
/*
* This is a comment that is long enough to warrant being stretched over
* the span of multiple lines. You'll notice this follows basically
* the same format as the JSDoc wrapping and comment block style.
*/
Important note: Multi-line comments must not begin with /** (double asterisk). Use /* (single asterisk) instead.