Skip to content

Instantly share code, notes, and snippets.

@devuri
Last active June 2, 2023 15:10
Show Gist options
  • Select an option

  • Save devuri/034ccb7c833f970192bb64317814da3b to your computer and use it in GitHub Desktop.

Select an option

Save devuri/034ccb7c833f970192bb64317814da3b to your computer and use it in GitHub Desktop.

Revisions

  1. devuri revised this gist Jun 2, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion disable-deactivate-plugins.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    /**
    * Prevent Admin users from deactivating plugins.
    *
    * While this will remove the deactivation link id does NOT prevent deactivation
    * While this will remove the deactivation link it does NOT prevent deactivation
    * It will only hide the link to deactivate.
    */
    add_filter( 'plugin_action_links', function ( $actions, $plugin_file, $plugin_data, $context ) {
  2. devuri created this gist Jun 2, 2023.
    17 changes: 17 additions & 0 deletions disable-deactivate-plugins.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <?php

    /**
    * Prevent Admin users from deactivating plugins.
    *
    * While this will remove the deactivation link id does NOT prevent deactivation
    * It will only hide the link to deactivate.
    */
    add_filter( 'plugin_action_links', function ( $actions, $plugin_file, $plugin_data, $context ) {

    if ( array_key_exists( 'deactivate', $actions ) ){
    unset( $actions['deactivate'] );
    }

    return $actions;

    }, 10, 4 );