'?paged=%#%',
'current' => $dataArray['current'],
'total' => $dataArray['max_page_num'],
'type' => 'array',
'prev_text' => '',
'next_text' => '',
));
if ( ! empty( $pagination ) ) {
$paginate .= '
';
}
echo wp_kses_post( $paginate );
}
}
// limiting the excerpt
if ( !function_exists('calibar_get_excerpt') ){
function calibar_get_excerpt($length, $postId = false){
if ( has_post_format( array( 'aside', 'audio', 'chat', 'link', 'quote', 'status', 'video' ) ) ) {
$excerpt = the_content();
echo wp_kses_post( $excerpt );
} else {
if ($postId) {
$post = get_post($postId);
$text = $post->post_excerpt;
} else {
global $post;
$text = $post->post_excerpt;
}
if ('' == $text) {
if ($postId) {
$text = $post->post_content;
} else {
$text = get_the_content('');
}
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
$text = strip_shortcodes($text);
$text = wp_strip_all_tags($text, true);
if (empty($length)) {
$length = 300;
}
$text = substr($text, 0, $length);
echo wp_kses_post( $text ). '…';
}
}
}
// Calibar Feature image call
if ( !function_exists('calibar_feature_image') ) {
function calibar_feature_image( $size ){
if( has_post_thumbnail() ) :
$url_thumbpost = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), $size );
$buffer = '
';
return $buffer;
endif;
}
}
if ( !function_exists( 'calibar_mod_main_query' ) ){
function calibar_mod_main_query( $query ) {
global $calibarOptions;
if ( isset($calibarOptions['tr_blog_page_content_num']) && !empty( $calibarOptions['tr_blog_page_content_num'] ) ) $posts_per_page = $calibarOptions['tr_blog_page_content_num'];
else $posts_per_page = 10;
if ( isset($calibarOptions['tr_blog_order']) && !empty( $calibarOptions['tr_blog_order'] ) ) $posts_order = $calibarOptions['tr_blog_order'];
else $posts_order = 'DESC';
if ( $query->is_home() && $query->is_main_query() ) {
$query->query_vars['posts_per_page'] = $posts_per_page;
$query->query_vars['order'] = $posts_order;
}
}
add_action( 'pre_get_posts', 'calibar_mod_main_query' );
}
// Calibar buffer image call
if ( !function_exists('calibar_image_buffer') ) {
function calibar_image_buffer( $size ){
$url_thumbpost = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), $size );
$buffer = '
';
echo wp_kses_post( $buffer );
}
}
if ( !function_exists('calibar_woo_image_buffer') ) {
function calibar_woo_image_buffer( $attachment_id , $size ){
$url_thumbpost = wp_get_attachment_image_src( $attachment_id , $size );
$buffer = '
';
echo wp_kses_post( $buffer );
}
}
if( !function_exists('calibar_time_ago') ) {
function calibar_time_ago( $type = 'post' ) {
$d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
echo human_time_diff($d('U'), current_time('timestamp')) . " " . esc_html__('ago','calibar');
}
}
/*===================================================================================
* Add Author Links
* =================================================================================*/
function calibar_add_to_author_profile( $contactmethods ) {
$contactmethods['google_profile'] = 'Google Profile URL';
$contactmethods['twitter_profile'] = 'Twitter Profile URL';
$contactmethods['facebook_profile'] = 'Facebook Profile URL';
return $contactmethods;
}
add_filter( 'user_contactmethods', 'calibar_add_to_author_profile', 10, 1);
function get_user_role()
{
global $authordata;
$author_roles = $authordata->roles;
$author_role = array_shift($author_roles);
return $author_role;
}
if ( !function_exists( 'calibar_getPostViews' ) ) {
function calibar_getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return " 0";
}
echo wp_kses_post( ''. $count );
}
}
if ( !function_exists( 'calibar_setPostViews' ) ) {
function calibar_setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
}
// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
if ( !function_exists( 'calibar_search_filter_form' ) ) {
function calibar_search_filter_form( $form ) {
$form = '';
return $form;
}
add_filter( 'get_search_form', 'calibar_search_filter_form' );
}
if( !function_exists('update_ads_slug')){
function update_ads_slug( $args, $post_type ) {
global $calibarOptions;
if( isset( $calibarOptions['tr_folio_slug'] ) && $calibarOptions['tr_folio_slug'] != '' ):
if ( 'folio' === $post_type ) {
$my_args = array(
'rewrite' => array( 'slug' => $calibarOptions['tr_folio_slug'], 'with_front' => true )
);
return array_merge( $args, $my_args );
}
endif;
return $args;
}
add_filter( 'register_post_type_args', 'update_ads_slug', 10, 2 );
}
/**
* @param $width
*
* @since 4.2
* @return bool|string
*/
function tr_wpb_translateColumnWidthToSpan( $width ) {
preg_match( '/(\d+)\/(\d+)/', $width, $matches );
if ( ! empty( $matches ) ) {
$part_x = (int) $matches[1];
$part_y = (int) $matches[2];
if ( $part_x > 0 && $part_y > 0 ) {
$value = ceil( $part_x / $part_y * 12 );
if ( $value > 0 && $value <= 12 ) {
$width = 'vc_col-lg-' . $value;
}
}
}
return $width;
}
if ( !function_exists( 'calibar_author_info' ) ) {
function calibar_author_info() {
$authorInfo = $google_profile = $facebook_profile = $twitter_profile = $authorDesc = $userid = '';
$userid = get_the_author_meta('ID');
$authorDesc = get_the_author_meta('description', $userid );
$google_profile = get_the_author_meta( 'google_profile', $userid );
$facebook_profile = get_the_author_meta( 'facebook_profile', $userid );
$twitter_profile = get_the_author_meta( 'twitter_profile', $userid );
$authorInfo .= '';
$authorInfo .= '
';
$authorInfo .= get_avatar( get_the_author_meta('email'), '100' );
$authorInfo .= '
';
$authorInfo .= '
'. get_the_author_link() .'';
$authorInfo .= '
'. esc_html( get_user_role( $userid ) ) .'';
$authorInfo .= '
'. $authorDesc .'
';
if ( ( isset( $google_profile ) && $google_profile != '' ) || ( isset( $twitter_profile ) && $twitter_profile != '' ) || ( isset( $facebook_profile ) && $facebook_profile != '' ) ) :
$authorInfo .= '
';
$authorInfo .= '
';
if ( isset( $google_profile ) && $google_profile != '' ) {
$authorInfo .= ' ';
}
if ( isset( $twitter_profile ) && $twitter_profile != '' ) {
$authorInfo .= ' ';
}
if ( isset( $facebook_profile ) && $facebook_profile != '' ) {
$authorInfo .= ' ';
}
$authorInfo .= '
';
$authorInfo .= '
';
endif;
$authorInfo .= '';
$authorInfo .= '
';
if ( ( isset( $google_profile ) && $google_profile != '' ) || ( isset( $twitter_profile ) && $twitter_profile != '' ) || ( isset( $facebook_profile ) && $facebook_profile != '' ) || !empty( $authorDesc ) ) :
echo wp_kses_post( $authorInfo );
else:
return null;
endif;
}
}