Changeset 193772 in webkit
- Timestamp:
- Dec 8, 2015, 12:43:33 PM (10 years ago)
- Location:
- trunk/Websites/webkit.org
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Websites/webkit.org/ChangeLog
r193677 r193772 1 2015-12-08 Jonathan Davis <jond@apple.com> 2 3 Fix social meta for home page. 4 https://bugs.webkit.org/show_bug.cgi?id=151764 5 6 Reviewed by Timothy Hatcher. 7 8 * wp-content/plugins/social-meta.php: 9 1 10 2015-12-07 Jonathan Davis <jond@apple.com> 2 11 -
trunk/Websites/webkit.org/wp-content/plugins/social-meta.php
r192897 r193772 8 8 */ 9 9 10 add_action('wp_head', function() { ?> 11 <?php 10 add_action('wp_head', function() { 11 12 $title = get_the_title(); 13 $description = get_the_excerpt(); 14 $type = 'article'; 15 16 $categories = array(); 17 $tags = array(); 18 $image_url = ''; 19 $twitter_handle = ''; 20 21 if (is_front_page() || is_home()) { 22 $title = get_bloginfo('name'); 23 $description = get_bloginfo('description'); 24 $type = 'website'; 25 } 26 27 if (is_single()) { 12 28 $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'large' ); 13 29 $image_url = $image_src[0]; 14 ?> 30 31 $categories = wp_get_object_terms(get_the_ID(), 'category', array('fields' => 'names')); 32 $tags = wp_get_object_terms(get_the_ID(), 'post_tag', array('fields' => 'names')); 33 34 // Post author data is not available in wp_head filter context 35 $post = get_post(); 36 $twitter_handle = get_the_author_meta('twitter', $post->post_author); 37 } 38 39 ?> 15 40 16 41 <!-- Schema.org markup --> 17 <meta itemprop="name" content="<?php the_title(); ?>"> 18 <meta itemprop="description" content="<?php the_excerpt(); ?>"> 19 <?php if ( $image_url ): ?> 20 <meta itemprop="image" content="<?php echo $image_url; ?>"> 21 <?php endif; ?> 42 <meta itemprop="name" content="<?php echo esc_attr($title); ?>"> 43 <?php if ($description): ?> 44 <meta itemprop="description" content="<?php echo esc_attr($description); ?>"> 45 <?php endif; ?> 46 <?php if ($image_url): ?> 47 <meta itemprop="image" content="<?php echo esc_url($image_url); ?>"> 48 <?php endif; ?> 22 49 23 50 <!-- Twitter Card data --> 24 51 <meta name="twitter:card" content="summary_large_image"> 25 52 <meta name="twitter:site" content="@webkit"> 26 <meta name="twitter:title" content="<?php the_title(); ?>"> 27 <meta name="twitter:description" content="<?php the_excerpt(); ?>"> 28 <?php if ( '' !== ( $twitter_handle = get_the_author_meta('twitter') ) ): ?> 29 <meta name="twitter:creator" content="@<?php echo esc_html($twitter_handle); ?>"> 30 <?php endif; ?> 31 <?php if ( $image_url ): // Twitter summary card with large image must be at least 280x150px ?> 32 <meta name="twitter:image:src" content="<?php echo $image_url; ?>"> 33 <?php endif; ?> 53 <meta name="twitter:title" content="<?php echo esc_attr($title); ?>"> 54 <?php if ($description): ?> 55 <meta name="twitter:description" content="<?php echo esc_attr($description); ?>"> 56 <?php endif; ?> 57 <?php if ($twitter_handle): ?> 58 <meta name="twitter:creator" content="@<?php echo esc_attr($twitter_handle); ?>"> 59 <?php endif; ?> 60 <?php if ($image_url): // Twitter summary card with large image must be at least 280x150px ?> 61 <meta name="twitter:image:src" content="<?php echo esc_url($image_url); ?>"> 62 <?php endif; ?> 34 63 35 64 <!-- Open Graph data --> 36 <meta property="og:title" content="<?php the_title(); ?>" />37 <meta property="og:type" content=" article" />65 <meta property="og:title" content="<?php echo esc_attr($title); ?>" /> 66 <meta property="og:type" content="<?php echo esc_attr($type); ?>" /> 38 67 <meta property="og:url" content="<?php the_permalink(); ?>" /> 39 <?php if ( $image_url ): ?> 40 <meta itemprop="og:image" content="<?php echo $image_url; ?>"> 41 <?php endif; ?> 42 <meta property="og:description" content="<?php the_excerpt(); ?>" /> 68 <?php if ($image_url): ?> 69 <meta itemprop="og:image" content="<?php echo esc_url($image_url); ?>"> 70 <?php endif; ?> 71 <?php if ($description): ?> 72 <meta property="og:description" content="<?php echo esc_attr($description); ?>" /> 73 <?php endif; ?> 43 74 <meta property="og:site_name" content="<?php bloginfo('title'); ?>" /> 44 75 <meta property="article:published_time" content="<?php the_time('c'); ?>" /> 45 76 <meta property="article:modified_time" content="<?php the_modified_date('c'); ?>" /> 46 <?php 47 $categories = wp_get_object_terms( get_the_ID(), 'category', array( 'fields' => 'names' ) ); 48 $tags = wp_get_object_terms( get_the_ID(), 'post_tag', array( 'fields' => 'names' ) ); 77 <?php 78 if (!empty($categories)): 79 $section = array_shift($categories); // The first category is used as the section 80 $tags = array_merge($categories, $tags); // The rest are prepended to the tag list 81 ?> 82 <meta property="article:section" content="<?php echo esc_attr($section); ?>" /> 83 <?php 84 endif; 49 85 50 if ( ! empty($categories) ): 51 $section = array_shift($categories); // The first category is used as the section 52 $tags = array_merge($categories, $tags); // The rest are prepended to the tag list 53 ?> 54 <meta property="article:section" content="<?php echo esc_attr($section); ?>" /> 55 <?php 56 endif; 57 58 if ( ! empty($tags) ): foreach( $tags as $tag ): 59 ?> 86 if (!empty($tags)): 87 foreach($tags as $tag): 88 ?> 60 89 <meta property="article:tag" content="<?php echo esc_attr($tag); ?>" /> 61 <?php 62 endforeach; endif; 63 ?> 90 <?php 91 endforeach; 92 endif; 93 ?> 64 94 65 95 <?php
Note:
See TracChangeset
for help on using the changeset viewer.