Changeset 202577 in webkit
- Timestamp:
- Jun 28, 2016 11:12:23 AM (8 years ago)
- Location:
- trunk/Websites/webkit.org
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Websites/webkit.org/ChangeLog
r202534 r202577 1 2016-06-28 Jon Davis <jond@apple.com> 2 3 Fixed Open Graph meta data and image entries. 4 https://bugs.webkit.org/show_bug.cgi?id=159167. 5 6 Reviewed by Timothy Hatcher. 7 8 This patch addresses Open Graph meta data issues: 9 10 - Added a high-resolution PNG of the WebKit logo because Facebook doesn't support SVG images 11 - Uses the first image of a page or post if not featured image is set 12 - Article date/time information should not be given for the homepage 13 - Added Facebook admins as per the Facebook Open Graph debugger 14 15 * wp-content/plugins/social-meta.php: 16 * wp-content/themes/webkit/images/ogimage.png: Added. 17 1 18 2016-06-27 Dean Jackson <dino@apple.com> 2 19 -
trunk/Websites/webkit.org/wp-content/plugins/social-meta.php
r202521 r202577 9 9 10 10 add_action('wp_head', function() { 11 11 12 12 $title = get_the_title(); 13 13 $description = get_the_excerpt(); 14 14 $type = 'article'; 15 15 16 16 $categories = array(); 17 17 $tags = array(); 18 $image_url = get_stylesheet_directory_uri() . '/images/ webkit.svg';18 $image_url = get_stylesheet_directory_uri() . '/images/ogimage.png'; 19 19 $twitter_handle = ''; 20 20 $published_time = ''; 21 $modified_time = ''; 22 23 $fb_admins = array( 24 'Jon Davis' => '1085088865', 25 'Tim Hatcher' => '854565306' 26 ); 27 21 28 if (is_front_page() || is_home()) { 22 29 $title = get_bloginfo('name'); 23 30 $description = get_bloginfo('description'); 24 $type = 'website'; 31 $type = 'website'; 25 32 } 26 33 27 34 if (is_single()) { 28 $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'large' ); 29 $image_url = $image_src[0]; 30 35 36 $post = get_post(); 37 38 if ( has_post_thumbnail() ) { 39 $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'large' ); 40 $image_url = $image_src[0]; 41 } else { 42 preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); 43 if ($matches[1][0]) $image_url = $matches[1][0]; 44 } 45 31 46 $categories = wp_get_object_terms(get_the_ID(), 'category', array('fields' => 'names')); 32 47 $tags = wp_get_object_terms(get_the_ID(), 'post_tag', array('fields' => 'names')); 33 48 34 49 // Post author data is not available in wp_head filter context 35 $post = get_post();36 50 $twitter_handle = get_the_author_meta('twitter', $post->post_author); 51 $published_time = get_the_time('c'); 52 $modified_time = get_the_modified_date('c'); 37 53 } 38 54 39 55 ?> 40 56 … … 63 79 64 80 <!-- Open Graph data --> 65 <meta property="og:title" content="<?php echo esc_attr($title); ?>" />66 <meta property="og:type" content="<?php echo esc_attr($type); ?>" />67 <meta property="og:url" content="<?php the_permalink(); ?>" />81 <meta property="og:title" content="<?php echo esc_attr($title); ?>"> 82 <meta property="og:type" content="<?php echo esc_attr($type); ?>"> 83 <meta property="og:url" content="<?php the_permalink(); ?>"> 68 84 <?php if ($image_url): ?> 69 85 <meta itemprop="og:image" content="<?php echo esc_url($image_url); ?>"> 70 86 <?php endif; ?> 71 87 <?php if ($description): ?> 72 <meta property="og:description" content="<?php echo esc_attr($description); ?>" />88 <meta property="og:description" content="<?php echo esc_attr($description); ?>"> 73 89 <?php endif; ?> 74 <meta property="og:site_name" content="<?php bloginfo('title'); ?>" /> 75 <meta property="article:published_time" content="<?php the_time('c'); ?>" /> 76 <meta property="article:modified_time" content="<?php the_modified_date('c'); ?>" /> 90 <meta property="og:site_name" content="<?php bloginfo('title'); ?>"> 91 <?php if ($published_time): ?> 92 <meta property="article:published_time" content="<?php echo $published_time; ?>"> 93 <?php endif; ?> 94 <?php if ($modified_time): ?> 95 <meta property="article:modified_time" content="<?php echo $modified_time; ?>"> 96 <?php endif; ?> 77 97 <?php 78 98 if (!empty($categories)): … … 80 100 $tags = array_merge($categories, $tags); // The rest are prepended to the tag list 81 101 ?> 82 <meta property="article:section" content="<?php echo esc_attr($section); ?>" />102 <meta property="article:section" content="<?php echo esc_attr($section); ?>"> 83 103 <?php 84 104 endif; … … 87 107 foreach($tags as $tag): 88 108 ?> 89 <meta property="article:tag" content="<?php echo esc_attr($tag); ?>" />90 <?php 91 endforeach; 109 <meta property="article:tag" content="<?php echo esc_attr($tag); ?>"> 110 <?php 111 endforeach; 92 112 endif; 113 114 if (!empty($fb_admins)): 115 foreach($fb_admins as $id): 93 116 ?> 94 117 <meta property="fb:admins" content="<?php echo esc_attr($id); ?>"> 95 118 <?php 119 endforeach; 120 endif; 96 121 });
Note: See TracChangeset
for help on using the changeset viewer.