![]() ![]() This is a “soft” rule, but long lines generally indicate unreadable or disorganized code. Lines should usually be no longer than 80 characters, and should not exceed 100 (counting tabs as 4 spaces).No whitespace at the end of line or on blank lines.The minification process creates a file that is optimized for browsers to read and process. These rules encourage liberal spacing for improved developer readability. Use spaces liberally throughout your code. “Whitespace-only” patches for older files are strongly discouraged.Īll new or updated JavaScript code will be reviewed to ensure it conforms to the standards, and passes JSHint. js files simply to conform to the standards is not an urgent issue. While the coding standards are important, refactoring older. WordPress is working to gradually improve this, so the code will be clean and easy to read at a glance. Many parts of the WordPress code structure for JavaScript are inconsistent in their style. ![]() “ Code refactoring should not be done just because we can.” – Lead Developer Andrew Nacin Any of the below standards and examples should be considered best practice for WordPress code, unless explicitly noted as anti-patterns. Many of the examples below have been adapted directly from the jQuery style guide these differences have all been integrated into the examples on this page. jQuery’s 100-character hard line limit is encouraged, but not strictly enforced.Some whitespace rules differ, for consistency with the WordPress PHP coding standards.Function contents are consistently indented, including full-file closure wrappers.Case statements are indented within switch blocks.WordPress uses single quotation marks for string declarations.Our standard differs from the jQuery guidelines in the following ways: ![]() The WordPress JavaScript Coding Standards are adapted from the jQuery JavaScript Style Guide. – Principles of Writing Consistent, Idiomatic JavaScript Standards are needed for formatting and styling JavaScript code to maintain the same code consistency as the WordPress standards provide for core PHP, HTML, and CSS code.Īll code in any code-base should look like a single person typed it, no matter how many people contributed. JavaScript has become a critical component in developing WordPress-based applications (themes and plugins) as well as WordPress core. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |