ID) ? get_post_meta( $post->ID, CANOPUS_META, true ) : ''; if ( isset( $metabox[ $index ]) ) { return $metabox[$index]; } else { return $default; } } function canopus_metaboxes(){ global $post; if ($post) { return get_post_meta( $post->ID, CANOPUS_META, true ); } return false; } function canopus_favicon() { if(!function_exists('wp_site_icon') || !has_site_icon()){ $fav = canopus_option('favicon'); if (!empty($fav['url'])) { $favicon = $fav['url']; } else { $favicon = CANOPUS_DIR . 'assets/img/favicon.png'; } echo '' . "\n"; } } // Print menu //======================================================= function canopus_menu() { wp_nav_menu(array( 'container' => false, 'menu_id' => '', 'menu_class' => 'sf-menu', 'fallback_cb' => 'canopus_nomenu', 'theme_location' => 'main' )); } function canopus_footer_menu() { wp_nav_menu(array( 'container' => 'div', 'container_class' => 'footer-menu', 'menu_id' => '', 'menu_class' => '', 'fallback_cb' => '', 'theme_location' => 'footer', 'depth' => '1' )); } function canopus_nomenu() { echo ""; } function canopus_mobilemenu($loc = 'main') { wp_nav_menu(array( 'container' => false, 'menu_id' => '', 'menu_class' => 'sf-mobile-menu clearfix', 'fallback_cb' => 'canopus_nomobile', 'theme_location' => $loc) ); } function canopus_nomobile() { echo ""; } // Print logo //======================================================= function canopus_logo($mobile = false) { $logo = canopus_option("logo"); $output = ''; return $output; } // Pagination //======================================================= function canopus_pagination($blog_query, $type = 'simple') { global $paged; $pages = intval($blog_query->max_num_pages); $paged = ($paged) ? intval($paged) : 1; if (empty($pages)) { $pages = 1; } if($type == 'simple' && 1 != $pages){ echo ''; }elseif($type == 'number' && 1 != $pages){ $big = 9999; // need an unlikely integer echo "
"; $pagination = paginate_links( array( 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'end_size' => 3, 'mid_size' => 6, 'format' => '?paged=%#%', 'current' => max(1, get_query_var('page')), 'total' => $blog_query->max_num_pages, 'type' => 'list', 'prev_text' => canopus_option('text_prev', esc_html__( 'Prev', 'canopus')), 'next_text' => canopus_option('text_next', esc_html__( 'Next', 'canopus')), ) ); echo balanceTags($pagination); echo "
"; }elseif($type == 'infinite' && 1 != $pages){ wp_enqueue_script('owl-carousel'); wp_enqueue_script('waypoints'); echo '
'; echo '
'; echo '
'; echo '
'; } } function canopus_get_image_by_id($id,$url=false,$size='full'){ $lrg_img=wp_get_attachment_image_src($id,$size); $output=''; if(isset($lrg_img[0])){ if($url){ $output.=$lrg_img[0]; }else{ $output.=''; } } return $output; } if (!function_exists('canopus_image')) { function canopus_image($size = 'full', $returnURL = false) { global $post; $attachment = get_post(get_post_thumbnail_id($post->ID)); if(!empty($attachment)){ if ($returnURL) { $lrg_img = wp_get_attachment_image_src($attachment->ID, $size); $url = $lrg_img[0]; $alt0 = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $alt = empty($alt0)?$attachment->post_title:$alt0; $caption = get_post( get_post_thumbnail_id() )->post_excerpt; $img['url'] = $url; $img['alt'] = $alt; $img['caption'] = $caption; return $img; } else { return get_the_post_thumbnail($post->ID,$size); } } } } if (!function_exists('canopus_single_title')) { function canopus_single_title(){ echo '

'.get_the_title().'

'; if(canopus_option('single_meta', true)){ echo '
'; $strtm_author_email = get_the_author_meta('email'); echo ''.get_avatar($strtm_author_email, $size = '40').esc_html__('by', 'canopus').' '; the_author_posts_link(); echo ''.get_the_time(get_option('date_format')).''; if(canopus_option('single_cats', true)){ echo ' '.esc_html__('in', 'canopus').' '.canopus_cats().''; } echo canopus_comment_count('strtm-button'); echo '
'; } } } if (!function_exists('canopus_author')) { function canopus_author(){ $description = get_the_author_meta('description'); if ($description != ''){ ?>

'; $social_links=explode("\n",$socials); foreach($social_links as $social_link){ $icon = canopus_social_icon(esc_url($social_link)); echo ''; } echo '
'; } ?>
'

' . '' . '

', 'email' => '

' . '' . '

', 'url' => '

' . '' . '

', ); return $fields; } add_filter('comment_form_default_fields', 'canopus_comment_form'); } if (!function_exists('canopus_comment')) { function canopus_comment($comment, $args, $depth){ $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : // Display trackbacks differently than normal comments. ?>
', '' ); ?>
id="comment-">

$depth, 'max_depth' => $args['max_depth']))) ?>
" . esc_html($comment_trans) . ""; } } } function canopus_cats($sep = ', '){ $cats = ''; foreach((get_the_category()) as $category) { $options = get_option("taxonomy_".$category->cat_ID); if (!isset($options['featured']) || !$options['featured']){ $cats .= '' . $category->name.''.$sep.''; } } if(!$cats && is_search()){ $cats = '' . esc_html__('Page', 'canopus') . ''; } return $cats; } if (!function_exists('canopus_categories_postcount')){ function canopus_categories_postcount($variable) { $pos = strpos($variable, '', $variable); $variable = str_replace(')', '', $variable); } return $variable; } } add_filter('wp_list_categories', 'canopus_categories_postcount'); add_filter('get_archives_link', 'canopus_categories_postcount'); if (!function_exists('canopus_post_share')) { function canopus_post_share() { $output = '
'; $output .= ''; $post_title = get_the_title(); $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; echo balanceTags($output); } } if(!function_exists('canopus_origshare_count')){ function canopus_origshare_count($socials = array('facebook', 'twitter', 'pinterest')){ $count = 0; foreach($socials as $social){ if($social == 'facebook'){ $url = get_permalink(); $contents=false; try { $contents = wp_remote_get('http://graph.facebook.com/?id='.$url); } catch(Exception $e) { $s_count = 0; } if(is_array($contents)&&isset($contents['body'])) { $json = json_decode($contents['body']); $s_count = isset($json->share->share_count) ? $json->share->share_count : 0; } else { $s_count = 0; } } elseif($social == 'pinterest') { $contents=false; $url = get_permalink(); try { $contents = wp_remote_get('http://widgets.pinterest.com/v1/urls/count.json?source=6&url='.$url); } catch(Exception $e) { $s_count = 0; } if(is_array($contents)&&isset($contents['body'])) { $contents['body']=str_replace(array('receiveCount(',')'),'',$contents['body']); $json = json_decode($contents['body']); $s_count = isset($json->count) ? $json->count : 0; } else { $s_count = 0; } } elseif($social == 'twitter'){ global $post; $s_count = get_post_meta($post->ID, 'post_twitter', true); } $count += intval($s_count, 10); } return $count; } } if (!function_exists('canopus_share_count')){ function canopus_share_count($socials = array('facebook', 'twitter', 'pinterest')){ global $post; $count = 0; foreach($socials as $social){ $s_count = get_post_meta($post->ID, 'post_' . $social, true); $count += intval($s_count, 10); } return intval($count, 10); } } if (isset($_REQUEST['social_pid']) && isset($_REQUEST['social_name'])){ $pid = intval($_REQUEST['social_pid']); update_post_meta($pid, 'post_' . $_REQUEST['social_name'], get_post_meta($pid, 'post_' . $_REQUEST['social_name'], true) + 1); die; } function canopus_social_link($link){ if(!empty($link)){ $social = canopus_social_icon(esc_url($link)); return ''.esc_attr($social['name']).''; } } function canopus_social_icon($url){ if(strpos($url,'twitter.com')) { $social['name']='twitter';$social['class']='ion-social-twitter';return $social; } if(strpos($url,'linkedin.com')){ $social['name']='linkedin';$social['class']='ion-social-linkedin';return $social;} if(strpos($url,'facebook.com')){ $social['name']='facebook';$social['class']='ion-social-facebook';return $social;} if(strpos($url,'delicious.com')) { $social['name']='delicious';$social['class']='fa fa-delicious';return $social;} if(strpos($url,'codepen.io')){ $social['name']='codepen';$social['class']='ion-social-codepen';return $social;} if(strpos($url,'github.com')){ $social['name']='github';$social['class']='ion-social-github';return $social;} if(strpos($url,'wordpress.org')||strpos($url,'wordpress.com')){$social['name']='wordpress';$social['class']='ion-social-wordpress';return $social;} if(strpos($url,'youtube.com')){$social['name']='youtube';$social['class']='ion-social-youtube';return $social;} if(strpos($url,'behance.net')){$social['name']='behance';$social['class']='fa fa-behance';return $social;} if(strpos($url,'pinterest.com')){$social['name']='pinterest';$social['class']='ion-social-pinterest';return $social;} if(strpos($url,'foursquare.com')){$social['name']='foursquare';$social['class']='ion-social-foursquare';return $social;} if(strpos($url,'soundcloud.com')){$social['name']='soundcloud';$social['class']='fa fa-soundcloud';return $social;} if(strpos($url,'dribbble.com')){$social['name']='dribbble';$social['class']='ion-social-dribbble';return $social;} if(strpos($url,'instagram.com')){$social['name']='instagram';$social['class']='ion-social-instagram';return $social;} if(strpos($url,'plus.google')||strpos($url,'google.com')){$social['name']='google';$social['class']='ion-social-googleplus';return $social;} if(strpos($url,'reddit.com')){$social['name']='reddit';$social['class']='fa fa-reddit';return $social;} if(strpos($url,'vimeo.com')){$social['name']='vimeo';$social['class']='fa fa-vimeo';return $social;} if(strpos($url,'vine.co')) { $social['name']='vine';$social['class']='fa fa-vine';return $social;} if(strpos($url,'twitch.tv')){$social['name']='twitch';$social['class']='ion-social-twitch';return $social;} if(strpos($url,'tumblr.com')){$social['name']='tumblr';$social['class']='ion-social-tumblr';return $social;} if(strpos($url,'apple.com')){ $social['name']='apple';$social['class']='ion-social-apple';return $social;} if(strpos($url,'trello.com')){$social['name']='trello';$social['class']='fa fa-trello';return $social;} if(strpos($url,'microsoft.com')){ $social['name']='microsoft'; $social['class']='ion-social-windows';return $social;} if(strpos($url,'spotify.com')){$social['name']='spotify';$social['class']='fa fa-spotify';return $social;} if(strpos($url,'snapchat.com')) { $social['name']='snapchat';$social['class']='ion-social-snapchat';return $social;} $social['name']='newsfeed'; $social['class']='ion-social-rss'; return $social; } function canopus_social_name_from_url($social_link,$option){ return trim(str_replace(array_merge(array('https:','http:','www.','/'),$option), '',$social_link)); } function canopus_related_posts($posts_per_page) { global $post; if (!empty($posts_per_page) && $categories = get_the_category($post->ID)) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id; $args = array( 'category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page' => $posts_per_page, // Number of related posts that will be shown. 'ignore_sticky_posts' => 1 ); $atts['img_size'] = 'canopus_grid_thumb'; $my_query = new wp_query( $args ); if( $my_query->have_posts() ) { ?>