disallow 0x0 unit size - #72
Open
jakewrfoster wants to merge 3 commits into
Open
Conversation
kjbenk
suggested changes
Oct 31, 2019
| 'add_more_label' => __( 'Add Size', 'ad-layers' ), | ||
| 'description' => __( 'Size cannot be 0x0.', 'ad-layers' ), | ||
| 'group_is_empty' => function( $values ) { | ||
| if ( isset( $values['width'], $values['height'] ) ) { |
There was a problem hiding this comment.
You should just be able to do
return empty( $values['width'] ) && empty( $values['height'] );There was a problem hiding this comment.
Also, if you really need all of these checks, then it might be easier to read stacked in a single if statement
| // Valid size, save the group. | ||
| return false; | ||
| } else { | ||
| return true; |
There was a problem hiding this comment.
So if the values are set but one of them is not numeric, the group should be considered empty?
Member
Author
There was a problem hiding this comment.
I think that the numeric checks can be removed since these fields are being sanitized by absint anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The current lack of
group_is_emptyallows for cases where ad-layers will save an ad unit size as 0x0. This size group then becomes impossible to remove. This PR ensures that any sizes groups that have a 0x0 ad unit will not be saved.@mboynes / @bcampeau: For backwards-compat reasons, is there any use-case for an ad unit being 0x0?