If you plan to write to a pugin folder since you used fopen
, fwite
, flose
you are using the wrong function:
File: wp-includes/link-template.php
3189: /**
3190: * Retrieves a URL within the plugins or mu-plugins directory.
3191: *
3192: * Defaults to the plugins directory URL if no arguments are supplied.
3193: *
3194: * @since 2.6.0
3195: *
3196: * @param string $path Optional. Extra path appended to the end of the URL, including
3197: * the relative directory if $plugin is supplied. Default empty.
3198: * @param string $plugin Optional. A full path to a file inside a plugin or mu-plugin.
3199: * The URL will be relative to its directory. Default empty.
3200: * Typically this is done by passing `__FILE__` as the argument.
3201: * @return string Plugins URL link with optional paths appended.
3202: */
3203: function plugins_url( $path="", $plugin = '' ) {
3204:
You should probable use this function:
File: wp-includes/plugin.php
703: /**
704: * Get the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in.
705: *
706: * @since 2.8.0
707: *
708: * @param string $file The filename of the plugin (__FILE__).
709: * @return string the filesystem path of the directory that contains the plugin.
710: */
711: function plugin_dir_path( $file ) {
712: return trailingslashit( dirname( $file ) );
713: }
Then you are on your own:
$plugin_dir = plugin_dir_path( __FILE__ );
$logfile = $plugin_dir . 'log.csv';
$fp = fopen($logfile, 'w');
fwrite($fp, $data);
fclose($fp);
At the moment plugins in WordPress have all the rights WordPress have when writing to a file system, and these are the rights given from the web server process.
Your naming convention is not perfect: $databaseURL
is probably bad chosen. This is not a URL.