';
echo $output;
}
}
}
//Displays the search form on search pages
add_action('cpotheme_before_content', 'cpotheme_search_form');
if(!function_exists('cpotheme_search_form')){
function cpotheme_search_form(){
if(is_search()){
$search_query = '';
if(isset($_GET['s']))
$search_query = esc_attr($_GET['s']);
echo '
';
echo '';
echo '
';
if(!have_posts()){
echo '
'.__('No results were found. Please try searching with different terms.', 'allegiant').'
';
}
}
}
}
//Displays the post image on listings and blog posts
if(!function_exists('cpotheme_postpage_image')){
function cpotheme_postpage_image(){
if(has_post_thumbnail()){
if(!is_singular('post')){
echo '';
the_post_thumbnail('portfolio');
echo '';
}else{
the_post_thumbnail();
}
}
}
}
//Displays the post title on listings
if(!function_exists('cpotheme_postpage_title')){
function cpotheme_postpage_title(){
if(!is_singular('post')){
echo '
';
}
}
}
//Displays the post content
if(!function_exists('cpotheme_postpage_content')){
function cpotheme_postpage_content(){
if(cpotheme_get_option('postpage_preview') === true || is_singular('post')){
the_content();
cpotheme_post_pagination();
}else{
the_excerpt();
}
}
}
//Displays the post date
if(!function_exists('cpotheme_postpage_date')){
function cpotheme_postpage_date($display = false, $date_format = '', $format_text =''){
if($date_format != '') {
$date_string = get_the_date($date_format);
}
else{
$date_format = get_option('date_format');
$date_string = get_the_date($date_format);
}
if($format_text != '') $date_string = sprintf($format_text, $date_string);
echo '
'.$date_string.'
';
}
}
//Displays the author link
if(!function_exists('cpotheme_postpage_author')){
function cpotheme_postpage_author($display = false, $format_text =''){
$author_alt = sprintf(esc_attr__('View all posts by %s', 'allegiant'), get_the_author());
$author = sprintf('%3$s', get_author_posts_url(get_the_author_meta('ID')), $author_alt,get_the_author());
if($format_text != ''){
$author = sprintf($format_text, $author);
}
echo '
'.$author.'
';
}
}
//Displays the category list for the current post
if(!function_exists('cpotheme_postpage_categories')){
function cpotheme_postpage_categories($display = false, $format_text =''){
$category_list = get_the_category_list(', ');
if($format_text != ''){
$category_list = sprintf($format_text, $category_list);
}
echo '
'.$category_list.'
';
}
}
//Displays the number of comments for the post
if(!function_exists('cpotheme_postpage_comments')){
function cpotheme_postpage_comments($display = false, $format_text = ''){
$comments_num = get_comments_number();
//Format comment texts
if($format_text != ''){
$text = $format_text;
}else{
if($comments_num == 0)
$text = __('No Comments', 'allegiant');
elseif($comments_num == 1)
$text = __('One Comment', 'allegiant');
else
$text = __('%1$s Comments', 'allegiant');
}
$comments = sprintf($text, number_format_i18n($comments_num));
echo '
';
echo $out;
}
}
//Paginates a list of posts, such as the blog or portfolio
if(!function_exists('cpotheme_numbered_pagination')){
function cpotheme_numbered_pagination($query = ''){
global $wp_query;
if($query != '')
$total_pages = $query->max_num_pages;
else
$total_pages = $wp_query->max_num_pages;
if($total_pages > 1){
echo '
';
}
}
}
//Paginates a single post by using a numbered list
if(!function_exists('cpotheme_post_pagination')){
function cpotheme_post_pagination(){
wp_link_pages(array('before' => '
', 'after' => '
', 'pagelink' => '%', 'separator' => ''));
}
}
//Prints the main navigation menu
if(!function_exists('cpotheme_menu')){
function cpotheme_menu($options = null){
if(has_nav_menu('main_menu')){
if(isset($options['toggle']) && $options['toggle'] == true) cpotheme_menu_toggle();
wp_nav_menu(array('menu_id' => 'menu-main', 'menu_class' => 'menu-main', 'theme_location' => 'main_menu', 'depth' => '4', 'fallback_cb' => 'cpotheme_default_menu', 'container' => false ));
}
}
}
//Prints the mobile navigation menu
if(!function_exists('cpotheme_mobile_menu')){
add_action('wp_footer', 'cpotheme_mobile_menu');
function cpotheme_mobile_menu($options = null){
if(has_nav_menu('main_menu')){
echo '';
wp_nav_menu(array('menu_id' => 'menu-mobile', 'menu_class' => 'menu-mobile', 'theme_location' => 'main_menu', 'depth' => '4', 'container' => false, 'fallback_cb' => 'cpotheme_default_menu', 'walker' => new Cpotheme_Menu_Walker()));
}
}
}
//Prints the main navigation menu
if(!function_exists('cpotheme_menu_toggle')){
function cpotheme_menu_toggle(){
if(has_nav_menu('main_menu'))
echo '';
}
}
//Prints the footer navigation menu
if(!function_exists('cpotheme_top_menu')){
function cpotheme_top_menu(){
if(has_nav_menu('top_menu')){
echo '
';
}
}
}
//Prints the footer navigation menu
if(!function_exists('cpotheme_footer_menu')){
function cpotheme_footer_menu(){
if(has_nav_menu('footer_menu')){
echo '';
}
}
}
//Prints a custom navigation menu based around a single taxonomy
if(!function_exists('cpotheme_secondary_menu')){
function cpotheme_secondary_menu($taxonomy = 'cpo_portfolio_category', $class){
if(taxonomy_exists($taxonomy)){
$feature_posts = get_terms($taxonomy, 'order=ASC&orderby=name');
if(sizeof($feature_posts) > 0){
$current_id = cpotheme_current_id();
echo '