How to disable option to deactivate plugin in WordPress

Did you ever feel the need to disable plugin deactivation option? I generally use ACF to add and show custom content for clients. Now if the client deactivate ACF plugin, this could break their site. Instead of taking this risk, we can easily disable the deactivation option for specific plugin.

function careless_disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
    $plugins = array(
        'advanced-custom-fields-pro/acf.php',//acf pro

    if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, $plugins) ) {
        unset( $actions['deactivate'] );
    return $actions;
add_filter( 'plugin_action_links', 'careless_disable_plugin_deactivation', 10, 4 );

In the $plugins array you can add any plugin in this format: plugin-directory-name/plugin-main-file-name.php.

Code goes in the functions.php file of your active theme.