Advertisement
miike

Untitled

Aug 17th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage coaster_Theme
  5. */
  6.  
  7.  
  8. // enable Theme Options page
  9. require_once ( get_stylesheet_directory() . '/theme-options.php' );
  10.  
  11.  
  12. // set content width
  13. if ( ! isset( $content_width ) ) $content_width = 625;
  14.  
  15.  
  16. // load Superfish JS script
  17. // excluding admin area
  18. if ( !is_admin() ) {
  19. wp_register_script('coaster_superfish', get_template_directory_uri('template_directory') . '/js/superfish.js?ver=2.9.2');
  20. wp_enqueue_script('coaster_superfish');
  21. }
  22.  
  23.  
  24. // enable feed links
  25. add_theme_support('automatic-feed-links');
  26.  
  27.  
  28. // enable dynamic sidebar
  29. function coaster_sidebars_init() {
  30. register_sidebar(array(
  31. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  32. 'after_widget' => '</div>',
  33. 'before_title' => '<h2 class="widgettitle">',
  34. 'after_title' => '</h2>',
  35. ));
  36. }
  37. add_action('widgets_init', 'coaster_sidebars_init');
  38.  
  39.  
  40. // enable WordPress menus
  41. add_action('init', 'coaster_register_menu');
  42. function coaster_register_menu() {
  43. register_nav_menu('coaster_nav', 'Main Navigation');
  44. register_nav_menu('coaster_left_nav', 'Left Sidebar Team Navigation');
  45. register_nav_menu('coaster_left_nav_vibe', 'Left Sidebar Mokovibe Navigation');
  46. }
  47.  
  48.  
  49.  
  50. // redirect to theme options page after theme activation
  51. if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
  52. echo("<script>self.location='".admin_url()."themes.php?page=coaster_theme_options';</script>");
  53. }
  54.  
  55.  
  56. // template for comments and pingbacks
  57. function coaster_comment( $comment, $args, $depth ) {
  58. $GLOBALS['comment'] = $comment;
  59. switch ( $comment->comment_type ) :
  60. case '' :
  61. ?>
  62. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  63. <div id="comment-<?php comment_ID(); ?>">
  64. <div class="comment-author vcard">
  65. <?php echo get_avatar( $comment, 40 ); ?>
  66. <?php printf( '%s <span class="says">says:</span>', sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  67. </div><!-- .comment-author .vcard -->
  68. <?php if ( $comment->comment_approved == '0' ) : ?>
  69. <em class="comment-awaiting-moderation">Your comment is awaiting moderation.</em>
  70. <br />
  71. <?php endif; ?>
  72.  
  73. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  74. <?php
  75. /* translators: 1: date, 2: time */
  76. printf( '%1$s at %2$s', get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( '(Edit)', ' ' );
  77. ?>
  78. </div><!-- .comment-meta .commentmetadata -->
  79.  
  80. <div class="comment-body"><?php comment_text(); ?></div>
  81.  
  82. <div class="reply">
  83. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  84. </div><!-- .reply -->
  85. </div><!-- #comment-## -->
  86.  
  87. <?php
  88. break;
  89. case 'pingback' :
  90. case 'trackback' :
  91. ?>
  92. <li class="post pingback">
  93. <p>Pingback: <?php comment_author_link(); ?><?php edit_comment_link( '(Edit)', ' ' ); ?></p>
  94. <?php
  95. break;
  96. endswitch;
  97. }
  98.  
  99.  
  100. // page pagination
  101. function coaster_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
  102. global $wpdb, $wp_query;
  103. $request = $wp_query->request;
  104. $posts_per_page = intval(get_query_var('posts_per_page'));
  105. $paged = intval(get_query_var('paged'));
  106.  
  107. if(empty($prelabel)) {
  108. $prelabel = '<strong>&laquo;</strong>';
  109. }
  110. if(empty($nxtlabel)) {
  111. $nxtlabel = '<strong>&raquo;</strong>';
  112. }
  113. $half_pages_to_show = round($pages_to_show/2);
  114. if (!is_single()) {
  115. if(!is_category()) {
  116. preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
  117. } else {
  118. preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
  119. }
  120. $fromwhere = $matches[1];
  121. $numposts = $wp_query->found_posts;
  122. $max_page = $wp_query->max_num_pages;
  123.  
  124. if(empty($paged) || $paged == 0) {
  125. $paged = 1;
  126. }
  127. if($max_page > 1 || $always_show) {
  128. echo "$before <div class='nav'>";
  129. if ($paged >= ($pages_to_show-1)) {
  130. echo '<a href="'.get_pagenum_link().'">&laquo; First</a>';
  131. }
  132. previous_posts_link($prelabel);
  133. for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
  134. if ($i >= 1 && $i <= $max_page) {
  135. if($i == $paged) {
  136. echo "<strong class='on'>$i</strong>";
  137. } else {
  138. echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> ';
  139. }
  140. }
  141. }
  142. next_posts_link($nxtlabel, $max_page);
  143. if (($paged+$half_pages_to_show) < ($max_page)) {
  144. echo '<a href="'.get_pagenum_link($max_page).'">Last &raquo;</a>';
  145. }
  146. echo "</div> $after";
  147. }
  148. }
  149. }
  150.  
  151. function new_excerpt_more($more) {
  152. global $post;
  153. return '<a href="'. get_permalink($post->ID) . '"> Read More > </a>';
  154. }
  155. add_filter('excerpt_more', 'new_excerpt_more');
  156.  
  157. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement