Helper function for running a shortcode.

@since  5.0.0
@access protected
@param  string    $tag
@param  string    $shortcode
@return string
333742
protected function doShortcode( $tag, $shortcode ) {

		if ( 'embed' === $tag ) {

			return $GLOBALS['wp_embed']->run_shortcode( $shortcode );

		} elseif ( 'video' === $tag ) {

			// Need to filter dimensions here to overwrite WP's
			// `<div>` surrounding the [video] shortcode.
			return do_shortcode( $this->filterDimensions( $shortcode ) );
		}

		return do_shortcode( $shortcode );
	}
963161
public function withTag($tag) {
        if (is_null($this->tags)) {
            $this->tags = [];
        }

        array_push($this->tags, $tag);
        return $this;
    }
383891
public function withTag(string $tag): self
    {
        if ($this->has($tag)) {
            return $this;
        }
        self::validateTag($tag);
        $newTags = $this->tags;
        $newTags[] = $tag;
        return new static($newTags);
    }
1336327
public TagInfo getTag(String shortname) {
        TagInfo tags[] = getTags();

        if (tags == null || tags.length == 0) {
            return null;
        }

        for (int i=0; i < tags.length; i++) {
            if (tags[i].getTagName().equals(shortname)) {
                return tags[i];
            }
        }
        return null;
    }
799693
public static function attsToString(Tag &$Tag)
    {
        /*
         * Return empty string if tag does not have attributes.
         */
        if (empty($Tag->attributes)) {
            return '';
        }

        $r = ' ';
        foreach ($Tag->attributes as $key => $value) {
            /*
             * Validate the attribute name.
             */
            $tmp = $key;
            if (!$Tag->hasOption('dontValidateAttrs') && !self::ensureAttrNameValidation($key)) {
                self::debug(sprintf('Invalid attribute name "%s" was changed to "%s"', $tmp, $key), 2, 7);
            }

            /*
             * If we have an value we make sure critical letters are escaped and use the format :name=":value"
             */
            if (!empty($value)) {
                $tmp = $value;
                if (!$Tag->hasOption('dontValidateAttrs') && !self::ensureAttrValueValidation($value)) {
                    self::debug(sprintf('Dangerous attribute value "%s" was changed to "%s"', $tmp, $value), 2, 7);
                }
                $value = str_replace('"', '&quot;', $value);
                $r .= "$key=\"$value\" ";
            } elseif ($value !== false) {
                /*
                 * No value? Alright just take the name.
                 */
                $r .= $key.' ';
            }
        }

        /*
         * Remove the last space and return.
         */

        return rtrim($r, ' ');
    }
1098212
public function format(Tag $tag): string
    {
        return '@' . $tag->getName() . str_repeat(' ', $this->maxLen - strlen($tag->getName()) + 1) . (string) $tag;
    }
1118939
public function get_bbcode($tag)
	{
		if(!isset($this->bbcodes[$tag]))
			return null;

		return $this->bbcodes[$tag];
	}
1354038
public function decorateHtmlTag($tag, array $attributes)
	{
		if (! $tag instanceof HtmlTag) {
			return null;
		}

		foreach ($attributes as $name => $value) {
			$tag->setAttribute($name, $value);
		}

		return $tag;
	}
1079718
public function shortCode($shortcode, $action)
    {
        return $this->getMocaBonita()->addMbShortcode($shortcode, $this->getMbPage(), $action);
    }
153433
public function getMbShortcode($shortcodeName)
    {
        if (!$this->mbShortCodes->has($shortcodeName)) {
            throw new MbException("The shortcode {$shortcodeName} has not been added to the MocaBonita shortcode list!");
        }

        return $this->mbShortCodes->get($shortcodeName);
    }
4483
public function tag($tag, $attr = null, $content = null, $close = false)
    {
        $tag = strtolower($tag);

        if (! empty($attr) && is_array($attr)) {
            $attr = $this->Attr->attr($attr);
        }

        if ($close) {
            return sprintf('<%s%s>%s</%1$s>', $tag, $attr, $content);
        } else {
            return sprintf('<%s%s>', $tag, $attr);
        }
    }
887830
public static Shortcode parse(final String shortcode) throws ParseException {
      String exp = shortcode.trim();

      if(exp.length() < 3) {
         throw new ParseException(String.format("Invalid shortcode ('%s')", exp), 0);
      }

      if(exp.charAt(0) != '[') {
         throw new ParseException("Expecting '['", 0);
      }

      int end = exp.indexOf(']');
      if(end == -1) {
         throw new ParseException("Expecting ']", 0);
      }

      Shortcode startTag = ShortcodeParser.parseStart(exp.substring(0, end + 1));

      end = exp.lastIndexOf("[/");
      if(end > 0) {
         if(exp.endsWith("[/" + startTag.name + "]")) {
            int start = shortcode.indexOf("]");
            return startTag.withContent(exp.substring(start + 1, end));
         } else {
            throw new ParseException("Invalid shortcode end", 0);
         }
      } else {
         return startTag;
      }
   }
356126
public function getLanguage($shortCode)
    {
        return (array_key_exists($shortCode, $this->getLanguages())) ? $this->getLanguages()[$shortCode] : false;
    }
888689
public function getLanguageByShortCode($shortCode)
    {
        return isset($this->getLanguages()[$shortCode]) ? $this->getLanguages()[$shortCode] : false;
    }
726453
public function callShortcode($tag, $attributes, $content, $extra = array())
    {
        if (!$tag || !isset($this->shortcodes[$tag])) {
            return false;
        }
        return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
    }
582807
function shortcodeHandler( $atts, $content = '' ) {

		global $id; // This is the Post ID, [@see WP_Query::setup_postdata, ...]

		$a = shortcode_atts(
			[
				'numbered' => 'yes',
				'symbol' => '*',
				'suptext' => ' ',
			], $atts
		);

		if ( ! $content ) {
			return '';
		}

		if ( ! isset( $this->footnotes[ $id ] ) ) {
			$this->footnotes[ $id ] = [];
			if ( 'no' === $a['numbered'] ) {
				$this->numbered[ $id ] = false;
			} else {
				$this->numbered[ $id ] = true;
			}
		}

		$this->footnotes[ $id ][] = $content;
		$footnotes = $this->footnotes[ $id ];
		$num = count( $footnotes );
		$numlabel = "$id-$num";

		$retval = '<a class="footnote" title="' . \Pressbooks\Sanitize\sanitize_xml_attribute( wp_strip_all_tags( $content ) ) . '" id="return-footnote-' . $numlabel . '" href="#footnote-' . $numlabel . '"><sup class="footnote">[';

		if ( $this->numbered[ $id ] ) {
			$retval .= $num;
		} else {
			$retval .= $a['symbol'];
		}

		if ( trim( $a['suptext'] ) ) {
			if ( $this->numbered[ $id ] ) {
				$retval .= '. ';
			}

			$retval .= $a['suptext'];
		}
		$retval .= ']</sup></a>';

		return $retval;
	}
685208
public function run($seq, $tag)
    {
        $this->controller->loadData($tag);

        $timings = $this->panel->calculateTimings();

        if (!isset($timings[$seq])) {
            throw new HttpException(404, 'Log message not found.');
        }

        $query = $timings[$seq]['info'];

        $results = $this->panel->getDb()->createCommand('EXPLAIN ' . $query)->queryAll();

        $output[] = '<table class="table"><thead><tr>' . implode(array_map(function ($key) {
                return '<th>' . $key . '</th>';
            }, array_keys($results[0]))) . '</tr></thead><tbody>';

        foreach ($results as $result) {
            $output[] = '<tr>' . implode(array_map(function ($value) {
                    return '<td>' . (empty($value) ? 'NULL' : htmlspecialchars($value)) . '</td>';
                }, $result)) . '</tr>';
        }
        $output[] = '</tbody></table>';
        return implode($output);
    }