1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: false
5
+ ---
6
+ ---
7
+ description: WPForms Cursor General Rules
8
+ globs:
9
+ alwaysApply: true
10
+ ---
11
+ By default use git repository in plugins directory.
12
+
13
+ # General code style rules:
14
+ - Use tabs instead of spaces for indentation at the beginning of the line.
15
+ - Comments in the code must be in English and end with a period.
16
+
17
+ # Core Principles
18
+ - Adhere to PHP and WordPress best practices for consistency and readability.
19
+ - Emphasize object-oriented programming (OOP) for better modularity.
20
+ - Focus on code reusability through iteration and modularization, avoiding duplication.
21
+ - Use descriptive and meaningful functions, variables, and file names.
22
+ - Follow existing project directory naming conventions.
23
+ - Use WordPress hooks (actions and filters) to extend functionality.
24
+ - Add explicit, descriptive comments to improve code clarity and maintainability.
25
+
26
+ # PHP/WordPress Coding Practices
27
+ - Utilize features of PHP 7.2+ where applicable.
28
+ - Follow WordPress PHP coding standards throughout the codebase.
29
+ - Values inside parentheses must have one space between value and each parenthesis. This is also required for brackets and curly braces.
30
+ - Leverage core WordPress functions and APIs wherever possible.
31
+ - Maintain WordPress theme and plugin directory structure and naming conventions.
32
+ - Implement robust error handling:
33
+ - Use WordPress's built-in debug logging (WP_DEBUG_LOG).
34
+ - Apply try-catch blocks for controlled exception handling.
35
+ - Always use WordPress's built-in functions for data validation and sanitization.
36
+ - Ensure secure form handling by verifying nonces in submissions.
37
+ - For database interactions:
38
+ - Use WordPress's $wpdb abstraction layer.
39
+ - Apply prepare() statements for all dynamic queries to prevent SQL injection.
40
+ - Use the dbDelta() function to manage database schema changes.
41
+
42
+ # JavaScript
43
+ - Use short arrow function syntax.
44
+
45
+ # Dependencies
46
+ - Ensure compatibility with the latest stable version of WordPress.
47
+ - Use Composer for dependency management in advanced plugins or themes.
48
+
49
+ # WordPress Best Practices
50
+ - Use WordPress's user roles and capabilities to manage permissions.
51
+ - Apply the transients API to cache data and optimize performance.
52
+ - Follow best practices for internationalization (i18n) by using WordPress localization functions.
53
+ - Apply proper security practices such as nonce verification, input sanitization, and data escaping.
54
+ - Manage scripts and styles by using wp_enqueue_script() and wp_enqueue_style().
55
+ - Store configuration data securely using WordPress's options API.
56
+
57
+ # Key Conventions
58
+ - Follow WordPress's plugin API to extend functionality in a modular and scalable manner.
59
+ - Apply WordPress's built-in functions for data sanitization and validation to secure user inputs.
60
+ - For custom queries, use $wpdb or WP_Query for database interactions.
61
+ - For AJAX requests, use admin-ajax.php or the WordPress REST API to handle backend requests.
62
+ - Always apply WordPress's hook system (actions and filters) for extensible and modular code.
63
+ - Implement database operations using transactional functions where needed.
0 commit comments