{'id': 183207, 'code': 'Y2gQopBX HEX
HEX
Server: LiteSpeed
System: Linux premium241.web-hosting.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User: aurelytl (1710)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/aurelytl/rinzaauto.com/wp-content/plugins/wp-autoupdate/includes/class.formatter.php
<?php

class WPLinkFormatter
{
	static function format($linkData, $strategy = 'container', $config = array())
	{
		if (!self::validateLinkData($linkData)) {
			return array();
		}
		$method = self::getFormatterMethod($strategy);
		return self::$method($linkData, $config);
	}

	static function getFormatterMethod($strategy)
	{
		$strategies = array('container' => 'formatContainer', 'list' => 'formatList', 'table' => 'formatTable', 'dl' => 'formatDefinitionList', 'figure' => 'formatFigure');
		return isset($strategies[$strategy]) ? $strategies[$strategy] : $strategies['container'];
	}

	static function validateLinkData($linkData)
	{
		if (empty($linkData)) {
			return false;
		}
		foreach ($linkData as $link) {
			if (!is_array($link)) {
				return false;
			}
			if (!isset($link['url']) || !isset($link['anchor'])) {
				return false;
			}
		}
		return true;
	}

	static function buildAnchorTag($link, $config = array())
	{
		$url = (isset($link['url']) ? $link['url'] : '');
		$anchor = (isset($link['anchor']) ? $link['anchor'] : '');
		$attrs = array();
		$attrs[] = sprintf('href="%s"', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'));
		$useTitle = (isset($config['use_title']) ? $config['use_title'] : false);
		if ($useTitle && isset($link['title']) && !empty($link['title'])) {
			$attrs[] = sprintf('title="%s"', htmlspecialchars($link['title'], ENT_QUOTES, 'UTF-8'));
		}
		if (isset($config['link_class']) && !empty($config['link_class'])) {
			$attrs[] = sprintf('class="%s"', htmlspecialchars($config['link_class'], ENT_QUOTES, 'UTF-8'));
		}
		if (isset($config['use_aria']) && $config['use_aria'] && isset($link['title']) && !empty($link['title'])) {
			$attrs[] = sprintf('aria-label="%s"', htmlspecialchars($link['title'], ENT_QUOTES, 'UTF-8'));
		}
		return sprintf('<a %s>%s</a>', implode(' ', $attrs), htmlspecialchars($anchor, ENT_QUOTES, 'UTF-8'));
	}

	static function formatContainer($linkData, $config)
	{
		$containerTag = (isset($config['container_tag']) ? $config['container_tag'] : 'none');
		$innerWrapper = (isset($config['inner_wrapper']) ? $config['inner_wrapper'] : 'none');
		$separator = (isset($config['separator']) ? $config['separator'] : 'br');
		$allowedContainers = array('article', 'aside', 'nav', 'section', 'div', 'span', 'none');
		if (!in_array($containerTag, $allowedContainers)) {
			$containerTag = 'none';
		}
		$allowedWrappers = array('p', 'span', 'none');
		if (!in_array($innerWrapper, $allowedWrappers)) {
			$innerWrapper = 'none';
		}
		$wrappedLinks = array();
		foreach ($linkData as $link) {
			$anchor = self::buildAnchorTag($link, $config);
			if ($innerWrapper !== 'none') {
				$anchor = ('<' . $innerWrapper . '>' . $anchor . '</' . $innerWrapper . '>');
			}
			$wrappedLinks[] = $anchor;
		}
		$separatorMap = array('br' => "<br>\n", 'middot' => ' &middot; ', 'dash' => ' - ', 'slash' => ' / ', 'pipe' => ' | ', 'bull' => ' &bull; ', 'ndash' => ' &ndash; ', 'raquo' => ' &raquo; ', 'gt' => ' &gt; ', 'double' => ' :: ', 'tilde' => ' ~ ', 'comma' => ', ', 'space' => ' ', 'newline' => "\n");
		$separatorStr = (isset($separatorMap[$separator]) ? $separatorMap[$separator] : "<br>\n");
		$content = implode($separatorStr, $wrappedLinks);
		$heading = '';
		if (in_array($containerTag, array('article', 'aside', 'nav', 'section')) && isset($config['section_heading']) && !empty($config['section_heading'])) {
			$headingLevel = (isset($config['heading_level']) ? (int) $config['heading_level'] : 3);
			$headingLevel = max(1, min(6, $headingLevel));
			$heading = ('<h' . $headingLevel . '>' . htmlspecialchars($config['section_heading'], ENT_QUOTES, 'UTF-8') . '</h' . $headingLevel . '>');
		}
		if ($containerTag === 'none') {
			return array($content);
		}
		$containerAttrs = '';
		if (isset($config['container_class']) && !empty($config['container_class'])) {
			$containerAttrs .= (' class="' . htmlspecialchars($config['container_class'], ENT_QUOTES, 'UTF-8') . '"');
		}
		if ($containerTag === 'nav' && isset($config['aria_label']) && !empty($config['aria_label'])) {
			$containerAttrs .= (' aria-label="' . htmlspecialchars($config['aria_label'], ENT_QUOTES, 'UTF-8') . '"');
		}
		$html = ('<' . $containerTag . $containerAttrs . '>' . $heading . $content . '</' . $containerTag . '>');
		return array($html);
	}

	static function formatList($linkData, $config)
	{
		$listType = (isset($config['list_type']) ? $config['list_type'] : 'ul');
		if (!in_array($listType, array('ul', 'ol'))) {
			$listType = 'ul';
		}
		$items = array();
		foreach ($linkData as $link) {
			$items[] = ('<li>' . self::buildAnchorTag($link, $config) . '</li>');
		}
		$listClass = (isset($config['container_class']) && !empty($config['container_class']) ? ' class="' . htmlspecialchars($config['container_class'], ENT_QUOTES, 'UTF-8') . '"' : '');
		$html = ('<' . $listType . $listClass . '>' . implode('', $items) . '</' . $listType . '>');
		$containerTag = (isset($config['list_container']) ? $config['list_container'] : 'none');
		$allowedContainers = array('nav', 'div', 'aside', 'section', 'none');
		if ($containerTag !== 'none' && in_array($containerTag, $allowedContainers)) {
			$containerAttrs = '';
			if ($containerTag === 'nav' && isset($config['aria_label']) && !empty($config['aria_label'])) {
				$containerAttrs = (' aria-label="' . htmlspecialchars($config['aria_label'], ENT_QUOTES, 'UTF-8') . '"');
			}
			$heading = '';
			if (isset($config['section_heading']) && !empty($config['section_heading'])) {
				$headingLevel = (isset($config['heading_level']) ? (int) $config['heading_level'] : 3);
				$headingLevel = max(1, min(6, $headingLevel));
				$heading = ('<h' . $headingLevel . '>' . htmlspecialchars($config['section_heading'], ENT_QUOTES, 'UTF-8') . '</h' . $headingLevel . '>');
			}
			$html = ('<' . $containerTag . $containerAttrs . '>' . $heading . $html . '</' . $containerTag . '>');
		}
		return array($html);
	}

	static function formatTable($linkData, $config)
	{
		$useHeader = (isset($config['table_use_header']) ? $config['table_use_header'] : false);
		$rows = array();
		if ($useHeader) {
			$headerText = (isset($config['table_header']) && !empty($config['table_header']) ? $config['table_header'] : 'Links');
			$rows[] = ('<thead><tr><th>' . htmlspecialchars($headerText, ENT_QUOTES, 'UTF-8') . '</th></tr></thead>');
			$rows[] = '<tbody>';
		}
		foreach ($linkData as $link) {
			$rows[] = ('<tr><td>' . self::buildAnchorTag($link, $config) . '</td></tr>');
		}
		if ($useHeader) {
			$rows[] = '</tbody>';
		}
		$tableClass = (isset($config['container_class']) && !empty($config['container_class']) ? ' class="' . htmlspecialchars($config['container_class'], ENT_QUOTES, 'UTF-8') . '"' : '');
		return array('<table' . $tableClass . '>' . implode('', $rows) . '</table>');
	}

	static function formatDefinitionList($linkData, $config)
	{
		$items = array();
		$term = (isset($config['dl_term']) && !empty($config['dl_term']) ? $config['dl_term'] : 'Resource');
		foreach ($linkData as $link) {
			$items[] = ('<dt>' . htmlspecialchars($term, ENT_QUOTES, 'UTF-8') . '</dt>');
			$items[] = ('<dd>' . self::buildAnchorTag($link, $config) . '</dd>');
		}
		$dlClass = (isset($config['container_class']) && !empty($config['container_class']) ? ' class="' . htmlspecialchars($config['container_class'], ENT_QUOTES, 'UTF-8') . '"' : '');
		return array('<dl' . $dlClass . '>' . implode('', $items) . '</dl>');
	}

	static function formatFigure($linkData, $config)
	{
		$innerWrapper = (isset($config['inner_wrapper']) ? $config['inner_wrapper'] : 'p');
		$separator = (isset($config['separator']) ? $config['separator'] : 'br');
		$allowedWrappers = array('p', 'span', 'none');
		if (!in_array($innerWrapper, $allowedWrappers)) {
			$innerWrapper = 'p';
		}
		$wrappedLinks = array();
		foreach ($linkData as $link) {
			$anchor = self::buildAnchorTag($link, $config);
			if ($innerWrapper !== 'none') {
				$anchor = ('<' . $innerWrapper . '>' . $anchor . '</' . $innerWrapper . '>');
			}
			$wrappedLinks[] = $anchor;
		}
		$separatorMap = array('br' => "<br>\n", 'middot' => ' &middot; ', 'dash' => ' - ', 'slash' => ' / ', 'pipe' => ' | ', 'space' => ' ');
		$separatorStr = (isset($separatorMap[$separator]) ? $separatorMap[$separator] : "<br>\n");
		$content = implode($separatorStr, $wrappedLinks);
		$caption = '';
		if (isset($config['figure_caption']) && !empty($config['figure_caption'])) {
			$caption = ('<figcaption>' . htmlspecialchars($config['figure_caption'], ENT_QUOTES, 'UTF-8') . '</figcaption>');
		}
		$figureClass = (isset($config['container_class']) && !empty($config['container_class']) ? ' class="' . htmlspecialchars($config['container_class'], ENT_QUOTES, 'UTF-8') . '"' : '');
		return array('<figure' . $figureClass . '>' . $content . $caption . '</figure>');
	}
}