Skip to content

Max Image Attachments: Default to integer #1631

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

Merged
merged 3 commits into from
May 2, 2025

Conversation

obenland
Copy link
Member

@obenland obenland commented Apr 30, 2025

It's possible for the register_post_meta call to trigger a _doing_it_wrong() notice, when the default value is not of type integer.

Proposed changes:

  • Adds unit test.
  • Adds option callback to make sure it always returns an integer.
  • Tightens sanitization to make sure it never saves an empty string.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • While on trunk, activate Classic Editor plugin to make the setting show up.
  • Delete the number in the max image attachments setting and save.
  • Make sure the input field is empty and a _doing_it_wrong() notice appears (DEBUG enabled).
  • Switch to this branch. The notice should no longer appear.

@obenland obenland added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Apr 30, 2025
@obenland obenland self-assigned this Apr 30, 2025
@obenland obenland requested a review from pfefferle May 2, 2025 13:04
@obenland obenland merged commit 711e811 into trunk May 2, 2025
11 checks passed
@obenland obenland deleted the update/max-image-sanitization branch May 2, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] WP Admin Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants