mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
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:
parent
bcd8955526
commit
aaebccd48c
@ -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'))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user