如何在使用过滤器时输出变量?
问题描述:
我想检查我在$file
中得到了什么。如何在使用过滤器时输出变量?
我在这里发现了simlar问题,但在这种情况下无法正常工作。 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);
感谢您的回复,但是如果我想在过滤器工作时回显一个单词,怎么样? – OMG
尝试使用'wp_die(print_r($ file,true))'。 –
谢谢,但没有工作:( – OMG