Update html_helper.php

Added hreflang parameter for link_tag function for calling <link href="https://domain.com/en" hreflang="x-default" rel="alternate"> and etc. And added checks for tags with rel expressions for  'alternate','canonical'  in this case attribute type dont use
This commit is contained in:
avegacms 2020-07-08 09:06:34 +06:00 committed by GitHub
parent bcd8955526
commit aaebccd48c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,9 +273,10 @@ if (! function_exists('link_tag'))
* @param string $title
* @param string $media
* @param boolean $indexPage should indexPage be added to the CSS path.
* @param string $hreflang
* @return string
*/
function link_tag($href = '', string $rel = 'stylesheet', string $type = 'text/css', string $title = '', string $media = '', bool $indexPage = false): string
function link_tag($href = '', string $rel = 'stylesheet', string $type = 'text/css', string $title = '', string $media = '', bool $indexPage = false, string $hreflang = ''): string
{
$link = '<link ';
@ -286,6 +287,7 @@ if (! function_exists('link_tag'))
$type = $href['type'] ?? $type;
$title = $href['title'] ?? $title;
$media = $href['media'] ?? $media;
$hreflang = $href['hreflang'] ?? '';
$indexPage = $href['indexPage'] ?? $indexPage;
$href = $href['href'] ?? '';
}
@ -306,7 +308,17 @@ if (! function_exists('link_tag'))
$link .= 'href="' . $href . '" ';
}
$link .= 'rel="' . $rel . '" type="' . $type . '" ';
if( $hreflang !== '' )
{
$link .= 'hreflang="' . $hreflang .'" ';
}
$link .= 'rel="' . $rel . '" ';
if( !in_array($rel, ['alternate','canonical']) )
{
$link .= 'type="' . $type . '" ';
}
if ($media !== '')
{
@ -321,7 +333,8 @@ if (! function_exists('link_tag'))
return $link . '/>';
}
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
if (! function_exists('video'))
{