Conversation
- Add 'wpmedia_plugin_family_show_imagify_banner' filter to allow developers to control banner visibility - Banner is enabled by default and can be disabled by setting filter to false - Bump version to 1.0.7 Fixes wp-media/wp-rocket#7556
There was a problem hiding this comment.
Pull request overview
This PR adds a filter hook to allow developers to control the visibility of the Imagify banner in Media gallery components. The change introduces the wpmedia_plugin_family_show_imagify_banner filter with type-safe application and bumps the plugin version to 1.0.7.
- Adds
wpmedia_plugin_family_show_imagify_bannerfilter to make banner visibility customizable - Introduces wp-media/apply-filters-typed dependency for type-safe filter handling
- Refactors
can_enqueue_admin_assets()method logic for clearer control flow
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Controller/PluginFamily.php | Adds filter hook with documentation, refactors conditional logic in can_enqueue_admin_assets(), and bumps version to 1.0.7 |
| composer.json | Adds wp-media/apply-filters-typed dependency for type-safe filter application |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix composer.json formatting (remove trailing whitespace and blank line) - Refactor can_enqueue_admin_assets to use optional override pattern - Revert test changes per review discussion
|
I've addressed the review comments from @jeawhanlee and Copilot: Changes in commit 49140f8:
The code now follows the requested patterns and formatting standards. |
- Add wpmedia_plugin_family_show_imagify_banner filter to enqueue_assets method - This ensures the filter works for both classic media library and block editor media modal - Fixes issue where banner was not hidden in block editor when filter returned false
- Create should_show_imagify_banner() method to centralize filter logic - Remove duplicate filter code from enqueue_assets() and can_enqueue_admin_assets() - Both methods now use the shared method for consistency and maintainability
|
@jeawhanlee Good point! I've refactored the code to eliminate the duplication. Changes in commit d935f98: Created a shared method: private function should_show_imagify_banner( bool $default_value = true ): boolThis method:
Both methods now use it:
|
|
Working as expected. existing issue(s) already on trunk. wp-media/wp-rocket#7962 |
Description
Fixes wp-media/wp-rocket#7556
Add filter to control Imagify banner on Media gallery components
Type of change
Detailed scenario
What was tested
How to test
How to test
Use the filter
add_filter( 'wpmedia_plugin_family_show_imagify_banner', '__return_false' );to enable/disable the bannerAffected Features & Quality Assurance Scope
Technical description
Documentation
This pull request introduces a new dependency for typed filter application, updates the plugin version, and enhances the logic for displaying the Imagify banner by making it filterable and type-safe. The most important changes are grouped below:
Dependency management:
wp-media/apply-filters-typedincomposer.jsonto support type-safe filter application.Plugin versioning:
1.0.6to1.0.7inPluginFamily.php.Admin banner display logic:
wpmedia_plugin_family_show_imagify_bannerthat uses the new type-safe filter application (wpm_apply_filters_typed). This allows developers to reliably modify the banner display behavior.New dependencies
"wp-media/apply-filters-typed": "^1.0"incomposer.jsonRisks
None
Mandatory Checklist
Code validation
Code style