twentyfourteen.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * A last try to show posts, in case the Featured Content plugin returns no IDs.
  4. *
  5. * @param array $featured_ids
  6. * @return array
  7. */
  8. function twentyfourteen_featured_content_post_ids( $featured_ids ) {
  9. if ( empty( $featured_ids ) ) {
  10. $featured_ids = array_slice( get_option( 'sticky_posts', array() ), 0, 6 );
  11. }
  12. return $featured_ids;
  13. }
  14. add_action( 'featured_content_post_ids', 'twentyfourteen_featured_content_post_ids' );
  15. /**
  16. * Set the default tag name for Featured Content.
  17. *
  18. * @param WP_Customize_Manager $wp_customize Theme Customizer object.
  19. * @return void
  20. */
  21. function twentyfourteen_customizer_default( $wp_customize ) {
  22. $wp_customize->get_setting( 'featured-content[tag-name]' )->default = 'featured';
  23. }
  24. add_action( 'customize_register', 'twentyfourteen_customizer_default' );
  25. /**
  26. * Sets a default tag of 'featured' for Featured Content.
  27. *
  28. * @param array $settings
  29. * @return array
  30. */
  31. function twentyfourteen_featured_content_default_settings( $settings ) {
  32. $settings['tag-name'] = 'featured';
  33. return $settings;
  34. }
  35. add_action( 'featured_content_default_settings', 'twentyfourteen_featured_content_default_settings' );
  36. /**
  37. * Removes sharing markup from post content if we're not in the loop and it's a
  38. * formatted post.
  39. *
  40. * @param bool $show Whether to show sharing options.
  41. * @param WP_Post $post The post to share.
  42. * @return bool
  43. */
  44. function twentyfourteen_mute_content_filters( $show, $post ) {
  45. $formats = get_theme_support( 'post-formats' );
  46. if ( ! in_the_loop() && has_post_format( $formats[0], $post ) ) {
  47. $show = false;
  48. }
  49. return $show;
  50. }
  51. add_filter( 'sharing_show', 'twentyfourteen_mute_content_filters', 10, 2 );
  52. function twentyfourteen_init_jetpack() {
  53. /**
  54. * Add our compat CSS file for custom widget stylings and such.
  55. * Set the version equal to filemtime for development builds, and the JETPACK__VERSION for production.
  56. */
  57. if ( ! is_admin() ) {
  58. $version = false;
  59. if ( method_exists( 'Jetpack', 'is_development_version' ) ) {
  60. $version = Jetpack::is_development_version() ? filemtime( plugin_dir_path( __FILE__ ) . 'twentyfourteen.css' ) : JETPACK__VERSION;
  61. }
  62. wp_enqueue_style( 'twentyfourteen-jetpack', plugins_url( 'twentyfourteen.css', __FILE__ ), array(), $version );
  63. wp_style_add_data( 'twentyfourteen-jetpack', 'rtl', 'replace' );
  64. }
  65. }
  66. add_action( 'init', 'twentyfourteen_init_jetpack' );