'; return; } if($use_ob) ob_start(); get_template_part('outputs/loops/'.$what_to_loop, 'loop'); if($use_ob) ob_end_flush(); } // This is a rather debateably good way to do this.. oh well! function get_sircontheme_loop($what_to_loop, $wp_loop = false){ ob_start(); sircontheme_loop($what_to_loop, $wp_loop, false); return ob_get_clean(); } //Archive, category, taxonomy... function get_sircontheme_archive_title(){ if(!is_home() && !is_archive()){ return get_the_title(); } $wpq = get_queried_object(); if($wpq->name){return $wpq->name;} if($wpq->taxonomy){return $wpq->taxonomy;} if($wpq->post_title){return $wpq->post_title;} } function sircontheme_archive_title(){ echo get_sircontheme_archive_title(); } //Posts and pages are allowed to hide their title. This function makes sure that happens function get_sircontheme_hideable_title($wrapper = 'h1', $classname_s = ''){ if($classname_s){ $classname_s = ' class="'.$classname_s.'"'; } $save_value = get_sircontheme_postdata('show_title'); //When using this function we need to take care of post types that do not provide this setting. Force these to ON if(!is_numeric($save_value)){$save_value = 1;} //The number 1 means ON return $save_value ? '<'.$wrapper.$classname_s.'>'.get_the_title().'' : ''; } function sircontheme_hideable_title($wrapper = 'h1', $classname_s = ''){echo get_sircontheme_hideable_title($wrapper, $classname_s);} //Author, publishdate etc function get_sircontheme_byline($includes = false){ if(!$includes){ $includes = array( 'date', 'author', 'comments', 'edit' ); } //Byline content, this is filled with content and is used near the end. $byline_content = array(); $separator = ' '; //What do we include? Create booleans $include_date = in_array('date', $includes); $include_author = in_array('author_link', $includes) || in_array('author_name', $includes) || in_array('author', $includes) && get_sircontheme_option('show-author'); $include_comments = in_array('comments', $includes) && comments_open(); $include_edit = in_array('edit', $includes) && current_user_can('edit_post'); // If date is included if($include_date){ $date = get_the_date(); $time = get_the_time(); $timestamp = strtotime($date.' '.$time); $time_tag = ''; $byline_content[] = '
  • '.$time_tag.'
  • '; } // If author is included if($include_author) { $author_id = get_the_author_meta('ID'); $author_name = get_the_author(); $author_link = ''.$author_name.''; $byline_content[] .='
  • '.$author_link.'
  • '; } // If comments are included if($include_comments) { $comments_number = get_comments_number(); $comments_link = '
  • '.$comments_number. ' '; if ($comments_number == 1) { $byline_content[] .= $comments_link.__('comment', 'sircon_evo').'
  • '; } else { $byline_content[] .= $comments_link.__('comments', 'sircon_evo').''; } } // If edit link is included if($include_edit) { $byline_content[] = '
  • '.__('Edit post', 'sircon_evo').'
  • '; } //Create the byline $byline = '
    '; $byline .= implode($byline_content); $byline .= '
    '; return $byline; } function sircontheme_byline(){ echo get_sircontheme_byline(); } // More detailed information about a blogpost. The meta appears in bottom of full posts, not in the loop function get_sircontheme_meta($includes = false) { if(!$includes) { $includes = array ( 'date', 'author', 'comments', 'categories', 'tags', 'edit' // Want to remove one of these? Just remove from the array, and voila! ); } $meta_content = array(); // Check what to include $include_date = in_array('date', $includes); $include_author = in_array('author', $includes) && get_sircontheme_option('show-author'); $include_comments = in_array('comments', $includes) && comments_open(); $include_categories = in_array('categories', $includes); $include_tags = in_array('tags', $includes); $include_edit = in_array('edit', $includes) && current_user_can('edit_post'); // If date is included if($include_date){ $date = get_the_date(); $time = get_the_time(); $timestamp = strtotime($date.' '.$time); $time_tag = ''; $meta_content[] = '
  • '.$time_tag.'
  • '; } // If author is included if($include_author) { $author_id = get_the_author_meta('ID'); $author_name = get_the_author(); $author_link = ''.$author_name.''; $meta_content[] .='
  • '.$author_link.'
  • '; } // If comments are included if($include_comments) { $comments_number = get_comments_number(); $comments_link = '
  • '.$comments_number.' '; if ($comments_number == 1) { $meta_content[] .= $comments_link.__('comment', 'sircon_evo').'
  • '; } else { $meta_content[] .= $comments_link.__('comments', 'sircon_evo').''; } } // If categories are included if($include_categories) { $category = array(); $separator= ', '; foreach((get_the_category()) as $cat) { $category[] .= ''.$cat->cat_name.''; } $meta_content[] .= '
  • ' .implode($separator, $category).'
  • '; } // If edit link is included if($include_edit) { $meta_content[] = '
  • '.__('Edit post', 'sircon_evo').'
  • '; } // If tags.. if($include_tags) { $tags = get_the_tags(); $output = array(); $separator= ', '; if($tags) { foreach($tags as $tag) { $tag_link = get_tag_link( $tag->term_id ); $output[] .= '' .$tag->name.''; } $meta_content[] .= '
  • ' .implode($separator, $output).'
  • '; } } $meta = '
    '; $meta .= implode($meta_content); $meta .= '
    '; return $meta; } function sircontheme_meta() { echo get_sircontheme_meta(); } //Creates an excerpt from the excerpt field, or a shortened version of the fulltext if no excerpt. Use in the loop function get_sircontheme_excerpt($excerpt_length = 220){ if(has_excerpt()){ $excerpt = apply_filters('the_content', get_the_excerpt()); //Has an actual excerpt! }else{ //Does not have an excerpt... Create one from the full content $excerpt = trim( strip_tags( apply_filters('the_content', get_the_content()) ) ); if(strlen($excerpt) > $excerpt_length){ //Pure textual content $excerpt = substr($excerpt, 0, $excerpt_length); //Cut after 220 characters //cut last word, to avoid mid-word end of excerpt. $excerpt_words = explode(' ', $excerpt); //Make array array_pop($excerpt_words); //Toss away last element in array, hopefully a useless half-word $excerpt = implode(' ', $excerpt_words); //Array to string } } if(!$excerpt){return '';} //Nothing to output $title = get_the_title(); //$aria_label = ' aria-label="'.__('An excerpt', 'sircon_evo').' '.$title.'"'; //How about NOT? --> Might make life easier for sensory-depraved individuals //Build the excerpt output $excerpt_output = '
    '; $excerpt_output .= 'The following is an excerpt.'; $excerpt_output .= '

    '.$excerpt.'

    '; $excerpt_output .= '
    '; //Done! return $excerpt_output; } //shorthand for "echo get_sircontheme_excerpt();" function sircontheme_excerpt($excerpt_length = 220){ echo get_sircontheme_excerpt($excerpt_length); } //Creates a simple readmore link. Please use inside a loop function get_sircontheme_readmore($text = false, $title = false){ //Prepare some fallback defaults if($text === false){$text = __('Read more', 'sircon_evo');} if($title === false){$title = get_the_title();} //For aria-label //Show some accessability love $aria_label = ' aria-label="'.sprintf(__('Click for the full article titled %s', 'sircon_evo').'"', '"'.$title.'"'); //Might make life easier for sensory-depraved individuals $href = ' href="'.get_permalink().'"'; //Just link to the current thing in the loop //Create string and return. Done! return ''.$text.''; } //shorthand for "echo get_sircontheme_readmore(a,b);" function sircontheme_readmore($text = false, $title = false){ echo get_sircontheme_readmore($text, $title); } function get_sircontheme_commentthis($text = false) { if($text == false) { $text = __('Comment this', 'sircon_evo'); } $href = ' href="'.get_permalink().'#respond"'; if(comments_open()) { return ''.$text.''; } } //Pagination! This is by wordpress default example, also with a dash of accessability function get_sircontheme_pagination($loop = false){ if(!$loop){ global $wp_query; $loop = $wp_query; } $current_page_number = get_sircontheme_pagination_page_number(); $big = 999999999; // need an unlikely integer $translated = __( 'Page', 'sircon_evo'); // Supply translatable string $pagination_output= paginate_links( array( 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, $current_page_number ), 'total' => $loop->max_num_pages, 'before_page_number' => ''.$translated.' ' )); //Reinsert rel=next/prev $pagination_output = str_replace(' class="next ', ' rel="next" aria-label="'.__('Next page', 'sircon_evo').'" class="next ', $pagination_output ); $pagination_output = str_replace(' class="prev ', ' rel="prev" aria-label="'.__('Previous page', 'sircon_evo').'" class="prev ', $pagination_output ); $output = ''; return $output; } function sircontheme_pagination($loop = false){ echo get_sircontheme_pagination($loop); } function sircontheme_social_sharing() { $url = get_permalink(); $output = '
    Tweet '; return $output; } function get_sircontheme_social_sharing() { echo sircontheme_social_sharing(); } //404 stuff //If the user has saved a wordpress page id, this is it! function get_sircontheme_404_pageid(){ return get_sircontheme_option('404-page-id'); } //Like the_content(), but tries to respect the wordpress page 404 setting function get_the_404_content(){ $content = ''; if(!get_sircontheme_404_pageid()){ $content = get_sircontheme_option('404-content'); }else{ ob_start(); the_content(); $content = ob_get_clean(); } return $content; } function the_404_content(){ echo get_the_404_content(); } ?>