@param string $html
@param array $attributes

@return string
424191
public function decorateOuterElement($html, $attributes)
    {
        if (! $html) {
            return $html;
        }

        $htmlAttr = [];
        foreach ($attributes as $key => $value) {
            $htmlAttr[] = sprintf('%s="%s"', $key, htmlspecialchars($value));
        }
        $htmlAttr = implode(' ', $htmlAttr);

        $html = preg_replace(
            '/(<\b[^><]*)>/i',
            '$1'.($htmlAttr ? ' '.$htmlAttr : '').'>',
            $html,
            1
        );

        return $html;
    }
494270
public function render( $attributes = array() ) 
    {
        if( ! $this->tagName ) {
            throw new Exception('tagName is not defined.');
        }

        $html = $this->open( $attributes );

        // render close tag
        if( $this->hasChildren() ) {
            $html .= $this->renderChildren();
        }

        $html .= $this->close();
        return $html;
    }
486378
public static function attributes(array $attributes = array())
    {
        $text = array();
        foreach ($attributes as $key => $value) {
            //if we have numeric keys (e.g. checked), set the value as
            //the $key (e.g. checked="checked"), but only if it
            //doesn't exist already
            if (is_numeric($key)) {
                $value = htmlspecialchars($value);
                if (!isset($attributes[$value])) {
                    $text[] = $value . '="' . $value . '"';
                }
                continue;
            }
            $text[] = $key . '="' . htmlspecialchars($value) . '"';
        }

        return empty($text) ? '' : ' ' . implode(' ', $text);
    }
693955
static function htmlAttributes(array $attributes = array()) {
    foreach ($attributes as $attribute => &$data) {
      $data = implode(' ', (array) $data);
      $data = $attribute . '="' . self::checkPlain($data) . '"';
    }
    return $attributes ? ' ' . implode(' ', $attributes) : '';
  }
280413
private function getTagAttributes($attributes)
    {
        if (!$attributes) {
            return '';
        }

        $tagAttributes = '';

        foreach ($attributes as $key => $attribute) {
            $tagAttributes .= ' ' . $key . '="' . $attribute . '"';
        }

        return $tagAttributes;
    }
166650
public function attributesToString(array $attributes = []): string
    {
        $html = [];
        foreach ($attributes as $key => $value) {
            if (is_array($value)) {
                $value = json_encode($value);
            }

            if (in_array($key, $this->booleanAttributes, true)) {
                $value = $this->prepareBooleanAttribute($key, $value);
            }

            if ($value === '') {
                continue;
            }

            $html[] = sprintf(
                '%s="%s"',
                $this->escapeAttribute($key),
                $this->escapeAttribute($value)
            );
        }

        return implode(' ', $html);
    }
238774
protected function renderAttributes(array $attributes)
    {
        foreach ($attributes as $name => $value) {
            if (is_array($value)) {
                $value = implode(' ', (array) $value);
            }
            $attributes[$name] = $name . '="' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '"';
        }

        return implode(' ', $attributes);
    }
849573
protected static function attributes($attributes)
	{
		$html = array();

		// For numeric keys we will assume that the key and the value are the same
		// as this will convert HTML attributes such as "required" to a correct
		// form like required="required" instead of using incorrect numerics.
		foreach ((array) $attributes as $key => $value)
		{
			$element = null;

			if (is_numeric($key))
			{
				$key = $value;
			}

			if (!is_null($value))
			{
				$element = $key . '="' . htmlentities($value, ENT_COMPAT, 'UTF-8') . '"';
			}

			if (!is_null($element))
			{
				$html[] = $element;
			}
		}

		return count($html) > 0 ? ' ' . implode(' ', $html) : '';
	}
533202
protected function attributesArrayToText($attributes)
    {
        $text = "";

        foreach ($attributes as $name => $value)
        {
            $text .= "{$name}=\"{$value}\" ";
        }

        $text = rtrim($text);

        return $text;
    }
85196
public function getHtml(array $attributes = []): string
    {
        return self::buildTag('input', null,
            array_merge(
                [
                    'type'    => 'radio',
                    'name'    => $this->name !== '' ? $this->name : false,
                    'value'   => $this->value,
                    'checked' => $this->isSelected,
                ],
                $attributes
            )
        );
    }
1163408
public function getHtml(array $attributes = []): string
    {
        $optionsHtml = '';
        foreach ($this->options as $option) {
            $optionsHtml .= $option->getHtml();
        }

        return self::buildTag('select', $optionsHtml,
            array_merge(
                [
                    'name'     => $this->getName(),
                    'required' => $this->isRequired() && $this->hasEmptyOption,
                ],
                $attributes
            ), true
        );
    }
861970
public static function attributes($attributes)
    {
        $buffer = '';

        foreach ($attributes as $name => $value) {
            $buffer .= ' ' . $name . '="' . static::attributeValue($value) . '"';
        }

        return $buffer;
    }
1082304
public static function createAttributes($attributes = [])
    {
        $list = [];

        foreach ($attributes as $key => $value)
        {
            $list[] = sprintf('%s="%s"', $key, is_array($value) ? implode(' ', $value) : $value);
        }

        return implode(' ', $list);
    }
160453
protected function attributes($attributes = [])
    {
        $ar = [];

        foreach ($attributes as $key => $value) {
            $element = $this->attribute($key, $value);
            if (!is_null($element)) {
                $ar[] = $element;
            }
        }

        return count($ar) > 0 ? ' '.implode(' ', $ar) : '';
    }
627618
public function attr(array $attributes)
    {
        $result = '';

        foreach ($attributes as $attribute => $value) {
            $result .= ' '.(is_int($attribute) ? $value : $attribute.'="'.str_replace('"', '&quot;', $value).'"');
        }

        return $result;
    }
629
protected function get_html_attributes( array $attributes ) {
		$html_attributes = '';
		if ( ! empty( $attributes ) ) {
			foreach ( $attributes as $attr => $val ) {
				$html_attributes .= \esc_attr( $attr ) . '="' . \esc_attr( $val ) . '" ';
			}
		}

		return $html_attributes;
	}
125141
public static function link(
        string $content = null, 
        array $attributes = []
    ) : string
    {
        return self::tag("link", $content, $attributes);
    }