如果您计划写入pugin文件夹fopen
, fwite
, flose
您使用了错误的功能:
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:
您可能应该使用此功能:
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: }
那你就靠自己了:
$plugin_dir = plugin_dir_path( __FILE__ );
$logfile = $plugin_dir . \'log.csv\';
$fp = fopen($logfile, \'w\');
fwrite($fp, $data);
fclose($fp);
目前,WordPress中的插件拥有WordPress写入文件系统时的所有权限,这些权限是web服务器进程赋予的。
您的命名约定不完美:$databaseURL
可能是选错了。这不是URL。