New Paste

 

Recent Pastes

Administrate




PageLines PasteBin.

PasteID: 6m7
Pasted by Anonymous, 2012-10-05 12:28:59 GMT
Expires Never
Paste size 3.27 Kb
Toggle Expand   Wrap   Raw
Copy Contents   Copy URL
 
  1. <?php
  2.  
  3. // Setup
  4. require_once( dirname(__FILE__) . '/setup.php' );
  5. require_once( dirname(__FILE__) . '/includes/class.AAMHCPosts.php' );
  6. require_once( dirname(__FILE__) . '/includes/class.AAMHCPostsCategory.php' );
  7.  
  8. function excerpt_ellipse($text) {
  9.     return str_replace('[...]', '...', $text);
  10. }
  11.  
  12. function string_limit_words($string, $word_limit)
  13. {
  14.     $words = explode(' ', $string, ($word_limit + 1));
  15.     if(count($words) > $word_limit)
  16.         array_pop($words);
  17.     return implode(' ', $words);
  18. }
  19.  
  20. // Add a class to the first and last menu item
  21. function add_first_and_last($output) {
  22.     $output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
  23.     $output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
  24.     return $output;
  25. }
  26. add_filter('wp_nav_menu', 'add_first_and_last');
  27.  
  28. // Register our custom menus
  29. function register_aamhc_menus() {
  30.     register_nav_menus( array( 'aamhc_main_nav' => __( 'AAMHC Main Nav', 'pagelines' ),
  31.         'aamhc_header_links' => __( 'AAMHC Header Links', 'pagelines' )
  32.     ));
  33. }
  34. add_action( 'init', 'register_aamhc_menus' );
  35.  
  36. /**
  37.  * Custom search form for AAMHC
  38.  *
  39.  * @param string $echo
  40.  * @return mixed
  41.  */
  42. function aamhc_search_form( $echo = false) {
  43.  
  44.         $searchfield = sprintf('<input placeholder="%s..." type="text"> <input type="submit" value="Go">',
  45.                                 __('Search', 'pagelines'), __('Go', 'pagelines') );
  46.  
  47.     $searchform = sprintf('<form method="get" class="searchform" onsubmit="this.submit();return false;" action="%s/" ><fieldset>%s</fieldset></form>',
  48.                     home_url(), $searchfield);
  49.  
  50.     if ( $echo )
  51.         echo apply_filters('pagelines_search_form', $searchform);
  52.     else
  53.         return apply_filters('pagelines_search_form', $searchform);
  54. }
  55.  
  56. /**
  57.  * Thumnail caption
  58.  */
  59. function the_post_thumbnail_caption() {
  60.     global $post;
  61.  
  62.     $thumb_id = get_post_thumbnail_id($post->id);
  63.  
  64.     $args = array(
  65.         'post_type' => 'attachment',
  66.         'post_status' => null,
  67.         'post_parent' => $post->ID,
  68.         'include'  => $thumb_id
  69.     );
  70.  
  71.     $thumbnail_image = get_posts($args);
  72.  
  73.     if ($thumbnail_image && isset($thumbnail_image[0])) {
  74.         //show thumbnail title
  75.         //echo $thumbnail_image[0]->post_title;
  76.  
  77.         error_log('is set');
  78.  
  79.         //Uncomment to show the thumbnail caption
  80.         return $thumbnail_image[0]->post_excerpt;
  81.  
  82.         //Uncomment to show the thumbnail description
  83.         //echo $thumbnail_image[0]->post_content;
  84.  
  85.         //Uncomment to show the thumbnail alt field
  86.         //$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
  87.         //if(count($alt)) echo $alt;
  88.     }
  89. }
  90.  
  91. add_filter('body_class','add_category_to_single');
  92. function add_category_to_single($classes, $class) {
  93.     if (is_single() ) {
  94.         global $post;
  95.         foreach((get_the_category($post->ID)) as $category) {
  96.             // add category slug to the $classes array
  97.             $classes[] = $category->category_nicename;
  98.         }
  99.     }
  100.     // return the $classes array
  101.     return $classes;
  102. }
 
 
 

 
 
 
 
 
Written by Xan Manning, 2010.
YOU NEED FLASH!