/**
 * Output Open Graph <meta> tags in the page header.
 */
function opengraph_meta_tags()
{
    $metadata = opengraph_metadata();
    foreach ($metadata as $key => $value) {
        if (empty($key) || empty($value)) {
            continue;
        }
        $value = (array) $value;
        foreach ($value as $v) {
            echo '<meta property="' . esc_attr($key) . '" content="' . esc_attr($v) . '" />' . "\n";
        }
    }
}
/**
 * Output Open Graph <meta> tags in the page header.
 */
function opengraph_meta_tags()
{
    $metadata = opengraph_metadata();
    foreach ($metadata as $key => $value) {
        if (empty($key) || empty($value)) {
            continue;
        }
        $value = (array) $value;
        foreach ($value as $v) {
            // check if "strict mode" is enabled
            if (OPENGRAPH_STRICT_MODE === false) {
                // use "property" and "name"
                printf('<meta property="%1$s" name="%1$s" content="%2$s" />' . PHP_EOL, esc_attr($key), esc_attr($v));
            } else {
                // use "name" attribute for Twitter Cards
                if (stripos($key, 'twitter:') === 0) {
                    printf('<meta name="%1$s" content="%2$s" />' . PHP_EOL, esc_attr($key), esc_attr($v));
                } else {
                    // use "property" attribute for Open Graph
                    printf('<meta property="%1$s" content="%2$s" />' . PHP_EOL, esc_attr($key), esc_attr($v));
                }
            }
        }
    }
}
Example #3
0
/**
 * Output Open Graph <meta> tags in the page header.
 */
function opengraph_meta_tags()
{
    $metadata = opengraph_metadata();
    foreach ($metadata as $key => $value) {
        if (empty($key) || empty($value)) {
            continue;
        }
        $value = (array) $value;
        foreach ($value as $v) {
            printf('<meta property="%1$s" name="%1$s" content="%2$s" />' . "\n", esc_attr($key), esc_attr($v));
        }
    }
}
Example #4
0
/**
 * Output Open Graph <meta> tags in the page header.
 */
function opengraph_meta_tags()
{
    global $opengraph_prefix_set;
    $prefix = '';
    if (!$opengraph_prefix_set) {
        $prefix = 'prefix="og: ' . esc_attr(OPENGRAPH_PREFIX_URI) . '" ';
    }
    $metadata = opengraph_metadata();
    foreach ($metadata as $key => $value) {
        if (empty($key) || empty($value)) {
            continue;
        }
        echo '<meta ' . $prefix . 'property="' . esc_attr($key) . '" content="' . esc_attr($value) . '" />' . "\n";
    }
}