Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems copying file to home directory PHP
    primarykey
    data
    text
    <p>I'm trying copy a single file from the Plugin directory inside of my Wordpress installation to the root directory of the Wordpress installation. I need the functionality to do this no matter where the installation is located. It's for my Wordpress plugin, and it doesn't seem to be working on a site I tested. </p> <p>Somehow I'm thinking that I'm not capturing each possible directory location in my <code>function destpath()</code> function. I need it to successfully find the exact directories of the Plugin folder so that it copies the file (process.php) to the exact root directory, no matter the location of the Wordpress install.</p> <pre><code>function destpath() { $base = dirname(__FILE__); $path = false; if (@file_exists(dirname(dirname($base))."/wp-config.php")) { $path = dirname(dirname($base))."/process.php"; } else if (@file_exists(dirname(dirname(dirname($base)))."/wp-config.php")) { $path = dirname(dirname(dirname($base)))."/process.php"; } else $path = false; if ($path != false) { $path = str_replace("\\", "/", $path); } return $path; } function pluginpath() { $base = dirname(__FILE__); $path = false; if (@file_exists(dirname(dirname($base))."/wp-content/plugins/malware finder/process.php")) { $path = dirname(dirname($base))."/wp-content/plugins/malware finder/process.php"; } else if (@file_exists(dirname(dirname(dirname($base)))."/wp-content/plugins/malware finder/process.php")) { $path = dirname(dirname(dirname($base)))."/wp-content/plugins/malware finder/process.php"; } else $path = false; if ($path != false) { $path = str_replace("\\", "/", $path); } return $path; } copy(pluginpath(), destpath()); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload