I'm working on wordpress project, Theme have some demos i've added add_menu_page where all of the demos stored e.g pictures and names, I know the REST-API where i've added condition if theme license is correct then give file, But i don't know how to add that file in theme directory of wordpress when user will click and remove previous one or overwrite previous file.

  • 1
    You can't. The only directory with guaranteed write access is the uploads directory, everything else might be write-protected. – fuxia Jul 19 '20 at 1:32

Hopefully you have access to your server (i.e. you don't use a wordpress.com website but have your own server).

You'll have to connect to the server with either SFTP or SSH (via the use of scp to copy files) or another similar protocol and upload the files to wherever you want. In order to use these, you generally have a special URL and you'll need a login/password (SFTP) or a security key (SSH). At times, the services offer you a system such as phpMyAdmin. That should also give you access to your server file system and you can upload files through that system.

The PHP code from Wordpress will not allow you to just go in and update just any file or directory for obvious security reasons (already the plugins are editable...)

If you do not own the server, depending on your provider, you may be able to ask them to do it for you. There may be extra charges or just plain refusal, again, for security reasons (especially if that provider runs many Wordpress websites, it could jeopardize the other sites).

  • Thank you for reply but i'm looking for admin_dashboard solution which will install theme without adding manually or with SFTP becasue for this need login/password which is big security issue. I want solution like many premium themes offering demos and when you click on selected demo it'll auto install. I've built everything my node server which will give file on request after checking license, but now stuck on wp upoad part, trying different options but no any progress yet! – Muizz Ahmed Jul 19 '20 at 3:41
  • Right. I was thinking that you manually installed a few files here and there with SFTP as required, then the themes can auto-install as required. That is, you don't give the login/password to the theme owner. Anyway, they can write code in their theme to do nearly anything they want to your Wordpress environment (possibly all your Apache2 accessible directories) so if you don't trust them, why not get a free theme and be done with it. – Alexis Wilke Jul 19 '20 at 4:00
  • I'm gonna start web market, i focused on main platform backend apis now building themes with some years of experience, I don't know a lot about wp_core just few things, So can i add files from wordpress admin dashboard to public_html without giving personal info ? – Muizz Ahmed Jul 19 '20 at 4:23
  • What I've seen before are plugins for things such as Google Analytics that will pretend that they added a file in the root (/) folder by capturing the URL. For Google Analytics, you're expected to add a file with some random number in hex such as A67F3C9...E.txt and that fille includes some info that Google Analytics uses to confirm that the site is what it says it is. I'd bet you could do the same thing with your theme. – Alexis Wilke Jul 19 '20 at 7:02
  • But i think it'd be good to launch few themes, just with api license and main platform will give updates if it's valid, first go in market without these things because phisher are everywhere so stop worrying start it. and thank you @Alexis Wilke, for giving time here! – Muizz Ahmed Jul 19 '20 at 12:08

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.