Created
August 25, 2020 07:07
-
-
Save knilkantha/0de61ce2645d80a3d8fa4edb6e8a6fec to your computer and use it in GitHub Desktop.
Hide deactivation option in specific WordPress plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Add this code on plugin's main file. This will hide current plugin's deactivation option | |
| add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'disable_plugin_deactivation' ); | |
| function disable_plugin_deactivation ($actions) { | |
| unset( $actions['deactivate'] ); | |
| return $actions; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Add this code on plugin's main file. This will hide current plugin's deactivation option | |
| add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 2 ); | |
| function disable_plugin_deactivation( $actions, $plugin_file) { | |
| if ( plugin_basename( __FILE__ ) === $plugin_file ) { | |
| unset( $actions['deactivate'] ); | |
| } | |
| return $actions; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //This will hide deactivate option on specific plugin, We can add this code on site-specific plugin or function.php | |
| add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 2 ); | |
| function disable_plugin_deactivation( $actions, $plugin_file ) { | |
| //To hide deactivate option on abc and xyz plugin. | |
| if ( in_array( $plugin_file, array('abc/abc.php','xyz/xyz.php') ) ){ | |
| unset( $actions['deactivate'] ); | |
| } | |
| return $actions; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment