- Follow the WordPress Coding Standards for PHP, HTML, CSS, and JavaScript.
- Use spaces for indentation, with four spaces per level.
- Limit lines to 80 characters where possible.
- Use
snake_casefor functions, methods, and variables;CamelCasefor classes. - Name files with lowercase letters and hyphens (e.g.,
class-exelearning-admin.php). - Include a file header in all PHP files with a brief description and author information.
- Write comments in clear and concise English.
- Use PHPDoc blocks for all functions, methods, classes, and files.
- Use inline comments sparingly to explain non-obvious parts of the code.
- Write self-documenting code with meaningful names.
- Avoid magic numbers; use constants or descriptive variables instead.
- Use a Test-Driven Development (TDD) approach where possible.
- Write unit tests with PHPUnit for PHP and Jest for JavaScript.
- Integrate testing into the development workflow, running tests automatically before merging.
- Use Git with feature branches for version control.
- Write clear, concise commit messages in English, using the imperative mood.
- Submit pull requests for all changes, ensuring review before merging.
- The main plugin file should be named
exelearning.php. - Place each class in its own file, named
class-pluginname-component.php(e.g.,class-exelearning-admin.php). - Place admin-specific functionality in the
admindirectory, including classes, assets, and templates. - Place shared functions, utilities, and custom post types in the
includesdirectory. - Place public-facing functionality in the
publicdirectory. - Store translation files in the
languagesdirectory. - Place tests in the
testsdirectory.
- Define plugin-specific constants in the main plugin file (
exelearning.php). - Use the WordPress options API for configuration, following a consistent naming scheme.
- Validate all user inputs and sanitize outputs using WordPress functions like
sanitize_text_field()andesc_html(). - Use WordPress nonces for form submissions and AJAX requests to prevent CSRF attacks.
- Use the plugin's slug as the text domain (e.g.,
exelearning). - Wrap all user-facing text in translation functions like
__(). - Use WordPress translation functions like
__(),esc_html_e(),_n(), and_x()for all user-facing strings.
- Ensure that all classes, methods, and functions are well-documented with PHPDoc.
- The
README.txtshould provide a detailed overview, including installation instructions, usage, and a changelog.