functions.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. /*
  3. Author: Eddie Machado
  4. URL: htp://themble.com/bones/
  5. This is where you can drop your custom functions or
  6. just edit things like thumbnail sizes, header images,
  7. sidebars, comments, ect.
  8. */
  9. // LOAD BONES CORE (if you remove this, the theme will break)
  10. require_once( 'library/bones.php' );
  11. // USE THIS TEMPLATE TO CREATE CUSTOM POST TYPES EASILY
  12. require_once( 'library/custom-post-type.php' );
  13. // CUSTOMIZE THE WORDPRESS ADMIN (off by default)
  14. // require_once get_template_directory() . 'library/admin.php';
  15. /*********************
  16. LAUNCH BONES
  17. Let's get everything up and running.
  18. *********************/
  19. function bones_ahoy() {
  20. // let's get language support going, if you need it
  21. load_theme_textdomain( 'bonestheme', get_template_directory() . '/library/translation' );
  22. // launching operation cleanup
  23. add_action( 'init', 'bones_head_cleanup' );
  24. // A better title
  25. add_filter( 'wp_title', 'rw_title', 10, 3 );
  26. // remove WP version from RSS
  27. add_filter( 'the_generator', 'bones_rss_version' );
  28. // remove pesky injected css for recent comments widget
  29. add_filter( 'wp_head', 'bones_remove_wp_widget_recent_comments_style', 1 );
  30. // clean up comment styles in the head
  31. add_action( 'wp_head', 'bones_remove_recent_comments_style', 1 );
  32. // clean up gallery output in wp
  33. add_filter( 'gallery_style', 'bones_gallery_style' );
  34. // enqueue base scripts and styles
  35. add_action( 'wp_enqueue_scripts', 'bones_scripts_and_styles', 999 );
  36. // ie conditional wrapper
  37. // launching this stuff after theme setup
  38. bones_theme_support();
  39. // adding sidebars to Wordpress (these are created in functions.php)
  40. add_action( 'widgets_init', 'bones_register_sidebars' );
  41. // cleaning up random code around images
  42. add_filter( 'the_content', 'bones_filter_ptags_on_images' );
  43. // cleaning up excerpt
  44. add_filter( 'excerpt_more', 'bones_excerpt_more' );
  45. } /* end bones ahoy */
  46. // let's get this party started
  47. add_action( 'after_setup_theme', 'bones_ahoy' );
  48. /************* OEMBED SIZE OPTIONS *************/
  49. if ( ! isset( $content_width ) ) {
  50. $content_width = 640;
  51. }
  52. /************* THUMBNAIL SIZE OPTIONS *************/
  53. // Thumbnail sizes
  54. add_image_size( 'bones-thumb-600', 600, 150, true );
  55. add_image_size( 'bones-thumb-300', 300, 100, true );
  56. /*
  57. to add more sizes, simply copy a line from above
  58. and change the dimensions & name. As long as you
  59. upload a "featured image" as large as the biggest
  60. set width or height, all the other sizes will be
  61. auto-cropped.
  62. To call a different size, simply change the text
  63. inside the thumbnail function.
  64. For example, to call the 300 x 300 sized image,
  65. we would use the function:
  66. <?php the_post_thumbnail( 'bones-thumb-300' ); ?>
  67. for the 600 x 100 image:
  68. <?php the_post_thumbnail( 'bones-thumb-600' ); ?>
  69. You can change the names and dimensions to whatever
  70. you like. Enjoy!
  71. */
  72. /************* ACTIVE SIDEBARS ********************/
  73. // Sidebars & Widgetizes Areas
  74. function bones_register_sidebars() {
  75. register_sidebar(array(
  76. 'id' => 'sidebar1',
  77. 'name' => __( 'Sidebar 1', 'bonestheme' ),
  78. 'description' => __( 'The first (primary) sidebar.', 'bonestheme' ),
  79. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  80. 'after_widget' => '</div>',
  81. 'before_title' => '<h4 class="widgettitle">',
  82. 'after_title' => '</h4>',
  83. ));
  84. /*
  85. to add more sidebars or widgetized areas, just copy
  86. and edit the above sidebar code. In order to call
  87. your new sidebar just use the following code:
  88. Just change the name to whatever your new
  89. sidebar's id is, for example:
  90. register_sidebar(array(
  91. 'id' => 'sidebar2',
  92. 'name' => __( 'Sidebar 2', 'bonestheme' ),
  93. 'description' => __( 'The second (secondary) sidebar.', 'bonestheme' ),
  94. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  95. 'after_widget' => '</div>',
  96. 'before_title' => '<h4 class="widgettitle">',
  97. 'after_title' => '</h4>',
  98. ));
  99. To call the sidebar in your template, you can just copy
  100. the sidebar.php file and rename it to your sidebar's name.
  101. So using the above example, it would be:
  102. sidebar-sidebar2.php
  103. */
  104. } // don't remove this bracket!
  105. /************* COMMENT LAYOUT *********************/
  106. // Comment Layout
  107. function bones_comments( $comment, $args, $depth ) {
  108. $GLOBALS['comment'] = $comment; ?>
  109. <div id="comment-<?php comment_ID(); ?>" <?php comment_class('cf'); ?>>
  110. <article class="cf">
  111. <header class="comment-author vcard">
  112. <?php
  113. /*
  114. this is the new responsive optimized comment image. It used the new HTML5 data-attribute to display comment gravatars on larger screens only. What this means is that on larger posts, mobile sites don't have a ton of requests for comment images. This makes load time incredibly fast! If you'd like to change it back, just replace it with the regular wordpress gravatar call:
  115. echo get_avatar($comment,$size='32',$default='<path_to_url>' );
  116. */
  117. ?>
  118. <?php // custom gravatar call ?>
  119. <?php
  120. // create variable
  121. $bgauthemail = get_comment_author_email();
  122. ?>
  123. <img data-gravatar="http://www.gravatar.com/avatar/<?php echo md5( $bgauthemail ); ?>?s=40" class="load-gravatar avatar avatar-48 photo" height="40" width="40" src="<?php echo get_template_directory_uri(); ?>/library/images/nothing.gif" />
  124. <?php // end custom gravatar call ?>
  125. <?php printf(__( '<cite class="fn">%1$s</cite> %2$s', 'bonestheme' ), get_comment_author_link(), edit_comment_link(__( '(Edit)', 'bonestheme' ),' ','') ) ?>
  126. <time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time(__( 'F jS, Y', 'bonestheme' )); ?> </a></time>
  127. </header>
  128. <?php if ($comment->comment_approved == '0') : ?>
  129. <div class="alert alert-info">
  130. <p><?php _e( 'Your comment is awaiting moderation.', 'bonestheme' ) ?></p>
  131. </div>
  132. <?php endif; ?>
  133. <section class="comment_content cf">
  134. <?php comment_text() ?>
  135. </section>
  136. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  137. </article>
  138. <?php // </li> is added by WordPress automatically ?>
  139. <?php
  140. } // don't remove this bracket!
  141. /*
  142. This is a modification of a function found in the
  143. twentythirteen theme where we can declare some
  144. external fonts. If you're using Google Fonts, you
  145. can replace these fonts, change it in your scss files
  146. and be up and running in seconds.
  147. */
  148. function bones_fonts() {
  149. wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic');
  150. wp_enqueue_style( 'googleFonts');
  151. }
  152. add_action('wp_print_styles', 'bones_fonts');
  153. /* DON'T DELETE THIS CLOSING TAG */ ?>