0

I'm currently designing a Wordpress plugin that will copy a file from the plugin directory to the root directory of the user's server. The code below currently contains MY server's location for the source and destination. But I'm unsure how to re-write this to make it applicable to ANY USER'S server configuration, whatever that may be.

In short, I want to copy process.php from the plugin directory to the root directory of the Wordpress installation for ANY user.

<?php

$baseurl = $_SERVER['DOCUMENT_ROOT'];

$pluginfile = '/testenvironment/wp-content/plugins/malware finder/process.php'; 

$destinationfile = '/testenvironment/process.php';

$pluginfilefullpath = $_SERVER['DOCUMENT_ROOT'] . $pluginfile;

$destinationfilefullpath = $_SERVER['DOCUMENT_ROOT'] . $destinationfile;

copy($pluginfilefullpath, $destinationfilefullpath); 

?>
Rob Myrick
  • 859
  • 11
  • 28
  • Maybe this can help: http://stackoverflow.com/questions/2354633/wordpress-root-directory – Optimist Feb 27 '12 at 00:06
  • Hi Optimist, that's a good reference. Any ideas how I could use it with my posted code? The code in your reference seems a little over my head. – Rob Myrick Feb 27 '12 at 00:18
  • I assume that if you copy the code in the accepted answer, the newly created `fs_get_wp_config_path()` function will return the root directory. In that case you can use `$destinationfile = fs_get_wp_config_path() . '/process.php';` – Optimist Feb 27 '12 at 00:29
  • I echoed this and it's returning the path of wp-config.php, so I'm still trying to make it work. If anyone could help that's great. Thanks – Rob Myrick Feb 27 '12 at 00:57

0 Answers0