我想在 Wordpress 的小部件描述中添加换行符,以在管理面板中显示使用说明,如下所示:
To format the text use the tags:
<h3>Subtitle</h3>
<strong>Bold</strong>
[:pt]Text in Portuguese
[:en]Text in English
[:es]Text in Spanish
到目前为止的想法是使用 ISO 8859-1 符号 (
) 添加空格,这不是最佳解决方案(描述为葡萄牙语):
register_sidebar( array(
'name' => 'Widget',
'id' => 'widget-user',
'description' => "Para formatar o texto, utilize as tags: <h3>Subtítulo laranja</h3> <strong>Negrito</strong> [:pt]Texto em português nbsp; [:en]Texto em inglês [:es]Texto em espanhol (o que estiver escrito fora das tags de idioma irão aparecer para todos",
'before_widget' => '<div class="widget-user"><div class="box">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
与'before_widget'、'after_widget'、'before_title'和'after_title'项不同,'description'不接受HTML。如果是这样,只需转义 HTML 即可轻松解决,我不想使用 .php 之类的 php 函数将其转换为 HTML htmlspecialchars()
。
我拼命尝试了这些但没有成功:
"description" => "This is a line <br> break test"
"description" => "This is a line \n break test"
"description" => "This is a line \r break test"
"description" => "This is a line \r\n break test"
"description" => htmlspecialchars("This is a line <br>break test")
htmlspecialchars("description") => "This is a line <br>break test"
"description" => htmlentities("This is a line <br>break test")
"description" => html_entity_decode("This is a line <br>break test")
"description" => nl2br("This is a line <br> break test")
nl2br("description") => nl2br("This is a line <br> break test")
那么,有什么想法吗?