使用过滤器时如何输出变量?
How to output variable when use filter?
我想查看我在 $file
中得到了什么。
我在这里发现了类似的问题,但在这种情况下不起作用。
https://wordpress.stackexchange.com/questions/51145/get-php-variable-from-functions-php-and-echo-it-in-theme-template-files
有人可以帮助我吗?或者给我一个关键字。
WordPress functions.php
function wp_modify_uploaded_file_names($file) {
$info = pathinfo($file['name']);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($file['name'], $ext);
$file['name'] = uniqid() . $ext; // uniqid method
print_r($file);
return $file;
}
add_filter('wp_handle_upload_prefilter', 'wp_modify_uploaded_file_names', 1, 1);
单个参数 $file
表示 $_FILES
数组的单个元素。您可以通过 $file['tmp_name']
.
访问服务器上存储上传文件的文件的临时文件名
我想查看我在 $file
中得到了什么。
我在这里发现了类似的问题,但在这种情况下不起作用。 https://wordpress.stackexchange.com/questions/51145/get-php-variable-from-functions-php-and-echo-it-in-theme-template-files
有人可以帮助我吗?或者给我一个关键字。
WordPress functions.php
function wp_modify_uploaded_file_names($file) {
$info = pathinfo($file['name']);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($file['name'], $ext);
$file['name'] = uniqid() . $ext; // uniqid method
print_r($file);
return $file;
}
add_filter('wp_handle_upload_prefilter', 'wp_modify_uploaded_file_names', 1, 1);
单个参数 $file
表示 $_FILES
数组的单个元素。您可以通过 $file['tmp_name']
.