-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace multisite-plugin-manager with custom functionality
- Loading branch information
1 parent
960618d
commit 5c46fcf
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Control which plugins users can activate themselves on KC network sites. | ||
*/ | ||
|
||
namespace KC\PTC; | ||
|
||
/** | ||
* Filter the list of plugins shown in the admin area. | ||
* | ||
* @param array $plugins An array of plugin data. | ||
* @return array Modified array of plugin data. | ||
*/ | ||
function filter_visible_plugins($plugins) { | ||
$allowed_plugins = get_network_option(get_current_network_id(), 'pm_user_control_list', []); | ||
|
||
$filtered_plugins = []; | ||
foreach ($plugins as $plugin_path => $plugin) { | ||
$plugin_slug = explode('/', $plugin_path)[0]; | ||
if ( | ||
in_array($plugin_slug, $allowed_plugins) || | ||
in_array($plugin_path, $allowed_plugins) || | ||
( is_plugin_active($plugin_path) && ! is_plugin_active_for_network($plugin_path) ) | ||
) { | ||
$filtered_plugins[] = $plugin; | ||
} | ||
} | ||
|
||
return $filtered_plugins; | ||
} | ||
add_filter('all_plugins', 'KC\PTC\filter_visible_plugins'); |