功能:
在中显示当前的语言属性
用法:
参数:
$doctype
(string) (optional) The type of html document ‘xhtml‘ or ‘html‘.
默认‘html‘
返回值:
void
这个函数没有返回值,用于直接输出
所在位置:
language_attributes() 包含在 wp-includes/general-template.php.
源码:
/**
* Display the language attributes for the html tag.
*
* Builds up a set of html attributes containing the text direction and language
* information for the page.
*
* @since 2.1.0
*
* @param string $doctype The type of html document (xhtml|html).
*/
function language_attributes($doctype = 'html') {
$attributes = array();
if ( function_exists( 'is_rtl' ) && is_rtl() )
$attributes[] = 'dir="rtl"';
if ( $lang = get_bloginfo('language') ) {
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
$attributes[] = "lang=\"$lang\"";
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
$attributes[] = "xml:lang=\"$lang\"";
}
$output = implode(' ', $attributes);
/**
* Filter the language attributes for display in the html tag.
*
* @since 2.5.0
*
* @param string $output A space-separated list of language attributes.
*/
echo apply_filters( 'language_attributes', $output );
}
示例:
>
...
相关函数:
感觉本站内容不错,读后有收获?小额赞助
还可以分享文章给好友: