Advertisement
Guest User

Untitled

a guest
Dec 5th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. <?php
  2. /* Custom code goes below this line. */
  3.  
  4. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
  5. add_filter( 'use_default_gallery_style', '__return_false' );
  6.  
  7. /* Add the Javascript */
  8. $path = get_stylesheet_directory_uri() .'/js/';
  9. wp_enqueue_script('post-navigation', $path.'jquery.navigate.js', array('jquery'));
  10.  
  11. function catch_that_image() {
  12. global $post, $posts;
  13. $first_img = '';
  14. ob_start();
  15. ob_end_clean();
  16.  
  17.  
  18. $transformed_content = apply_filters('the_content',$post->post_content);
  19.  
  20.  
  21. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $transformed_content, $matches);
  22. $first_img = $matches [1] [0];
  23.  
  24. if(empty($first_img)){ //Defines a default image
  25. $first_img = "/images/default.jpg";
  26. }
  27. return $first_img;
  28. }
  29.  
  30. function pagination($pages = '', $range = 4)
  31. {
  32. $showitems = ($range * 2)+1;
  33.  
  34. global $paged;
  35. if(empty($paged)) $paged = 1;
  36.  
  37. if($pages == '')
  38. {
  39. global $wp_query;
  40. $pages = $wp_query->max_num_pages;
  41. if(!$pages)
  42. {
  43. $pages = 1;
  44. }
  45. }
  46.  
  47. if(1 != $pages)
  48. {
  49. echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
  50. if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";
  51. if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>";
  52.  
  53. for ($i=1; $i <= $pages; $i++)
  54. {
  55. if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
  56. {
  57. echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
  58. }
  59. }
  60.  
  61. if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a>";
  62. if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last &raquo;</a>";
  63. echo "</div>\n";
  64. }
  65. }
  66.  
  67. function mam_posts_where ($where) {
  68.    global $mam_global_where;
  69.    if ($mam_global_where) $where .= " $mam_global_where";
  70.    return $where;
  71. }
  72. add_filter('posts_where','mam_posts_where');
  73.  
  74. $posts_per_row = 3;
  75. $posts_per_page = 15;
  76. $pageURL = 'http';
  77. $post_type = 'post';
  78.  
  79. if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  80. $pageURL .= "://";
  81. if ($_SERVER["SERVER_PORT"] != "80") {
  82.  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  83. } else {
  84.  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  85. }
  86.  
  87. $letters = $wpdb->get_col(
  88. "SELECT DISTINCT LEFT(post_title,1) AS first_letter FROM $wpdb->posts
  89. WHERE post_type = '$post_type' AND post_status = 'publish'
  90. ORDER BY first_letter ASC"
  91. );
  92.  
  93. $first_letter = ($_GET['first_letter']) ? $_GET['first_letter'] : $letters[0];
  94.  
  95. /* Custom code goes above this line. */
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement