sdc-build-wp 4.1.0 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composer.json +2 -3
- package/composer.lock +3 -313
- package/index.js +38 -21
- package/lib/blocks.js +8 -6
- package/lib/style.js +17 -0
- package/package.json +1 -1
- package/vendor/composer/autoload_classmap.php +0 -37
- package/vendor/composer/autoload_psr4.php +0 -1
- package/vendor/composer/autoload_real.php +2 -0
- package/vendor/composer/autoload_static.php +0 -53
- package/vendor/composer/installed.json +1 -329
- package/vendor/composer/installed.php +3 -39
- package/vendor/composer/platform_check.php +26 -0
- package/lib/bustCache.js +0 -14
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md +0 -22
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md +0 -285
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/composer.json +0 -71
- package/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php +0 -637
- package/vendor/phpcsstandards/phpcsextra/CHANGELOG.md +0 -590
- package/vendor/phpcsstandards/phpcsextra/LICENSE +0 -165
- package/vendor/phpcsstandards/phpcsextra/Modernize/Docs/FunctionCalls/DirnameStandard.xml +0 -40
- package/vendor/phpcsstandards/phpcsextra/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +0 -382
- package/vendor/phpcsstandards/phpcsextra/Modernize/ruleset.xml +0 -5
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Docs/Arrays/ArrayBraceSpacingStandard.xml +0 -94
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Docs/Arrays/CommaAfterLastStandard.xml +0 -43
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php +0 -305
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php +0 -226
- package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/ruleset.xml +0 -5
- package/vendor/phpcsstandards/phpcsextra/README.md +0 -573
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/DisallowShortArraySyntaxStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/DuplicateArrayKeyStandard.xml +0 -44
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/MixedArrayKeyTypesStandard.xml +0 -40
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/MixedKeyedUnkeyedArrayStandard.xml +0 -31
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/DisallowAnonClassParenthesesStandard.xml +0 -24
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/DisallowFinalClassStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/ModifierKeywordOrderStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/RequireAnonClassParenthesesStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/RequireFinalClassStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/ConstructorDestructorReturnStandard.xml +0 -64
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/ForeachUniqueAssignmentStandard.xml +0 -26
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoDoubleNegativeStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoEchoSprintfStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml +0 -43
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/LowercaseClassResolutionKeywordStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/ModifierKeywordOrderStandard.xml +0 -30
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/UppercaseMagicConstantsStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/DisallowAlternativeSyntaxStandard.xml +0 -35
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/DisallowLonelyIfStandard.xml +0 -49
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/IfElseDeclarationStandard.xml +0 -37
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Files/SeparateFunctionsFromOOStandard.xml +0 -45
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml +0 -42
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml +0 -33
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Lists/DisallowLongListSyntaxStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Lists/DisallowShortListSyntaxStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/DisallowCurlyBraceSyntaxStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/DisallowDeclarationWithoutNameStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/EnforceCurlyBraceSyntaxStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/OneDeclarationPerFileStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/NamingConventions/NoReservedKeywordParameterNamesStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/OOStructures/AlphabeticExtendsImplementsStandard.xml +0 -27
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/ConcatPositionStandard.xml +0 -31
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowLogicalAndOrStandard.xml +0 -30
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowShortTernaryStandard.xml +0 -26
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowStandalonePostIncrementDecrementStandard.xml +0 -44
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/StrictComparisonsStandard.xml +0 -29
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/TypeSeparatorSpacingStandard.xml +0 -33
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/PHP/LowercasePHPTagStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/PHP/OneStatementInShortEchoTagStandard.xml +0 -41
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml +0 -39
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseClassStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseConstStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseFunctionStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml +0 -29
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/LowercaseFunctionConstStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoLeadingBackslashStandard.xml +0 -23
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml +0 -30
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/AnonClassKeywordSpacingStandard.xml +0 -31
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml +0 -94
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/DisallowInlineTabsStandard.xml +0 -25
- package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/PrecisionAlignmentStandard.xml +0 -29
- package/vendor/phpcsstandards/phpcsextra/Universal/Helpers/DummyTokenizer.php +0 -60
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +0 -89
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php +0 -297
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php +0 -174
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php +0 -134
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php +0 -112
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/DisallowFinalClassSniff.php +0 -116
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php +0 -188
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php +0 -81
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/RequireFinalClassSniff.php +0 -102
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php +0 -153
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoDoubleNegativeSniff.php +0 -269
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php +0 -131
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php +0 -216
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php +0 -106
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php +0 -199
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php +0 -89
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php +0 -216
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php +0 -348
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php +0 -164
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php +0 -190
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php +0 -233
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php +0 -120
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php +0 -71
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php +0 -86
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php +0 -81
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php +0 -80
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php +0 -81
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php +0 -96
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php +0 -190
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php +0 -275
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/ConcatPositionSniff.php +0 -204
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php +0 -112
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowShortTernarySniff.php +0 -76
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php +0 -197
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/StrictComparisonsSniff.php +0 -116
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php +0 -85
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/PHP/LowercasePHPTagSniff.php +0 -87
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php +0 -101
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php +0 -248
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php +0 -211
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php +0 -207
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php +0 -156
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php +0 -170
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php +0 -155
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php +0 -79
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php +0 -408
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +0 -173
- package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +0 -445
- package/vendor/phpcsstandards/phpcsextra/Universal/ruleset.xml +0 -5
- package/vendor/phpcsstandards/phpcsextra/composer.json +0 -69
- package/vendor/phpcsstandards/phpcsutils/.phpdoc.xml.dist +0 -36
- package/vendor/phpcsstandards/phpcsutils/CHANGELOG.md +0 -1106
- package/vendor/phpcsstandards/phpcsutils/LICENSE +0 -165
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php +0 -551
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php +0 -781
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php +0 -123
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php +0 -202
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/InvalidTokenArray.php +0 -44
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestFileNotFound.php +0 -47
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestMarkerNotFound.php +0 -43
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestTargetNotFound.php +0 -50
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Fixers/SpacesFixer.php +0 -246
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/Cache.php +0 -218
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php +0 -687
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php +0 -269
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/NoFileCache.php +0 -164
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/StableCollections.php +0 -75
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php +0 -459
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php +0 -837
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/TokenHelper.php +0 -55
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Arrays.php +0 -227
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Conditions.php +0 -156
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php +0 -232
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php +0 -276
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php +0 -828
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/GetTokensAsString.php +0 -262
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Lists.php +0 -359
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/MessageHelper.php +0 -145
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Namespaces.php +0 -389
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php +0 -116
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Numbers.php +0 -322
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php +0 -359
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Operators.php +0 -252
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Orthography.php +0 -120
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Parentheses.php +0 -419
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php +0 -510
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Scopes.php +0 -143
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/TextStrings.php +0 -331
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php +0 -432
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Variables.php +0 -333
- package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/ruleset.xml +0 -4
- package/vendor/phpcsstandards/phpcsutils/README.md +0 -297
- package/vendor/phpcsstandards/phpcsutils/composer.json +0 -92
- package/vendor/phpcsstandards/phpcsutils/phpcsutils-autoload.php +0 -68
- package/vendor/wp-coding-standards/wpcs/CHANGELOG.md +0 -1654
- package/vendor/wp-coding-standards/wpcs/LICENSE +0 -21
- package/vendor/wp-coding-standards/wpcs/README.md +0 -261
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +0 -261
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php +0 -257
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionParameterSniff.php +0 -111
- package/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php +0 -358
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/ArrayIndentationStandard.xml +0 -116
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml +0 -31
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml +0 -50
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/CodeAnalysis/EscapedNotTranslatedStandard.xml +0 -24
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml +0 -35
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/DateTime/RestrictedFunctionsStandard.xml +0 -54
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/PrefixAllGlobalsStandard.xml +0 -119
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/ValidHookNameStandard.xml +0 -35
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/ValidPostTypeSlugStandard.xml +0 -121
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/IniSetStandard.xml +0 -40
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/StrictInArrayStandard.xml +0 -53
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/YodaConditionsStandard.xml +0 -27
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Security/SafeRedirectStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CapabilitiesStandard.xml +0 -69
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CapitalPDangitStandard.xml +0 -43
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/ClassNameCaseStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CronIntervalStandard.xml +0 -45
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedClassesStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml +0 -23
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedParametersStandard.xml +0 -40
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/EnqueuedResourceParametersStandard.xml +0 -92
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/EnqueuedResourcesStandard.xml +0 -57
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/PostsPerPageStandard.xml +0 -73
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml +0 -27
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/ControlStructureSpacingStandard.xml +0 -150
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/ObjectOperatorSpacingStandard.xml +0 -19
- package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/OperatorSpacingStandard.xml +0 -61
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ArrayWalkingFunctionsHelper.php +0 -108
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ConstantsHelper.php +0 -135
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ContextHelper.php +0 -394
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/DeprecationHelper.php +0 -84
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/EscapingFunctionsTrait.php +0 -256
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/FormattingFunctionsHelper.php +0 -60
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/IsUnitTestTrait.php +0 -238
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ListHelper.php +0 -101
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/MinimumWPVersionTrait.php +0 -159
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/PrintingFunctionsTrait.php +0 -122
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/RulesetPropertyHelper.php +0 -73
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/SanitizationHelperTrait.php +0 -418
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/SnakeCaseHelper.php +0 -60
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/UnslashingFunctionsHelper.php +0 -59
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ValidationHelper.php +0 -349
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/VariableHelper.php +0 -262
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPDBTrait.php +0 -115
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPGlobalVariablesHelper.php +0 -312
- package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPHookHelper.php +0 -113
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniff.php +0 -72
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +0 -252
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +0 -550
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +0 -174
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +0 -583
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInTernaryConditionSniff.php +0 -173
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EscapedNotTranslatedSniff.php +0 -89
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php +0 -301
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +0 -761
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php +0 -242
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php +0 -57
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php +0 -63
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/SlowDBQuerySniff.php +0 -58
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php +0 -168
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php +0 -59
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php +0 -313
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +0 -1297
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +0 -188
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +0 -277
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php +0 -230
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +0 -289
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php +0 -63
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php +0 -100
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DontExtractSniff.php +0 -52
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/IniSetSniff.php +0 -193
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php +0 -245
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php +0 -73
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php +0 -70
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php +0 -45
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/StrictInArraySniff.php +0 -122
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/TypeCastsSniff.php +0 -90
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/YodaConditionsSniff.php +0 -124
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/EscapeOutputSniff.php +0 -903
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/NonceVerificationSniff.php +0 -422
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/PluginMenuSlugSniff.php +0 -126
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/SafeRedirectSniff.php +0 -45
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php +0 -244
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php +0 -862
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php +0 -371
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapabilitiesSniff.php +0 -478
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php +0 -315
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/ClassNameCaseSniff.php +0 -897
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CronIntervalSniff.php +0 -321
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +0 -152
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +0 -1708
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php +0 -291
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +0 -509
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +0 -160
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php +0 -54
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php +0 -241
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +0 -108
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php +0 -436
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php +0 -977
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/PostsPerPageSniff.php +0 -102
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +0 -59
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +0 -486
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +0 -63
- package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php +0 -60
- package/vendor/wp-coding-standards/wpcs/WordPress/ruleset.xml +0 -13
- package/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml +0 -948
- package/vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml +0 -109
- package/vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml +0 -199
- package/vendor/wp-coding-standards/wpcs/composer.json +0 -88
- package/vendor/wp-coding-standards/wpcs/phpcs.xml.dist.sample +0 -153
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* WordPress Coding Standard.
|
|
4
|
-
*
|
|
5
|
-
* @package WPCS\WordPressCodingStandards
|
|
6
|
-
* @link https://github.com/WordPress/WordPress-Coding-Standards
|
|
7
|
-
* @license https://opensource.org/licenses/MIT MIT
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
namespace WordPressCS\WordPress\Sniffs\NamingConventions;
|
|
11
|
-
|
|
12
|
-
use PHP_CodeSniffer\Util\Tokens;
|
|
13
|
-
use PHPCSUtils\Utils\FunctionDeclarations;
|
|
14
|
-
use PHPCSUtils\Utils\NamingConventions;
|
|
15
|
-
use PHPCSUtils\Utils\ObjectDeclarations;
|
|
16
|
-
use PHPCSUtils\Utils\Scopes;
|
|
17
|
-
use WordPressCS\WordPress\Helpers\DeprecationHelper;
|
|
18
|
-
use WordPressCS\WordPress\Helpers\SnakeCaseHelper;
|
|
19
|
-
use WordPressCS\WordPress\Sniff;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Enforces WordPress function name and method name format, based upon Squiz code.
|
|
23
|
-
*
|
|
24
|
-
* @link https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions
|
|
25
|
-
*
|
|
26
|
-
* @since 0.1.0
|
|
27
|
-
* @since 0.13.0 Class name changed: this class is now namespaced.
|
|
28
|
-
* @since 2.0.0 The `get_name_suggestion()` method has been moved to the
|
|
29
|
-
* WordPress native `Sniff` base class as `get_snake_case_name_suggestion()`.
|
|
30
|
-
* @since 2.2.0 Will now ignore functions and methods which are marked as @deprecated.
|
|
31
|
-
* @since 3.0.0 This sniff has been refactored and no longer extends the upstream
|
|
32
|
-
* PEAR.NamingConventions.ValidFunctionName sniff.
|
|
33
|
-
*/
|
|
34
|
-
final class ValidFunctionNameSniff extends Sniff {
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns an array of tokens this test wants to listen for.
|
|
38
|
-
*
|
|
39
|
-
* @since 3.0.0
|
|
40
|
-
*
|
|
41
|
-
* @return array
|
|
42
|
-
*/
|
|
43
|
-
public function register() {
|
|
44
|
-
return array( \T_FUNCTION );
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Processes this test, when one of its tokens is encountered.
|
|
49
|
-
*
|
|
50
|
-
* @since 3.0.0
|
|
51
|
-
*
|
|
52
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
53
|
-
*
|
|
54
|
-
* @return int|void Integer stack pointer to skip forward or void to continue
|
|
55
|
-
* normal file processing.
|
|
56
|
-
*/
|
|
57
|
-
public function process_token( $stackPtr ) {
|
|
58
|
-
|
|
59
|
-
if ( DeprecationHelper::is_function_deprecated( $this->phpcsFile, $stackPtr ) === true ) {
|
|
60
|
-
/*
|
|
61
|
-
* Deprecated functions don't have to comply with the naming conventions,
|
|
62
|
-
* otherwise functions deprecated in favour of a function with a compliant
|
|
63
|
-
* name would still trigger an error.
|
|
64
|
-
*/
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
$name = FunctionDeclarations::getName( $this->phpcsFile, $stackPtr );
|
|
69
|
-
if ( empty( $name ) === true ) {
|
|
70
|
-
// Live coding or parse error.
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if ( '' === ltrim( $name, '_' ) ) {
|
|
75
|
-
// Ignore special functions, like __().
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
$ooPtr = Scopes::validDirectScope( $this->phpcsFile, $stackPtr, Tokens::$ooScopeTokens );
|
|
80
|
-
if ( false === $ooPtr ) {
|
|
81
|
-
$this->process_function_declaration( $stackPtr, $name );
|
|
82
|
-
} else {
|
|
83
|
-
$this->process_method_declaration( $stackPtr, $name, $ooPtr );
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Processes a function declaration for a function in the global namespace.
|
|
89
|
-
*
|
|
90
|
-
* @since 0.1.0
|
|
91
|
-
* @since 3.0.0 Renamed from `processTokenOutsideScope()` to `process_function_declaration()`.
|
|
92
|
-
* Method signature has been changed as well as this method no longer overloads
|
|
93
|
-
* a method from the PEAR sniff which was previously the sniff parent.
|
|
94
|
-
*
|
|
95
|
-
* @param int $stackPtr The position where this token was found.
|
|
96
|
-
* @param string $functionName The name of the function.
|
|
97
|
-
*
|
|
98
|
-
* @return void
|
|
99
|
-
*/
|
|
100
|
-
protected function process_function_declaration( $stackPtr, $functionName ) {
|
|
101
|
-
// PHP magic functions are exempt from our rules.
|
|
102
|
-
if ( FunctionDeclarations::isMagicFunctionName( $functionName ) === true ) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Is the function name prefixed with "__" ?
|
|
107
|
-
if ( preg_match( '`^__[^_]`', $functionName ) === 1 ) {
|
|
108
|
-
$error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
|
|
109
|
-
$errorData = array( $functionName );
|
|
110
|
-
$this->phpcsFile->addError( $error, $stackPtr, 'FunctionDoubleUnderscore', $errorData );
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
$suggested_name = SnakeCaseHelper::get_suggestion( $functionName );
|
|
114
|
-
if ( $suggested_name !== $functionName ) {
|
|
115
|
-
$error = 'Function name "%s" is not in snake case format, try "%s"';
|
|
116
|
-
$errorData = array(
|
|
117
|
-
$functionName,
|
|
118
|
-
$suggested_name,
|
|
119
|
-
);
|
|
120
|
-
$this->phpcsFile->addError( $error, $stackPtr, 'FunctionNameInvalid', $errorData );
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Processes a method declaration.
|
|
126
|
-
*
|
|
127
|
-
* @since 0.1.0
|
|
128
|
-
* @since 3.0.0 Renamed from `processTokenWithinScope()` to `process_method_declaration()`.
|
|
129
|
-
* Method signature has been changed as well, as this method no longer overloads
|
|
130
|
-
* a method from the PEAR sniff which was previously the sniff parent.
|
|
131
|
-
*
|
|
132
|
-
* @param int $stackPtr The position where this token was found.
|
|
133
|
-
* @param string $methodName The name of the method.
|
|
134
|
-
* @param int $currScope The position of the current scope.
|
|
135
|
-
*
|
|
136
|
-
* @return void
|
|
137
|
-
*/
|
|
138
|
-
protected function process_method_declaration( $stackPtr, $methodName, $currScope ) {
|
|
139
|
-
|
|
140
|
-
if ( \T_ANON_CLASS === $this->tokens[ $currScope ]['code'] ) {
|
|
141
|
-
$className = '[Anonymous Class]';
|
|
142
|
-
} else {
|
|
143
|
-
$className = ObjectDeclarations::getName( $this->phpcsFile, $currScope );
|
|
144
|
-
|
|
145
|
-
// PHP4 constructors are allowed to break our rules.
|
|
146
|
-
if ( NamingConventions::isEqual( $methodName, $className ) === true ) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// PHP4 destructors are allowed to break our rules.
|
|
151
|
-
if ( NamingConventions::isEqual( $methodName, '_' . $className ) === true ) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// PHP magic methods are exempt from our rules.
|
|
157
|
-
if ( FunctionDeclarations::isMagicMethodName( $methodName ) === true ) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
$extended = ObjectDeclarations::findExtendedClassName( $this->phpcsFile, $currScope );
|
|
162
|
-
$interfaces = ObjectDeclarations::findImplementedInterfaceNames( $this->phpcsFile, $currScope );
|
|
163
|
-
|
|
164
|
-
// If this is a child class or interface implementation, it may have to use camelCase or double underscores.
|
|
165
|
-
if ( ! empty( $extended ) || ! empty( $interfaces ) ) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Is the method name prefixed with "__" ?
|
|
170
|
-
if ( preg_match( '`^__[^_]`', $methodName ) === 1 ) {
|
|
171
|
-
$error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
|
|
172
|
-
$errorData = array( $className . '::' . $methodName );
|
|
173
|
-
$this->phpcsFile->addError( $error, $stackPtr, 'MethodDoubleUnderscore', $errorData );
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Check for all lowercase.
|
|
177
|
-
$suggested_name = SnakeCaseHelper::get_suggestion( $methodName );
|
|
178
|
-
if ( $suggested_name !== $methodName ) {
|
|
179
|
-
$error = 'Method name "%s" in class %s is not in snake case format, try "%s"';
|
|
180
|
-
$errorData = array(
|
|
181
|
-
$methodName,
|
|
182
|
-
$className,
|
|
183
|
-
$suggested_name,
|
|
184
|
-
);
|
|
185
|
-
$this->phpcsFile->addError( $error, $stackPtr, 'MethodNameInvalid', $errorData );
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* WordPress Coding Standard.
|
|
4
|
-
*
|
|
5
|
-
* @package WPCS\WordPressCodingStandards
|
|
6
|
-
* @link https://github.com/WordPress/WordPress-Coding-Standards
|
|
7
|
-
* @license https://opensource.org/licenses/MIT MIT
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
namespace WordPressCS\WordPress\Sniffs\NamingConventions;
|
|
11
|
-
|
|
12
|
-
use PHP_CodeSniffer\Util\Tokens;
|
|
13
|
-
use PHPCSUtils\Utils\TextStrings;
|
|
14
|
-
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
|
|
15
|
-
use WordPressCS\WordPress\Helpers\WPHookHelper;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Use lowercase letters in action and filter names. Separate words via underscores.
|
|
19
|
-
*
|
|
20
|
-
* This sniff is only testing the hook invoke functions as when using 'add_action'/'add_filter'
|
|
21
|
-
* you can't influence the hook name.
|
|
22
|
-
*
|
|
23
|
-
* Hook names invoked with `do_action_deprecated()` and `apply_filters_deprecated()` are ignored.
|
|
24
|
-
*
|
|
25
|
-
* @link https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions
|
|
26
|
-
*
|
|
27
|
-
* @since 0.10.0
|
|
28
|
-
* @since 0.11.0 Extends the WordPressCS native `AbstractFunctionParameterSniff` class.
|
|
29
|
-
* @since 0.13.0 Class name changed: this class is now namespaced.
|
|
30
|
-
*/
|
|
31
|
-
class ValidHookNameSniff extends AbstractFunctionParameterSniff {
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Additional word separators.
|
|
35
|
-
*
|
|
36
|
-
* This public variable allows providing additional word separators which
|
|
37
|
-
* will be allowed in hook names via a property in the phpcs.xml config file.
|
|
38
|
-
*
|
|
39
|
-
* Example usage:
|
|
40
|
-
* <rule ref="WordPress.NamingConventions.ValidHookName">
|
|
41
|
-
* <properties>
|
|
42
|
-
* <property name="additionalWordDelimiters" value="-"/>
|
|
43
|
-
* </properties>
|
|
44
|
-
* </rule>
|
|
45
|
-
*
|
|
46
|
-
* Provide several extra delimiters as one string:
|
|
47
|
-
* <rule ref="WordPress.NamingConventions.ValidHookName">
|
|
48
|
-
* <properties>
|
|
49
|
-
* <property name="additionalWordDelimiters" value="-/."/>
|
|
50
|
-
* </properties>
|
|
51
|
-
* </rule>
|
|
52
|
-
*
|
|
53
|
-
* @var string
|
|
54
|
-
*/
|
|
55
|
-
public $additionalWordDelimiters = '';
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Regular expression to test for correct punctuation of a hook name.
|
|
59
|
-
*
|
|
60
|
-
* The placeholder will be replaced by potentially provided additional
|
|
61
|
-
* word delimiters in the `prepare_regex()` method.
|
|
62
|
-
*
|
|
63
|
-
* @var string
|
|
64
|
-
*/
|
|
65
|
-
protected $punctuation_regex = '`[^\w%s]`';
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Groups of functions to restrict.
|
|
69
|
-
*
|
|
70
|
-
* @since 0.11.0
|
|
71
|
-
*
|
|
72
|
-
* @return array
|
|
73
|
-
*/
|
|
74
|
-
public function getGroups() {
|
|
75
|
-
// Only retrieve functions which are not used for deprecated hooks.
|
|
76
|
-
$this->target_functions = WPHookHelper::get_functions( false );
|
|
77
|
-
|
|
78
|
-
return parent::getGroups();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Process the parameters of a matched function.
|
|
83
|
-
*
|
|
84
|
-
* @since 0.11.0
|
|
85
|
-
*
|
|
86
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
87
|
-
* @param string $group_name The name of the group which was matched.
|
|
88
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
89
|
-
* in lowercase.
|
|
90
|
-
* @param array $parameters Array with information about the parameters.
|
|
91
|
-
*
|
|
92
|
-
* @return void
|
|
93
|
-
*/
|
|
94
|
-
public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
|
|
95
|
-
|
|
96
|
-
$hook_name_param = WPHookHelper::get_hook_name_param( $matched_content, $parameters );
|
|
97
|
-
if ( false === $hook_name_param ) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
$regex = $this->prepare_regex();
|
|
102
|
-
|
|
103
|
-
$case_errors = 0;
|
|
104
|
-
$underscores = 0;
|
|
105
|
-
$content = array();
|
|
106
|
-
$expected = array();
|
|
107
|
-
$last_non_empty = null;
|
|
108
|
-
|
|
109
|
-
for ( $i = $hook_name_param['start']; $i <= $hook_name_param['end']; $i++ ) {
|
|
110
|
-
// Skip past comment tokens.
|
|
111
|
-
if ( isset( Tokens::$commentTokens[ $this->tokens[ $i ]['code'] ] ) ) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
$content[ $i ] = $this->tokens[ $i ]['content'];
|
|
116
|
-
$expected[ $i ] = $this->tokens[ $i ]['content'];
|
|
117
|
-
|
|
118
|
-
// Skip past potential variable array access: `$var['key']`.
|
|
119
|
-
if ( \T_VARIABLE === $this->tokens[ $i ]['code'] ) {
|
|
120
|
-
do {
|
|
121
|
-
$open_bracket = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
|
|
122
|
-
if ( false === $open_bracket
|
|
123
|
-
|| \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $open_bracket ]['code']
|
|
124
|
-
|| ! isset( $this->tokens[ $open_bracket ]['bracket_closer'] )
|
|
125
|
-
) {
|
|
126
|
-
$last_non_empty = $i;
|
|
127
|
-
continue 2;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
$i = $this->tokens[ $open_bracket ]['bracket_closer'];
|
|
131
|
-
|
|
132
|
-
} while ( isset( $this->tokens[ $i ] ) && $i <= $hook_name_param['end'] );
|
|
133
|
-
|
|
134
|
-
$last_non_empty = $i;
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Skip over parameters passed to function calls.
|
|
139
|
-
if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code']
|
|
140
|
-
&& ( \T_STRING === $this->tokens[ $last_non_empty ]['code']
|
|
141
|
-
|| \T_VARIABLE === $this->tokens[ $last_non_empty ]['code'] )
|
|
142
|
-
&& isset( $this->tokens[ $i ]['parenthesis_closer'] )
|
|
143
|
-
) {
|
|
144
|
-
$i = $this->tokens[ $i ]['parenthesis_closer'];
|
|
145
|
-
$last_non_empty = $i;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Skip past non text string tokens.
|
|
150
|
-
if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) === false ) {
|
|
151
|
-
$last_non_empty = $i;
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
$last_non_empty = $i;
|
|
156
|
-
$string = TextStrings::stripQuotes( $this->tokens[ $i ]['content'] );
|
|
157
|
-
|
|
158
|
-
/*
|
|
159
|
-
* Here be dragons - a double quoted string can contain extrapolated variables
|
|
160
|
-
* which don't have to comply with these rules.
|
|
161
|
-
*/
|
|
162
|
-
if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) {
|
|
163
|
-
$transform = $this->transform_complex_string( $string, $regex );
|
|
164
|
-
$case_transform = $this->transform_complex_string( $string, $regex, 'case' );
|
|
165
|
-
$punct_transform = $this->transform_complex_string( $string, $regex, 'punctuation' );
|
|
166
|
-
} else {
|
|
167
|
-
$transform = $this->transform( $string, $regex );
|
|
168
|
-
$case_transform = $this->transform( $string, $regex, 'case' );
|
|
169
|
-
$punct_transform = $this->transform( $string, $regex, 'punctuation' );
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if ( $string === $transform ) {
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) {
|
|
177
|
-
$expected[ $i ] = '"' . $transform . '"';
|
|
178
|
-
} else {
|
|
179
|
-
$expected[ $i ] = '\'' . $transform . '\'';
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if ( $string !== $case_transform ) {
|
|
183
|
-
++$case_errors;
|
|
184
|
-
}
|
|
185
|
-
if ( $string !== $punct_transform ) {
|
|
186
|
-
++$underscores;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
$first_non_empty = $this->phpcsFile->findNext(
|
|
191
|
-
Tokens::$emptyTokens,
|
|
192
|
-
$hook_name_param['start'],
|
|
193
|
-
( $hook_name_param['end'] + 1 ),
|
|
194
|
-
true
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
$data = array(
|
|
198
|
-
trim( implode( '', $expected ) ),
|
|
199
|
-
trim( implode( '', $content ) ),
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
if ( $case_errors > 0 ) {
|
|
203
|
-
$error = 'Hook names should be lowercase. Expected: %s, but found: %s.';
|
|
204
|
-
$this->phpcsFile->addError( $error, $first_non_empty, 'NotLowercase', $data );
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if ( $underscores > 0 ) {
|
|
208
|
-
$error = 'Words in hook names should be separated using underscores. Expected: %s, but found: %s.';
|
|
209
|
-
$this->phpcsFile->addWarning( $error, $first_non_empty, 'UseUnderscores', $data );
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Prepare the punctuation regular expression.
|
|
215
|
-
*
|
|
216
|
-
* Merges the existing regular expression with potentially provided extra word delimiters to allow.
|
|
217
|
-
* This is done 'late' and for each found token as otherwise inline `phpcs:set` directives
|
|
218
|
-
* would be ignored.
|
|
219
|
-
*
|
|
220
|
-
* @return string
|
|
221
|
-
*/
|
|
222
|
-
protected function prepare_regex() {
|
|
223
|
-
$extra = '';
|
|
224
|
-
if ( '' !== $this->additionalWordDelimiters && \is_string( $this->additionalWordDelimiters ) ) {
|
|
225
|
-
$extra = preg_quote( $this->additionalWordDelimiters, '`' );
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return sprintf( $this->punctuation_regex, $extra );
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Transform an arbitrary string to lowercase and replace punctuation and spaces with underscores.
|
|
233
|
-
*
|
|
234
|
-
* @param string $text_string The target string.
|
|
235
|
-
* @param string $regex The punctuation regular expression to use.
|
|
236
|
-
* @param string $transform_type Whether to do a partial or complete transform.
|
|
237
|
-
* Valid values are: 'full', 'case', 'punctuation'.
|
|
238
|
-
* @return string
|
|
239
|
-
*/
|
|
240
|
-
protected function transform( $text_string, $regex, $transform_type = 'full' ) {
|
|
241
|
-
|
|
242
|
-
switch ( $transform_type ) {
|
|
243
|
-
case 'case':
|
|
244
|
-
return strtolower( $text_string );
|
|
245
|
-
|
|
246
|
-
case 'punctuation':
|
|
247
|
-
return preg_replace( $regex, '_', $text_string );
|
|
248
|
-
|
|
249
|
-
case 'full':
|
|
250
|
-
default:
|
|
251
|
-
return preg_replace( $regex, '_', strtolower( $text_string ) );
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Transform a complex string which may contain variable extrapolation.
|
|
257
|
-
*
|
|
258
|
-
* @param string $text_string The target string.
|
|
259
|
-
* @param string $regex The punctuation regular expression to use.
|
|
260
|
-
* @param string $transform_type Whether to do a partial or complete transform.
|
|
261
|
-
* Valid values are: 'full', 'case', 'punctuation'.
|
|
262
|
-
* @return string
|
|
263
|
-
*/
|
|
264
|
-
protected function transform_complex_string( $text_string, $regex, $transform_type = 'full' ) {
|
|
265
|
-
$plain_text = TextStrings::stripEmbeds( $text_string );
|
|
266
|
-
$embeds = TextStrings::getEmbeds( $text_string );
|
|
267
|
-
|
|
268
|
-
$transformed_text = $this->transform( $plain_text, $regex, $transform_type );
|
|
269
|
-
|
|
270
|
-
// Inject the embeds back into the text string.
|
|
271
|
-
foreach ( $embeds as $offset => $embed ) {
|
|
272
|
-
$transformed_text = substr_replace( $transformed_text, $embed, $offset, 0 );
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return $transformed_text;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* WordPress Coding Standard.
|
|
4
|
-
*
|
|
5
|
-
* @package WPCS\WordPressCodingStandards
|
|
6
|
-
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
|
7
|
-
* @license https://opensource.org/licenses/MIT MIT
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
namespace WordPressCS\WordPress\Sniffs\NamingConventions;
|
|
11
|
-
|
|
12
|
-
use PHP_CodeSniffer\Util\Tokens;
|
|
13
|
-
use PHPCSUtils\Tokens\Collections;
|
|
14
|
-
use PHPCSUtils\Utils\PassedParameters;
|
|
15
|
-
use PHPCSUtils\Utils\TextStrings;
|
|
16
|
-
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Validates post type names.
|
|
20
|
-
*
|
|
21
|
-
* Checks the post type slug for invalid characters, long function names
|
|
22
|
-
* and reserved names.
|
|
23
|
-
*
|
|
24
|
-
* @link https://developer.wordpress.org/reference/functions/register_post_type/
|
|
25
|
-
*
|
|
26
|
-
* @since 2.2.0
|
|
27
|
-
*/
|
|
28
|
-
final class ValidPostTypeSlugSniff extends AbstractFunctionParameterSniff {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Max length of a post type name is limited by the SQL field.
|
|
32
|
-
*
|
|
33
|
-
* @since 2.2.0
|
|
34
|
-
*
|
|
35
|
-
* @var int
|
|
36
|
-
*/
|
|
37
|
-
const POST_TYPE_MAX_LENGTH = 20;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Regex to validate the characters that can be used as the post type slug.
|
|
41
|
-
*
|
|
42
|
-
* @link https://developer.wordpress.org/reference/functions/register_post_type/
|
|
43
|
-
* @since 2.2.0
|
|
44
|
-
* @since 3.0.0 Renamed from `POST_TYPE_CHARACTER_WHITELIST` to `VALID_POST_TYPE_CHARACTERS`.
|
|
45
|
-
*
|
|
46
|
-
* @var string
|
|
47
|
-
*/
|
|
48
|
-
const VALID_POST_TYPE_CHARACTERS = '/^[a-z0-9_-]+$/';
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Array of functions that must be checked.
|
|
52
|
-
*
|
|
53
|
-
* @since 2.2.0
|
|
54
|
-
*
|
|
55
|
-
* @var array<string, true> Key is function name, value irrelevant.
|
|
56
|
-
*/
|
|
57
|
-
protected $target_functions = array(
|
|
58
|
-
'register_post_type' => true,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Array of reserved post type names which can not be used by themes and plugins.
|
|
63
|
-
*
|
|
64
|
-
* Source: {@link https://developer.wordpress.org/reference/functions/register_post_type/#reserved-post-types}
|
|
65
|
-
*
|
|
66
|
-
* {@internal To be updated after every major release. Last updated for WordPress 6.5-RC3.}
|
|
67
|
-
*
|
|
68
|
-
* @since 2.2.0
|
|
69
|
-
*
|
|
70
|
-
* @var array<string, true> Key is reserved post type name, value irrelevant.
|
|
71
|
-
*/
|
|
72
|
-
protected $reserved_names = array(
|
|
73
|
-
'action' => true, // Not a WP post type, but prevents other problems.
|
|
74
|
-
'attachment' => true,
|
|
75
|
-
'author' => true, // Not a WP post type, but prevents other problems.
|
|
76
|
-
'custom_css' => true,
|
|
77
|
-
'customize_changeset' => true,
|
|
78
|
-
'nav_menu_item' => true,
|
|
79
|
-
'oembed_cache' => true,
|
|
80
|
-
'order' => true, // Not a WP post type, but prevents other problems.
|
|
81
|
-
'page' => true,
|
|
82
|
-
'post' => true,
|
|
83
|
-
'revision' => true,
|
|
84
|
-
'theme' => true, // Not a WP post type, but prevents other problems.
|
|
85
|
-
'user_request' => true,
|
|
86
|
-
'wp_block' => true,
|
|
87
|
-
'wp_font_face' => true,
|
|
88
|
-
'wp_font_family' => true,
|
|
89
|
-
'wp_global_styles' => true,
|
|
90
|
-
'wp_navigation' => true,
|
|
91
|
-
'wp_template' => true,
|
|
92
|
-
'wp_template_part' => true,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* All valid tokens for in the first parameter of register_post_type().
|
|
97
|
-
*
|
|
98
|
-
* Set in `register()`.
|
|
99
|
-
*
|
|
100
|
-
* @since 2.2.0
|
|
101
|
-
*
|
|
102
|
-
* @var array<int|string, int|string>
|
|
103
|
-
*/
|
|
104
|
-
private $valid_tokens = array();
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Returns an array of tokens this test wants to listen for.
|
|
108
|
-
*
|
|
109
|
-
* @since 2.2.0
|
|
110
|
-
*
|
|
111
|
-
* @return array
|
|
112
|
-
*/
|
|
113
|
-
public function register() {
|
|
114
|
-
$this->valid_tokens = Tokens::$textStringTokens + Tokens::$heredocTokens + Tokens::$emptyTokens;
|
|
115
|
-
return parent::register();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Process the parameter of a matched function.
|
|
120
|
-
*
|
|
121
|
-
* Errors on invalid post type names when reserved keywords are used,
|
|
122
|
-
* the post type is too long, or contains invalid characters.
|
|
123
|
-
*
|
|
124
|
-
* @since 2.2.0
|
|
125
|
-
*
|
|
126
|
-
* @param int $stackPtr The position of the current token in the stack.
|
|
127
|
-
* @param string $group_name The name of the group which was matched.
|
|
128
|
-
* @param string $matched_content The token content (function name) which was matched
|
|
129
|
-
* in lowercase.
|
|
130
|
-
* @param array $parameters Array with information about the parameters.
|
|
131
|
-
*
|
|
132
|
-
* @return void
|
|
133
|
-
*/
|
|
134
|
-
public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
|
|
135
|
-
$post_type_param = PassedParameters::getParameterFromStack( $parameters, 1, 'post_type' );
|
|
136
|
-
if ( false === $post_type_param || '' === $post_type_param['clean'] ) {
|
|
137
|
-
// Error for using empty slug.
|
|
138
|
-
$this->phpcsFile->addError(
|
|
139
|
-
'register_post_type() called without a post type slug. The slug must be a non-empty string.',
|
|
140
|
-
false === $post_type_param ? $stackPtr : $post_type_param['start'],
|
|
141
|
-
'Empty'
|
|
142
|
-
);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
$string_start = $this->phpcsFile->findNext( Collections::textStringStartTokens(), $post_type_param['start'], ( $post_type_param['end'] + 1 ) );
|
|
147
|
-
$string_pos = $this->phpcsFile->findNext( Tokens::$textStringTokens, $post_type_param['start'], ( $post_type_param['end'] + 1 ) );
|
|
148
|
-
|
|
149
|
-
$has_invalid_tokens = $this->phpcsFile->findNext( $this->valid_tokens, $post_type_param['start'], ( $post_type_param['end'] + 1 ), true );
|
|
150
|
-
if ( false !== $has_invalid_tokens || false === $string_pos ) {
|
|
151
|
-
// Check for non string based slug parameter (we cannot determine if this is valid).
|
|
152
|
-
$this->phpcsFile->addWarning(
|
|
153
|
-
'The post type slug is not a string literal. It is not possible to automatically determine the validity of this slug. Found: %s.',
|
|
154
|
-
$stackPtr,
|
|
155
|
-
'NotStringLiteral',
|
|
156
|
-
array(
|
|
157
|
-
$post_type_param['clean'],
|
|
158
|
-
),
|
|
159
|
-
3
|
|
160
|
-
);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
$post_type = TextStrings::getCompleteTextString( $this->phpcsFile, $string_start );
|
|
165
|
-
if ( isset( Tokens::$heredocTokens[ $this->tokens[ $string_start ]['code'] ] ) ) {
|
|
166
|
-
// Trim off potential indentation from PHP 7.3 flexible heredoc/nowdoc content.
|
|
167
|
-
$post_type = ltrim( $post_type );
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
$data = array(
|
|
171
|
-
$post_type,
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
// Warn for dynamic parts in the slug parameter.
|
|
175
|
-
if ( 'T_DOUBLE_QUOTED_STRING' === $this->tokens[ $string_pos ]['type']
|
|
176
|
-
|| ( 'T_HEREDOC' === $this->tokens[ $string_pos ]['type']
|
|
177
|
-
&& strpos( $this->tokens[ $string_pos ]['content'], '$' ) !== false )
|
|
178
|
-
) {
|
|
179
|
-
$this->phpcsFile->addWarning(
|
|
180
|
-
'The post type slug may, or may not, get too long with dynamic contents and could contain invalid characters. Found: "%s".',
|
|
181
|
-
$string_pos,
|
|
182
|
-
'PartiallyDynamic',
|
|
183
|
-
$data
|
|
184
|
-
);
|
|
185
|
-
$post_type = TextStrings::stripEmbeds( $post_type );
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if ( preg_match( self::VALID_POST_TYPE_CHARACTERS, $post_type ) === 0 ) {
|
|
189
|
-
// Error for invalid characters.
|
|
190
|
-
$this->phpcsFile->addError(
|
|
191
|
-
'register_post_type() called with invalid post type "%s". Post type contains invalid characters. Only lowercase alphanumeric characters, dashes, and underscores are allowed.',
|
|
192
|
-
$string_pos,
|
|
193
|
-
'InvalidCharacters',
|
|
194
|
-
$data
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if ( isset( $this->reserved_names[ $post_type ] ) ) {
|
|
199
|
-
// Error for using reserved slug names.
|
|
200
|
-
$this->phpcsFile->addError(
|
|
201
|
-
'register_post_type() called with reserved post type "%s". Reserved post types should not be used as they interfere with the functioning of WordPress itself.',
|
|
202
|
-
$string_pos,
|
|
203
|
-
'Reserved',
|
|
204
|
-
$data
|
|
205
|
-
);
|
|
206
|
-
} elseif ( stripos( $post_type, 'wp_' ) === 0 ) {
|
|
207
|
-
// Error for using reserved slug prefix.
|
|
208
|
-
$this->phpcsFile->addError(
|
|
209
|
-
'The post type passed to register_post_type() uses a prefix reserved for WordPress itself. Found: "%s".',
|
|
210
|
-
$string_pos,
|
|
211
|
-
'ReservedPrefix',
|
|
212
|
-
$data
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Error for slugs that are too long.
|
|
217
|
-
if ( strlen( $post_type ) > self::POST_TYPE_MAX_LENGTH ) {
|
|
218
|
-
$this->phpcsFile->addError(
|
|
219
|
-
'A post type slug must not exceed %d characters. Found: "%s" (%d characters).',
|
|
220
|
-
$string_pos,
|
|
221
|
-
'TooLong',
|
|
222
|
-
array(
|
|
223
|
-
self::POST_TYPE_MAX_LENGTH,
|
|
224
|
-
$post_type,
|
|
225
|
-
strlen( $post_type ),
|
|
226
|
-
)
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|