Plugin – Edit file in the backend through

Hello there,

I’m just programming my own plugin and I want it to offer the possibility to edit a specific file in the backend which stores for example custom css-code.

I used the method file_put_contents() but nothing happend, no file was stored (and the directory was correct!). So I tried it with error reporting but no error was shown. As I thought that the reason could be the directory permissions I look at the permissions of the directory of the file and of the file itself. I changed the permissions for a short time so that every permission is given for everyone (rwx-rwx-rwx) – but it still didn’t work.

Then I tried to edit the same file by using the WordPress plugin editor – and – it worked (no matter that the permission was ‘rwx-r—r–‘. But this way doesn’t fit for me cause I need a way to let my website editors only writing one but not all files of my plugin.

So now my question: How is it possible to programm a text-file-editor similar to the wordpress plugin editor but only for one specific file?

Or more general: How can I programm a text field for the backend from which the inserted text is stored in a file of the plugin directory?

Thank you
Daniel

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer