WordPress at a glance
function is not described

Symfony\Component\CssSelector\XPath

Translator::getXpathLiteral() public WC 1.0

{} It's a method of the class: Translator{}

No Hooks.

Return

String.

Usage

$result = Translator::getXpathLiteral( $element );
$element(string) (required)
-

Code of Translator::getXpathLiteral() WC 5.4.1

<?php
public static function getXpathLiteral($element)
{
    if (false === strpos($element, "'")) {
        return "'".$element."'";
    }

    if (false === strpos($element, '"')) {
        return '"'.$element.'"';
    }

    $string = $element;
    $parts = array();
    while (true) {
        if (false !== $pos = strpos($string, "'")) {
            $parts[] = sprintf("'%s'", substr($string, 0, $pos));
            $parts[] = "\"'\"";
            $string = substr($string, $pos + 1);
        } else {
            $parts[] = "'$string'";
            break;
        }
    }

    return sprintf('concat(%s)', implode($parts, ', '));
}