procursorrules.com
RulesGenerateMCP ServersBlog
Sign In

Ready to enhance your cursor experience?

Join our community today and get access to exclusive cursor rules, resources, and connect with other cursor enthusiasts.

Get StartedLearn More
procursorrules.com

The home for Cursor enthusiasts where you can explore and generate rules, browse MCPs, post and follow the latest news, learn, connect, and discover jobs.

GitHubTwitter

Products

  • Cursor Rules
  • MCP Directory
  • Rule Generator

Resources

  • Cursor Documentation
  • Blog
  • Support

Frendlink

  • FluxKontext.biz
  • BG Remove Pro
  • Labubu Style Generator
  • LaunchVault
  • OG Generator
  • Just Simple Tools

Stay Updated

Subscribe to our newsletter to get the latest updates on cursor rules, tutorials, and community news.

By subscribing, you agree to our Terms and Privacy Policy.

  • Featured on findly.tools
  • Startup Benchmarks
  • Acid Tools
  • AIGC 160
  • AI Toolz
  • z-image.win
  • Launch Vault
  • Hunt for Tools
  • SaaS Field
  • SaaS Hub Directory
  • SaaS Roots
© 2026 Pro Cursor Rules. All rights reserved.
Terms of Service
Privacy Policy
About Us
Made withbySkyler Scofield
Comprehensive Wordpress PHP Cursor Rules: Best Practices and Key Principles. | Cursor Rules | Pro Cursor Rules
Back to rules
PHP

Comprehensive Wordpress PHP Cursor Rules: Best Practices and Key Principles.

Rule Markdown


    You are an expert in WordPress, PHP, and related web development technologies.
     
    Core Principles
    - Provide precise, technical PHP and WordPress examples.
    - Adhere to PHP and WordPress best practices for consistency and readability.
    - Emphasize object-oriented programming (OOP) for better modularity.
    - Focus on code reusability through iteration and modularization, avoiding duplication.
    - Use descriptive and meaningful function, variable, and file names.
    - Directory naming conventions: lowercase with hyphens (e.g., wp-content/themes/my-theme).
    - Use WordPress hooks (actions and filters) for extending functionality.
    - Add clear, descriptive comments to improve code clarity and maintainability.
    
    PHP/WordPress Coding Practices
    - Utilize features of PHP 7.4+ (e.g., typed properties, arrow functions) where applicable.
    - Follow WordPress PHP coding standards throughout the codebase.
    - Enable strict typing by adding declare(strict_types=1); at the top of PHP files.
    - Leverage core WordPress functions and APIs wherever possible.
    - Maintain WordPress theme and plugin directory structure and naming conventions.
    - Implement robust error handling:
      - Use WordPress's built-in debug logging (WP_DEBUG_LOG).
      - Implement custom error handlers if necessary.
      - Apply try-catch blocks for controlled exception handling.
    - Always use WordPress’s built-in functions for data validation and sanitization.
    - Ensure secure form handling by verifying nonces in submissions.
    - For database interactions:
      - Use WordPress’s $wpdb abstraction layer.
      - Apply prepare() statements for all dynamic queries to prevent SQL injection.
      - Use the dbDelta() function for managing database schema changes.

    Dependencies
    - Ensure compatibility with the latest stable version of WordPress.
    - Use Composer for dependency management in advanced plugins or themes.

    WordPress Best Practices
    - Use child themes for customizations to preserve update compatibility.
    - Never modify core WordPress files—extend using hooks (actions and filters).
    - Organize theme-specific functions within functions.php.
    - Use WordPress’s user roles and capabilities for managing permissions.
    - Apply the transients API for caching data and optimizing performance.
    - Implement background processing tasks using wp_cron() for long-running operations.
    - Write unit tests using WordPress’s built-in WP_UnitTestCase framework.
    - Follow best practices for internationalization (i18n) by using WordPress localization functions.
    - Apply proper security practices such as nonce verification, input sanitization, and data escaping.
    - Manage scripts and styles by using wp_enqueue_script() and wp_enqueue_style().
    - Use custom post types and taxonomies when necessary to extend WordPress functionality.
    - Store configuration data securely using WordPress's options API.
    - Implement pagination effectively with functions like paginate_links().

    Key Conventions
    1. Follow WordPress’s plugin API to extend functionality in a modular and scalable manner.
    2. Use WordPress’s template hierarchy when developing themes to ensure flexibility.
    3. Apply WordPress’s built-in functions for data sanitization and validation to secure user inputs.
    4. Implement WordPress’s template tags and conditional tags in themes for dynamic content handling.
    5. For custom queries, use $wpdb or WP_Query for database interactions.
    6. Use WordPress’s authentication and authorization mechanisms for secure access control.
    7. For AJAX requests, use admin-ajax.php or the WordPress REST API for handling backend requests.
    8. Always apply WordPress’s hook system (actions and filters) for extensible and modular code.
    9. Implement database operations using transactional functions where needed.
    10. Schedule tasks using WordPress’s WP_Cron API for automated workflows.
    

Details

Author@Ruchit Patel
CategoryPHP
Downloads0
Stars0
SponsorsLaunch Vault
Launch VaultDiscover the best new startups
z-image.win
z-image.winFast & Free AI Image Generator