| | 1 | <?php |
| | 2 | |
| | 3 | /* |
| | 4 | * Plugin Name: WordCamp Jetpack Overrides |
| | 5 | * Description: Adjustments to Jetpack functionality for WordCamp.org |
| | 6 | * Version: 0.1 |
| | 7 | * Author: Brandon Kraft |
| | 8 | */ |
| | 9 | |
| | 10 | |
| | 11 | /* |
| | 12 | * Open Graph Default Image |
| | 13 | * Provides a default image for sharing WordCamp home/pages to Facebook/Twitter/Google+ other than the Jetpack "blank" image. |
| | 14 | */ |
| | 15 | |
| | 16 | function wc_default_og_image() { |
| | 17 | $default_img = plugins_url( 'img/wp-default-og.png', __FILE__ ); |
| | 18 | return $default_img; |
| | 19 | } |
| | 20 | add_filter( 'jetpack_open_graph_image_default', 'wc_default_og_image' ); |
| | 21 | |
| | 22 | /* |
| | 23 | * Add Twitter Card type |
| | 24 | * Added the twiter:card = summary OG tag for the home page and other !is_singular() pages, which is not added by default by Jetpack. |
| | 25 | */ |
| | 26 | |
| | 27 | function wc_add_og_twitter_summary( $og_tags ) { |
| | 28 | if ( is_home() || is_front_page() ) { |
| | 29 | $og_tags['twitter:card'] = 'summary'; |
| | 30 | } |
| | 31 | |
| | 32 | return $og_tags; |
| | 33 | } |
| | 34 | add_filter( 'jetpack_open_graph_tags', 'wc_add_og_twitter_summary'); |
| | 35 | |
| | 36 | /* |
| | 37 | * Add default Twitter account as @WordCamp for when individual WCs do not set their Settings->Sharing option for Twitter cards only. Sets the "via" tag to blank to avoid slamming @WordCamp moderators with a ton of shared posts. |
| | 38 | */ |
| | 39 | |
| | 40 | function wc_twitter_sitetag( $site_tag ) { |
| | 41 | if ( $site_tag == 'jetpack' ) { |
| | 42 | $site_tag = 'WordCamp'; |
| | 43 | add_filter('jetpack_sharing_twitter_via', ''); |
| | 44 | } |
| | 45 | |
| | 46 | return $site_tag; |
| | 47 | } |
| | 48 | add_filter( 'jetpack_twitter_cards_site_tag', 'wc_twitter_sitetag'); |
| | 49 | No newline at end of file |