functions.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. // remove WP version from RSS
  25. add_filter( 'the_generator', 'bones_rss_version' );
  26. // remove pesky injected css for recent comments widget
  27. add_filter( 'wp_head', 'bones_remove_wp_widget_recent_comments_style', 1 );
  28. // clean up comment styles in the head
  29. add_action( 'wp_head', 'bones_remove_recent_comments_style', 1 );
  30. // clean up gallery output in wp
  31. add_filter( 'gallery_style', 'bones_gallery_style' );
  32. // enqueue base scripts and styles
  33. add_action( 'wp_enqueue_scripts', 'bones_scripts_and_styles', 999 );
  34. // ie conditional wrapper
  35. // launching this stuff after theme setup
  36. bones_theme_support();
  37. // adding sidebars to Wordpress (these are created in functions.php)
  38. add_action( 'widgets_init', 'bones_register_sidebars' );
  39. // cleaning up random code around images
  40. add_filter( 'the_content', 'bones_filter_ptags_on_images' );
  41. // cleaning up excerpt
  42. add_filter( 'excerpt_more', 'bones_excerpt_more' );
  43. } /* end bones ahoy */
  44. // let's get this party started
  45. add_action( 'after_setup_theme', 'bones_ahoy' );
  46. /************* OEMBED SIZE OPTIONS *************/
  47. if ( ! isset( $content_width ) ) {
  48. $content_width = 640;
  49. }
  50. /************* THUMBNAIL SIZE OPTIONS *************/
  51. // Thumbnail sizes
  52. add_image_size( 'bones-thumb-600', 600, 150, true );
  53. add_image_size( 'bones-thumb-300', 300, 100, true );
  54. /*
  55. to add more sizes, simply copy a line from above
  56. and change the dimensions & name. As long as you
  57. upload a "featured image" as large as the biggest
  58. set width or height, all the other sizes will be
  59. auto-cropped.
  60. To call a different size, simply change the text
  61. inside the thumbnail function.
  62. For example, to call the 300 x 300 sized image,
  63. we would use the function:
  64. <?php the_post_thumbnail( 'bones-thumb-300' ); ?>
  65. for the 600 x 100 image:
  66. <?php the_post_thumbnail( 'bones-thumb-600' ); ?>
  67. You can change the names and dimensions to whatever
  68. you like. Enjoy!
  69. */
  70. /************* ACTIVE SIDEBARS ********************/
  71. // Sidebars & Widgetizes Areas
  72. function bones_register_sidebars() {
  73. register_sidebar(array(
  74. 'id' => 'sidebar1',
  75. 'name' => __( 'Sidebar 1', 'bonestheme' ),
  76. 'description' => __( 'The first (primary) sidebar.', 'bonestheme' ),
  77. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  78. 'after_widget' => '</div>',
  79. 'before_title' => '<h4 class="widgettitle">',
  80. 'after_title' => '</h4>',
  81. ));
  82. /*
  83. to add more sidebars or widgetized areas, just copy
  84. and edit the above sidebar code. In order to call
  85. your new sidebar just use the following code:
  86. Just change the name to whatever your new
  87. sidebar's id is, for example:
  88. register_sidebar(array(
  89. 'id' => 'sidebar2',
  90. 'name' => __( 'Sidebar 2', 'bonestheme' ),
  91. 'description' => __( 'The second (secondary) sidebar.', 'bonestheme' ),
  92. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  93. 'after_widget' => '</div>',
  94. 'before_title' => '<h4 class="widgettitle">',
  95. 'after_title' => '</h4>',
  96. ));
  97. To call the sidebar in your template, you can just copy
  98. the sidebar.php file and rename it to your sidebar's name.
  99. So using the above example, it would be:
  100. sidebar-sidebar2.php
  101. */
  102. } // don't remove this bracket!
  103. /************* COMMENT LAYOUT *********************/
  104. // Comment Layout
  105. function bones_comments( $comment, $args, $depth ) {
  106. $GLOBALS['comment'] = $comment; ?>
  107. <div id="comment-<?php comment_ID(); ?>" <?php comment_class('cf'); ?>>
  108. <article class="cf">
  109. <header class="comment-author vcard">
  110. <?php
  111. /*
  112. 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:
  113. echo get_avatar($comment,$size='32',$default='<path_to_url>' );
  114. */
  115. ?>
  116. <?php // custom gravatar call ?>
  117. <?php
  118. // create variable
  119. $bgauthemail = get_comment_author_email();
  120. ?>
  121. <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" />
  122. <?php // end custom gravatar call ?>
  123. <?php printf(__( '<cite class="fn">%1$s</cite> %2$s', 'bonestheme' ), get_comment_author_link(), edit_comment_link(__( '(Edit)', 'bonestheme' ),' ','') ) ?>
  124. <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>
  125. </header>
  126. <?php if ($comment->comment_approved == '0') : ?>
  127. <div class="alert alert-info">
  128. <p><?php _e( 'Your comment is awaiting moderation.', 'bonestheme' ) ?></p>
  129. </div>
  130. <?php endif; ?>
  131. <section class="comment_content cf">
  132. <?php comment_text() ?>
  133. </section>
  134. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  135. </article>
  136. <?php // </li> is added by WordPress automatically ?>
  137. <?php
  138. } // don't remove this bracket!
  139. /*
  140. This is a modification of a function found in the
  141. twentythirteen theme where we can declare some
  142. external fonts. If you're using Google Fonts, you
  143. can replace these fonts, change it in your scss files
  144. and be up and running in seconds.
  145. */
  146. function bones_fonts() {
  147. wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic');
  148. wp_enqueue_style( 'googleFonts');
  149. }
  150. add_action('wp_print_styles', 'bones_fonts');
  151. /* DON'T DELETE THIS CLOSING TAG */ ?>