Skip to content

Commit

Permalink
Replace multisite-plugin-manager with custom functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mikethicke committed Oct 14, 2024
1 parent 960618d commit 5c46fcf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"wpackagist-plugin/issuem":"^2.8.7",
"wpackagist-plugin/jetpack":"^12.2",
"wpackagist-plugin/mathml-block":"^1.2.1",
"wpackagist-plugin/multisite-plugin-manager":"^3.1.6",
"wpackagist-plugin/ninja-forms":"^3.6.16",
"wpackagist-plugin/participants-database":"^2.1.5",
"wpackagist-plugin/pressforward":"^5.2.9",
Expand Down
1 change: 1 addition & 0 deletions core-plugins/humanities-commons/humanities-commons.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function hcommons_write_error_log( $error_type, $error_message, $info = null ) {
require_once ( dirname( __FILE__ ) . '/mailchimp.php' );
require_once ( dirname( __FILE__ ) . '/class-kc-ptc-command.php' );
require_once ( dirname( __FILE__ ) . '/class-kc-command.php' );
require_once ( dirname( __FILE__ ) . '/manage-plugins.php' );

class Humanities_Commons {

Expand Down
31 changes: 31 additions & 0 deletions core-plugins/humanities-commons/manage-plugins.php
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');

0 comments on commit 5c46fcf

Please sign in to comment.