ID, 'description', true) !='') $my_output .= get_post_meta($post->ID, 'description', true); else { while(have_posts()):the_post(); $my_excerpt = str_replace(array("\r\n", "\r", "\n"), ' ', get_the_excerpt()); $my_output .= strip_tags(apply_filters('the_excerpt', $my_excerpt)); $my_output = strip_tags($my_output); endwhile; } break; default: $my_output .= esc_html( get_bloginfo('name') . __(': ') . get_bloginfo('description') ); } return $my_output; } // Create meta-keywords function theme_meta_keywords() { $my_output = ''; global $post; switch(true) { case (is_category()): $my_output .= strtolower(single_cat_title('', false)); break; case (is_tag()): $my_output .= strtolower(single_tag_title('', false)); break; case (is_archive()): $my_output .= __('archives ', 'blackcurrent') ; if(is_year()) $my_output .= get_the_time('Y'); if(is_month()) $my_output .= strtolower(get_the_time('F Y')); if(is_day()) $my_output .= strtolower(get_the_time('l F Y')); break; case (is_page()): $my_output .= strtolower(trim(wp_title('',false,''))); if(get_post_meta($post->ID, 'keywords', true) !='') $my_output .= ' '.get_post_meta($post->ID, 'keywords', true); break; case (is_single()): $my_output .= strtolower(trim(wp_title('',false,''))); if(get_post_meta($post->ID, 'keywords', true) !='') $my_output .= ' '.get_post_meta($post->ID, 'keywords', true); foreach((get_the_category()) as $category) { $my_output .= ' ' . strtolower($category->cat_name); } break; default: $my_output .= esc_html( strtolower( get_bloginfo('name').' '.get_bloginfo('description') ) ); } return $my_output; } // Create decent attachment links function theme_attachment_link($id) { // grab file extension $bits = explode('.',get_attached_file($id)); $ext = '.'.$bits[count($bits)-1].' format'; // get the icon link $icon_link = wp_get_attachment_link($id,'thumbnail',false,true); // get the text link $text_link = wp_get_attachment_link($id,'',false,false); // get the filesize in kilobytes if(@filesize(get_attached_file($id))) { $filesize = ceil(filesize(get_attached_file($id))/1024).'K'; return $icon_link. ' '.$text_link.' ('.$ext.' '.$filesize.')'; } else return $icon_link. ' '.$text_link.' ('.$ext.')'; } // Create decent attachment download links function theme_attachment_download_link($msg, $my_mime_type, $or) { // create download link based on attachment mime type $download=''; $viewer_links = 'http://office.microsoft.com/en-gb/downloads/ha010449811033.aspx'; switch (true) { case (stristr($my_mime_type,'pdf')): $download = 'Adobe Acrobat Reader'; break; case (stristr($my_mime_type,'msword')): $download = 'Microsoft® Word ' . $or . ' Word Viewer'; break; case (stristr($my_mime_type,'excel')): $download = 'Microsoft® Excel ' . $or . ' Excel Viewer 2003'; break; case (stristr($my_mime_type,'powerpoint')): $download = 'Microsoft® Powerpoint ' . $or . ' Powerpoint Reader'; break; case (stristr($my_mime_type,'quicktime')): $download = 'Quicktime'; break; } if($download !='') return $msg . $download; } /* theme_link_pages() function taken from ePage Links plugin by Rich Pedley (http://quirm.net/) Alternative for wp_link_pages to be able to specifiy wrappers for each link. Simply use theme_link_pages(array('blink'=>'<li>','alink'=>'</li>','before' => '<ul>', 'after' => '</ul>', 'next_or_number' => 'number')); in place of wp_link_pages in your themes. eg. theme_link_pages(array('blink'=>'
  • ','alink'=>'
  • ','before' => '', 'next_or_number' => 'number')); */ function theme_link_pages($args = '') { global $post; if (is_array($args) ) $r = &$args; else parse_str($args, $r); $defaults = array('before' => '

    ' . __('Pages:','blackcurrent'), 'after' => '

    ', 'next_or_number' => 'number', 'nextpagelink' => __('Next page','blackcurrent'), 'previouspagelink' => __('Previous page','blackcurrent'), 'pagelink' => '%', 'more_file' => '', 'echo' => 1, 'blink'=>'','alink'=>''); $r = array_merge($defaults, $r); extract($r, EXTR_SKIP); global $id, $page, $numpages, $multipage, $more, $pagenow; if ($more_file != '' ) $file = $more_file; else $file = $pagenow; $output = ''; if ($multipage ) { if ('number' == $next_or_number ) { $output .= $before; for ($i = 1; $i < ($numpages+1); $i = $i + 1 ) { $j = str_replace('%',"$i",$pagelink); $output .= ' '; if (($i != $page) || ((!$more) && ($page==1)) ) { if (1 == $i ) { $output .= $blink.''.$j.''.$alink; } else { if ('' == get_option('permalink_structure') || 'draft' == $post->post_status ) $output .= $blink.''.$j.''.$alink; else $output .= $blink.''.$j.''.$alink; } }else{ $output .= $blink.''.$j.''.$alink; } } $output .= $after; } else { if ($more ) { $output .= $before; $i = $page - 1; if ($i && $more ) { if (1 == $i ) { $output .= $blink.'' . $previouspagelink . ''.$alink; } else { if ('' == get_option('permalink_structure') || 'draft' == $post->post_status ) $output .= $blink.'' . $previouspagelink . ''.$alink; else $output .= $blink.'' . $previouspagelink . ''.$alink; } } $i = $page + 1; if ($i <= $numpages && $more ) { if (1 == $i ) { $output .= $blink.'' . $nextpagelink . ''.$alink; } else { if ('' == get_option('permalink_structure') || 'draft' == $post->post_status ) $output .= $blink.'' . $nextpagelink . ''.$alink; else $output .= $blink.'' . $nextpagelink . ''.$alink; } } $output .= $after; } } } if ($echo ) echo $output; return $output; } // Remove gallery css function theme_remove_gallery_css( $css ) { return preg_replace( "##s", '', $css ); } add_filter( 'gallery_style', 'theme_remove_gallery_css' ); // Return page tree function theme_page_tree($this_page) { if( !$this_page->post_parent ) { $pagelist = '
  • ' . $this_page->post_title . ''; $children = wp_list_pages('title_li=&child_of='.$this_page->ID.'&echo=0'); if( $children ) $pagelist .= ''; $pagelist .= '
  • '; } elseif( $this_page->ancestors ) { // get the top ID of this page. Page ids DESC so top level ID is the last one $ancestor = end($this_page->ancestors); $pagelist = wp_list_pages('title_li=&include='.$ancestor.'&echo=0'); $pagelist = str_replace('', '', $pagelist); $pagelist .= ''; } return $pagelist; } // Get archive date function theme_get_archive_date() { if (is_day()) $this_archive = get_the_time('j F Y'); elseif (is_month()) $this_archive = get_the_time('F Y'); else $this_archive = get_the_time('Y'); return $this_archive; } // test to see if a string is empty or set to zero function is_populated($string) { if($string != '' && $string != 0) return true; else return false; } /* theme_enhanced_cat_list * Echoes the wp_list_categories output with extra class applied to the topmost parent category. * Relies on theme_top_cats() * @param string $curr_cat: Current Category ID * @param string $catlist: Ouput from wp_list_categories * @param string Optional $extra_class: Additonal class to be added to the li element. Defaults to 'current-cat-ancestor'. * **/ function theme_enhanced_cat_list($curr_cat_id,$catlist, $extra_class='current-cat-ancestor') { $top_cats = theme_top_cats(); foreach( $top_cats as $top_cat) { if( cat_is_ancestor_of($top_cat, $curr_cat_id) ) { $cat_ancestor_class = 'cat-item-'. $top_cat; $amended_class = $cat_ancestor_class . ' ' . $extra_class; break; } else $cat_ancestor_class = ''; } if( $cat_ancestor_class != '' && stristr( $catlist, $cat_ancestor_class) ) $new_catlist = str_replace($cat_ancestor_class, $amended_class, $catlist ); else $new_catlist = $catlist; echo $new_catlist; } // Get ids for all top level (parent) categories // Used by theme_enhanced_cat_list function theme_top_cats() { $toplevel = array(); $allcats = get_terms('category', 'orderby=name&hide_empty=0'); foreach( $allcats as $cat ) { if( $cat->parent == 0) $toplevel[] = $cat->term_id; } return $toplevel; }