Documentation

WordPressCodingStandards

Table of Contents

Classes

AbstractArrayAssignmentRestrictionsSniff
Restricts array assignment of certain keys.
AbstractClassRestrictionsSniff
Restricts usage of some classes.
AbstractFunctionParameterSniff
Advises about parameters used in function calls.
AbstractFunctionRestrictionsSniff
Restricts usage of some functions.
ArrayWalkingFunctionsHelper
Helper functions and function lists for checking whether a function applies a callback to an array.
FormattingFunctionsHelper
Helper functions and function lists for checking whether a function is a formatting function.
UnslashingFunctionsHelper
Helper functions and function lists for checking whether a function is an unslashing function.
ValidationHelper
Helper function for checking whether a token is validated.
WPGlobalVariablesHelper
Helper utilities for recognizing WP global variables.
WPHookHelper
Helper utilities for recognizing functions related to the WP Hook mechanism.
Sniff
Represents a PHP_CodeSniffer sniff for sniffing WordPress coding standards.
ArrayDeclarationSpacingSniff
Enforces WordPress array spacing format.
ArrayIndentationSniff
Enforces WordPress array indentation for multi-line arrays.
ArrayKeySpacingRestrictionsSniff
Check for proper spacing in array key references.
MultipleStatementAlignmentSniff
Enforces alignment of the double arrow assignment operator for multi-item, multi-line arrays.
AssignmentInTernaryConditionSniff
Detects variable assignments being made within conditions.
EscapedNotTranslatedSniff
Flag calls to escaping functions which look like they may have been intended as calls to the "translate + escape" sister-function due to the presence of more than one parameter.
CurrentTimeTimestampSniff
Don't use current_time() to get a (timezone corrected) "timestamp".
RestrictedFunctionsSniff
Forbids the use of various native DateTime related PHP/WP functions and suggests alternatives.
DirectDatabaseQuerySniff
Flag Database direct queries.
PreparedSQLPlaceholdersSniff
Checks for incorrect use of the $wpdb->prepare method.
PreparedSQLSniff
Sniff for prepared SQL.
RestrictedClassesSniff
Verifies that no database related PHP classes are used.
RestrictedFunctionsSniff
Verifies that no database related PHP functions are used.
SlowDBQuerySniff
Flag potentially slow queries.
FileNameSniff
Ensures filenames do not contain underscores and where applicable are prefixed with `class-`.
PrefixAllGlobalsSniff
Verify that everything defined in the global namespace is prefixed with a theme/plugin specific prefix.
ValidFunctionNameSniff
Enforces WordPress function name and method name format, based upon Squiz code.
ValidHookNameSniff
Use lowercase letters in action and filter names. Separate words via underscores.
ValidPostTypeSlugSniff
Validates post type names.
ValidVariableNameSniff
Checks the naming of variables and member variables.
DevelopmentFunctionsSniff
Restrict the use of various development functions.
DiscouragedPHPFunctionsSniff
Discourages the use of various native PHP functions and suggests alternatives.
DontExtractSniff
Restricts the usage of extract().
IniSetSniff
Detect use of the `ini_set()` function.
NoSilencedErrorsSniff
Discourage the use of the PHP error silencing operator.
POSIXFunctionsSniff
Perl compatible regular expressions (PCRE, preg_ functions) should be used in preference to their POSIX counterparts.
PregQuoteDelimiterSniff
Flag calling preg_quote() without the second ($delimiter) parameter.
RestrictedPHPFunctionsSniff
Forbids the use of various native PHP functions and suggests alternatives.
StrictInArraySniff
Flag calling in_array(), array_search() and array_keys() without true as the third parameter.
TypeCastsSniff
Verifies the correct usage of type cast keywords.
YodaConditionsSniff
Enforces Yoda conditional statements.
EscapeOutputSniff
Verifies that all outputted strings are escaped.
NonceVerificationSniff
Checks that nonce verification accompanies form processing.
PluginMenuSlugSniff
Warn about __FILE__ for page registration.
SafeRedirectSniff
Encourages use of wp_safe_redirect() to avoid open redirect vulnerabilities.
ValidatedSanitizedInputSniff
Flag any non-validated/sanitized input ( _GET / _POST / etc. ).
I18nTextDomainFixerSniff
Comprehensive I18n text domain fixer tool.
CastStructureSpacingSniff
Ensure cast statements are preceded by whitespace.
ControlStructureSpacingSniff
Checks that control structures have the correct spacing around brackets, based upon Squiz code.
ObjectOperatorSpacingSniff
Ensure there is no whitespace before/after an object operator.
OperatorSpacingSniff
Verify operator spacing, uses the Squiz sniff, but additionally also sniffs for the `!` (boolean not) and the boolean and logical and/or operators.
AlternativeFunctionsSniff
Discourages the use of various functions and suggests (WordPress) alternatives.
CapabilitiesSniff
Check that capabilities are used correctly.
CapitalPDangitSniff
Capital P Dangit!
ClassNameCaseSniff
Verify whether references to WP native classes use the proper casing for the class name.
CronIntervalSniff
Flag cron schedules less than 15 minutes.
DeprecatedClassesSniff
Restricts the use of deprecated WordPress classes and suggests alternatives.
DeprecatedFunctionsSniff
Restricts the use of various deprecated WordPress functions and suggests alternatives.
DeprecatedParametersSniff
Check for usage of deprecated parameters in WP functions and suggest alternative based on the parameter passed.
DeprecatedParameterValuesSniff
Check for usage of deprecated parameter values in WP functions and provide alternative based on the parameter passed.
DiscouragedConstantsSniff
Warns against usage of discouraged WP CONSTANTS and recommends alternatives.
DiscouragedFunctionsSniff
Discourages the use of various WordPress functions and suggests alternatives.
EnqueuedResourceParametersSniff
This checks the enqueued 4th and 5th parameters to make sure the version and in_footer are set.
EnqueuedResourcesSniff
Makes sure scripts and styles are enqueued and not explicitly echo'd.
GlobalVariablesOverrideSniff
Warns about overwriting WordPress native global variables.
I18nSniff
Makes sure WP internationalization functions are used properly.
PostsPerPageSniff
Flag returning high or infinite posts_per_page.

Traits

EscapingFunctionsTrait
Helper functions and function lists for checking whether an escaping function is being used.
IsUnitTestTrait
Helper utilities for sniffs which need to take into account whether the code under examination is unit test code or not.
MinimumWPVersionTrait
Helper utilities for sniffs which take the minimum supported WP version of the code under examination into account.
PrintingFunctionsTrait
Helper functions and function lists for checking whether a function prints output.
WPDBTrait
Helper utilities for sniffs which examine WPDB method calls.

        
On this page

Search results