plugin-check icon indicating copy to clipboard operation
plugin-check copied to clipboard

Create Enqueued_Resources_Check

Open mehulkaklotar opened this issue 3 years ago • 1 comments
trafficstars

Description

Checks that all plugin scripts and styles are enqueued using core functions and not directly output in HTML. This will use the existing WordPress.WP.EnqueuedResources sniff in the WordPress Coding Standards.

Acceptance Criteria

  • Class Enqueued_Resources_Check should be created and exists at includes/Checker/Checks
  • Class Enqueued_Resources_Check should extend the Abstract_PHP_CodeSniffer_Check abstract class
  • Class should implement the public get_args() and return an associative array of the required PHPCS arguments
    • 'sniffs' => 'WordPress.WP.EnqueuedResources'
    • 'standard' => 'WordPress'
  • Add a sample <link> in the tests/testdata/plugins/test-plugin-with-errors\test-plugin-with-errors.php file to include any sample script. Make sure it will come under the WordPress.WP.EnqueuedResources error.

Tests Coverage

  • get_args() method returns the expected array of PHPCS arguments for the check
  • run() method adds warnings to the $check_result when checking an invalid file - check reference here
  • run() method does not add any warnings to the $check_result when checking a valid file - check reference here

mehulkaklotar avatar Nov 21 '22 14:11 mehulkaklotar

@felixarntz I have updated AC for this epic, and it is ready for review now. Thanks! 🙂

vishalkakadiya avatar Feb 08 '23 12:02 vishalkakadiya