WPSEO_OpenGraph::add_opengraph_namespace PHP Method

add_opengraph_namespace() public method

Filter for the namespace, adding the OpenGraph namespace.
public add_opengraph_namespace ( string $input ) : string
$input string The input namespace string.
return string
    public function add_opengraph_namespace($input)
    {
        $namespaces = array('og: http://ogp.me/ns#');
        if ($this->options['fbadminapp'] != 0 || is_array($this->options['fb_admins']) && $this->options['fb_admins'] !== array()) {
            $namespaces[] = 'fb: http://ogp.me/ns/fb#';
        }
        /**
         * Allow for adding additional namespaces to the <html> prefix attributes.
         *
         * @since 3.9.0
         *
         * @param array $namespaces Currently registered namespaces which are to be
         *                          added to the prefix attribute.
         *                          Namespaces are strings and have the following syntax:
         *                          ns: http://url.to.namespace/definition
         */
        $namespaces = apply_filters('wpseo_html_namespaces', $namespaces);
        $namespace_string = implode(' ', array_unique($namespaces));
        if (strpos($input, ' prefix=') !== false) {
            $regex = '`prefix=([\'"])(.+?)\\1`';
            $replace = 'prefix="$2 ' . $namespace_string . '"';
            $input = preg_replace($regex, $replace, $input);
        } else {
            $input .= ' prefix="' . $namespace_string . '"';
        }
        return $input;
    }