bones.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /* Welcome to Bones :)
  3. This is meant to be a very helpful development tool.
  4. I hope it makes your life easier!
  5. Developed by: Eddie Machado
  6. URL: http://themble.com/bones/
  7. */
  8. // remove some WP defaults
  9. function removeHeadLinks() {
  10. // remove simple discovery link
  11. remove_action('wp_head', 'rsd_link');
  12. // remove windows live writer link
  13. remove_action('wp_head', 'wlwmanifest_link');
  14. // remove the version number
  15. remove_action('wp_head', 'wp_generator');
  16. // remove header links
  17. }
  18. add_action('init', 'removeHeadLinks');
  19. // Add RSS links to <head> section
  20. add_theme_support('automatic-feed-links');
  21. // loading jquery reply elements on single pages automatically
  22. function bones_queue_js(){
  23. if (!is_admin()){
  24. if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
  25. wp_enqueue_script( 'comment-reply' );
  26. }
  27. }
  28. add_action('wp_print_scripts', 'bones_queue_js');
  29. // Adding WP 3.0 Functions
  30. //menus
  31. add_theme_support( 'menus' );
  32. // thumbnails
  33. add_theme_support('post-thumbnails');
  34. set_post_thumbnail_size(125, 125, true); /* more sizes are available using the functions.php file */
  35. // custom backgrounds
  36. add_custom_background();
  37. // header image define
  38. define('NO_HEADER_TEXT', true ); // I prefer no header text, you can change this
  39. // define('HEADER_TEXTCOLOR', 'ffffff'); // the text color in the header ( to use uncomment it and comment no header tx
  40. define('HEADER_IMAGE', '%s/images/default_header.jpg'); // %s is the template dir uri
  41. define('HEADER_IMAGE_WIDTH', 1044); // the width of the logo
  42. define('HEADER_IMAGE_HEIGHT', 150); // the height of the logo
  43. // gets included in the site header
  44. function header_style() { ?>
  45. <style type="text/css"> header[role=banner] { background: url(<?php header_image(); ?>); } </style><?php
  46. }
  47. // gets included in the admin header
  48. function admin_header_style() {
  49. ?><style type="text/css">
  50. #headimg {
  51. width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  52. height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  53. }
  54. </style><?php
  55. }
  56. add_custom_image_header('header_style', 'admin_header_style');
  57. // adding post format support
  58. add_theme_support( 'post-formats',
  59. array(
  60. 'aside', /* Typically styled without a title. Similar to a Facebook note update */
  61. 'gallery', /* A gallery of images. Post will likely contain a gallery shortcode and will have image attachments */
  62. 'link', /* A link to another site. Themes may wish to use the first <a href=ÓÓ> tag in the post content as the external link for that post. An alternative approach could be if the post consists only of a URL, then that will be the URL and the title (post_title) will be the name attached to the anchor for it */
  63. 'image', /* A single image. The first <img /> tag in the post could be considered the image. Alternatively, if the post consists only of a URL, that will be the image URL and the title of the post (post_title) will be the title attribute for the image */
  64. 'quote', /* A quotation. Probably will contain a blockquote holding the quote content. Alternatively, the quote may be just the content, with the source/author being the title */
  65. 'status', /*A short status update, similar to a Twitter status update */
  66. 'video', /* A single video. The first <video /> tag or object/embed in the post content could be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL. May also contain the video as an attachment to the post, if video support is enabled on the blog (like via a plugin) */
  67. 'audio', /* An audio file. Could be used for Podcasting */
  68. 'chat' /* A chat transcript */
  69. )
  70. );
  71. // Creating the Nav Menus
  72. function bones_menus() {
  73. if (function_exists( 'register_nav_menus' )) {
  74. register_nav_menus(
  75. array(
  76. 'main_nav' => 'The Main Menu',
  77. 'footer_links' => 'Footer Links'
  78. )
  79. );
  80. }
  81. }
  82. add_action( 'init', 'bones_menus' );
  83. function bones_main_nav() {
  84. // display the wp3 menu if available
  85. wp_nav_menu(
  86. array(
  87. 'menu' => 'main_nav', /* menu name */
  88. 'theme_location' => 'main_nav', /* where in the theme it's assigned */
  89. 'container_class' => 'menu', /* container class */
  90. 'fallback_cb' => 'bones_main_nav_fallback' /* menu fallback */
  91. )
  92. );
  93. }
  94. function bones_footer_links() {
  95. // display the wp3 menu if available
  96. wp_nav_menu(
  97. array(
  98. 'menu' => 'footer_links', /* menu name */
  99. 'theme_location' => 'footer_links', /* where in the theme it's assigned */
  100. 'container_class' => 'footer-links', /* container class */
  101. 'fallback_cb' => 'bones_footer_links_fallback' /* menu fallback */
  102. )
  103. );
  104. }
  105. function bones_main_nav_fallback() { wp_page_menu( 'show_home=Home&menu_class=menu' ); }
  106. function bones_footer_links_fallback() { echo '<ul class="footer-links"><li>Bones<li></ul>'; }
  107. // Related Posts Function (call using bones_related_posts(); )
  108. function bones_related_posts() {
  109. echo '<ul id="bones-related-posts">';
  110. global $post;
  111. $tags = wp_get_post_tags($post->ID);
  112. if($tags) {
  113. foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
  114. $args = array(
  115. 'tag' => $tag_arr,
  116. 'numberposts' => 5,
  117. 'post__not_in' => array($post->ID)
  118. );
  119. $related_posts = get_posts($args);
  120. if($related_posts) {
  121. foreach ($related_posts as $post) : setup_postdata($post); ?>
  122. <li class="related_post"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  123. <?php endforeach; } else { ?>
  124. <li class="no_related_post">No Related Posts Yet!</li>
  125. <?php }
  126. }
  127. wp_reset_query();
  128. echo '</ul>';
  129. }
  130. ?>