/modules/minileven/theme/pub/minileven/inc/tweaks.php

  1. <?php 
  2. /** 
  3. * Custom functions that act independently of the theme templates 
  4. * 
  5. * Eventually, some of the functionality here could be replaced by core features 
  6. * 
  7. * @package Minileven 
  8. * @since Minileven 2.0 
  9. */ 
  10.  
  11. /** 
  12. * Sets the post excerpt length based on number of characters, without breaking words at the end 
  13. * 
  14. */ 
  15. function minileven_excerpt( $count ) { 
  16. $excerpt = get_the_content(); 
  17. $excerpt = strip_tags( $excerpt ); 
  18. $excerpt = strip_shortcodes( $excerpt ); 
  19. $excerpt = substr( $excerpt, 0, $count ); 
  20. $excerpt = substr( $excerpt, 0, strripos( $excerpt, " " ) ); 
  21. $excerpt = $excerpt . minileven_continue_reading_link(); 
  22. return $excerpt; 
  23. /** 
  24.   
  25. /** 
  26. * Returns a "Continue Reading" link for excerpts 
  27. */ 
  28. function minileven_continue_reading_link() { 
  29. return ' … <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'jetpack' ) . '</a>'; 
  30.  
  31. /** 
  32. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and minileven_continue_reading_link(). 
  33. */ 
  34. function minileven_auto_excerpt_more( $more ) { 
  35. return ' …' . minileven_continue_reading_link(); 
  36. add_filter( 'excerpt_more', 'minileven_auto_excerpt_more' ); 
  37.  
  38. /** 
  39. * Adds a pretty "Continue Reading" link to custom post excerpts. 
  40. * 
  41. * To override this link in a child theme, remove the filter and add your own 
  42. * function tied to the get_the_excerpt filter hook. 
  43. */ 
  44. function minileven_custom_excerpt_more( $output ) { 
  45. if ( has_excerpt() && ! is_attachment() ) { 
  46. $output .= minileven_continue_reading_link(); 
  47. return $output; 
  48. add_filter( 'get_the_excerpt', 'minileven_custom_excerpt_more' ); 
  49.  
  50. /** 
  51. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. 
  52. */ 
  53. function minileven_page_menu_args( $args ) { 
  54. $args['show_home'] = true; 
  55. return $args; 
  56. add_filter( 'wp_page_menu_args', 'minileven_page_menu_args' ); 
  57.  
  58. /** 
  59. * Adds a custom class to the array of body classes, to allow Minileven to be targeted with Custom CSS. 
  60. */ 
  61. function minileven_body_classes( $classes ) { 
  62. $classes[] = 'mobile-theme'; 
  63. return $classes; 
  64. add_filter( 'body_class', 'minileven_body_classes' ); 
  65.  
  66. /** 
  67. * Filters wp_title to print a neat <title> tag based on what is being viewed. 
  68. * 
  69. * @since Minileven 2.0 
  70. */ 
  71. function minileven_wp_title( $title, $sep ) { 
  72. global $page, $paged; 
  73.  
  74. if ( is_feed() ) 
  75. return $title; 
  76.  
  77. // Add the blog name 
  78. $title .= get_bloginfo( 'name' ); 
  79.  
  80. // Add the blog description for the home/front page. 
  81. $site_description = get_bloginfo( 'description', 'display' ); 
  82. if ( $site_description && ( is_home() || is_front_page() ) ) 
  83. $title .= " $sep $site_description"; 
  84.  
  85. // Add a page number if necessary: 
  86. if ( $paged >= 2 || $page >= 2 ) 
  87. $title .= " $sep " . sprintf( __( 'Page %s', 'jetpack' ), max( $paged, $page ) ); 
  88.  
  89. return $title; 
  90. add_filter( 'wp_title', 'minileven_wp_title', 10, 2 ); 
  91.  
  92. /** 
  93. * Add theme support for Responsive Videos. 
  94. */ 
  95. add_theme_support( 'jetpack-responsive-videos' ); 
.