Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
# disallow-file-edit-wordpress
# Disallow File Edit - WordPress Plugin

## In wp-config.php
```
define('DISALLOW_FILE_EDIT', true);
A simple WordPress plugin that enhances security by disabling the file editor and file modifications in the WordPress admin area.

## Features

- Disables the plugin and theme file editor in WordPress admin
- Prevents file modifications including plugin/theme installation and updates
- Lightweight and easy to use
- No configuration needed - works immediately upon activation

## Installation

1. Download the plugin files
2. Upload the `disallow-file-edit.php` file to the `/wp-content/plugins/disallow-file-edit/` directory, or install the plugin through the WordPress plugins screen directly
3. Activate the plugin through the 'Plugins' screen in WordPress

## What This Plugin Does

This plugin defines two WordPress security constants:

- `DISALLOW_FILE_EDIT` - Disables the plugin and theme file editor in the WordPress admin
- `DISALLOW_FILE_MODS` - Disables all file modifications including plugin/theme installation and updates

## Alternative Configuration Methods

If you prefer not to use a plugin, you can achieve the same result by adding the following code:

### In wp-config.php
```php
define('DISALLOW_FILE_EDIT', true);
define('DISALLOW_FILE_MODS', true);
```
# OR

## In Functions.php
### In Functions.php

```
```php
function disable_mytheme_action() {

define('DISALLOW_FILE_EDIT', true);

define('DISALLOW_FILE_MODS', true);

}
add_action('init','disable_mytheme_action');
```

## License

This plugin is licensed under GPL v2 or later.
37 changes: 37 additions & 0 deletions disallow-file-edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Plugin Name: Disallow File Edit
* Plugin URI: https://github.com/TibetOS/disallow-file-edit-wordpress
* Description: Disables the file editor and file modifications in WordPress admin for enhanced security.
* Version: 1.0.0
* Author: TibetOS
* Author URI: https://github.com/TibetOS
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: disallow-file-edit
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}

/**
* Disable file editing and modifications in WordPress admin.
*
* This function defines two constants that enhance WordPress security:
* - DISALLOW_FILE_EDIT: Disables the plugin and theme file editor in admin
* - DISALLOW_FILE_MODS: Disables all file modifications including plugin/theme installation and updates
*/
function disallow_file_edit_init() {
// Disable the plugin and theme file editor
if ( ! defined( 'DISALLOW_FILE_EDIT' ) ) {
define( 'DISALLOW_FILE_EDIT', true );
}

// Disable all file modifications (plugin/theme installation, updates, etc.)
if ( ! defined( 'DISALLOW_FILE_MODS' ) ) {
define( 'DISALLOW_FILE_MODS', true );
}
}
add_action( 'init', 'disallow_file_edit_init' );