|
@@ -173,4 +173,70 @@ function dw_deliver_form_mail() {
|
|
|
}
|
|
|
|
|
|
add_shortcode('dwsearch', 'get_search_form');
|
|
|
+
|
|
|
+function doctype_opengraph($output) {
|
|
|
+ return $output . '
|
|
|
+ xmlns:og="http://opengraphprotocol.org/schema/"
|
|
|
+ xmlns:fb="http://www.facebook.com/2008/fbml"';
|
|
|
+}
|
|
|
+add_filter('language_attributes', 'doctype_opengraph');
|
|
|
+
|
|
|
+function dw_opengraph() {
|
|
|
+ global $post;
|
|
|
+
|
|
|
+ if(is_single()) {
|
|
|
+ if(has_post_thumbnail($post->ID)) {
|
|
|
+ $img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'full');
|
|
|
+ } else {
|
|
|
+ $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg';
|
|
|
+ }
|
|
|
+ $img_src = $img_src[0];
|
|
|
+ if($excerpt = $post->post_excerpt) {
|
|
|
+ $excerpt = strip_tags($post->post_excerpt);
|
|
|
+ $excerpt = str_replace("", "'", $excerpt);
|
|
|
+ } else {
|
|
|
+ $excerpt = get_bloginfo('description');
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <meta property="og:title" content="<?php echo the_title(); ?>"/>
|
|
|
+ <meta property="og:description" content="<?php echo $excerpt; ?>"/>
|
|
|
+ <meta property="og:type" content="article"/>
|
|
|
+ <meta property="og:url" content="<?php echo the_permalink(); ?>"/>
|
|
|
+ <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/>
|
|
|
+ <meta property="og:image" content="<?php echo $img_src; ?>"/>
|
|
|
+ <meta property="fb:app_id" content="203136806559589" />
|
|
|
+ <meta name="twitter:card" content="summary_large_image">
|
|
|
+ <meta name="twitter:site" content="@windhamdavid">
|
|
|
+ <meta name="twitter:creator" content="@windhamdavid">
|
|
|
+ <meta name="twitter:title" content="<?php echo the_title(); ?>">
|
|
|
+ <meta name="twitter:description" content="<?php echo $excerpt; ?>">
|
|
|
+ <meta name="twitter:image" content="<?php echo $img_src; ?>">
|
|
|
+<?php
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
|
|
|
+ $media_url = get_post_meta( get_the_ID(), 'media', true );
|
|
|
+ $media = get_media_embedded_in_content( $content );
|
|
|
+ if( !empty($media) ) {
|
|
|
+ $video_url = $media[0];
|
|
|
+ ?>
|
|
|
+ <meta property="og:video" content="<?php echo $media_url; ?>" />
|
|
|
+ <meta property="og:video:secure_url" content="<?php echo $media_url; ?>" />
|
|
|
+ <meta property="og:video:width" content="1280" />
|
|
|
+ <meta property="og:video:height" content="720" />
|
|
|
+ <meta property="og:video:type" content="video/mp4" />
|
|
|
+ <meta name="twitter:player" content="https://davidawindham.com/wha/container.html" />
|
|
|
+ <meta name="twitter:player:width" content="1280" />
|
|
|
+ <meta name="twitter:player:height" content="720" />
|
|
|
+ <meta name="twitter:player:stream" content="<?php echo $media_url; ?>" />
|
|
|
+ <meta name="twitter:player:stream:content_type" content="video/mp4" />
|
|
|
+<?php
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+add_action('wp_head', 'dw_opengraph', 5);
|
|
|
+
|
|
|
+
|
|
|
?>
|