From fd70fa5ff7cec722a69f3e720a962aea3dec03fe Mon Sep 17 00:00:00 2001 From: Sébastien Adam Date: Wed, 25 Nov 2015 18:25:17 +0100 Subject: HTML Helper - meta(): now can generate HTML meta charset & Open Graph property --- system/helpers/html_helper.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 28fbe00be..4e25f8c9b 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -338,7 +338,7 @@ if ( ! function_exists('link_tag')) if ( ! function_exists('meta')) { /** - * Generates meta tags from an array of key/values + * Generates meta tags from an array of key/values, compatible with html5 and open graph * * @param array * @param string @@ -359,13 +359,14 @@ if ( ! function_exists('meta')) // Turn single array into multidimensional $name = array($name); } - + $allowed_type = array('charset', 'http-equiv', 'name', 'property'); $str = ''; foreach ($name as $meta) { - $type = (isset($meta['type']) && $meta['type'] !== 'name') ? 'http-equiv' : 'name'; + $meta['type'] = (isset($meta['type']) && ($meta['type'] == 'equiv')) ? 'http-equiv' : $meta['type']; // backward compatibility + $type = (isset($meta['type']) && in_array($meta['type'], $allowed_type))? $meta['type'] : 'name'; $name = isset($meta['name']) ? $meta['name'] : ''; - $content = isset($meta['content']) ? $meta['content'] : ''; + $content = (isset($meta['content']) && $type != 'charset') ? $meta['content'] : ''; $newline = isset($meta['newline']) ? $meta['newline'] : "\n"; $str .= ''.$newline; -- cgit v1.2.3-24-g4f1b