| 1 |
<?php |
| 2 |
// Exit if accessed directly. |
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Disable the built-in file editor in WordPress. |
| 9 |
* |
| 10 |
* This function disables the theme and plugin file editors in the WordPress dashboard |
| 11 |
* if the 'ns_shield_file_editor' option is enabled. Note that installing and deleting plugins remain allowed. |
| 12 |
* |
| 13 |
* @return void |
| 14 |
*/ |
| 15 |
function ns_shield_disable_file_editor() { |
| 16 |
if ( get_option( 'ns_shield_file_editor' ) ) { |
| 17 |
// Disable file editing if not already defined. |
| 18 |
if ( ! defined( 'DISALLOW_FILE_EDIT' ) ) { |
| 19 |
define( 'DISALLOW_FILE_EDIT', true ); |
| 20 |
} |
| 21 |
} |
| 22 |
} |
| 23 |
add_action( 'init', 'ns_shield_disable_file_editor' ); |
| 24 |
|
| 25 |
|