Учитывая ваш код, электронное письмо будет удалено в любом случае (из-за esc_html), поэтому мы должны принять это.
Затем, прежде чем передавать строку в ваш printf
, мы должны сначала разобрать ее, используя обычный экспресс, чтобы найти электронное письмо, и заменить его ссылкой.
См модифицированную функцию ниже:
function maker_site_description() {
$class = 'site-description';
if (! get_theme_mod('display_blogdescription', true)) {
$class .= ' screen-reader-text';
}
// First we have to load the description into a variable
$description = get_bloginfo('description');
// This is a regular express that will find email addresses
$pattern = '/[a-z\d._%+-][email protected][a-z\d.-]+\.[a-z]{2,4}\b/i';
// Search the description for emails, and assign to $matches variable
preg_match($pattern, $description, $matches);
// Only make changes if a match has been found
if (! empty($matches[0])) {
$email = $matches[0];
// Build the "mailto" link
$link = '<a href="mailto:' . $email . '">' . $email . '</a>';
// Replace the email with the link in the description
$description = str_ireplace($email, $link, $description);
}
// NOW we can print, but we have to remove the esc_html
printf('<p class="%s">%s</p>', esc_attr($class), $description);
}
Вы имеете в виду электронный встраивается в тексте описания? Есть больше текста, чем просто электронная почта? Например, * «Добро пожаловать на мой сайт! Чтобы связаться со мной, напишите мне по адресу [email protected] Удовольствие!» * –