twentysixteen.php
| 1 | <?php |
| 2 | /** |
| 3 | * Jetpack Compatibility File |
| 4 | * See: https://jetpack.com/ |
| 5 | * |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Add Jetpack theme supports for Twenty Sixteen. |
| 11 | */ |
| 12 | function twentysixteen_jetpack_setup() { |
| 13 | /** |
| 14 | * Add theme support for Responsive Videos. |
| 15 | */ |
| 16 | add_theme_support( 'jetpack-responsive-videos' ); |
| 17 | } |
| 18 | add_action( 'after_setup_theme', 'twentysixteen_jetpack_setup' ); |
| 19 | |
| 20 | /** |
| 21 | * Enqueue Jetpack compat styles for Twenty Sixteen. |
| 22 | */ |
| 23 | function twentysixteen_init_jetpack() { |
| 24 | /** |
| 25 | * Add our compat CSS file for custom widget stylings and such. |
| 26 | * Set the version equal to filemtime for development builds, and the JETPACK__VERSION for production |
| 27 | * or skip it entirely for wpcom. |
| 28 | */ |
| 29 | if ( ! is_admin() ) { |
| 30 | $version = false; |
| 31 | if ( method_exists( 'Jetpack', 'is_development_version' ) ) { |
| 32 | $version = Jetpack::is_development_version() ? filemtime( plugin_dir_path( __FILE__ ) . 'twentysixteen.css' ) : JETPACK__VERSION; |
| 33 | } |
| 34 | wp_enqueue_style( 'twentysixteen-jetpack', plugins_url( 'twentysixteen.css', __FILE__ ), array(), $version ); |
| 35 | wp_style_add_data( 'twentysixteen-jetpack', 'rtl', 'replace' ); |
| 36 | } |
| 37 | } |
| 38 | add_action( 'init', 'twentysixteen_init_jetpack' ); |
| 39 | |
| 40 | /** |
| 41 | * Alter gallery widget default width. |
| 42 | */ |
| 43 | function twentysixteen_gallery_widget_content_width() { |
| 44 | return 390; |
| 45 | } |
| 46 | add_filter( 'gallery_widget_content_width', 'twentysixteen_gallery_widget_content_width' ); |
| 47 | |
| 48 | /** |
| 49 | * Remove ratings from excerpts that are used as intro on blog index, single, and archive pages. |
| 50 | */ |
| 51 | function twentysixteen_remove_share() { |
| 52 | if ( is_single() || is_archive() || is_home() ) { |
| 53 | remove_filter( 'the_excerpt', 'sharing_display', 19 ); |
| 54 | if ( class_exists( 'Jetpack_Likes' ) ) { |
| 55 | remove_filter( 'the_excerpt', array( Jetpack_Likes::init(), 'post_likes' ), 30 ); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | add_action( 'loop_start', 'twentysixteen_remove_share' ); |
| 60 |