= 2 || $page >= 2)
$full_title .= ' | '.sprintf( __('Page %s', 'cpocore'), max($paged, $page));
return $title;
}
}
//Displays the current page's title. Used in the main banner area.
if(!function_exists('cpotheme_page_title')){
function cpotheme_page_title(){
global $post;
if(isset($post->ID)) $current_id = $post->ID; else $current_id = false;
$title_tag = function_exists('is_woocommerce') && is_woocommerce() && is_singular('product') ? 'span' : 'h1';
echo '<'.$title_tag.' class="pagetitle-title heading">';
if(function_exists('is_woocommerce') && is_woocommerce()){
woocommerce_page_title();
}elseif(is_category() || is_tag() || is_tax()){
echo single_tag_title('', true);
}elseif(is_author()){
the_author();
}elseif(is_date()){
_e('Archive', 'cpocore');
}elseif(is_404()){
echo __('Page Not Found', 'cpocore');
}elseif(is_search()){
echo __('Search Results for', 'cpocore').' "'.get_search_query().'"';
}else{
echo get_the_title($current_id);
}
echo ''.$title_tag.'>';
}
}
//Displays the current page's title. Used in the main banner area.
if(!function_exists('cpotheme_header_image')){
function cpotheme_header_image(){
$url = apply_filters('cpotheme_header_image', get_header_image());
if($url != '')
return $url;
else
return false;
}
}
//Displays a Revolution Slider assigned to the current page.
if(!function_exists('cpotheme_header_slider')){
function cpotheme_header_slider(){
if(function_exists('putRevSlider')){
$current_id = cpotheme_current_id();
if(is_tax() || is_category() || is_tag())
$page_slider = cpotheme_tax_meta($current_id, 'page_slider');
else
$page_slider = get_post_meta($current_id, 'page_slider', true);
if($page_slider != '0' && $page_slider != ''){
echo '
';
putRevSlider($page_slider);
echo '
';
}
}
}
}
//Display custom favicon
if(!function_exists('cpotheme_favicon')){
add_action('wp_head','cpotheme_favicon');
function cpotheme_favicon(){
$favicon_url = cpotheme_get_option('general_favicon');
if($favicon_url != '')
echo ' ';
}
}
//Add theme-specific body classes
add_filter('body_class', 'cpotheme_body_class');
function cpotheme_body_class($body_classes = ''){
$current_id = cpotheme_current_id();
$classes = '';
//Sidebar Layout
$classes .= ' sidebar-'.cpotheme_get_sidebar_position();
//Full Width Pages
if(is_404() || is_search())
$page_full = 0;
elseif(is_tax() || is_category() || is_tag())
$page_full = cpotheme_tax_meta($current_id, 'page_full');
else
$page_full = get_post_meta($current_id, 'page_full', true);
if($page_full == '1')
$classes .= ' content-full';
$body_classes[] = $classes;
return $body_classes;
}
//Display viewport tag
if(!function_exists('cpotheme_viewport')){
add_action('wp_head','cpotheme_viewport');
function cpotheme_viewport(){
$responsive_styles = get_template_directory_uri().'/style-responsive.css';
echo ' '."\n";
}
}
//Print pingback metatag
if(!function_exists('cpotheme_pingback')){
add_action('wp_head','cpotheme_pingback');
function cpotheme_pingback(){
if(get_option('default_ping_status') == 'open')
echo ' '."\n";
}
}
//Print charset metatag
if(!function_exists('cpotheme_charset')){
add_action('wp_head','cpotheme_charset');
function cpotheme_charset(){
echo ' '."\n";
}
}
//Display shortcut edit links for logged in users
if(!function_exists('cpotheme_edit')){
function cpotheme_edit(){
if(cpotheme_get_option('general_editlinks'))
edit_post_link(' '.__('Edit', 'cpocore'));
}
}
//Display the site's logo
if(!function_exists('cpotheme_logo')){
function cpotheme_logo($width = 0, $height = 0){
$output = '';
if(cpotheme_get_option('general_texttitle') == 0){
if(cpotheme_get_option('general_logo') == ''){
if(defined('CPOTHEME_LOGO_WIDTH')) $width = CPOTHEME_LOGO_WIDTH;
$output .= '
';
}else{
$logo_width = cpotheme_get_option('general_logo_width');
if($logo_width != '') $logo_width = ' style="width:'.$logo_width.'px;"';
$output .= '
';
}
}
$classes = '';
if(cpotheme_get_option('general_texttitle') == 0) $classes = ' hidden';
if(is_singular() && !is_front_page()){
$output .= '
'.get_bloginfo('name').' ';
}else{
$output .= '
';
}
$output .= '
';
echo $output;
}
}
//Display language switcher
if(!function_exists('cpotheme_languages')){
function cpotheme_languages($display = false){
if($display || cpotheme_get_option('layout_languages') == 1 && function_exists('icl_get_languages')):
$output = '';
$langs = icl_get_languages('skip_missing=0&orderby=code');
//Print current active language
foreach($langs as $current_lang):
if($current_lang['language_code'] == ICL_LANGUAGE_CODE):
$output .= '
';
$output .= '
';
$output .= $current_lang['native_name'];
$output .= '
';
endif;
endforeach;
//Print full lagnguage list
$output .= '
';
$output .= '
';
echo $output;
endif;
}
}
//Display woocommerce cart
if(!function_exists('cpotheme_cart')){
function cpotheme_cart($display = false){
if(($display || cpotheme_get_option('layout_cart') == 1) && function_exists('is_woocommerce')){
global $woocommerce;
$output = '';
echo $output;
}
}
}
//Display social links
if(!function_exists('cpotheme_social_links')){
function cpotheme_social_links(){
echo '';
}
}
//Display social links - old and deprecated
if(!function_exists('cpotheme_social')){
function cpotheme_social(){
$output = '';
$output .= cpotheme_social_item(cpotheme_get_option('social_facebook'), 'Facebook', 'facebook');
$output .= cpotheme_social_item(cpotheme_get_option('social_twitter'), 'Twitter', 'twitter');
$output .= cpotheme_social_item(cpotheme_get_option('social_gplus'), 'Google Plus', 'google-plus');
$output .= cpotheme_social_item(cpotheme_get_option('social_youtube'), 'YouTube', 'youtube');
$output .= cpotheme_social_item(cpotheme_get_option('social_linkedin'), 'LinkedIn', 'linkedin');
$output .= cpotheme_social_item(cpotheme_get_option('social_pinterest'), 'Pinterest', 'pinterest');
$output .= cpotheme_social_item(cpotheme_get_option('social_foursquare'), 'Foursquare', 'foursquare');
$output .= cpotheme_social_item(cpotheme_get_option('social_tumblr'), 'Tumblr', 'tumblr');
$output .= cpotheme_social_item(cpotheme_get_option('social_flickr'), 'Flickr', 'flickr');
$output .= cpotheme_social_item(cpotheme_get_option('social_instagram'), 'Instagram', 'instagram');
$output .= cpotheme_social_item(cpotheme_get_option('social_dribbble'), 'Dribbble', 'dribbble');
$output .= cpotheme_social_item(cpotheme_get_option('social_skype'), 'Skype', 'skype');
$output .= '
';
echo $output;
}
}
if(!function_exists('cpotheme_social_item')){
function cpotheme_social_item($url, $title = '', $name = ''){
if($url != ''):
$output = '';
if($name != '') $output .= ' ';
if($title != '') $output .= ''.$title.' ';
$output .= ' ';
return $output;
endif;
}
}
//Prints speed, timeout and effect values for the homepage slider
if(!function_exists('cpotheme_slider_data')){
function cpotheme_slider_data($navigation = true, $pagination = true){
$output = '';
$output .= ' data-cycle-pause-on-hover="true"';
$output .= ' data-cycle-slides=".slide"';
if($navigation){
$output .= ' data-cycle-prev=".slider-prev"';
$output .= ' data-cycle-next=".slider-next"';
}
if($pagination){
$output .= ' data-cycle-pager=".slider-pages"';
}
$slider_timeout = (int)cpotheme_get_option('slider_timeout');
if($slider_timeout == '') $slider_timeout = '8000';
$output .= ' data-cycle-timeout="'.$slider_timeout.'"';
$slider_speed = (int)cpotheme_get_option('slider_speed');
if($slider_speed == '') $slider_speed = '2000';
$output .= ' data-cycle-speed="'.$slider_speed.'"';
$slider_effect = (int)cpotheme_get_option('slider_effect');
if($slider_effect == '') $slider_effect = 'fade';
$output .= ' data-cycle-fx="'.$slider_effect.'"';
echo $output;
}
}
//Print an option content
if(!function_exists('cpotheme_block')){
function cpotheme_block($option, $wrapper = '', $subwrapper = ''){
$content = cpotheme_get_option($option);
if($content != ''){
if($wrapper != '') echo '';
if($subwrapper != '') echo '
';
echo do_shortcode(stripslashes(html_entity_decode(cpotheme_get_option($option))));
if($subwrapper != '') echo '
';
if($wrapper != '') echo '
';
}
}
}
//Print subfooter sidebars
if(!function_exists('cpotheme_subfooter')){
function cpotheme_subfooter(){
$footer_columns = cpotheme_get_option('layout_subfooter_columns');
if($footer_columns == '') $footer_columns = 3;
for($count = 1; $count <= $footer_columns; $count++){
if(is_active_sidebar('footer-widgets-'.$count)){
$footer_last = $count == $footer_columns ? ' col-last' : '';
echo '';
dynamic_sidebar('footer-widgets-'.$count);
echo '
';
}
}
echo '
';
}
}
//Print footer copyright line
if(!function_exists('cpotheme_footer')){
function cpotheme_footer(){
echo '';
}
}
//Print submenu navigation
if(!function_exists('cpotheme_submenu')){
function cpotheme_submenu(){
$ancestors = array_reverse(get_post_ancestors(get_the_ID()));
if(empty($ancestors[0]) || $ancestors[0] == 0) $ancestors[0] = get_the_ID();
echo '';
}
}
//Print submenu navigation
if(!function_exists('cpotheme_sitemap')){
function cpotheme_sitemap(){
//Print page list
echo '';
echo '
'.__('Pages', 'cpocore').' ';
echo '
'.wp_list_pages('sort_column=menu_order&title_li=&echo=0').' ';
echo '
';
//Print post categories and tag cloud
echo '';
echo '
'.__('Post Categories', 'cpocore').' ';
echo '
'.wp_list_categories('title_li=&show_count=1&echo=0').' ';
echo '
'.__('Post Tags', 'cpocore').' ';
echo '
'.wp_tag_cloud('echo=0').' ';
echo '
';
echo '
';
}
}
//Enqueue custom font stylesheets from Google Fonts
if(!function_exists('cpotheme_fonts')){
function cpotheme_fonts($font_name, $load_variants = false){
$font_variants = $load_variants != false ? ':100,300,400,700' : '';
if(is_array($font_name)){
foreach($font_name as $current_font)
if(!in_array($current_font, array('Arial', 'Georgia', 'Times+New+Roman', 'Verdana'))){
$font_id = 'cpotheme-font-'.strtolower(str_replace('+', '-', $current_font));
wp_enqueue_style($font_id, '//fonts.googleapis.com/css?family='.$current_font.$font_variants);
}
}else{
if(!in_array($font_name, array('Arial', 'Georgia', 'Times+New+Roman', 'Verdana'))){
$font_id = 'cpotheme-font-'.strtolower(str_replace('+', '-', $font_name));
wp_enqueue_style($font_id, '//fonts.googleapis.com/css?family='.$font_name.$font_variants);
}
}
}
}
//Adds custom analytics code in the footer
if(!function_exists('cpotheme_layout_analytics')){
add_action('wp_footer','cpotheme_layout_analytics');
function cpotheme_layout_analytics(){
$output = stripslashes(html_entity_decode(cpotheme_get_option('general_analytics'), ENT_QUOTES));
//$output = stripslashes($output);
echo $output;
}
}
//Adds custom css code in the footer
if(!function_exists('cpotheme_layout_css')){
add_action('wp_head','cpotheme_layout_css', 25);
function cpotheme_layout_css(){
$output = cpotheme_get_option('general_css');
if($output != ''){
$output = '';
echo $output;
}
}
}
//Retireve sidebar position (DEPRECATED)
if(!function_exists('cpotheme_sidebar_position')){
function cpotheme_sidebar_position(){
$sidebar_position = cpotheme_get_option('sidebar_position');
if($sidebar_position == 'left')
echo 'content-right';
elseif($sidebar_position == 'none')
echo 'content-wide';
}
}
// Generates breadcrumb navigation
if(!function_exists('cpotheme_breadcrumb')){
function cpotheme_breadcrumb($display = false){
if(!is_home() && !is_front_page() && ($display || cpotheme_get_option('layout_breadcrumbs'))){
//Use WooCommerce navigation if it's a shop page
if(function_exists('is_woocommerce') && function_exists('woocommerce_breadcrumb') && is_woocommerce()){
woocommerce_breadcrumb();
return;
}
$result = '';
if(function_exists('yoast_breadcrumb')){
$result = yoast_breadcrumb('','', false);
}
if($result == ''){
global $post;
if(is_object($post)) $pid = $post->ID; else $pid = '';
$result = '';
if($pid != ''){
$result = " ";
//Add post hierarchy
if(is_singular()):
$post_data = get_post($pid);
$result .= "".apply_filters('the_title', $post_data->post_title)." \n";
//Add post hierarchy
while($post_data->post_parent):
$post_data = get_post($post_data->post_parent);
$result = "".apply_filters('the_title', $post_data->post_title)." \n".$result;
endwhile;
elseif(is_tax()):
$result .= single_tag_title('', false);
elseif(is_author()):
$author = get_userdata(get_query_var('author'));
$result .= $author->display_name;
//Prefix with a taxonomy if possible
elseif(is_category()):
$post_data = get_the_category($pid);
if(isset($post_data[0])):
$data = get_category_parents($post_data[0]->cat_ID, TRUE, ' » ');
if(!is_object($data)):
$result .= substr($data, 0, -8);
endif;
endif;
elseif(is_search()):
$result .= __('Search Results', 'cpocore');
else:
if(isset($post->ID)) $current_id = $post->ID; else $current_id = false;
if($current_id){
$result .= get_the_title($current_id);
}
endif;
}elseif(is_404()){
$result = " ";
$result .= __('Page Not Found', 'cpocore');
}
$result = ''.__('Home', 'cpocore').' '.$result;
}
$output = ''.$result.'
';
echo $output;
}
}
}
//Displays the post date
if(!function_exists('cpotheme_postpage_date')){
function cpotheme_postpage_date($display = false, $date_format = '', $format_text =''){
if($display || cpotheme_get_option('postpage_dates') != 0){
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 =''){
if($display || cpotheme_get_option('postpage_authors') != 0){
$author_alt = sprintf(esc_attr__('View all posts by %s', 'cpocore'), 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 =''){
if($display || cpotheme_get_option('postpage_categories') != 0){
$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 = ''){
if($display || cpotheme_get_option('postpage_comments') != 0){
$comments_num = get_comments_number();
//Format comment texts
if($format_text != ''){
$text = $format_text;
}else{
if($comments_num == 0)
$text = __('No Comments', 'cpocore');
elseif($comments_num == 1)
$text = __('One Comment', 'cpocore');
else
$text = __('%1$s Comments', 'cpocore');
}
$comments = sprintf($text, number_format_i18n($comments_num));
echo '';
}
}
}
//Displays the post tags
if(!function_exists('cpotheme_postpage_tags')){
function cpotheme_postpage_tags($display = false, $before = '', $separator = ', ', $after = ''){
if($display || cpotheme_get_option('postpage_tags') != 0){
echo '';
the_tags($before, $separator, $after);
echo '
';
}
}
}
//Display Read More link for post excerpts
if(!function_exists('cpotheme_postpage_readmore')){
function cpotheme_postpage_readmore($classes = ''){
return ''.apply_filters('cpotheme_readmore', __('Read More', 'cpotheme')).' ';
}
}
//Displays the author link
if(!function_exists('cpotheme_author_links')){
function cpotheme_author_links(){
echo '';
}
}
//Displays visual media of a particular post
if(!function_exists('cpotheme_post_media')){
function cpotheme_post_media($post_id, $media_type, $video = '', $options = null){
$args = array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_status' => null,
'post_mime_type' => 'image',
'exclude' => get_post_thumbnail_id(),
'post_parent' => $post_id);
switch($media_type){
case 'none': break;
case 'image': the_post_thumbnail(); break;
case 'slideshow': cpotheme_post_slideshow($args); break;
case 'gallery': cpotheme_post_gallery($args, 3); break;
case 'video': cpotheme_post_video($video); break;
default: the_post_thumbnail(); break;
}
}
}
//Displays a slideshow of the given query
if(!function_exists('cpotheme_post_slideshow')){
function cpotheme_post_slideshow($args, $options = null){
$attachments = get_posts($args);
$image_size = isset($options['size']) ? $options['size'] : 'large';
$thumb_count = 0;
if($attachments){ ?>
>
ID, $image_size); ?>
ID, 'full'); ?>
post_excerpt != ''): ?>
post_excerpt; ?>
'; ?>
post_excerpt != ''): ?>
post_excerpt; ?>
ID, $size); ?>
ID, 'full'); ?>
get('paged')));
$total_pages = max(1, absint($query->max_num_pages));
if($total_pages == 1) return;
$pages_to_show = 8;
$larger_page_to_show = 10;
$larger_page_multiple = 2;
$pages_to_show_minus_1 = $pages_to_show - 1;
$half_page_start = floor( $pages_to_show_minus_1/2 );
$half_page_end = ceil( $pages_to_show_minus_1/2 );
$start_page = $current_page - $half_page_start;
$end_page = $current_page + $half_page_end;
if(($end_page - $start_page) != $pages_to_show_minus_1)
$end_page = $start_page + $pages_to_show_minus_1;
if($end_page > $total_pages){
$start_page = $total_pages - $pages_to_show_minus_1;
$end_page = $total_pages;
}
if($start_page < 1)
$start_page = 1;
$out = '';
//First Page Link
if(1 == $current_page)
$out .= ''.__('First', 'cpocore').' ';
else
$out .= '';
//Show each page
foreach(range($start_page, $end_page) as $i){
if($i == $current_page)
$out .= "$i ";
else
$out .= '';
}
//Last Page Link
if($total_pages == $current_page)
$out .= ''.__('Last', 'cpocore').' ';
else
$out .= '';
$out = '';
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' => '', '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 nav_main', 'theme_location' => 'main_menu', 'depth' => '4', 'container' => false, 'walker' => new Cpotheme_Menu_Walker()));
}
}
}
//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, '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 '';
}
}
}
//Displays a dropdown list of the main menu items
if(!function_exists('cpotheme_mobile_menu')){
function cpotheme_mobile_menu(){
if(has_nav_menu('main_menu')){
//Get all custom menus, then retrieve the one set to the main menu
$menu_locations = get_nav_menu_locations();
$menu_object = wp_get_nav_menu_object($menu_locations['main_menu']);
if($menu_object){
$menu_items = wp_get_nav_menu_items($menu_object->term_id);
$current_parent = array();
$current_level = 0;
$last_id = 'root';
$output = '';
$output .= '';
echo $output;
}
}else{
//Default page list
$args = array('sort_column' => 'menu_order');
$menu_items = get_pages($args);
$current_parent = array();
$current_level = 0;
$last_id = -1;
$output = '';
$output .= '