admin管理员组文章数量:1316339
php I have a filter for limit max upload file size with custtom message. I want to add link there, but html does not work here. Can you help me someone?
Here is my code
add_filter("wp_handle_upload_prefilter", function ($file) {
$file_size_limit = 1024;
$current_size = $file["size"];
$current_size = $current_size / 1024;
if ($current_size > $file_size_limit) {
$file["error"] = sprintf(
__("File is too large contact <a href=\"mailto:[email protected]\">admin</a>."));
}
return $file;
});
My problem is that I got a plain text instead of html.
Thanks for help.
php I have a filter for limit max upload file size with custtom message. I want to add link there, but html does not work here. Can you help me someone?
Here is my code
add_filter("wp_handle_upload_prefilter", function ($file) {
$file_size_limit = 1024;
$current_size = $file["size"];
$current_size = $current_size / 1024;
if ($current_size > $file_size_limit) {
$file["error"] = sprintf(
__("File is too large contact <a href=\"mailto:[email protected]\">admin</a>."));
}
return $file;
});
My problem is that I got a plain text instead of html.
Thanks for help.
Share Improve this question asked Nov 11, 2020 at 14:42 SilmarionSilmarion 11 bronze badge 4 |1 Answer
Reset to default 0Please try this to add HTML:
$link = '<a href="mailto:[email protected]">admin</a>';
sprintf( __( 'File is too large contact %s.', 'my-textdomain' ), $link );
In this case the placeholder "%s" is replaced with the value of the variable "$link". And that variable is filled before.
本文标签: functionsHow to add HTML into error message
版权声明:本文标题:functions - How to add HTML into error message 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742001806a2411163.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
add_action('admin_notices', function () {…}
But that show message at load page before upload media. – Silmarion Commented Nov 11, 2020 at 15:12contact admin at [email protected]
as a stopgap until a solution is found. The key difference withadmin_notices
is that PHP is what's outputting that markup, whereas on upload it's being returned in JSON for javascript to handle, because uploads happen via AJAX. You may get what you want if you use the simple uploader in the media section of the admin area, rather than the JS uploader in post edit screens etc – Tom J Nowell ♦ Commented Nov 11, 2020 at 15:13