By following the simple guidelines below it will make your pull request easier to merge.
Please read the following guidelines before opening an issue.
- Search for existing issues. Make sure that the same issue hasn’t already been reported and/or resolved.
- Create an isolated and reproducible test case. Be sure the problem exists in this repo’s code with a reduced test case that should be included in each bug report.
- Include a live example. Make use of jsBin or jsFiddle to share your isolated test cases.
- Share as much information as possible. Include operating system and version, browser and version, version of this code, etc. where appropriate. Also include steps to reproduce the bug.
- Fork it.
- Create your feature branch (
$ git checkout -b my-new-feature
). - Commit your changes (
$ git commit -am 'Add some feature'
). - Push to the branch (
$ git push origin my-new-feature
). - Create new Pull Request.
Tips:
- GitHub Flow in the Browser.
- Install EditorConfig plugin for your code editor.
- If you have commit access to this repository and want to make big change (or you’re not sure about something), create a new branch and open a pull request.
- CSS changes must be done in the “preprocessed” files; never edit the compiled files.
- If modifying the “preprocessed” files, be sure to generate and commit a compiled version of the code.
- Try not to pollute your pull request with unintended changes--keep them simple and small.
- When applicable, try to share which browsers your code has been tested in before submitting a pull request.
- If using Sublime Text, install DocBlockr. Here’s my DocBlockr preferences:
{
"jsdocs_align_tags": "no",
"jsdocs_spacer_between_sections": "after_description",
"jsdocs_newline_after_block": true,
"jsdocs_return_description": false,
"jsdocs_param_description": false
}
Unless otherwise noted, the code in this repo will be maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered with the following format:
<major>.<minor>.<patch>
… and constructed with the following guidelines:
- Breaking backward compatibility bumps the major (and resets the minor and patch).
- New additions, including new icons, without breaking backward compatibility bumps the minor (and resets the patch).
- Bug fixes and misc changes bumps the patch.
For more information on Semantic Versioning, please visit http://semver.org.
In general, and for anything not listed below, take care to maintain the existing coding style of the document(s) you’re editing.
Using
if (constant == variable)
instead ofif (variable == constant)
, likeif (4 == foo)
. Because it’s like saying “if blue is the sky” or “if tall is the man”.
Unless otherwise specified, please use K&R style indentation.
- Limit comment line lengths to 72 characters.
- Where applicable, use documentation style comments (jsdoc, phpdoc, etc.).
- Tabs for primary indentation alignment and then spaces on top of that for detail alignment.
Use tabs for outdents and spaces for lining things up. An example:
;(function($, window, document, undefined) {
'use strict';
// Tabs got us here …
var $foo,
$baz = TRUE,
bar = 'Foo!'; // … and spaces lined things up!
console.log(bar);
}(jQuery, window, document));
- Tabs for indentation.
- Double quotes only.
- Always quote attributes.
- Always use proper indentation.
- Use tags and elements appropriate for an HTML5 doctype.
- Please omit the
/
on self-closing tags.
Suggested (approximate) precedence of commonly used CSS properties:
selector {
font: value;
font-*: value;
color: value;
text-*: value;
letter-spacing: value;
word-spacing: value;
line-height: value;
list-*: value;
background: value;
background-*: value;
border: value;
border-*: value;
margin: value;
margin-*: value;
padding: value;
padding-*: value;
width: value;
height: value;
float: value;
display: value;
clear: value;
position: value;
left: value;
right: value;
top: value;
bottom: value;
overflow: value;
z-index: value;
-prefixed-and-css3: value;
}
- Multiple-line approach (one property and value per line).
- Always add a space after a property’s colon (.e.g,
display: block;
, notdisplay:block;
). - End all lines with a semi-colon.
- For multiple, comma-separated selectors, place each selector on its own line
- Attribute selectors, like
input[type="text"]
should always wrap the attribute’s value in double quotes, for consistency and safety (see this blog post on unquoted attribute values that can lead to XSS attacks). - For style definitions that contain a single
property: value;
, always put opening and closing curly braces on the same line (e.g.,.foo { property: value; }
). - Put IDs before class attributes and put both as close to the start of tag as possible, like:
<form id="foo" class="bar" action="http://foo.com" method="get">…</form> <!-- /#foo -->
. - Make sure all closing classes/IDs have an comment “identifier”, like:
<div class=".b1_ew"> … </div> <!-- /.b1_ew -->
; this make it easier to follow structure of generated HTML. Note that an#id
trumps a.class
when labeling the ending comment. If no#id
and multiple.class
es, use the first class as the comment label (assuming that it’s typically the most “important”).
- Tab indentation.
- Single-quotes.
- Semicolon.
- Strict mode.
- Always declare your variables with a var statement.
- One var statement per scope, and that it be at the top.
- Space after keywords and between arguments and operators.
- Don’t “equality overkill”.
- Avoid spaghetti code and try to have one exit point for methods.
- Always use curly braces around
if
s.
Follow PEP 8 – Style Guide for Python Code.
NOT!
Cushion nots like this:
<?php if ( ! is_wp_error($rss)): ?>
… not this:
<?php if(!is_wp_error($rss)): ?>
Cushion ifs:
See above.
Cushion spaces:
- Do not add cushion spaces, for example:
bloginfo( 'name' );
; this is prefered:bloginfo('name');
.
Comments:
- For indent-level single line comments, use a
#
character.- If the comment refers to the line after, append a “:” (colon) to end of comment (unless comment calls for some other sort of punctuation).
- For single line comments at the end of code lines, use
//
characters.- Because this comment refers to the line its on, put a period at end.
- For descriptive comments, it’s preferable to use DocBlock comment styles.
- From PEP8: “For flowing long blocks of text (docstrings or comments), limiting the length to 72 characters is recommended.” I’m not totally hardcore about this restriction, but I think it looks good and makes sense.
- For all comments, use proper capitalization and punctuation.
- Upper case AND, OR, AS, TRUE, FALSE, NULL, etc. Example:
foreach ($this->headers AS $key=>$value) { //… }
. - Curly braces may be omitted for single line
if
s,for
s,foreach
s, etc. Example:if ($foo) echo 'bar';
.
General example:
<?php
/**
* Description goes here.
*<---- If an empty line, no space here. Example:
*
* Note space on other side of astrix? That’s so it lines up with top/left-most `**`.
*/
//<----- No space here. Some IDEs will add space here if you hit return key after the `*/`.
global $page, $paged;
wp_title('|', TRUE, 'right');
# Add the blog name:
bloginfo('name');
# Add the blog description for the home/front page:
$site_description = get_bloginfo('description', 'display'); // Blah blah blah.
if ($site_description && (is_home() || is_front_page())) echo ' | ' . $site_description;
# Add a page number if necessary:
if ($paged >= 2 || $page >= 2) echo ' | ' . sprintf(__('Page %s', 'octavo'), max($paged, $page));
foreach ($authors AS $author) echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
?>
By contributing your code, you agree to license your contribution under the terms of the LICENSE found at the root of the repository.