Skip to content

Instantly share code, notes, and snippets.

@smartdeal
Last active June 13, 2018 13:08
Show Gist options
  • Save smartdeal/607bc01a0e09f3e732c95441ebdbcb51 to your computer and use it in GitHub Desktop.
Save smartdeal/607bc01a0e09f3e732c95441ebdbcb51 to your computer and use it in GitHub Desktop.
[Как запретить клиентам отключать важные плагины в WordPress] #WP #WP_functions
<?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