Changeset 4481 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
- Timestamp:
- 12/04/2016 09:33:59 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
r4478 r4481 10 10 namespace WordPressdotorg\Plugin_Directory\Theme; 11 11 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 12 use WordPressdotorg\Plugin_Directory\Template; 12 13 13 14 /** … … 157 158 158 159 /** 160 * Adds meta tags for richer social media integrations. 161 */ 162 function social_meta_data() { 163 if ( ! is_singular( 'plugin' ) ) { 164 return; 165 } 166 167 $post_id = get_the_ID(); 168 $banner = Template::get_plugin_banner( $post_id ); 169 $banner['banner_2x'] = $banner['banner_2x'] ? $banner['banner'] : false; 170 $icon = Template::get_plugin_icon( $post_id ); 171 172 printf( '<meta property="og:title" content="%s" />' . "\n", the_title_attribute( array( 'echo' => false, 'post' => $post_id ) ) ); 173 printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt( $post_id ) ) ) ); 174 printf( '<meta property="og:site_name" content="WordPress.org" />' . "\n" ); 175 printf( '<meta property="og:type" content="website" />' . "\n" ); 176 printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink( $post_id ) ) ); 177 printf( '<meta name="twitter:card" content="summary_large_image">' . "\n" ); 178 printf( '<meta name="twitter:site" content="@WordPress">' . "\n" ); 179 180 if ( $banner['banner_2x'] ) { 181 printf( '<meta name="twitter:image" content="%s" />' . "\n", $banner['banner_2x'] ); 182 } 183 if ( isset( $banner['banner'] ) ) { 184 printf( '<meta property="og:image" content="%s" />' . "\n", $banner['banner'] ); 185 } 186 if ( ! $icon['generated'] && ( $icon['icon_2x'] || $icon['icon'] ) ) { 187 printf( '<meta name="thumbnail" content="%s" />', $icon['icon_2x'] ?: $icon['icon'] ); 188 } 189 } 190 add_action( 'wp_head', __NAMESPACE__ . '\social_meta_data' ); 191 192 /** 159 193 * Adds hreflang link attributes to plugin pages. 160 194 *
Note: See TracChangeset
for help on using the changeset viewer.