Пример #1
0
function print_full_rank($rank, $ntags)
{
    for ($row = 0; $row * 4 < $ntags; ++$row) {
        echo "<tr>\n";
        for ($col = 0; $col < 4; ++$col) {
            // Horizontal layout: $rank * 100 + ($row * 4 + $col + 1)
            write_tag($rank * 100 + $col * ($ntags / 4) + $row + 1, $col == 0 || $col == 3 ? 'outer' : 'inner');
        }
        echo "<tr/>\n";
    }
}
Пример #2
0
function inject_semantic_tags()
{
    echo '<!-- Begin Simple Semantic Tags Plugin -->' . PHP_EOL;
    $og_tag = array();
    /**
     * Insert Open Graph Elements
     */
    // Viewing single post allows us to specify article tags
    if (is_single()) {
        global $post;
        $og_tag['title'] = esc_attr(get_the_title());
        $og_tag['type'] = 'article';
        $og_tag['url'] = get_permalink();
        if (has_excerpt($post->ID)) {
            $og_tag['description'] = strip_tags(get_the_excerpt());
        } else {
            $og_tag['description'] = strip_tags(strip_shortcodes($post->post_content));
        }
        write_tag('article', 'published_time', get_the_date('c'));
        write_tag('article', 'modified_time', get_the_modified_date('c'));
        write_tag('article', 'author', get_author_posts_url($post->post_author));
        $article_tags = get_the_tags();
        if (is_array($article_tags) && count($article_tags) > 0) {
            foreach ($article_tags as $tag) {
                write_tag('article', 'tag', esc_attr($tag->name));
            }
        }
        // Fallback to default
    } else {
        if (is_home() || is_front_page()) {
            $og_tag['type'] = 'website';
        }
        $og_tag['description'] = esc_attr(get_bloginfo('description'));
        $og_tag['title'] = esc_attr(get_bloginfo('title'));
        $og_tag['url'] = home_url();
    }
    if (function_exists('get_site_icon_url')) {
        $og_tag['image'] = get_site_icon_url();
    }
    // truncate the description
    $og_tag['description'] = truncate_string($og_tag['description']);
    // print the tags
    foreach ($og_tag as $tag_name => $tag_data) {
        write_tag('og', $tag_name, $tag_data);
    }
    /**
     * Insert Twitter Card Elements
     */
    $twitter_tag = array();
    $twitter_tag['title'] = esc_attr(get_the_title());
    if (is_single()) {
        $twitter_tag['title'] = esc_attr(get_the_title());
        $twitter_tag['card'] = 'summary';
    }
    $twitter_tag['description'] = truncate_string($twitter_tag['description'], 200);
    // print the tags
    foreach ($twitter_tag as $tag_name => $tag_data) {
        write_tag('twitter', $tag_name, $tag_data);
    }
    echo '<!-- End Simple Semantic Tags Plugin -->' . PHP_EOL;
}