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.
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