Plugin Directory

Changeset 3474812


Ignore:
Timestamp:
03/04/2026 06:05:22 PM (4 weeks ago)
Author:
whiteshadow
Message:

Minor: Add HtmlHelper::outputTag()

Mainly because I didn't succeed at reliably adding tag() to the exception list for PHPCS, so it kept reporting outputs as potentially missing HTML escaping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin-menu-editor/trunk/customizables/HtmlHelper.php

    r2848682 r3474812  
    1212     * @return string
    1313     */
    14     public static function tag($tagName, $attributes = array(), $content = null) {
     14    public static function tag($tagName, $attributes = array(), $content = null): string {
    1515        $html = '<' . $tagName;
    1616        $charset = self::getCharset();
     
    7979        return $charset;
    8080    }
     81
     82    /**
     83     * Output a HTML tag with the specified name, attributes and content.
     84     *
     85     * @param string $tagName
     86     * @param array<string,mixed> $attributes
     87     * @param string|null $content
     88     */
     89    public static function outputTag(string $tagName, array $attributes = array(), ?string $content = null) {
     90        //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The tag() method handles escaping.
     91        echo self::tag($tagName, $attributes, $content);
     92    }
    8193}
Note: See TracChangeset for help on using the changeset viewer.