language_attributes

Definition:
function language_attributes($doctype = 'html') {}

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.

Parameters

  • string $doctype: The type of html document (xhtml|html).

Defined filters

  • language_attributes
    apply_filters('language_attributes', $output)

Source code

function language_attributes($doctype = 'html') {

	$attributes = array();

	$output = '';



	if ( function_exists( 'is_rtl' ) )

		$attributes[] = 'dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"';



	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);

	$output = apply_filters('language_attributes', $output);

	echo $output;

}

2241

No comments yet... Be the first to leave a reply!

Leave a comment