You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 2020-09-25 Update code examples to use Markdown code fence notation instead of shortcodes.
3
4
- 2019-12-21 Update `javascript.md` from the [handbook page](https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/).
4
5
- 2019-12-21 Update `accessibility.md` from the [handbook page](https://make.wordpress.org/core/handbook/best-practices/coding-standards/accessibility-coding-standards/).
5
6
- 2018-01-14 Initial import from https://make.wordpress.org/core/handbook/best-practices/
If a Backbone class does not have an initialize function it should be documented by using @inheritDoc as follows:
197
197
198
-
[js]
198
+
```javascript
199
199
/**
200
200
* Summary. (use period)
201
201
*
@@ -220,15 +220,15 @@ If a Backbone class does not have an initialize function it should be documented
220
220
Class =Parent.extend( /**@lendsnamespace.Class.prototype*/{
221
221
// Functions and properties.
222
222
} );
223
-
[/js]
223
+
```
224
224
225
225
<blockquote>Note: This currently doesn't provide the expected functionality due to a bug with JSDoc's inheritDoc tag. See the issue <ahref="https://github.com/jsdoc3/jsdoc/issues/1012">here</a></blockquote>
226
226
<h2>Local functions</h2>
227
227
At times functions will be assigned to a local variable before being assigned as a class member.
228
228
Such functions should be marked as inner functions of the namespace that uses them using <code>~</code>.
229
229
The functions should be formatted as follows:
230
230
231
-
[js]
231
+
```javascript
232
232
/**
233
233
* Function description, you can use any JSDoc here as long as the function remains private.
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 <code>~</code>.
@@ -274,7 +274,7 @@ Class members should be formatted as follows:
274
274
<li><strong>@memberof:</strong> Optionally use this to override what class this is a member of.</li>
275
275
</ul>
276
276
277
-
[js]
277
+
```javascript
278
278
/**
279
279
* Short description. (use period)
280
280
*
@@ -287,7 +287,7 @@ Class members should be formatted as follows:
287
287
* @member{type}realName
288
288
* @memberofclassName
289
289
*/
290
-
[/js]
290
+
```
291
291
292
292
<h2>Namespaces</h2>
293
293
Namespaces should be formatted as follows:
@@ -299,7 +299,7 @@ Namespaces should be formatted as follows:
299
299
<li><strong>@property:</strong> Properties that this namespace exposes. Use a period at the end.</li>
300
300
</ul>
301
301
302
-
[js]
302
+
```javascript
303
303
/**
304
304
* Short description. (use period)
305
305
*
@@ -310,25 +310,25 @@ Namespaces should be formatted as follows:
310
310
*
311
311
* @property{type}key Description.
312
312
*/
313
-
[/js]
313
+
```
314
314
315
315
<h2>Inline Comments</h2>
316
316
Inline comments inside methods and functions should be formatted as follows:
317
317
<h3>Single line comments</h3>
318
318
319
-
[js]
319
+
```javascript
320
320
// Extract the array values.
321
-
[/js]
321
+
```
322
322
323
323
<h3>Multi-line comments</h3>
324
324
325
-
[js]
325
+
```javascript
326
326
/*
327
327
* This is a comment that is long enough to warrant being stretched over
328
328
* the span of multiple lines. You'll notice this follows basically
329
329
* the same format as the JSDoc wrapping and comment block style.
330
330
*/
331
-
[/js]
331
+
```
332
332
333
333
<strong>Important note:</strong> Multi-line comments must not begin with <code>/**</code> (double asterisk). Use <code>/*</code> (single asterisk) instead.
334
334
<h2>File Headers</h2>
@@ -338,7 +338,7 @@ Whenever possible, all WordPress JavaScript files should contain a header block.
338
338
339
339
WordPress uses JSHint for general code quality testing. Any inline configuration options should be placed at the end of the header block.
340
340
341
-
[js]
341
+
```javascript
342
342
/**
343
343
* Summary. (use period)
344
344
*
@@ -351,7 +351,7 @@ WordPress uses JSHint for general code quality testing. Any inline configuration
0 commit comments