-
Notifications
You must be signed in to change notification settings - Fork 81
Fix #1764 #1765
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
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.
Pull Request Overview
This PR ensures the saved default for max image attachments is not overridden when using the block editor unless the classic editor plugin is active.
- Update
default_max_image_attachments()
to reset the value only in block mode when the classic editor plugin is inactive - Add tests for the new behavior under different editor modes
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/includes/class-test-options.php | Add test_default_max_image_attachments() covering block mode behavior |
includes/class-options.php | Update default_max_image_attachments() to ignore stored setting in block mode without classic editor plugin |
Comments suppressed due to low confidence (2)
includes/class-options.php:145
- Wrap the
is_plugin_active
call in afunction_exists('is_plugin_active')
check to avoid a fatal error when that function isn’t loaded outside admin contexts.
( site_supports_blocks() && ! is_plugin_active( 'classic-editor/classic-editor.php' ) )
tests/includes/class-test-options.php:43
- [nitpick] Add a test case that simulates the classic editor plugin being active in block mode (mocking
is_plugin_active
to return true) to verify numeric values are preserved instead of reset.
public function test_default_max_image_attachments() {
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 change has the potential to create a similar confusion on sites where the option value is greater than 4, where it'll be reduced back to the default.
Overall, I think we should re-consider the removal of the setting for sites using the Block Editor. While these sites do have a way of specifying the number of attachments on a per-post basis, the setting would enable it across posts and define a general preference.
Makes sense! I re-enabled the option for all users. I think this is the simplest, most consistent, and most straightforward solution so far. |
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.
Thank you!
The problem with the current implementation of the "default attachment number" is, that the default will not be changed if the user has saved the old default (
3
).This PR checks if the plugin runs inThis PR re-adds the "Media attachments" setting, to be able to change the default.block
mode and ignores the setting then.Fixes #1764
Proposed changes:
Check for blog mode inget_option
hook (classic editor
orblock editor
)Only use option if blog usesclassic editor
otherwise fall back to defaultOther information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Allow users of the block editor to set the default number of media attachments.