get_language_attributes
Gets the language attributes for the html tag.
Description
get_language_attributes( (string) $doctype = 'html' );
Builds up a set of html attributes containing the text direction and language information for the page.
Parameters (1)
- 0. $doctype — Optional. (string) =>
'html'
- The type of html document. Accepts xhtml or html.. Default html..
Usage
if ( !function_exists( 'get_language_attributes' ) ) { require_once ABSPATH . WPINC . '/general-template.php'; } // Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'. $doctype = 'html'; // NOTICE! Understand what this does before running. $result = get_language_attributes($doctype);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/general-template.php
- function get_language_attributes( $doctype = 'html' ) {
- $attributes = array();
- $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);
- /**
- * Filters the language attributes for display in the html tag.
- *
- * @since 2.5.0
- * @since 4.3.0 Added the `$doctype` parameter.
- *
- * @param string $output A space-separated list of language attributes.
- * @param string $doctype The type of html document (xhtml|html).
- */
- return apply_filters( 'language_attributes', $output, $doctype );
- }