CoreFiles by mySites.guru
dropdown-metismenu_heading.php69 lines, 1,842 bytes, from Joomla_4.1.3-Stable-Full_Package.zip
Raw History Compare with 4.1.2
md5
b4b5a9dc89a87d69643e2a45446961d3
sha1
8aa873630fb83ac81d7b1a38600b195a3fc2213f
sha256
7a885a034152cd7e6d8d731d4e4a5a10dd63517c93b807d1ccf1c9ba9d72f5c0
<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_menu
 *
 * @copyright   (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Utilities\ArrayHelper;

$attributes = [];

if ($item->anchor_title)
{
	$attributes['title'] = $item->anchor_title;
}

$attributes['class'] = 'mod-menu__heading nav-header';
$attributes['class'] .= $item->anchor_css ? ' ' . $item->anchor_css : null;

$linktype = $item->title;

if ($item->menu_icon)
{
	// The link is an icon
	if ($itemParams->get('menu_text', 1))
	{
		// If the link text is to be displayed, the icon is added with aria-hidden
		$linktype = '<span class="p-2 ' . $item->menu_icon . '" aria-hidden="true"></span>' . $item->title;
	}
	else
	{
		// If the icon itself is the link, it needs a visually hidden text
		$linktype = '<span class="p-2 ' . $item->menu_icon . '" aria-hidden="true"></span><span class="visually-hidden">' . $item->title . '</span>';
	}
}
elseif ($item->menu_image)
{
	// The link is an image, maybe with an own class
	$image_attributes = [];

	if ($item->menu_image_css)
	{
		$image_attributes['class'] = $item->menu_image_css;
	}

	$linktype = HTMLHelper::_('image', $item->menu_image, $item->title, $image_attributes);

	if ($itemParams->get('menu_text', 1))
	{
		$linktype .= '<span class="image-title">' . $item->title . '</span>';
	}
}

if ($showAll && $item->deeper)
{
	$attributes['class'] .= ' mm-collapsed mm-toggler mm-toggler-nolink';
	$attributes['aria-haspopup'] = 'true';
	$attributes['aria-expanded'] = 'false';
	echo '<button ' . ArrayHelper::toString($attributes) . '>' . $linktype . '</button>';
}
else
{
	echo '<span ' . ArrayHelper::toString($attributes) . '>' . $linktype . '</span>';
}

The same content is in 25 releases, Joomla 4.1.0-alpha3 to 4.2.0-beta2. See them all, or every version of this file.