Make WordPress Core

Opened 2 years ago

Last modified 12 months ago

#56301 assigned feature request

Add File Backup Feature in wp_edit_theme_plugin_file()

Reported by: sajjad67's profile sajjad67 Owned by: sajjad67's profile sajjad67
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Filesystem API Keywords: 2nd-opinion
Focuses: Cc:


I thought about the security before creating this ticket, but still let's discuss about the possibility of it for once! The way it works now is if you edit a file using the plugin/theme-editor.php, there's no way of going back! It only checks for any Fatal Error!

Now what i think, would it be good/bad if we add a feature to create a (temp) backup of each file edited, like we do for posts/pages as revisions! There's lots to take into consideration before we discuss about it, i know! But is there anyone else thinking like me this could be a feature!!

Let me know if it's open for any further discussion!

Attachments (2)

file.php.patch (600 bytes) - added by sajjad67 2 years ago.
A Testing Patch, Added an action hook inside wp_edit_theme_plugin_file() function
2-file.php.patch (686 bytes) - added by sajjad67 2 years ago.
$plugin and $theme variable as params

Download all attachments as: .zip

Change History (7)

#1 @sajjad67
2 years ago

@SergeyBiryukov @audrasjb @ipstenu LMK your thoughts!! Thanks!

#2 @audrasjb
2 years ago

  • Keywords 2nd-opinion added
  • Version 6.0 deleted

Hello, welcome back to Trac and thank you for the proposal!

I think this project should ideally be proposed in a Feature Plugin, so it could get a blogpost on Make/Core to introduce the feature, to help contributors testing it live on a website, to make sure it's relevant and to discuss whether it's something worth adding in Core or if it is plugins territory.

Looking at wp_edit_theme_plugin_file() I'm thinking we could at least add some hook to help building this Feature Plugin.

#3 @sajjad67
2 years ago

@audrasjb I am not sure how to propose that in a Feature Plugin... Never done that! But a hook is best option in the function with filename, previous_content, new_content params.

LMK how we can go ahead with that!

Last edited 2 years ago by sajjad67 (previous) (diff)

2 years ago

A Testing Patch, Added an action hook inside wp_edit_theme_plugin_file() function

#4 @sajjad67
2 years ago

In the action hook, there's possible to add some more params, such as $plugin, $theme whether it is a plugin or theme being edited! as conditionally it theme being edited $plugin value is set to null, same goes for $theme variable.

2 years ago

$plugin and $theme variable as params

This ticket was mentioned in Slack in #core by sajjad67. View the logs.

12 months ago

Note: See TracTickets for help on using tickets.