|
@@ -1,93 +1,96 @@
|
|
|
<?php
|
|
<?php
|
|
|
/* Welcome to Bones :)
|
|
/* Welcome to Bones :)
|
|
|
-This is meant to be a very helpful development tool.
|
|
|
|
|
-I hope it makes your life easier!
|
|
|
|
|
|
|
+This is the core Bones file where most of the
|
|
|
|
|
+main functions & features reside. If you have
|
|
|
|
|
+any custom functions, it's best to put them
|
|
|
|
|
+in the functions.php file.
|
|
|
|
|
|
|
|
Developed by: Eddie Machado
|
|
Developed by: Eddie Machado
|
|
|
URL: http://themble.com/bones/
|
|
URL: http://themble.com/bones/
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-// remove some WP defaults
|
|
|
|
|
-function removeHeadLinks() {
|
|
|
|
|
- // remove simple discovery link
|
|
|
|
|
- remove_action('wp_head', 'rsd_link');
|
|
|
|
|
- // remove windows live writer link
|
|
|
|
|
- remove_action('wp_head', 'wlwmanifest_link');
|
|
|
|
|
- // remove the version number
|
|
|
|
|
- remove_action('wp_head', 'wp_generator');
|
|
|
|
|
|
|
+// Adding Translation Option
|
|
|
|
|
+load_theme_textdomain( 'bonestheme', TEMPLATEPATH.'/languages' );
|
|
|
|
|
+$locale = get_locale();
|
|
|
|
|
+$locale_file = TEMPLATEPATH."/languages/$locale.php";
|
|
|
|
|
+if ( is_readable($locale_file) ) require_once($locale_file);
|
|
|
|
|
+
|
|
|
|
|
+// Cleaning up the Wordpress Head
|
|
|
|
|
+function bones_head_cleanup() {
|
|
|
// remove header links
|
|
// remove header links
|
|
|
|
|
+ remove_action( 'wp_head', 'feed_links_extra', 3 ); // Category Feeds
|
|
|
|
|
+ remove_action( 'wp_head', 'feed_links', 2 ); // Post and Comment Feeds
|
|
|
|
|
+ remove_action( 'wp_head', 'rsd_link' ); // EditURI link
|
|
|
|
|
+ remove_action( 'wp_head', 'wlwmanifest_link' ); // Windows Live Writer
|
|
|
|
|
+ remove_action( 'wp_head', 'index_rel_link' ); // index link
|
|
|
|
|
+ remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // previous link
|
|
|
|
|
+ remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
|
|
|
|
|
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // Links for Adjacent Posts
|
|
|
|
|
+ remove_action( 'wp_head', 'wp_generator' ); // WP version
|
|
|
|
|
+ if (!is_admin()) {
|
|
|
|
|
+ wp_deregister_script('jquery'); // De-Register jQuery
|
|
|
|
|
+ wp_register_script('jquery', '', '', '', true); // It's already in the Header
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- add_action('init', 'removeHeadLinks');
|
|
|
|
|
- // Add RSS links to <head> section
|
|
|
|
|
- add_theme_support('automatic-feed-links');
|
|
|
|
|
|
|
+ // launching operation cleanup
|
|
|
|
|
+ add_action('init', 'bones_head_cleanup');
|
|
|
|
|
+ // remove WP version from RSS
|
|
|
|
|
+ function bones_rss_version() { return ''; }
|
|
|
|
|
+ add_filter('the_generator', 'bones_rss_version');
|
|
|
|
|
|
|
|
// loading jquery reply elements on single pages automatically
|
|
// loading jquery reply elements on single pages automatically
|
|
|
-function bones_queue_js(){
|
|
|
|
|
- if (!is_admin()){
|
|
|
|
|
- if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
|
|
|
|
|
- wp_enqueue_script( 'comment-reply' );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+function bones_queue_js(){ if (!is_admin()){ if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) wp_enqueue_script( 'comment-reply' ); }
|
|
|
|
|
+}
|
|
|
|
|
+ // reply on comments script
|
|
|
|
|
+ add_action('wp_print_scripts', 'bones_queue_js');
|
|
|
|
|
+
|
|
|
|
|
+// Fixing the Read More in the Excerpts
|
|
|
|
|
+// This removes the annoying […] to a Read More link
|
|
|
|
|
+function bones_excerpt_more($more) {
|
|
|
|
|
+ global $post;
|
|
|
|
|
+ // edit here if you like
|
|
|
|
|
+ return '... <a href="'. get_permalink($post->ID) . '" title="Read '.get_the_title($post->ID).'">Read more »</a>';
|
|
|
}
|
|
}
|
|
|
-add_action('wp_print_scripts', 'bones_queue_js');
|
|
|
|
|
|
|
+add_filter('excerpt_more', 'bones_excerpt_more');
|
|
|
|
|
|
|
|
-// Adding WP 3.0 Functions
|
|
|
|
|
- //menus
|
|
|
|
|
- add_theme_support( 'menus' );
|
|
|
|
|
- // thumbnails
|
|
|
|
|
- add_theme_support('post-thumbnails');
|
|
|
|
|
- set_post_thumbnail_size(125, 125, true); /* more sizes are available using the functions.php file */
|
|
|
|
|
- // custom backgrounds
|
|
|
|
|
- add_custom_background();
|
|
|
|
|
- // header image define
|
|
|
|
|
- define('NO_HEADER_TEXT', true ); // I prefer no header text, you can change this
|
|
|
|
|
- // define('HEADER_TEXTCOLOR', 'ffffff'); // the text color in the header ( to use uncomment it and comment no header tx
|
|
|
|
|
- define('HEADER_IMAGE', '%s/images/default_header.jpg'); // %s is the template dir uri
|
|
|
|
|
- define('HEADER_IMAGE_WIDTH', 1044); // the width of the logo
|
|
|
|
|
- define('HEADER_IMAGE_HEIGHT', 150); // the height of the logo
|
|
|
|
|
- // gets included in the site header
|
|
|
|
|
- function header_style() { ?>
|
|
|
|
|
- <style type="text/css"> header[role=banner] { background: url(<?php header_image(); ?>); } </style><?php
|
|
|
|
|
- }
|
|
|
|
|
- // gets included in the admin header
|
|
|
|
|
- function admin_header_style() {
|
|
|
|
|
- ?><style type="text/css">
|
|
|
|
|
- #headimg {
|
|
|
|
|
- width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
|
|
|
|
|
- height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
|
|
|
|
|
- }
|
|
|
|
|
- </style><?php
|
|
|
|
|
- }
|
|
|
|
|
- add_custom_image_header('header_style', 'admin_header_style');
|
|
|
|
|
|
|
+// Adding WP 3+ Functions & Theme Support
|
|
|
|
|
+function bones_theme_support() {
|
|
|
|
|
+ add_theme_support('post-thumbnails'); // wp thumbnails (sizes handled in functions.php)
|
|
|
|
|
+ set_post_thumbnail_size(125, 125, true); // default thumb size
|
|
|
|
|
+ add_custom_background(); // wp custom background
|
|
|
|
|
+ add_theme_support('automatic-feed-links'); // rss thingy
|
|
|
|
|
+ // to add header image support go here: http://themble.com/support/adding-header-background-image-support/
|
|
|
// adding post format support
|
|
// adding post format support
|
|
|
- add_theme_support( 'post-formats',
|
|
|
|
|
|
|
+ add_theme_support( 'post-formats', // post formats
|
|
|
array(
|
|
array(
|
|
|
- 'aside', /* Typically styled without a title. Similar to a Facebook note update */
|
|
|
|
|
- 'gallery', /* A gallery of images. Post will likely contain a gallery shortcode and will have image attachments */
|
|
|
|
|
- '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 */
|
|
|
|
|
- '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 */
|
|
|
|
|
- '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 */
|
|
|
|
|
- 'status', /*A short status update, similar to a Twitter status update */
|
|
|
|
|
- '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) */
|
|
|
|
|
- 'audio', /* An audio file. Could be used for Podcasting */
|
|
|
|
|
- 'chat' /* A chat transcript */
|
|
|
|
|
|
|
+ 'aside', // title less blurb
|
|
|
|
|
+ 'gallery', // gallery of images
|
|
|
|
|
+ 'link', // quick link to other site
|
|
|
|
|
+ 'image', // an image
|
|
|
|
|
+ 'quote', // a quick quote
|
|
|
|
|
+ 'status', // a Facebook like status update
|
|
|
|
|
+ 'video', // video
|
|
|
|
|
+ 'audio', // audio
|
|
|
|
|
+ 'chat' // chat transcript
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ add_theme_support( 'menus' ); // wp menus
|
|
|
|
|
+ register_nav_menus( // wp3+ menus
|
|
|
|
|
+ array(
|
|
|
|
|
+ 'main_nav' => 'The Main Menu', // main nav in header
|
|
|
|
|
+ 'footer_links' => 'Footer Links' // secondary nav in footer
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-// Creating the Nav Menus
|
|
|
|
|
-function bones_menus() {
|
|
|
|
|
- if (function_exists( 'register_nav_menus' )) {
|
|
|
|
|
- register_nav_menus(
|
|
|
|
|
- array(
|
|
|
|
|
- 'main_nav' => 'The Main Menu',
|
|
|
|
|
- 'footer_links' => 'Footer Links'
|
|
|
|
|
- )
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-add_action( 'init', 'bones_menus' );
|
|
|
|
|
|
|
+ // launching this stuff after theme setup
|
|
|
|
|
+ add_action('after_setup_theme','bones_theme_support');
|
|
|
|
|
+ // adding sidebars to Wordpress (these are created in functions.php)
|
|
|
|
|
+ add_action( 'widgets_init', 'bones_register_sidebars' );
|
|
|
|
|
+ // adding the bones search form (created in functions.php)
|
|
|
|
|
+ add_filter( 'get_search_form', 'bones_wpsearch' );
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
function bones_main_nav() {
|
|
function bones_main_nav() {
|
|
|
// display the wp3 menu if available
|
|
// display the wp3 menu if available
|
|
@@ -95,7 +98,7 @@ function bones_main_nav() {
|
|
|
array(
|
|
array(
|
|
|
'menu' => 'main_nav', /* menu name */
|
|
'menu' => 'main_nav', /* menu name */
|
|
|
'theme_location' => 'main_nav', /* where in the theme it's assigned */
|
|
'theme_location' => 'main_nav', /* where in the theme it's assigned */
|
|
|
- 'container_class' => 'menu', /* container class */
|
|
|
|
|
|
|
+ 'container_class' => 'menu clearfix', /* container class */
|
|
|
'fallback_cb' => 'bones_main_nav_fallback' /* menu fallback */
|
|
'fallback_cb' => 'bones_main_nav_fallback' /* menu fallback */
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
@@ -107,40 +110,105 @@ function bones_footer_links() {
|
|
|
array(
|
|
array(
|
|
|
'menu' => 'footer_links', /* menu name */
|
|
'menu' => 'footer_links', /* menu name */
|
|
|
'theme_location' => 'footer_links', /* where in the theme it's assigned */
|
|
'theme_location' => 'footer_links', /* where in the theme it's assigned */
|
|
|
- 'container_class' => 'footer-links', /* container class */
|
|
|
|
|
|
|
+ 'container_class' => 'footer-links clearfix', /* container class */
|
|
|
'fallback_cb' => 'bones_footer_links_fallback' /* menu fallback */
|
|
'fallback_cb' => 'bones_footer_links_fallback' /* menu fallback */
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function bones_main_nav_fallback() { wp_page_menu( 'show_home=Home&menu_class=menu' ); }
|
|
|
|
|
-function bones_footer_links_fallback() { echo '<ul class="footer-links"><li>Bones<li></ul>'; }
|
|
|
|
|
|
|
+// this is the fallback for header menu
|
|
|
|
|
+function bones_main_nav_fallback() {
|
|
|
|
|
+ wp_page_menu( 'show_home=Home&menu_class=menu' );
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// this is the fallback for footer menu
|
|
|
|
|
+function bones_footer_links_fallback() {
|
|
|
|
|
+ /* you can put a default here if you like */
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/****************** PLUGINS & EXTRA FEATURES **************************/
|
|
|
|
|
|
|
|
// Related Posts Function (call using bones_related_posts(); )
|
|
// Related Posts Function (call using bones_related_posts(); )
|
|
|
function bones_related_posts() {
|
|
function bones_related_posts() {
|
|
|
echo '<ul id="bones-related-posts">';
|
|
echo '<ul id="bones-related-posts">';
|
|
|
- global $post;
|
|
|
|
|
- $tags = wp_get_post_tags($post->ID);
|
|
|
|
|
- if($tags) {
|
|
|
|
|
- foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
|
|
|
|
|
- $args = array(
|
|
|
|
|
- 'tag' => $tag_arr,
|
|
|
|
|
- 'numberposts' => 5,
|
|
|
|
|
- 'post__not_in' => array($post->ID)
|
|
|
|
|
- );
|
|
|
|
|
- $related_posts = get_posts($args);
|
|
|
|
|
- if($related_posts) {
|
|
|
|
|
- foreach ($related_posts as $post) : setup_postdata($post); ?>
|
|
|
|
|
- <li class="related_post"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
|
|
|
|
|
- <?php endforeach; } else { ?>
|
|
|
|
|
- <li class="no_related_post">No Related Posts Yet!</li>
|
|
|
|
|
- <?php }
|
|
|
|
|
|
|
+ global $post;
|
|
|
|
|
+ $tags = wp_get_post_tags($post->ID);
|
|
|
|
|
+ if($tags) {
|
|
|
|
|
+ foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
|
|
|
|
|
+ $args = array(
|
|
|
|
|
+ 'tag' => $tag_arr,
|
|
|
|
|
+ 'numberposts' => 5, /* you can change this to show more */
|
|
|
|
|
+ 'post__not_in' => array($post->ID)
|
|
|
|
|
+ );
|
|
|
|
|
+ $related_posts = get_posts($args);
|
|
|
|
|
+ if($related_posts) {
|
|
|
|
|
+ foreach ($related_posts as $post) : setup_postdata($post); ?>
|
|
|
|
|
+ <li class="related_post"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
|
|
|
|
|
+ <?php endforeach; }
|
|
|
|
|
+ else { ?>
|
|
|
|
|
+ <li class="no_related_post">No Related Posts Yet!</li>
|
|
|
|
|
+ <?php }
|
|
|
}
|
|
}
|
|
|
wp_reset_query();
|
|
wp_reset_query();
|
|
|
echo '</ul>';
|
|
echo '</ul>';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+// Numeric Page Navi (built into the theme by default)
|
|
|
|
|
+function page_navi($before = '', $after = '') {
|
|
|
|
|
+ global $wpdb, $wp_query;
|
|
|
|
|
+ $request = $wp_query->request;
|
|
|
|
|
+ $posts_per_page = intval(get_query_var('posts_per_page'));
|
|
|
|
|
+ $paged = intval(get_query_var('paged'));
|
|
|
|
|
+ $numposts = $wp_query->found_posts;
|
|
|
|
|
+ $max_page = $wp_query->max_num_pages;
|
|
|
|
|
+ if ( $numposts <= $posts_per_page ) { return; }
|
|
|
|
|
+ if(empty($paged) || $paged == 0) {
|
|
|
|
|
+ $paged = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ $pages_to_show = 7;
|
|
|
|
|
+ $pages_to_show_minus_1 = $pages_to_show-1;
|
|
|
|
|
+ $half_page_start = floor($pages_to_show_minus_1/2);
|
|
|
|
|
+ $half_page_end = ceil($pages_to_show_minus_1/2);
|
|
|
|
|
+ $start_page = $paged - $half_page_start;
|
|
|
|
|
+ if($start_page <= 0) {
|
|
|
|
|
+ $start_page = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ $end_page = $paged + $half_page_end;
|
|
|
|
|
+ if(($end_page - $start_page) != $pages_to_show_minus_1) {
|
|
|
|
|
+ $end_page = $start_page + $pages_to_show_minus_1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if($end_page > $max_page) {
|
|
|
|
|
+ $start_page = $max_page - $pages_to_show_minus_1;
|
|
|
|
|
+ $end_page = $max_page;
|
|
|
|
|
+ }
|
|
|
|
|
+ if($start_page <= 0) {
|
|
|
|
|
+ $start_page = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ echo $before.'<nav class="page-navigation"><ol class="bones_page_navi clearfix">'."";
|
|
|
|
|
+ if ($start_page >= 2 && $pages_to_show < $max_page) {
|
|
|
|
|
+ $first_page_text = "First";
|
|
|
|
|
+ echo '<li class="bpn-first-page-link"><a href="'.get_pagenum_link().'" title="'.$first_page_text.'">'.$first_page_text.'</a></li>';
|
|
|
|
|
+ }
|
|
|
|
|
+ echo '<li class="bpn-prev-link">';
|
|
|
|
|
+ previous_posts_link('<<');
|
|
|
|
|
+ echo '</li>';
|
|
|
|
|
+ for($i = $start_page; $i <= $end_page; $i++) {
|
|
|
|
|
+ if($i == $paged) {
|
|
|
|
|
+ echo '<li class="bpn-current">'.$i.'</li>';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ echo '<li><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ echo '<li class="bpn-next-link">';
|
|
|
|
|
+ next_posts_link('>>');
|
|
|
|
|
+ echo '</li>';
|
|
|
|
|
+ if ($end_page < $max_page) {
|
|
|
|
|
+ $last_page_text = "Last";
|
|
|
|
|
+ echo '<li class="bpn-last-page-link"><a href="'.get_pagenum_link($max_page).'" title="'.$last_page_text.'">'.$last_page_text.'</a></li>';
|
|
|
|
|
+ }
|
|
|
|
|
+ echo '</ol></nav>'.$after."";
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
?>
|