Skip to content

Instantly share code, notes, and snippets.

@the-sufi
Created July 30, 2021 02:00
Show Gist options
  • Save the-sufi/8a7b709d144392c7397a29f985fd9428 to your computer and use it in GitHub Desktop.
Save the-sufi/8a7b709d144392c7397a29f985fd9428 to your computer and use it in GitHub Desktop.
WordPress - Disable option to deactivate Plugin
<?php
/**
* Disable option to deactivate Plugin
*
* @param $actions
* @param $plugin_file
* @param $plugin_data
* @param $context
* @return mixed
*/
function dctit_disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
$plugins = array(
'advanced-custom-fields-pro/acf.php',//update/add/delete as needed
);
if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, $plugins) ) {
unset( $actions['deactivate'] );
}
return $actions;
}
add_filter( 'plugin_action_links', 'dctit_disable_plugin_deactivation', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment