root / drupal7 / sites / all / themes / bootstrap / templates / system / html-tag.vars.php @ 9525582e
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* Stub file for "html_tag" theme hook [pre]process functions.
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Processes variables for the "html_tag" theme hook.
|
9 |
*
|
10 |
* See theme function for list of available variables.
|
11 |
*
|
12 |
* @see theme_html_tag()
|
13 |
*
|
14 |
* @ingroup theme_process
|
15 |
*/
|
16 |
function bootstrap_process_html_tag(&$variables) { |
17 |
// Reference the element and tag name for easier coding below.
|
18 |
$element = &$variables['element']; |
19 |
$tag = $element['#tag']; |
20 |
if ($tag === 'style' || $tag === 'script') { |
21 |
// Remove default "type" attribute. Leave others unaffected as it may be
|
22 |
// needed and used for other purposes.
|
23 |
// @see http://stackoverflow.com/a/5265361/1226717
|
24 |
// @see https://www.drupal.org/node/2201779
|
25 |
$types = array( |
26 |
// @see http://www.w3.org/TR/html5/document-metadata.html#attr-style-type
|
27 |
'style' => 'text/css', |
28 |
// @see http://www.w3.org/TR/html5/scripting-1.html#attr-script-type
|
29 |
'script' => 'text/javascript', |
30 |
); |
31 |
if (!empty($element['#attributes']['type']) && $element['#attributes']['type'] === $types[$tag]) { |
32 |
unset($element['#attributes']['type']); |
33 |
} |
34 |
|
35 |
// Remove CDATA comments. CDATA is only required for DOCTYPES that are XML
|
36 |
// based, HTML5 is not.
|
37 |
$cdata_prefix = array( |
38 |
'style' => "\n<!--/*--><![CDATA[/*><!--*/\n", |
39 |
'script' => "\n<!--//--><![CDATA[//><!--\n", |
40 |
); |
41 |
$cdata_suffix = array( |
42 |
'style' => "\n/*]]>*/-->\n", |
43 |
'script' => "\n//--><!]]>\n", |
44 |
); |
45 |
if (
|
46 |
!empty($element['#value_prefix']) && $element['#value_prefix'] === $cdata_prefix[$tag] && |
47 |
!empty($element['#value_suffix']) && $element['#value_suffix'] === $cdata_suffix[$tag] |
48 |
) { |
49 |
unset($element['#value_prefix'], $element['#value_suffix']); |
50 |
} |
51 |
|
52 |
// Remove the "media=all" attribute, leave others unaffected.
|
53 |
if (isset($element['#attributes']['media']) && $element['#attributes']['media'] === 'all') { |
54 |
unset($element['#attributes']['media']); |
55 |
} |
56 |
} |
57 |
} |