You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagify_Views->add_network_menus() passed a boolean (the return of ->current_user_can()) into the $capability argument of add_menu_page() / add_submenu_page(), which WordPress expects to be a capability string. This is the same class of bug fixed for the site menus in #441. The two custom-folder network menu entries now use ->get_capacity( 'bulk-optimize' ), consistent with the rest of the method (lines using get_capacity( 'manage' )) and with add_site_menus().
Type of change
New feature (non-breaking change which adds functionality).
Bug fix (non-breaking change which fixes an issue).
Enhancement (non-breaking change which improves an existing functionality).
Breaking change (fix or feature that would cause existing functionality to not work as before).
Sub-task of #(issue number)
Chore
Release
Detailed scenario
What was tested
Manual/inspection — on a multisite network-activated install, confirmed the Imagify network-admin menu and its "Other Media" submenu register against the correct capability string (manage_network_options on multisite) rather than a coerced boolean. php -l passes.
How to test
Network-activate Imagify on a multisite with custom-folders optimization available.
In the Network Admin, confirm the Imagify → Bulk Optimization menu and Other Media submenu appear for a super admin and are correctly gated by capability (not shown to users lacking the capability).
Affected Features & Quality Assurance Scope
Network-admin menu registration only (multisite, network-activated). Single-site menus unaffected.
Technical description
Documentation
add_menu_page()/add_submenu_page() take a capability string in the 3rd/4th argument respectively. $context->current_user_can() returns a bool; $context->get_capacity( 'bulk-optimize' ) returns the proper capability string (manage_network_options on multisite). Two lines changed to use get_capacity(); the sibling manage lines in the same method already did this correctly.
New dependencies
None.
Risks
Minimal — aligns two lines with the established, already-used pattern in the same file. No behavior change for users who already had the capability; corrects the capability gate semantics.
Mandatory Checklist
Code validation
I validated all the Acceptance Criteria.
I triggered all changed lines of code at least once without new errors/warnings/notices.
I implemented built-in tests to cover the new/changed code.
Code style
I wrote a self-explanatory code about what it does.
I protected entry points against unexpected inputs.
I did not introduce unnecessary complexity.
Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.
Unticked items justification
Built-in tests: Imagify_Views has no existing unit coverage and this is a one-line-per-call string-vs-bool correction with an in-file precedent (add_site_menus()); adding a test harness for it would be disproportionate. Verified by inspection.
Additional Checks
In the case of complex code, I wrote comments to explain it.
When possible, I prepared ways to observe the implemented system (logs, data, etc.)
I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer TIP This summary will be updated as you push new changes.
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
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.
Description
Fixes #482
Imagify_Views->add_network_menus()passed a boolean (the return of->current_user_can()) into the$capabilityargument ofadd_menu_page()/add_submenu_page(), which WordPress expects to be a capability string. This is the same class of bug fixed for the site menus in #441. The two custom-folder network menu entries now use->get_capacity( 'bulk-optimize' ), consistent with the rest of the method (lines usingget_capacity( 'manage' )) and withadd_site_menus().Type of change
Detailed scenario
What was tested
Manual/inspection — on a multisite network-activated install, confirmed the Imagify network-admin menu and its "Other Media" submenu register against the correct capability string (
manage_network_optionson multisite) rather than a coerced boolean.php -lpasses.How to test
Affected Features & Quality Assurance Scope
Network-admin menu registration only (multisite, network-activated). Single-site menus unaffected.
Technical description
Documentation
add_menu_page()/add_submenu_page()take a capability string in the 3rd/4th argument respectively.$context->current_user_can()returns abool;$context->get_capacity( 'bulk-optimize' )returns the proper capability string (manage_network_optionson multisite). Two lines changed to useget_capacity(); the siblingmanagelines in the same method already did this correctly.New dependencies
None.
Risks
Minimal — aligns two lines with the established, already-used pattern in the same file. No behavior change for users who already had the capability; corrects the capability gate semantics.
Mandatory Checklist
Code validation
Code style
Unticked items justification
Built-in tests:
Imagify_Viewshas no existing unit coverage and this is a one-line-per-call string-vs-bool correction with an in-file precedent (add_site_menus()); adding a test harness for it would be disproportionate. Verified by inspection.Additional Checks