Last active
June 13, 2018 13:08
-
-
Save smartdeal/607bc01a0e09f3e732c95441ebdbcb51 to your computer and use it in GitHub Desktop.
[Как запретить клиентам отключать важные плагины в WordPress] #WP #WP_functions
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
<?php | |
function mihdan_disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) { | |
// Удалить ссылку редактирования исходного кода | |
// для всех плагинов | |
if ( array_key_exists( 'edit', $actions ) ) { | |
unset( $actions[ 'edit' ] ); | |
} | |
// Массив важных плагинов | |
$important_plugins = array( | |
'wpmu-dev-plusone/plusone.php', | |
'plugin-folder-name/plugin.php', | |
); | |
// Удалить ссылку деактивирования у | |
// критически важных плагинов | |
if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, $important_plugins ) ) { | |
unset( $actions[ 'deactivate' ] ); | |
} | |
return $actions; | |
} | |
add_filter( 'plugin_action_links', 'mihdan_disable_plugin_deactivation', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment