<shortcode name="NAME">
<bbCode>BBCODE</bbCode>
<parameters>
<parameter name="KEY">VALUE</parameter>
<parameter name="KEY">VALUE</parameter>
</parameters>
<content>CONTENT></content>
</shortcode>

@param ShortcodeInterface $shortcode

@return string
541926
public function serialize(ShortcodeInterface $shortcode)
    {
        $doc = new \DOMDocument('1.0', 'UTF-8');
        $doc->preserveWhiteSpace = false;
        $doc->formatOutput = true;

        $code = $doc->createElement('shortcode');
        $code->setAttribute('name', $shortcode->getName());
        $xml = $doc->appendChild($code);
        $xml->appendChild($this->createCDataNode($doc, 'bbCode', $shortcode->getBbCode()));

        $parameters = $xml->appendChild($doc->createElement('parameters'));
        foreach($shortcode->getParameters() as $key => $value) {
            $parameter = $doc->createElement('parameter');
            $parameter->setAttribute('name', $key);
            if(null !== $value) {
                $parameter->appendChild($doc->createCDATASection($value));
            }

            $parameters->appendChild($parameter);
        }

        $xml->appendChild($this->createCDataNode($doc, 'content', $shortcode->getContent()));

        return $doc->saveXML();
    }
510390
public function getFirstValueByAttributeCodeAsString(string $code, $asTitle = true)
    {
        $attributeValue = $this->getFirstValueByAttributeCode($code);

        if (!$attributeValue) {
            return "";
        }

        $field = $asTitle ? 'title' : 'value';

        return $attributeValue->$field;
    }
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;
	}
1171319
public function generateCodeValue(TokenInterface $token): string
    {
        $codeValue = bin2hex(random_bytes(16)) . uniqid();

        assert(is_string($codeValue) === true && empty($codeValue) === false);

        return $codeValue;
    }
1160748
public function emailShortCodeHandler( $atts, $content, $shortcode ) {
		$atts = shortcode_atts(
			[
				'class' => null,
				'address' => null,
			],
			$atts,
			$shortcode
		);

		$address = $atts['address'] ?? $content;

		if ( ! is_email( $address ) ) {
			return '';
		}

		if ( $address === $content ) {
			return sprintf(
				'<a href="mailto:%1$s"%2$s>%1$s</a>',
				antispambot( $address ),
				( isset( $atts['class'] ) ) ? sprintf( ' class="%s"', $atts['class'] ) : ''
			);
		} else {
			return sprintf(
				'<a href="mailto:%1$s"%2$s>%3$s</a>',
				antispambot( $address ),
				( isset( $atts['class'] ) ) ? sprintf( ' class="%s"', $atts['class'] ) : '',
				( $content ) ? $content : antispambot( $address )
			);
		}
	}
1296079
protected function get_shortcode_ui_class( $tag ) {
		$ui_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_UI )
			? $this->getConfigKey( $tag, self::KEY_CUSTOM_UI )
			: self::DEFAULT_SHORTCODE_UI;

		return $ui_class;
	}
475133
public function getCode(): string
  {
    $lines       = [];
    $indentLevel = 0;

    foreach ($this->lines as $line)
    {
      $mode = $this->indentationMode($line);

      // Increment or decrement indentation level.
      if ($mode & self::C_INDENT_INCREMENT_BEFORE)
      {
        $indentLevel++;
      }
      if ($mode & self::C_INDENT_DECREMENT_BEFORE)
      {
        $indentLevel = max(0, $indentLevel - 1);
      }
      if ($mode & self::C_INDENT_DECREMENT_BEFORE_DOUBLE)
      {
        $indentLevel = max(0, $indentLevel - 2);
      }

      // If the line is a separator shorten the separator.
      if ($this->separator!==null && $line==$this->separator)
      {
        $line = $this->shortenSeparator($this->width - $this->indentation * $indentLevel);
      }

      // Append the line with indentation.
      $lines[] = $this->addIndentation($line, $indentLevel);

      // Increment or decrement indentation level.
      if ($mode & self::C_INDENT_INCREMENT_AFTER)
      {
        $indentLevel++;
      }
      if ($mode & self::C_INDENT_DECREMENT_AFTER)
      {
        $indentLevel = max(0, $indentLevel - 1);
      }
    }

    if (empty($lines))
    {
      return '';
    }

    return implode(PHP_EOL, $lines).PHP_EOL;
  }
331228
protected function getExpectedCode()
    {
        $options = $this->session->get($this->key, array());

        if (is_array($options) && isset($options['phrase'])) {
            return $options['phrase'];
        }

        return null;
    }
650165
public function get_context_name($withprefix = true, $short = false) {
        global $DB;

        $name = '';
        if ($category = $DB->get_record('course_categories', array('id'=>$this->_instanceid))) {
            if ($withprefix){
                $name = get_string('category').': ';
            }
            $name .= format_string($category->name, true, array('context' => $this));
        }
        return $name;
    }
496566
public function stripAllShortcodes($content)
    {
        if (empty($this->_shortcodes)) {
            return $content;
        }
        return preg_replace_callback($this->shortcodeRegex(), [$this, 'stripShortcodeTag'], $content);
    }
925707
protected function get_shortcode_class( $tag ) {
		$shortcode_class = $this->hasConfigKey( $tag, self::KEY_CUSTOM_CLASS )
			? $this->getConfigKey( $tag, self::KEY_CUSTOM_CLASS )
			: self::DEFAULT_SHORTCODE;

		return $shortcode_class;
	}
715568
public static function shortcodeToEntities($content) {
        $replacements = self::getShortcodeEntities();
        return str_replace(array_keys($replacements), $replacements, $content);
    }
65484
public function toStringCode()
    {
        if (!$this->isInterface() && !$this->isAbstract()) {
            $tabulationFormatted = $this->getTabulationFormatted();
            $code = PHP_EOL . $tabulationFormatted
                . '{'
                . $this->codeToString()
                . $tabulationFormatted
                . '}';

            return $code;
        }

        return ';';
    }
1207777
private function getContext($contextCode)
    {
        if (empty($contextCode)) {
            $contextCode = ContextInterface::DEFAULT_CONTEXT;
        }

        if ($contextCode instanceof ContextInterface) {
            return $contextCode;
        }

        $context = $this->contextManager->find($contextCode);

        if (!$context instanceof ContextInterface) {
            $context = $this->contextManager->create();

            $context->setId($contextCode);
            $context->setName($contextCode);
            $context->setEnabled(true);

            $this->contextManager->save($context);
        }

        return $context;
    }
267952
public function codeDesc()
    {
        // Cast code to string from SimpleXMLObject
        $code = (string)$this->code;
        return array_key_exists($code, self::$codes) ? self::$codes[$code] : '';
    }
490068
public static function getName($code)
    {
        if (!isset(self::$codesDescriptions[$code])) {
            throw new InvalidArgumentException("Invalid code $code specified");
        }

        return self::$codesDescriptions[$code];
    }
811868
public function register(ShortcodeInterface $shortcode, ?string $name = null): ManagerInterface
    {
        parent::register($shortcode, $name);
        if ($shortcode instanceof AliasInterface) {
            foreach ($shortcode->getAlias() as $alias) {
                if (!$this->isRegistered($alias)) {
                    parent::register($shortcode, $alias);
                }
            }
        }

        return $this;
    }