File: /home/aprilnet/public_html/sciohost.org/wp-content/themes/doris/inc/libs/atbs_core.php
<?php
$doris_default_options = array
(
'last_tab' => '',
'bk-primary-color' => '#325534',
'body-typography' => array
(
'font-family' => 'Rubik',
'font-options' => '',
'google' => '1',
'font-backup' => 'Arial, Helvetica, sans-serif',
'subsets' => '',
'letter-spacing' => '',
),
'heading-typography' => array
(
'font-family' => 'Playfair Display',
'font-options' => '',
'google' => '1',
'font-backup' => 'Arial, Helvetica, sans-serif',
'subsets' => '',
'letter-spacing' => '',
),
'meta-typography' => array
(
'font-family' => 'Rubik',
'font-options' => '',
'google' => '1',
'font-backup' => 'Arial, Helvetica, sans-serif',
'subsets' => '',
'letter-spacing' => '',
),
'tertiary-typography' => array
(
'font-family' => 'Rubik',
'font-options' => '',
'google' => '1',
'font-backup' => 'Arial, Helvetica, sans-serif',
'subsets' => '',
'letter-spacing' => '',
),
'menu-typography' => array
(
'font-family' => 'Rubik',
'font-options' => '',
'google' => '1',
'font-backup' => 'Arial, Helvetica, sans-serif',
'subsets' => '',
'letter-spacing' => '',
),
'bk-load-more-text' => 'Load more news',
'bk-no-more-text' => 'No more news',
'bk-sticky-menu-switch' => '1',
'bk-sticky-menu-logo' => array
(
'url' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/sticky-logo.png',
'id' => '418',
'height' => '53',
'width' => '191',
'thumbnail' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/sticky-logo-150x53.png',
'title' => 'sticky-logo',
'caption' => '',
'alt' => '',
'description' => '',
),
'bk-logo' => array
(
'url' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/doris-logo.png',
'id' => '416',
'height' => '69',
'width' => '200',
'thumbnail' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/doris-logo-150x69.png',
'title' => 'doris-logo',
'caption' => '',
'alt' => '',
'description' => '',
),
'bk-site-logo-size-option' => 'original',
'site-logo-width' => '300',
'bk-mobile-logo' => array
(
'url' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/doris-logo.png',
'id' => '416',
'height' => '69',
'width' => '200',
'thumbnail' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/doris-logo-150x69.png',
'title' => 'doris-logo',
'caption' => '',
'alt' => '',
'description' => '',
),
'bk-offcanvas-mobile-menu' => 'main-menu',
'bk-offcanvas-mobile-logo' => array
(
'url' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/doris-logo.png',
'id' => '416',
'height' => '69',
'width' => '200',
'thumbnail' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/08/doris-logo-150x69.png',
'title' => 'doris-logo',
'caption' => '',
'alt' => '',
'description' => '',
),
'bk-offcanvas-mobile-social' => array
(
'0' => 'fb',
'1' => 'twitter',
'2' => 'instagram',
'3' => 'youtube',
),
'bk-social-header' => array
(
'0' => '',
'1' => 'twitter',
'2' => 'instagram',
'3' => 'youtube',
),
'bk-social-media-links' => array
(
'fb' => '',
'twitter' => '',
'linkedin' => '',
'pinterest' => '',
'instagram' => '',
'dribbble' => '',
'youtube' => '',
'vimeo' => '',
'vk' => '',
'vine' => '',
'snapchat' => '',
'rss' => '',
),
'bk-fb-sw' => '1',
'bk-tw-sw' => '1',
'bk-gp-sw' => '1',
'bk-pi-sw' => '1',
'bk-li-sw' => '1',
'bk-post-view--cache-time' => '300',
'bk-single-template' => 'single-1',
'bk-feat-img-status' => '1',
'bk-single-meta-items' => '10',
'bk_post_sb_select' => 'home_sidebar',
'bk_post_sb_position' => 'right',
'bk_post_sb_sticky' => '1',
'bk-authorbox-sw' => '1',
'bk-postnav-sw' => '1',
'bk-related-sw' => '1',
'bk_related_source' => 'category_tag',
'bk_category_content_layout' => 'listing_list',
'bk_category_post_icon' => 'enable',
'bk_category_sidebar_select' => 'home_sidebar',
'bk_category_sidebar_position' => 'right',
'bk_category_sidebar_sticky' => '1',
'bk_archive_header_style' => 'grey-bg',
'bk_archive_content_layout' => 'listing_list',
'bk_archive_post_icon' => 'enable',
'bk_archive_sidebar_select' => 'home_sidebar',
'bk_archive_sidebar_position' => 'right',
'bk_archive_sidebar_sticky' => '1',
'bk_author_content_layout' => 'listing_grid',
'bk_author_post_icon' => 'enable',
'bk_author_sidebar_select' => 'home_sidebar',
'bk_author_sidebar_position' => 'right',
'bk_author_sidebar_sticky' => '1',
'bk_search_content_layout' => 'listing_list',
'bk_search_post_icon' => 'enable',
'bk_search_sidebar_select' => 'home_sidebar',
'bk_search_sidebar_position' => 'right',
'bk_search_sidebar_sticky' => '1',
'bk_blog_content_layout' => 'listing_list',
'bk_blog_post_icon' => 'enable',
'bk_blog_sidebar_select' => 'home_sidebar',
'bk_blog_sidebar_position' => 'right',
'bk_blog_sidebar_sticky' => '1',
'404--sub-title-text' => '',
'404--notice-text' => '',
'404-search' => '1',
'bk_page_feat_img' => '1',
'bk_page_layout' => 'no_sidebar',
'bk_page_sidebar_select' => 'home_sidebar',
'bk_page_sidebar_position' => 'right',
'bk_page_sidebar_sticky' => '1',
'bk-footer-logo' => array
(
'url' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/06/light-logo.png',
'id' => '315',
'height' => '32',
'width' => '97',
'thumbnail' => 'https://allthebestsofts.com/doris/wp-content/uploads/2019/06/light-logo.png',
'title' => 'light-logo',
'caption' => '',
'alt' => '',
'description' => '',
),
'bk-social-footer' => array
(
'0' => 'fb',
'1' => 'twitter',
'2' => 'instagram',
'3' => 'youtube',
),
'bk-footer-copyright' => 'Doris � 2019. Made with love by bkninja',
'REDUX_last_saved' => '1551691628',
'REDUX_LAST_SAVE' => '1551691628',
);
if (!class_exists('atbs_core')) {
class atbs_core {
static $globalBuff = array();
static $globalGradientBG = array();
static function bk_get_global_var($bk_var){
if ($bk_var == 'doris_option') {
if ( class_exists( 'ReduxFrameworkPlugin' ) ) {
global $doris_option;
return $doris_option;
}else {
global $doris_default_options;
return $doris_default_options;
}
}
}
static function bk_get_theme_option($theoption = '') {
$doris_option = atbs_core::bk_get_global_var('doris_option');
$output = '';
if ((isset($doris_option[$theoption])) && (($doris_option[$theoption]) != NULL)){
$output = $doris_option[$theoption];
}else {
$output = '';
}
return $output;
}
static function doris_rwmb_meta($theoption, $arg, $termID ){
$ret = '';
if(function_exists('rwmb_meta')) {
$ret = rwmb_meta( $theoption, $arg, $termID );
}else {
$ret = '';
}
return $ret;
}
static function bk_check_isset($var, $strCompare) {
if(isset($var) && ($var != $strCompare)) {
return 1;
}else {
return 0;
}
}
static function bk_check_array($var) {
if((is_array($var) && (count($var) > 0))) {
return true;
}else {
return false;
}
}
/**
* ************* Post Views *********************
*---------------------------------------------------
*/
static function bk_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";
}
return $count;
}
static function bk_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);
}
return false;
}
/**
* ************* Socical Media Links *********************
*---------------------------------------------------
*/
static function bk_get_social_media_links($socialOptions){
$socialHTML = '';
$doris_option = atbs_core::bk_get_global_var('doris_option');
if(count($socialOptions) < 1) {
return;
}
if(isset($doris_option['bk-social-media-links'])):
$socialItems = $doris_option['bk-social-media-links'];
endif;
foreach($socialOptions as $socialItem) :
switch ($socialItem) {
case 'fb':
if ($socialItems['fb']){
$socialHTML .= '<li><a href="'.$socialItems['fb'].'" target="_blank"><i class="mdicon mdicon-facebook"></i></a></li>';
}
break;
case 'twitter' :
if ($socialItems['twitter']){
$socialHTML .= '<li><a href="'.$socialItems['twitter'].'" target="_blank"><i class="mdicon mdicon-twitter"></i></a></li>';
}
break;
case 'linkedin' :
if ($socialItems['linkedin']){
$socialHTML .= '<li><a href="'.$socialItems['linkedin'].'" target="_blank"><i class="mdicon mdicon-linkedin"></i></a></li>';
}
break;
case 'pinterest' :
if ($socialItems['pinterest']){
$socialHTML .= '<li><a href="'.$socialItems['pinterest'].'" target="_blank"><i class="mdicon mdicon-pinterest-p"></i></a></li>';
}
break;
case 'instagram' :
if ($socialItems['instagram']){
$socialHTML .= '<li><a href="'.$socialItems['instagram'].'" target="_blank"><i class="mdicon mdicon-instagram"></i></a></li>';
}
break;
case 'dribbble';
if ($socialItems['dribbble']){
$socialHTML .= '<li><a href="'.$socialItems['dribbble'].'" target="_blank"><i class="mdicon mdicon-dribbble"></i></a></li>';
}
break;
case 'youtube';
if ($socialItems['youtube']){
$socialHTML .= '<li><a href="'.$socialItems['youtube'].'" target="_blank"><i class="mdicon mdicon-youtube"></i></a></li>';
}
break;
case 'vimeo';
if ($socialItems['vimeo']){
$socialHTML .= '<li><a href="'.$socialItems['vimeo'].'" target="_blank"><i class="mdicon mdicon-vimeo"></i></a></li>';
}
break;
case 'vk';
if ($socialItems['vk']){
$socialHTML .= '<li><a href="'.$socialItems['vk'].'" target="_blank"><i class="mdicon mdicon-vk"></i></a></li>';
}
break;
case 'vine';
if ($socialItems['vine']){
$socialHTML .= '<li><a href="'.$socialItems['vine'].'" target="_blank"><i class="mdicon mdicon-vine"></i></a></li>';
}
break;
case 'snapchat';
if ($socialItems['snapchat']){
$socialHTML .= '<li><a href="'.$socialItems['snapchat'].'" target="_blank"><i class="mdicon mdicon-snapchat-ghost"></i></a></li>';
}
break;
case 'rss';
if ($socialItems['rss']){
$socialHTML .= '<li><a href="'.$socialItems['rss'].'" target="_blank"><i class="mdicon mdicon-rss_feed"></i></a></li>';
}
break;
default:
break;
}
endforeach;
return $socialHTML;
}
static function bk_get_doris_module_heading($module_subTile = '', $module_Title = ''){
if($module_Title == '') {
return '';
}
$module_heading = '';
$module_heading .= '<div class="block-heading block-doris-heading ">';
$module_heading .= '<h4>'.esc_html($module_Title).'</h4>';
if($module_subTile != '') :
$module_heading .= '<span class="typescale-1">'.esc_html($module_subTile).'</span>';
endif;
$module_heading .= '</div>';
return $module_heading;
}
static function bk_get_block_heading($bk_heading, $headingClass = '', $viewallButton = ''){
$doris_option = atbs_core::bk_get_global_var('doris_option');
$block_heading = '';
//Check default heading condition
if( isset($doris_option['bk-default-module-heading']) &&
(($doris_option['bk-default-module-heading'] == 'center') ||
($doris_option['bk-default-module-heading'] == 'large-center') ||
($doris_option['bk-default-module-heading'] == 'line-around') ||
($doris_option['bk-default-module-heading'] == 'large-line-around')) ){
$viewallButton = '';
}
if($bk_heading != null) {
$heading_allow_html = array(
'span' => array(),
);
$block_heading .= '<div class="block-heading '.$headingClass.'">';
$block_heading .= '<h4 class="block-heading__title">'.wp_kses($bk_heading, $heading_allow_html).'</h4>';
if(($viewallButton != '') && (isset($viewallButton['view_all_link']) && ($viewallButton['view_all_link'] != ''))) {
if(isset($viewallButton['view_all_text']) && ($viewallButton['view_all_text'] != '')) {
$viewAllText = $viewallButton['view_all_text'];
}else {
$viewAllText = esc_html__('View all','doris');
}
if(isset($viewallButton['view_all_link']) && ($viewallButton['view_all_link'] != '')) {
$viewAllLink = $viewallButton['view_all_link'];
}else {
$viewAllLink = '#';
}
if(isset($viewallButton['view_all_target']) && ($viewallButton['view_all_target'] != '')) {
$viewAllTarget = $viewallButton['view_all_target'];
}else {
$viewAllTarget = '_blank';
}
$block_heading .= '<a href="'.esc_url($viewAllLink).'" target="'.esc_attr($viewAllTarget).'" class="block-heading__secondary">';
$block_heading .= '<span class="first-word">'.esc_attr($viewAllText).'</span>';
$block_heading .= '<i class="mdicon mdicon-arrow_forward mdicon--last"></i>';
$block_heading .= '</a>';
}
$block_heading .= '</div>';
}
return $block_heading;
}
static function bk_get_block_heading_class($headingStyle = '', $heading_inverse = 'no'){
$doris_option = atbs_core::bk_get_global_var('doris_option');
$headingClass = '';
//Check default heading condition
if(($headingStyle == 'default') && isset($doris_option['bk-default-module-heading'])) {
$headingStyle = $doris_option['bk-default-module-heading'];
}
switch($headingStyle) {
case 'line':
$headingClass = 'block-heading--line';
break;
case 'large-line':
$headingClass = 'block-heading--line block-heading--lg';
break;
case 'no-line':
$headingClass = '';
break;
case 'large-no-line':
$headingClass = 'block-heading--lg';
break;
case 'line-under':
$headingClass = 'block-heading--line-under';
break;
case 'large-line-under':
$headingClass = 'block-heading--lg block-heading--line-under';
break;
case 'center':
$headingClass = 'block-heading--center';
break;
case 'large-center':
$headingClass = 'block-heading--lg block-heading--center';
break;
case 'line-around':
$headingClass = 'has-block-heading-line-around';
break;
case 'large-line-around':
$headingClass = 'block-heading--lg has-block-heading-line-around';
break;
default:
$headingClass = 'block-heading--line';
break;
}
if($heading_inverse == 'yes') {
$headingClass .= ' block-heading--inverse';
}
return $headingClass;
}
static function bk_get_widget_heading_class($headingStyle = '', $heading_inverse = 'no'){
$doris_option = atbs_core::bk_get_global_var('doris_option');
$headingClass = '';
//Check force condition
if(($headingStyle == 'default') && isset($doris_option['bk-default-widget-heading'])) {
$headingStyle = $doris_option['bk-default-widget-heading'];
}
switch($headingStyle) {
case 'line':
$headingClass = 'block-heading--line';
break;
case 'no-line':
$headingClass = '';
break;
case 'line-under':
$headingClass = 'block-heading--line-under';
break;
case 'center':
$headingClass = 'block-heading--center';
break;
case 'line-around':
$headingClass = 'has-block-heading-line-around';
break;
default:
$headingClass = 'block-heading--line';
break;
}
if($heading_inverse == 'yes') {
$headingClass .= ' block-heading--inverse';
}
return $headingClass;
}
static function bk_get_post_excerpt($length) {
$bk_excerpt = '';
$the_excerpt = get_the_excerpt();
$bk_excerpt .= '<div class="excerpt">';
$bk_excerpt .= self::the_excerpt_limit_by_word($the_excerpt, $length);
$bk_excerpt .= '</div>';
return $bk_excerpt;
}
static function the_excerpt_limit_by_word($string, $word_limit){
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
$strout = implode(' ', $words);
if (strlen($strout) < strlen($string))
$strout .=" ...";
return $strout;
}
static function bk_add_buff($buffType= '', $buffID = '', $buffContent = '', $val = ''){
if($buffType != '') :
if($buffID != '') :
//self::$globalBuff[$buffType][$buffID] = '';
if($buffContent != '') :
self::$globalBuff[$buffType][$buffID][$buffContent] = $val;
endif;
endif;
endif;
}
static function doris_create_ajax_security_code(){
$doris_security_code = wp_create_nonce( 'doris_ajax_security' );
self::bk_add_buff('doris_security', 'doris_security_code', 'content', $doris_security_code);
}
static function atbs_add_buff_arrows(){
$sliderArrows = array();
$sliderArrows['light-next'] = ATBS_TEMPLATE_URL.'/images/arrows/light-next-arrow.png';
$sliderArrows['light-prev'] = ATBS_TEMPLATE_URL.'/images/arrows/light-prev-arrow.png';
$sliderArrows['dark-next'] = ATBS_TEMPLATE_URL.'/images/arrows/dark-next-arrow.png';
$sliderArrows['dark-prev'] = ATBS_TEMPLATE_URL.'/images/arrows/dark-prev-arrow.png';
self::bk_add_buff('tnm_arrows', 'sliderArrows', 'content', $sliderArrows);
}
static function bk_get_sub_categories($bkParentCat) {
$catList = array();
$args = array('child_of' => $bkParentCat);
$categories = get_categories( $args );
if(count($categories) > 0) {
foreach($categories as $key => $category) {
$catList[$key] = $category;
}
}
return $catList;
}
static function bk_get_post_title_link( $bkPostId ) {
$titleLink = '';
$category = get_the_category($bkPostId);
$titleLink .= '<a href="'.get_permalink($bkPostId).'">';
$titleLink .= get_the_title($bkPostId);
$titleLink .= '</a>';
return $titleLink;
}
static function bk_get_post_icon_video_only ($bkPostID) {
$str_ret = '';
$postformat = get_post_format( $bkPostID );
switch($postformat) {
case "video":
$str_ret = '<span><i class="fa fa-play post-icon video-icon"></i></span>';
break;
default:
$str_ret = '';
break;
}
return $str_ret;
}
static function bk_check_has_post_thumbnail($postID){
if($postID == '') {
$postID = get_the_ID();
}
$featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( $postID ) );
if ( ! empty( $featured_image_url ) ) {
return true;
}else {
return false;
}
}
static function get_feature_image($postID = '', $thumbSize, $clickable = true, $postIcon = ''){
$feat_img = '';
if($postID == '') {
$postID = get_the_ID();
}
if(atbs_core::bk_check_has_post_thumbnail($postID)) {
if($clickable == true) {
$feat_img .= '<a href="'.get_permalink($postID).'">';
}
$feat_img .= get_the_post_thumbnail($postID, $thumbSize);
if($postIcon != '') {
$feat_img .= self::bk_get_post_icon($postID, $postIcon);
}
if($clickable == true) {
$feat_img .= '</a> <!-- close a tag -->';
}
}
return $feat_img;
}
static function bk_get_post_thumbnail_bg_link($customArgs){
$bkThumbId = get_post_thumbnail_id( $customArgs['postID'] );
$bkThumbUrl = wp_get_attachment_image_src( $bkThumbId, $customArgs['thumbSize'] );
return esc_url($bkThumbUrl[0]);
}
/**
* ********* Get Post Category ************
*---------------------------------------------------
*/
static function bk_get_post_cat_link($postID, $catClass = '', $allowALL = ''){
$html = '';
$category = get_the_category($postID);
if(isset($category[0]) && $category[0]){
foreach ($category as $key => $value) {
$html.= '<a class="post__cat cat-'.$value->term_id.' '.$catClass.'" href="'.get_category_link($value->term_id ).'">'.$value->cat_name.'</a>';
if($allowALL != 1) return $html;
}
}
return $html;
}
/**
* ********* Count Post Category ************
*---------------------------------------------------
*/
static function bk_count_post_in_category($categoryIDs){
$html = '';
$category = array();
$postCount = array();
$catArray = array();
if($categoryIDs[0] == 0) {
$catArray = get_terms(
array( 'category' ), // Taxonomies
array( 'fields' => 'ids' ) // Fields
);
}else {
$catArray = $categoryIDs;
}
foreach ($catArray as $key => $catID) {
$category[$key] = get_category($catID);
$postCount[$catID] = $category[$key]->category_count;
}
return $postCount;
}
/**
* ************* Meta Cases *********************
*---------------------------------------------------
*/
static function bk_get_comment_number_and_text ($postID) {
$comments = '';
$num_comments = get_comments_number($postID);
if ( $num_comments == 0 ) {
$comments = esc_html__('0 Comments', 'doris');
} elseif ( $num_comments > 1 ) {
$comments = $num_comments . esc_html__(' Comments', 'doris');
} else {
$comments = esc_html__('1 Comment', 'doris');
}
return $comments;
}
static function bk_meta_cases( $meta_type ) {
$bk_meta = $meta_type;
$postID = get_the_ID();
$doris_article_date_unix = get_the_time('U', $postID);
$bk_meta_str = '';
switch ($bk_meta) {
case 'date':
$timestamp_lastweek = strtotime("-1 week");
$timestamp_post = get_the_time('U', $postID);
if($timestamp_post <= $timestamp_lastweek) {
$bk_meta_str .= '<time class="time published" datetime="'.date(DATE_W3C, $doris_article_date_unix).'" title="'.get_the_time('F j, Y \a\t g:i a', $postID) .'"><i class="mdicon mdicon-schedule"></i>'.get_the_date('', $postID).'</time>';
}else {
$bk_meta_str .= '<time class="time published" datetime="'.date(DATE_W3C, $doris_article_date_unix).'" title="'.get_the_time('F j, Y \a\t g:i a', $postID) .'"><i class="mdicon mdicon-schedule"></i>'.human_time_diff( get_the_time('U'), current_time('timestamp') ) . esc_html__(' ago', 'doris') .'</time>';
}
break;
case 'date_without_icon':
$timestamp_lastweek = strtotime("-1 week");
$timestamp_post = get_the_time('U', $postID);
if($timestamp_post <= $timestamp_lastweek) {
$bk_meta_str .= '<time class="time published" datetime="'.date(DATE_W3C, $doris_article_date_unix).'" title="'.get_the_time('F j, Y \a\t g:i a', $postID) .'">'.get_the_date('', $postID).'</time>';
}else {
$bk_meta_str .= '<time class="time published" datetime="'.date(DATE_W3C, $doris_article_date_unix).'" title="'.get_the_time('F j, Y \a\t g:i a', $postID) .'">'.human_time_diff( get_the_time('U'), current_time('timestamp') ) . esc_html__(' ago', 'doris') .'</time>';
}
break;
case 'author':
$bk_meta_str .= '<span class="entry-author"> '.esc_html__('By ', 'doris');
$bk_meta_str .= '<a class="entry-author__name" href="'. get_author_posts_url(get_the_author_meta( 'ID' )).'">'. get_the_author() .'</a>';
$bk_meta_str .= '</span>';
break;
case 'bg':
$thumb130 = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'doris-xxs-1_1');
$bk_meta_str .= '<div class="meta-bg" style="background-image:url('.$thumb130['0'].');background-size:cover;background-position:50% 50%;background-repeat:no-repeat;"></div>';
break;
case 'view':
if (defined('DORIS_EXTENSION')) {
if(self::bk_getPostViews($postID) > 1) {
$bk_meta_str .= '<span><i class="mdicon mdicon-visibility"></i>'. self::bk_getPostViews($postID) .' '. esc_html__('views', 'doris') .'</span>';
}else {
$bk_meta_str .= '<span><i class="mdicon mdicon-visibility"></i>'. self::bk_getPostViews($postID) .' '. esc_html__('view', 'doris') .'</span>';
}
}
break;
case 'comment':
if (defined('DORIS_EXTENSION')) {
$bk_meta_str .= '<span><a title="'.esc_attr(self::bk_get_comment_number_and_text($postID)).'" href="'.get_permalink($postID).'"><i class="mdicon mdicon-chat_bubble_outline"></i>'.get_comments_number($postID).' '. esc_html__('comments', 'doris') .'</a></span>';
}
break;
case 'comment_text':
if (defined('DORIS_EXTENSION')) {
$bk_meta_str .= '<span><a title="'.esc_attr(self::bk_get_comment_number_and_text($postID)).'" href="'.get_permalink($postID).'"><i class="mdicon mdicon-chat_bubble_outline"></i>'.self::bk_get_comment_number_and_text($postID).'</a></span>';
}
break;
default:
esc_html_e('No Case Matched!', 'doris');
}
return $bk_meta_str;
}
static function bk_get_post_meta( $meta_arg, $metaSeperator = 0 ) {
$bk_meta = '';
$seperator = '';
if($metaSeperator == 1) {
$seperator = '<span class="meta-seperator">·</span>';
}
if ((isset($meta_arg[0])) && ($meta_arg[0] != null)) {
$bk_meta .= self::bk_meta_cases($meta_arg[0]);
}
if ((isset($meta_arg[1])) && ($meta_arg[1] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[1]);
}
if ((isset($meta_arg[2])) && ($meta_arg[2] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[2]);
}
if ((isset($meta_arg[3])) && ($meta_arg[3] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[3]);
}
if ((isset($meta_arg[4])) && ($meta_arg[4] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[4]);
}
if ((isset($meta_arg[5])) && ($meta_arg[5] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[5]);
}
if ((isset($meta_arg[6])) && ($meta_arg[6] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[6]);
}
if ((isset($meta_arg[7])) && ($meta_arg[7] != null)) {
$bk_meta .= $seperator;
$bk_meta .= self::bk_meta_cases($meta_arg[7]);
}
return $bk_meta;
}
static function bk_count_gallery_length($postID){
$postFormat = self::bk_post_format_detect($postID);
$galleryLength = 0;
if($postFormat == 'gallery') :
$galleryImages = self::doris_rwmb_meta( 'bk_gallery_content', $args = array('type' => 'image'), $postID );
$galleryLength = count($galleryImages);
endif;
return $galleryLength;
}
/**
* Review Score Star
*/
static function bk_get_post_score_star( $reviewScore = 0 ) {
$starHalf = '<span class="mdicon mdicon-star_half">';
$starHTML = '';
$starCount = intval($reviewScore/2);
$i = 0;
for($i = 0; $i < $starCount; $i++) {
$starHTML .= '<span class="mdicon mdicon-star"></span>';
}
if($reviewScore%2){
$starHTML .= '<span class="mdicon mdicon-star_half">';
}
return $starHTML;
}
/**
* Return Post Format
*/
static function bk_post_format_detect($postID) {
if(function_exists('has_post_format')) {
if(get_post_format( $postID ) != '') {
return get_post_format( $postID );
}else {
//Is this review post?
$reviewCheck = get_post_meta($postID, 'bk_review_checkbox', true );
if($reviewCheck == 1) {
$postScore = get_post_meta($postID, 'bk_review_score', true );
if(($postScore != 0) && ($postScore != '')) {
return 'review';
}else {
return '';
}
}else {
return '';
}
}
}else {
return '';
}
}
static function bk_get_post_icon($postID, $postIcon){
$postIconStr = '';
if($postID == ''){
$postID = $postID;
}
if(isset($postIcon['postIconClass'])) {
$iconClass = $postIcon['postIconClass'];
}else {
$iconClass = '';
}
if($postIcon['iconType'] == 'gallery') {
$postIconStr .= '<div class="'.$iconClass.'">';
$postIconStr .= '<i class="mdicon mdicon-filter"></i><span>'.self::bk_count_gallery_length($postID).'</span>';
$postIconStr .= '</div>';
}elseif($postIcon['iconType'] == 'review') {
$reviewScore = get_post_meta($postID, 'bk_review_score', true);
$postIconStr = '<div class="'.$iconClass.'">';
$postIconStr .= '<div class="post-score '.$postID.'">';
$postIconStr .= '<span class="post-score-value">'.$reviewScore.'</span>';
$postIconStr .= '</div>';
$postIconStr .= '</div>';
}elseif($postIcon['iconType'] == 'video') {
$postIconStr .= '<div class="post-type-icon '.$iconClass.'">';
$postIconStr .= '<i class="mdicon mdicon-play_circle_outline"></i>';
$postIconStr .= '</div>';
}elseif($postIcon['iconType'] == 'comment_box') {
if(get_comments_number($postID) > 0) {
$postIconStr .= '<a href="'.get_permalink($postID).'" title="'.esc_attr(self::bk_get_comment_number_and_text($postID)).'" class="comments-count-box overlay-item">'.get_comments_number($postID).'</a>';
}else {
$postIconStr .= '';
}
}else {
$postIconStr .= '';
}
return $postIconStr;
}
/**
* bk_overlay_footer_style
*
*/
static function bk_overlay_footer_style($footerStyle) {
$footerArgs = array();
switch ($footerStyle) {
case '1-col':
$footerArgs['footerType'] = '';
$footerArgs['footerClass'] = '';
break;
case '1-col-border':
$footerArgs['footerType'] = '';
$footerArgs['footerClass'] = 'post__meta--border-top';
break;
case '2-cols':
$footerArgs['footerType'] = '2-cols';
$footerArgs['footerClass'] = 'post__meta--flex';
break;
case '2-cols-border':
$footerArgs['footerType'] = '2-cols';
$footerArgs['footerClass'] = 'post__meta--flex post__meta--border-top';
break;
default:
$footerArgs['footerType'] = '';
$footerArgs['footerClass'] = '';
break;
}
return $footerArgs;
}
/**
* bk_get_meta_list
*
*/
static function bk_get_meta_list($metaInput) {
$metaCase = $metaInput;
$metaArray = array();
switch ($metaCase) {
case 1:
$metaArray = array('author');
break;
case 2:
$metaArray = array('author', 'date');
break;
case 3:
$metaArray = array('author', 'date', 'comment');
break;
case 4:
$metaArray = array('author', 'date', 'view');
break;
case 5:
$metaArray = array('author', 'comment', 'view');
break;
case 6:
$metaArray = array('author', 'view');
break;
case 7:
$metaArray = array('author', 'comment');
break;
case 8:
$metaArray = array('date');
break;
case 9:
$metaArray = array('date', 'comment');
break;
case 10:
$metaArray = array('date', 'view');
break;
case 11:
$metaArray = array('date', 'comment', 'view');
break;
case 12:
$metaArray = array('comment', 'view');
break;
default:
$metaArray = array('author', 'date', 'comment');
break;
}
return $metaArray;
}
/**
* bk_get_cat_class
* 1 => Category Top Left
* 2 => Category Overlap
* 3 => Category Above Title (No Background)
* 4 => Category Above Title (Has Background)
* 0 => Disable Category
*
*/
static function bk_get_cat_class($catStyle) {
$catClass = '';
switch ($catStyle) {
case 1:
$catClass = 'post__cat post__cat--bg cat-theme-bg overlay-item--top-left';
break;
case 2:
$catClass = 'post__cat post__cat--bg post__cat--overlap cat-theme-bg';
break;
case 3:
$catClass = 'post__cat cat-theme';
break;
case 4:
$catClass = 'post__cat post__cat--bg cat-theme-bg';
break;
default:
$catClass = 'post__cat post__cat--bg cat-theme-bg overlay-item--top-left';
break;
}
return $catClass;
}
/**
* media - post format
*
*/
static function bk_get_gallery_1($postID){
$htmlOutput = '';
$galleryImages = self::doris_rwmb_meta( 'bk_gallery_content', $args = array('type' => 'image'), $postID );
if($galleryImages == null ) return '';
$htmlOutput .= '<div class="doris-gallery-wrap">';
$htmlOutput .= '<div class="fotorama doris-gallery-slider doris-post-media-wide" data-width="100%" data-allowfullscreen="true" data-click="false" data-nav="false">';
foreach ( $galleryImages as $image ){
$attachment = wp_get_attachment_image_src($image['ID'], 'doris-l-16_9');
$caption = wp_get_attachment_caption($image['ID']);
$htmlOutput .= '<a href="'.$attachment[0].'" data-size="1200x675" data-caption="'.$caption.'"></a>';
}
$htmlOutput .= '</div>';
$htmlOutput .= '</div>';
return $htmlOutput;
}
static function bk_get_gallery_2($postID){
$htmlOutput = '';
$galleryImages = self::doris_rwmb_meta( 'bk_gallery_content', $args = array('type' => 'image'), $postID );
$htmlOutput .= '<div class="doris-gallery-wrap">';
$htmlOutput .= '<div class="fotorama doris-gallery-slider doris-post-media-wide" data-width="100%" data-allowfullscreen="true" data-click="false">';
foreach ( $galleryImages as $image ){
$attachment = wp_get_attachment_image_src($image['ID'], 'doris-l-16_9');
$caption = wp_get_attachment_caption($image['ID']);
$htmlOutput .= '<a href="'.$attachment[0].'" data-size="1200x675" data-caption="'.$caption.'"></a>';
}
$htmlOutput .= '</div>';
$htmlOutput .= '</div>';
return $htmlOutput;
}
static function bk_get_gallery_3($postID){
$htmlOutput = '';
$galleryImages = self::doris_rwmb_meta( 'bk_gallery_content', $args = array('type' => 'image'), $postID );
$htmlOutput .= '<div class="doris-gallery-wrap">';
$htmlOutput .= '<div class="fotorama doris-gallery-slider doris-post-media-wide" data-width="100%" data-nav="thumbs" data-allowfullscreen="true" data-click="false">';
foreach ( $galleryImages as $image ){
$attachment = wp_get_attachment_image_src($image['ID'], 'doris-l-16_9');
$attachmentThumb = wp_get_attachment_image_src($image['ID'], 'doris-xxs-4_3');
$caption = wp_get_attachment_caption($image['ID']);
$htmlOutput .= '<a href="'.$attachment[0].'" data-size="1200x675" data-caption="'.$caption.'">';
$htmlOutput .= '<img src="'.$attachmentThumb[0].'" alt="'.esc_attr__('Image alt', 'doris').'" width="180" height="135" />';
$htmlOutput .= '</a>';
}
$htmlOutput .= '</div>';
$htmlOutput .= '</div>';
return $htmlOutput;
}
static function bk_get_gallery_4($postID){
$htmlOutput = '';
$galleryID = uniqid('gallery-');
$galleryImages = self::doris_rwmb_meta( 'bk_gallery_content', $args = array('type' => 'image'), $postID );
$htmlOutput .= '<div class="doris-block doris-block--fullwidth doris-carousel doris-gallery-4">';
$htmlOutput .= '<div class="doris-carousel__inner">';
$htmlOutput .= '<div class="post-gallery-slider js-carousel-4i20m--center owl-carousel">';
foreach ( $galleryImages as $image ){
$attachmentThumb = wp_get_attachment_image($image['ID'], 'doris-xl-4_3');
$caption = wp_get_attachment_caption($image['ID']);
$htmlOutput .= '<figure class="slide-item">';
$htmlOutput .= '<div class="gallery-thumb">';
$htmlOutput .= $attachmentThumb;
$htmlOutput .= '</div>';
if($caption != ''):
$htmlOutput .= '<figcaption class="wp-caption-text gallery-caption">';
$htmlOutput .= $caption;
$htmlOutput .= '</figcaption>';
endif;
$htmlOutput .= '</figure>';
}
$htmlOutput .= '</div>';
$htmlOutput .= '</div>';
$htmlOutput .= '</div>';
return $htmlOutput;
}
static function bk_get_video_media($bkURL){
$htmlOutput = '';
if($bkURL != ''):
$bkUrlParse = parse_url($bkURL);
if (isset($bkUrlParse['host']) && (($bkUrlParse['host'] == 'www.youtube.com')||($bkUrlParse['host'] == 'youtube.com'))) {
$videoID = self::bk_parse_youtube($bkURL);
$htmlOutput .= '<div class="doris-responsive-video">';
$htmlOutput .= '<iframe width="1050" height="591" src="//www.youtube.com/embed/'.$videoID.'" allowFullScreen ></iframe>';
$htmlOutput .= '</div>';
}else if (isset($bkUrlParse['host']) && (($bkUrlParse['host'] == 'www.vimeo.com')||($bkUrlParse['host'] == 'vimeo.com'))) {
$videoID = self::bk_parse_vimeo($bkURL);
$htmlOutput .= '<div class="doris-responsive-video">';
$htmlOutput .= '<iframe src="//player.vimeo.com/video/'.$videoID.'?title=0&byline=0&portrait=0" allowfullscreen></iframe>';
$htmlOutput .= '</div>';
}else {
$htmlOutput .= '<div class="doris-error--notice"><span>'.esc_html__('Please put the correct video link to the video post format section', 'doris').'</span></div>';
}
endif;
return $htmlOutput;
}
/**
* ************* Get youtube ID *****************
*---------------------------------------------------
*/
static function bk_parse_youtube($link){
$regexstr = '~
# Match Youtube link and embed code
(?: # Group to match embed codes
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
|(?: # Group to match if older embed
(?:<object .*>)? # Match opening Object tag
(?:<param .*</param>)* # Match all param tags
(?:<embed [^>]*src=")? # Match embed tag to the first quote of src
)? # End older embed code group
)? # End embed code groups
(?: # Group youtube url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
(?: # Group host alternatives.
youtu\.be/ # Either youtu.be,
| youtube\.com # or youtube.com
| youtube-nocookie\.com # or youtube-nocookie.com
) # End Host Group
(?:\S*[^\w\-\s])? # Extra stuff up to VIDEO_ID
([\w\-]{11}) # $1: VIDEO_ID is numeric
[^\s]* # Not a space
) # End group
"? # Match end quote if part of src
(?:[^>]*>)? # Match any extra stuff up to close brace
(?: # Group to match last embed code
</iframe> # Match the end of the iframe
|</embed></object> # or Match the end of the older embed
)? # End Group of last bit of embed code
~ix';
preg_match($regexstr, $link, $matches);
return $matches[1];
}
/**
* ************* Get vimeo ID *****************
*---------------------------------------------------
*/
static function bk_parse_vimeo($link){
$regexstr = '~
# Match Vimeo link and embed code
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
(?: # Group vimeo url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
vimeo\.com # Match vimeo.com
(?:[\/\w]*\/videos?)? # Optional video sub directory this handles groups links also
\/ # Slash before Id
([0-9]+) # $1: VIDEO_ID is numeric
[^\s]* # Not a space
) # End group
"? # Match end quote if part of src
(?:[^>]*></iframe>)? # Match the end of the iframe
(?:<p>.*</p>)? # Match any title information stuff
~ix';
preg_match($regexstr, $link, $matches);
return $matches[1];
}
/**
* ************* Get Dailymotion ID *****************
*---------------------------------------------------
*/
static function bk_parse_dailymotion($link){
preg_match('#<object[^>]+>.+?http://www.dailymotion.com/swf/video/([A-Za-z0-9]+).+?</object>#s', $link, $matches);
// Dailymotion url
if(!isset($matches[1])) {
preg_match('#http://www.dailymotion.com/video/([A-Za-z0-9]+)#s', $link, $matches);
}
// Dailymotion iframe
if(!isset($matches[1])) {
preg_match('#http://www.dailymotion.com/embed/video/([A-Za-z0-9]+)#s', $link, $matches);
}
return $matches[1];
}
static function get_post_icon_class($postSource, $iconSize = '', $iconPosition = 'top-right', $addClass = ''){
$postIconClass = '';
if($iconPosition == 'top-right'){
$postIconClass = 'overlay-item post-type-icon--inverse';
}elseif($iconPosition == 'top-left'){
$postIconClass = 'overlay-item--top-left post-type-icon--inverse';
}elseif($iconPosition == 'left-bottom'){
$postIconClass = 'overlay-item--left-bottom post-type-icon--inverse';
}elseif($iconPosition == 'right-bottom'){
$postIconClass = 'overlay-item--right-bottom post-type-icon--inverse';
}else {
$postIconClass = 'overlay-item--center-xy post-type-icon';
}
if($postSource == 'gallery'){
$postIconClass = 'overlay-item post-type-icon--inverse gallery-icon';
}else {
if($iconSize == 'large') {
$postIconClass .= ' post-type-icon--lg';
}else if($iconSize == 'medium') {
$postIconClass .= ' post-type-icon--md';
}else if($iconSize == 'small') {
$postIconClass .= ' post-type-icon--sm';
}
}
$postIconClass .= ' '.$addClass;
return $postIconClass;
}
static function doris_html_render($html_render, $check = 0){
if($check != 0) {
return $html_render;
}else {
return $html_render;
}
}
static function atbs_get_fb_shares( $url ) {
$cache_key = 'atbs_share' . $url;
$access_token = '302279024028514|497aa83b22106564b42e5399d45b8abd';
$count = get_transient( $cache_key ); // try to get value from Wordpress cache
// if no value in the cache
//if ( $count === false ) {
$response = wp_remote_get( add_query_arg( array(
'id' => urlencode( $url ),
'access_token' => $access_token,
'fields' => 'engagement'
), 'https://graph.facebook.com/v3.0/' ) );
$body = json_decode( $response['body'] );
$count = intval( $body->engagement->share_count );
set_transient( $cache_key, $count, 7200 ); // store value in cache for a 2 hour
//}
return $count;
}
static function social_share_counter( $url ) {
$url_id = preg_replace('/[^A-Za-z0-9]/', '', $url);
$bk_social_count = array();
$bk_social_count['facebook'] = self::atbs_get_fb_shares($url);
//remove twitter counter API
$bk_social_count['twitter'] = 0;
//linkedin
$json_string = wp_remote_get( "http://www.linkedin.com/countserv/count/share?url=$url&format=json", array( 'timeout' => 100 ) );
if ( ! is_wp_error( $json_string ) && isset( $json_string['body'] ) ) {
$json = json_decode( $json_string['body'], true );
$bk_social_count['linkedin'] = isset( $json['count'] ) ? intval( $json['count'] ) : 0;
} else {
$bk_social_count['linkedin'] = 0;
}
//Pinterest
$bk_social_count['pinterest'] = 0;
$json_string = wp_remote_get( 'http://api.pinterest.com/v1/urls/count.json?url=' . $url, array( 'timeout' => 100 ) );
if ( ! is_wp_error( $json_string ) && isset( $json_string['body'] ) ) {
$json_string = preg_replace( '/^receiveCount\((.*)\)$/', "\\1", $json_string['body'] );
$json = json_decode( $json_string, true );
$bk_social_count['pinterest'] = isset( $json['count'] ) ? intval( $json['count'] ) : 0;
} else {
$bk_social_count['pinterest'] = 0;
}
/** StumbledUpon **/
$bk_social_count['stumbledupon'] = 0;
$json_string = wp_remote_get( 'http://www.stumbleupon.com/services/1.01/badge.getinfo?url='.$url, array( 'timeout' => 100 ) );
if ( ! is_wp_error( $json_string ) && isset( $json_string['body'] ) ) {
$json = json_decode( $json_string['body'], true );
$bk_social_count['stumbledupon'] = isset( $json['result']['views'] ) ? intval( $json['result']['views'] ) : 0;
} else {
$bk_social_count['stumbledupon'] = 0;
}
//count all
$bk_social_count['all'] = $bk_social_count['twitter'] + $bk_social_count['pinterest'] + $bk_social_count['facebook'] + $bk_social_count['linkedin'] + $bk_social_count['stumbledupon'];
return $bk_social_count;
}
//the default options
static function pagenavi_init() {
$pagenavi_options = array();
$pagenavi_options['pages_text'] = esc_html__('Page %CURRENT_PAGE% of %TOTAL_PAGES%', 'doris');
$pagenavi_options['current_text'] = '%PAGE_NUMBER%';
$pagenavi_options['page_text'] = '%PAGE_NUMBER%';
$pagenavi_options['first_text'] = esc_html__('1', 'doris');
$pagenavi_options['last_text'] = esc_html__('%TOTAL_PAGES%', 'doris');
$pagenavi_options['next_text'] = '<span class="doris-pagination__item doris-pagination__item-next"><i class="mdicon mdicon-arrow_forward"></i></span>';
$pagenavi_options['prev_text'] = '<span class="doris-pagination__item doris-pagination__item-prev"><i class="mdicon mdicon-arrow_back"></i></span>';
$pagenavi_options['dotright_text'] = esc_html__('...', 'doris');
$pagenavi_options['dotleft_text'] = esc_html__('...', 'doris');
$pagenavi_options['num_pages'] = 3;
$pagenavi_options['always_show'] = 0;
$pagenavi_options['num_larger_page_numbers'] = 3;
$pagenavi_options['larger_page_numbers_multiple'] = 1000;
return $pagenavi_options;
}
static function post_share_meta($postID) {
$doris_option = atbs_core::bk_get_global_var('doris_option');
$htmlOutput = '';
$titleget = get_the_title($postID);
$bk_url = get_permalink($postID);
$fb_oc = "window.open('http://www.facebook.com/sharer.php?u=".urlencode(get_permalink())."','Facebook','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;";
$tw_oc = "window.open('http://twitter.com/share?url=".urlencode(get_permalink())."&text=".str_replace(" ", "%20", $titleget)."','Twitter share','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;";
$li_oc = "window.open('http://www.linkedin.com/shareArticle?mini=true&url=".urlencode(get_permalink())."','Linkedin','width=863,height=500,left='+(screen.availWidth/2-431)+',top='+(screen.availHeight/2-250)+''); return false;";
$share_box = 1;
if ($share_box){
$social_share['fb'] = $doris_option['bk-fb-sw'];
$social_share['tw'] = $doris_option['bk-tw-sw'];
$social_share['gp'] = $doris_option['bk-gp-sw'];
$social_share['pi'] = $doris_option['bk-pi-sw'];
$social_share['li'] = $doris_option['bk-li-sw'];
$fbText = $twText = $gpText = $piText = $stuText = $liText = '';
}
$htmlOutput .= '<ul class="social-list social-list--md list-horizontal">';
if ($social_share['fb']):
$htmlOutput .= '<li><a onClick="'.$fb_oc.'" href="http://www.facebook.com/sharer.php?u='.urlencode(get_permalink()).'"><div class="share-item__icon"><i class="mdicon mdicon-facebook " title="'.esc_attr__('Facebook','doris').'"></i></div></a></li>';
endif;
if ($social_share['tw']):
$htmlOutput .= '<li><a onClick="'.$tw_oc.'" href="http://twitter.com/share?url='.urlencode(get_permalink()).'&text='.str_replace(" ", "%20", $titleget).'"><div class="share-item__icon"><i class="mdicon mdicon-twitter " title="'.esc_attr__('Twitter','doris').'"></i></div></a></li>';
endif;
if ($social_share['pi']):
$htmlOutput .= '<li><a href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());"><div class="share-item__icon"><i class="mdicon mdicon-pinterest-p " title="'.esc_attr__('Pinterest','doris').'"></i></div></a></li>';
endif;
if ($social_share['li']):
$htmlOutput .= '<li><a onClick="'.$li_oc.'" href="http://www.linkedin.com/shareArticle?mini=true&url='. urlencode(get_permalink()).'"><div class="share-item__icon"><i class="mdicon mdicon-linkedin " title="'.esc_attr__('Linkedin','doris').'"></i></div></a></li>';
endif;
$htmlOutput .= '</ul>';
return $htmlOutput;
}
static function doris_round_number($num, $tonearest) {
return floor($num/$tonearest)*$tonearest;
}
static function doris_get_pagination() {
if (is_singular()) {
return; //no pagination on single pages
}
global $wpdb, $wp_query;
$pagenavi_options = self::pagenavi_init();
$pagination_ret = '';
$request = $wp_query->request;
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;
$max_page = $wp_query->max_num_pages;
if(empty($paged) || $paged == 0) {
$paged = 1;
}
$pages_to_show = intval($pagenavi_options['num_pages']);
$larger_page_to_show = intval($pagenavi_options['num_larger_page_numbers']);
$larger_page_multiple = intval($pagenavi_options['larger_page_numbers_multiple']);
$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 = $paged - $half_page_start;
if($start_page <= 0) {
$start_page = 1;
}
$end_page = $paged + $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 > $max_page) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if($start_page <= 0) {
$start_page = 1;
}
$larger_per_page = $larger_page_to_show*$larger_page_multiple;
$larger_start_page_start = (self::doris_round_number($start_page, 10) + $larger_page_multiple) - $larger_per_page;
$larger_start_page_end = self::doris_round_number($start_page, 10) + $larger_page_multiple;
$larger_end_page_start = self::doris_round_number($end_page, 10) + $larger_page_multiple;
$larger_end_page_end = self::doris_round_number($end_page, 10) + ($larger_per_page);
if($larger_start_page_end - $larger_page_multiple == $start_page) {
$larger_start_page_start = $larger_start_page_start - $larger_page_multiple;
$larger_start_page_end = $larger_start_page_end - $larger_page_multiple;
}
if($larger_start_page_start <= 0) {
$larger_start_page_start = $larger_page_multiple;
}
if($larger_start_page_end > $max_page) {
$larger_start_page_end = $max_page;
}
if($larger_end_page_end > $max_page) {
$larger_end_page_end = $max_page;
}
if($max_page > 1 || intval($pagenavi_options['always_show']) == 1) {
$pagination_ret .= '<div class="doris-pagination">';
$pagination_ret .= '<h4 class="doris-pagination__title sr-only">'.esc_html__('Posts navigation', 'doris').'</h4>';
$pagination_ret .= '<div class="doris-pagination__links text-center">';
$pagination_ret .= get_previous_posts_link($pagenavi_options['prev_text']);
if ($start_page >= 2 && $pages_to_show < $max_page) {
$first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']);
$pagination_ret .= '<a href="'.esc_url(get_pagenum_link()).'" class="doris-pagination__item" title="'.esc_attr($first_page_text).'">'.esc_html($first_page_text).'</a>';
if(!empty($pagenavi_options['dotleft_text']) && ($start_page > 2)) {
$pagination_ret .= '<span class="doris-pagination__item doris-pagination__dots">'.$pagenavi_options['dotleft_text'].'</span>';
}
}
if($larger_page_to_show > 0 && $larger_start_page_start > 0 && $larger_start_page_end <= $max_page) {
for($i = $larger_start_page_start; $i < $larger_start_page_end; $i+=$larger_page_multiple) {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
$pagination_ret .= '<a href="'.esc_url(get_pagenum_link($i)).'" class="doris-pagination__item" title="'.esc_attr($page_text).'">'.esc_html($page_text).'</a>';
}
}
for($i = $start_page; $i <= $end_page; $i++) {
if($i == $paged) {
$current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']);
$pagination_ret .= '<span class="doris-pagination__item doris-pagination__item-current">'.$current_page_text.'</span>';
} else {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
$pagination_ret .= '<a href="'.esc_url(get_pagenum_link($i)).'" class="doris-pagination__item" title="'.esc_attr($page_text).'">'.esc_html($page_text).'</a>';
}
}
if($larger_page_to_show > 0 && $larger_end_page_start < $max_page) {
for($i = $larger_end_page_start; $i <= $larger_end_page_end; $i+=$larger_page_multiple) {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
$pagination_ret .= '<a href="'.esc_url(get_pagenum_link($i)).'" class="doris-pagination__item" title="'.esc_attr($page_text).'">'.esc_html($page_text).'</a>';
}
}
if ($end_page < $max_page) {
if(!empty($pagenavi_options['dotright_text']) && ($end_page + 1 < $max_page)) {
$pagination_ret .= '<span class="doris-pagination__item doris-pagination__dots">'.$pagenavi_options['dotright_text'].'</span>';
}
$last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']);
$pagination_ret .= '<a href="'.esc_url(get_pagenum_link($max_page)).'" class="doris-pagination__item" title="'.esc_attr($last_page_text).'">'.esc_html($last_page_text).'</a>';
}
$pagination_ret .= get_next_posts_link($pagenavi_options['next_text'], $max_page);
$pagination_ret .= '</div>';
$pagination_ret .= '</div>';
}
return $pagination_ret;
}
static function doris_get_instagram( $search_for, $cache_hours, $nr_images, $attachment ) {
if ( isset( $search_for['username'] ) && !empty( $search_for['username'] ) ) {
$search = 'user';
$search_string = $search_for['username'];
} else {
return '';
}
$opt_name = 'jr_insta_' . md5( $search . '_' . $search_string );
$instaData = get_transient( $opt_name );
$user_opt = (array) get_option( $opt_name );
if ( false === $instaData || $user_opt['search_string'] != $search_string || $user_opt['search'] != $search || $user_opt['cache_hours'] != $cache_hours || $user_opt['nr_images'] != $nr_images || $user_opt['attachment'] != $attachment ) {
$instaData = array();
$user_opt['search'] = $search;
$user_opt['search_string'] = $search_string;
$user_opt['cache_hours'] = $cache_hours;
$user_opt['nr_images'] = $nr_images;
$user_opt['attachment'] = $attachment;
if ( 'user' == $search ) {
$response = wp_remote_get( 'https://www.instagram.com/' . trim( $search_string ), array( 'sslverify' => false, 'timeout' => 60 ) );
}
if ( is_wp_error( $response ) ) {
return '';
//return $response->get_error_message();
}
if ( $response['response']['code'] == 200 ) {
$json = str_replace( 'window._sharedData = ', '', strstr( $response['body'], 'window._sharedData = ' ) );
// Compatibility for version of php where strstr() doesnt accept third parameter
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
$json = strstr( $json, '</script>', true );
} else {
$json = substr( $json, 0, strpos( $json, '</script>' ) );
}
$json = rtrim( $json, ';' );
// Function json_last_error() is not available before PHP * 5.3.0 version
if ( function_exists( 'json_last_error' ) ) {
( $results = json_decode( $json, true ) ) && json_last_error() == JSON_ERROR_NONE;
} else {
$results = json_decode( $json, true );
}
if ( $results && is_array( $results ) ) {
if ( isset( $results['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'] ) ) {
$entry_data = $results['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'];
} elseif ( isset( $results['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) {
$entry_data = $results['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'];
}
if ( empty( $entry_data ) ) {
return '';
}
foreach ( $entry_data as $current => $result ) {
if ( true === $result['node']['is_video'] ) {
$nr_images ++;
$type = 'video';
continue;
}else {
$type = 'image';
}
if ( $current >= $nr_images ) {
break;
}
$caption = esc_html__( 'Instagram Image', 'doris' );
if ( ! empty( $result['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) {
$caption = wp_kses( $result['node']['edge_media_to_caption']['edges'][0]['node']['text'], array() );
}
$image_data = array(
'description' => $caption,
'link' => trailingslashit( '//instagram.com/p/' . $result['node']['shortcode'] ),
'time' => $result['node']['taken_at_timestamp'],
'comments' => $result['node']['edge_media_to_comment']['count'],
'likes' => $result['node']['edge_liked_by']['count'],
'thumbnail' => preg_replace( '/^https?\:/i', '', $result['node']['thumbnail_resources'][0]['src'] ),
'small' => preg_replace( '/^https?\:/i', '', $result['node']['thumbnail_resources'][2]['src'] ),
'large' => preg_replace( '/^https?\:/i', '', $result['node']['thumbnail_resources'][4]['src'] ),
'original' => preg_replace( '/^https?\:/i', '', $result['node']['display_url'] ),
'type' => $type,
);
$instaData[] = $image_data;
} // end -> foreach
} // end -> ( $results ) && is_array( $results ) )
} else {
return $response['response']['message'];
} // end -> $response['response']['code'] === 200 )
update_option( $opt_name, $user_opt );
} // end -> false === $instaData
return $instaData;
}
static function doris_footer_instagram(){
$doris_option = atbs_core::bk_get_global_var('doris_option');
$photos_arr = array();
$search_for['username'] = $doris_option['bk-footer-instagram-username'];
$amount = 6;
$photos_arr = self::doris_get_instagram( $search_for, $amount, $amount, false );
if (empty($photos_arr)) return '';
?>
<div class="site-footer__section site-footer__section--seperated">
<div class="doris-block footer-instagram">
<ul class="list-unstyled clearfix">
<?php
foreach($photos_arr as $photo)
{
?>
<li class="instagram-item"><a target="_blank" href="<?php echo esc_url($photo['link']); ?>"><img src="<?php echo esc_url($photo['large']); ?>" alt="<?php echo esc_attr($photo['description']); ?>" /></a></li>
<?php
}
?>
</ul>
</div>
</div>
<?php
}
} // Close atbs_core class
}