Add early exit clauses to files with procedural code #790
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This was flagged during plugin review of the "Dominant Color Images" submission. Any files with procedural code should have an early exit condition. Most typically the one based on whether
! defined( 'ABSPATH' )
, but another relevant constant can used as well. For example, in the files where we already check for a Performance Lab specific constant on top of the file, we don't have to add to or update those files.Keep in mind that this is only required for files with procedural code, i.e. not files that only contain a class or similar construct.
There are varying opinions on this approach, but given it's requested by the plugin review team and is not a big deal to add, let's follow the pattern.
Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.