• Skip to main content
  • Skip to primary sidebar
  • Business
  • WordPress
  • Security
  • Marketing
  • Publicity
  • Computing
  • Resources
  • Whatevs

Purely Wordpress

Just The Tech, News, and Info We Deem To Post

  • Home
  • About
  • Contact
  • Contribute
You are here: Home / WordPress Core / Disable WordPress Plugin Deactivation

Disable WordPress Plugin Deactivation

Screenshot of WordPress plugin php and html code

Add the following code to your WordPress theme’s function.php file, or a functionality plugin.

add_filter( 'plugin_action_links', 'slt_lock_plugins', 10, 4 );
function slt_lock_plugins( $actions, $plugin_file, $plugin_data, $context ) {
	// Remove edit link for all
	if ( array_key_exists( 'edit', $actions ) )
		unset( $actions['edit'] );
	// Remove deactivate link for crucial plugins
	if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
		'slt-custom-fields/slt-custom-fields.php',
		'slt-file-select/slt-file-select.php',
		'slt-simple-events/slt-simple-events.php',
		'slt-widgets/slt-widgets.php'
	)))
		unset( $actions['deactivate'] );
	return $actions;
}

by Jack Alltrade on September 6, 2017

Filed Under: WordPress Core Tagged With: Code, Plugins, WP Core

Reader Interactions

Share Your Two Cents Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • Code Snippets
  • Development
  • File Management
  • Genesis Framework
  • Hosting
  • Legacy
  • Plugins
  • SEO
  • Tech Terms
  • Themes
  • User Experience
  • User Interface
  • WordPress Core
  • WordPress Functionality

© Copyright Jack Alltrade & Associates 2025 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates