2

I see that some plugins like Wordfence can write on core folders like wp-includes or wp-admin (if write permission is enable). In case everything is permitted, is there a way to interact with the hosting from admin dashboard only? Assuming this is on the site installation folder only.


See also:
Is there a way to figure out the way to access hosting if I have admin privilege?WordPress file manager plugin that can change file permission? in Software Recommendations

6
  • 1
    Your host would need an API to access its information, and you would need to write a plugin that uses that API. So you will need to ask your host what is available. It's almost certainly impossible to create a plugin that can interact with any user's host, no matter who they are. – Jacob Peattie Apr 14 '20 at 14:01
  • thank you. You can make that answer and I'll accept it. But I forget to mention that I just want to modify the folder in which the site is installed. For example, if a plugin can change and update the sitemap, can I manually delete it with some plugins, regardless of my hosting? – Ooker Apr 14 '20 at 19:34
  • It depends on the file permissions of the account. You can theoretically read and write whatever files you want on the same hosting account, but in an optimally configured WordPress environment, the only place place you can reliably write files with your plugin is the uploads directory. – Jacob Peattie Apr 15 '20 at 1:06
  • I need to read and write files like that. What resource do I need to know more? – Ooker Apr 15 '20 at 4:56
  • @JacobPeattie What do you mean by 'Your host would need an API'? PHP can manipulate the file system without problems, if the PHP server has sufficient permissions. – dboris Apr 15 '20 at 14:21
4

You basically have two options:

  1. Use any of the available File Manager plugins for WordPress. Just Google them, literally that phrase I just used.
  2. Implement a custom PHP code in your theme or custom plugin which will utilize any of the PHP functions for manipulating the files. For example, check these:

There are also a ton of functions for more advanced file manipulation in PHP. Check this for reference: Filesystem Functions

2
  • hmm, if chmod() can change permissions, then wouldn't that create a vulnerability, since you need to open write permission somewhere? – Ooker Apr 16 '20 at 15:27
  • Every line of the code executed on the server possibly creates a vulnerability. To effectively use chmod() PHP server has to already have write permission on the files. If the PHP server has write permissions, it doesn't mean any user have it as well, because that depends on the owner and the group the file belongs to. I suggest you check this or this to learn more. – dboris Apr 17 '20 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.