-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disallow 0x0 unit size #72
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified
'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should just be able to do
return empty( $values['width'] ) && empty( $values['height'] );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if the values are set but one of them is not numeric, the group should be considered empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the numeric checks can be removed since these fields are being sanitized by absint
anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛳️
The current lack of
group_is_empty
allows 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?