functions.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. /************* INCLUDE NEEDED FILES ***************/
  10. /*
  11. 1. library/bones.php
  12. - head cleanup (remove rsd, uri links, junk css, ect)
  13. - enqueueing scripts & styles
  14. - theme support functions
  15. - custom menu output & fallbacks
  16. - related post function
  17. - page-navi function
  18. - removing <p> from around images
  19. - customizing the post excerpt
  20. - custom google+ integration
  21. - adding custom fields to user profiles
  22. */
  23. require_once( 'library/bones.php' ); // if you remove this, bones will break
  24. /*
  25. 2. library/custom-post-type.php
  26. - an example custom post type
  27. - example custom taxonomy (like categories)
  28. - example custom taxonomy (like tags)
  29. */
  30. require_once( 'library/custom-post-type.php' ); // you can disable this if you like
  31. /*
  32. 3. library/admin.php
  33. - removing some default WordPress dashboard widgets
  34. - an example custom dashboard widget
  35. - adding custom login css
  36. - changing text in footer of admin
  37. */
  38. // require_once( 'library/admin.php' ); // this comes turned off by default
  39. /*
  40. 4. library/translation/translation.php
  41. - adding support for other languages
  42. */
  43. // require_once( 'library/translation/translation.php' ); // this comes turned off by default
  44. /************* THUMBNAIL SIZE OPTIONS *************/
  45. // Thumbnail sizes
  46. add_image_size( 'bones-thumb-600', 600, 150, true );
  47. add_image_size( 'bones-thumb-300', 300, 100, true );
  48. /*
  49. to add more sizes, simply copy a line from above
  50. and change the dimensions & name. As long as you
  51. upload a "featured image" as large as the biggest
  52. set width or height, all the other sizes will be
  53. auto-cropped.
  54. To call a different size, simply change the text
  55. inside the thumbnail function.
  56. For example, to call the 300 x 300 sized image,
  57. we would use the function:
  58. <?php the_post_thumbnail( 'bones-thumb-300' ); ?>
  59. for the 600 x 100 image:
  60. <?php the_post_thumbnail( 'bones-thumb-600' ); ?>
  61. You can change the names and dimensions to whatever
  62. you like. Enjoy!
  63. */
  64. add_filter( 'image_size_names_choose', 'bones_custom_image_sizes' );
  65. function bones_custom_image_sizes( $sizes ) {
  66. return array_merge( $sizes, array(
  67. 'bones-thumb-600' => __('600px by 150px'),
  68. 'bones-thumb-300' => __('300px by 100px'),
  69. ) );
  70. }
  71. /*
  72. The function above adds the ability to use the dropdown menu to select
  73. the new images sizes you have just created from within the media manager
  74. when you add media to your content blocks. If you add more image sizes,
  75. duplicate one of the lines in the array and name it according to your
  76. new image size.
  77. */
  78. /************* ACTIVE SIDEBARS ********************/
  79. // Sidebars & Widgetizes Areas
  80. function bones_register_sidebars() {
  81. register_sidebar(array(
  82. 'id' => 'sidebar1',
  83. 'name' => __( 'Sidebar 1', 'bonestheme' ),
  84. 'description' => __( 'The first (primary) sidebar.', 'bonestheme' ),
  85. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  86. 'after_widget' => '</div>',
  87. 'before_title' => '<h4 class="widgettitle">',
  88. 'after_title' => '</h4>',
  89. ));
  90. /*
  91. to add more sidebars or widgetized areas, just copy
  92. and edit the above sidebar code. In order to call
  93. your new sidebar just use the following code:
  94. Just change the name to whatever your new
  95. sidebar's id is, for example:
  96. register_sidebar(array(
  97. 'id' => 'sidebar2',
  98. 'name' => __( 'Sidebar 2', 'bonestheme' ),
  99. 'description' => __( 'The second (secondary) sidebar.', 'bonestheme' ),
  100. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  101. 'after_widget' => '</div>',
  102. 'before_title' => '<h4 class="widgettitle">',
  103. 'after_title' => '</h4>',
  104. ));
  105. To call the sidebar in your template, you can just copy
  106. the sidebar.php file and rename it to your sidebar's name.
  107. So using the above example, it would be:
  108. sidebar-sidebar2.php
  109. */
  110. } // don't remove this bracket!
  111. /************* COMMENT LAYOUT *********************/
  112. // Comment Layout
  113. function bones_comments( $comment, $args, $depth ) {
  114. $GLOBALS['comment'] = $comment; ?>
  115. <li <?php comment_class(); ?>>
  116. <article id="comment-<?php comment_ID(); ?>" class="clearfix">
  117. <header class="comment-author vcard">
  118. <?php
  119. /*
  120. 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:
  121. echo get_avatar($comment,$size='32',$default='<path_to_url>' );
  122. */
  123. ?>
  124. <?php // custom gravatar call ?>
  125. <?php
  126. // create variable
  127. $bgauthemail = get_comment_author_email();
  128. ?>
  129. <img data-gravatar="http://www.gravatar.com/avatar/<?php echo md5( $bgauthemail ); ?>?s=32" class="load-gravatar avatar avatar-48 photo" height="32" width="32" src="<?php echo get_template_directory_uri(); ?>/library/images/nothing.gif" />
  130. <?php // end custom gravatar call ?>
  131. <?php printf(__( '<cite class="fn">%s</cite>', 'bonestheme' ), get_comment_author_link()) ?>
  132. <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>
  133. <?php edit_comment_link(__( '(Edit)', 'bonestheme' ),' ','') ?>
  134. </header>
  135. <?php if ($comment->comment_approved == '0') : ?>
  136. <div class="alert alert-info">
  137. <p><?php _e( 'Your comment is awaiting moderation.', 'bonestheme' ) ?></p>
  138. </div>
  139. <?php endif; ?>
  140. <section class="comment_content clearfix">
  141. <?php comment_text() ?>
  142. </section>
  143. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  144. </article>
  145. <?php // </li> is added by WordPress automatically ?>
  146. <?php
  147. } // don't remove this bracket!
  148. /************* SEARCH FORM LAYOUT *****************/
  149. // Search Form
  150. function bones_wpsearch($form) {
  151. $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
  152. <label class="screen-reader-text" for="s">' . __( 'Search for:', 'bonestheme' ) . '</label>
  153. <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . esc_attr__( 'Search the Site...', 'bonestheme' ) . '" />
  154. <input type="submit" id="searchsubmit" value="' . esc_attr__( 'Search' ) .'" />
  155. </form>';
  156. return $form;
  157. } // don't remove this bracket!
  158. ?>