Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"phpstan/extension-installer": true
}
},
"require": {
"wp-media/apply-filters-typed": "^1.0"
},
"require-dev": {
"phpcompatibility/phpcompatibility-wp": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
Expand Down
26 changes: 23 additions & 3 deletions src/Controller/PluginFamily.php
Comment thread
Miraeld marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PluginFamily implements PluginFamilyInterface {
*
* @var string
*/
private $version = '1.0.6';
private $version = '1.0.8';

/**
* Error transient.
Expand Down Expand Up @@ -380,6 +380,17 @@ public function enqueue_assets() {
return;
}

/**
* Filters whether to show the Imagify banner on Media gallery components.
*
* @since 1.0.8
*
* @param bool $show_banner Whether to enqueue the block editor assets and show the banner.
*/
if ( ! wpm_apply_filters_typed( 'boolean', 'wpmedia_plugin_family_show_imagify_banner', true ) ) {
return;
}

$script_url = plugin_dir_url( __DIR__ ) . 'assets/js/index.js';

wp_enqueue_script(
Expand Down Expand Up @@ -447,6 +458,8 @@ private function can_enqueue_admin_assets( $page = '' ): bool {
}

$allowed_pages = $this->screen_ids;
$can_enqueue = in_array( $page, $allowed_pages, true );

if ( empty( $page ) ) {
// Map configured admin pages to corresponding get_current_screen()->id values.
$allowed_screen_ids = array_unique(
Expand All @@ -467,10 +480,17 @@ static function ( $p ) {
)
);

return in_array( get_current_screen()->id, $allowed_screen_ids, true );
$can_enqueue = in_array( get_current_screen()->id, $allowed_screen_ids, true );
}

return in_array( $page, $allowed_pages, true );
/**
* Filters whether to show the Imagify banner on Media gallery components.
*
* @since 1.0.8
*
* @param bool $can_enqueue Whether to enqueue the admin assets and show the banner.
*/
return wpm_apply_filters_typed( 'boolean', 'wpmedia_plugin_family_show_imagify_banner', $can_enqueue );
}

/**
Expand Down
Loading