Commit 6d19fba0 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Use a filter to block plugin installs

This approach doesn't break the site-health report and allows for live
background updates of components.
parent a9906e6f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -4,14 +4,6 @@
 * Additional configurations required by the docker image
 ****/

/**
 * Plugins, themes and language packs cannot be configured through the admin 
 * interface; modify the configuration in /etc/wordpress/ according to the 
 * documentation for PLUGINS[_LIST], THEMES[_LIST] and LANGUAGES[_LIST]
 **/
if ( !defined( 'WP_CLI' ) )
	define('DISALLOW_FILE_MODS', true);

/**
 * Disable running wp-cron.php on every page load. A sidecar process
 * examines the status of cron jobs and handles scheduling and running them.
+19 −0
Original line number Diff line number Diff line
<?php
/**
 * Plugin Name: Disable New Plugins
 * Plugin URI: https://code.kodo.org.uk/singing-chimes.co.uk/wordpress/tree/master/plugins
 * Description: Removes the "Add Plugin" button from the admin dashboard
 * Licence: MPL-2.0
 * Licence URI: https://www.mozilla.org/en-US/MPL/2.0/
 * Author: Dominik Sekotill
 * Author URI: https://code.kodo.org.uk/dom
 */

add_filter( 'user_has_cap', 'override_plugin_install', 10, 3 );

function override_plugin_install( $allcaps, $caps, $args ) {
	if ( 'install_plugins' == $args[0] ) {
		$allcaps[$caps[0]] = false;
	}
	return $allcaps;
}