Beispiel #1
0
/**
 * Add Facebook Open Graph Tag to wp_head
 *
 * @since 1.2.3
 */
function dp_fb_ogtags()
{
    $site_name = esc_attr(get_option('blogname'));
    $type = is_front_page() ? 'website' : 'article';
    $url = get_permalink();
    $title = dp_get_doc_title();
    $desc = dp_get_doc_desc();
    $image = '';
    $admins = '';
    // Get image
    if (is_singular()) {
        global $post;
        // Get image by feature image
        $image = dp_thumb_url('large', false, $post->ID);
        // Get image from post attachments
        if (empty($image) && ($images = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID))) {
            if (is_array($images) && !empty($images)) {
                $image = wp_get_attachment_thumb_url(current($images)->ID);
            }
        }
        // Get first image from post content
        if (empty($image) && preg_match('/<img[^>]*src=([\'"])(.*?)\\1/i', $post->post_content, $matches)) {
            $image = $matches[2];
        }
    }
    // Generate meta tags
    $nl = "\n";
    $tags = '';
    $tags .= '<meta property="og:site_name" content="' . $site_name . '" />' . $nl;
    $tags .= '<meta property="og:type" content="' . $type . '" />' . $nl;
    $tags .= '<meta property="og:url" content="' . $url . '" />' . $nl;
    if ($title) {
        $tags .= '<meta property="og:title" content="' . $title . '" />' . $nl;
    }
    if ($desc) {
        $tags .= '<meta property="og:description" content="' . esc_attr($desc) . '" />' . $nl;
    }
    if ($image) {
        $tags .= '<meta property="og:image" content="' . $image . '" />' . $nl;
    }
    if ($admins) {
        $tags .= '<meta property="fb:admins" content="' . esc_attr($admins) . '" />' . $nl;
    }
    echo $tags;
}
Beispiel #2
0
    the_date();
    ?>
</span>
					
					<?php 
    edit_post_link(__('Edit', 'dp'), ' <span class="sep">/</span> ');
    ?>
				</p>
				
				<?php 
    // Thumbnail
    global $post;
    $post_type = get_post_type($post_type);
    $post_format = get_post_format($post->ID);
    if (!$post_format && $post_type == 'post' && get_option('dp_single_thumb')) {
        $thumb_url = dp_thumb_url('custom-large', '', $post->ID, false);
        if (!empty($thumb_url)) {
            echo '<div id="thumb" class="rich-content"><img src="' . $thumb_url . '" alt="' . esc_attr(get_the_title($post->ID)) . '" /><span class="vertical-align"></div>';
        }
    }
    ?>

				<div class="entry-content rich-content">
					<?php 
    the_content();
    ?>
					<?php 
    wp_link_pages(array('before' => '<p class="entry-nav pag-nav"><span>' . __('Pages:', 'dp') . '</span> ', 'after' => '</p>', 'next_or_number' => 'number'));
    ?>
				</div><!-- end .entry-content -->