Enter your keyword

Blog

How to Disable Plugin Deactivation in Wordpress

add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 4 );
function disable_plugin_deactivation( $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(
        'json-rest-api/plugin.php'
    )))
        unset( $actions['deactivate'] );
    return $actions;
}

No Comments

Add your review

Your email address will not be published.

* Feilds are Required.