File: /home/aprilnet/public_html/sciohost.org/wp-content/themes/doris/inc/blocks/posts_listing_grid.php
<?php
if (!class_exists('doris_posts_listing_grid')) {
class doris_posts_listing_grid {
static $pageInfo=0;
public function render( $page_info ) {
$block_str = '';
$moduleID = uniqid('doris_posts_listing_grid-');
$moduleConfigs = array();
self::$pageInfo = $page_info;
//get config
$moduleConfigs['sub_title'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_sub_title', true );
$moduleConfigs['title'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_title', true );
$moduleConfigs['orderby'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_orderby', true );
$moduleConfigs['tags'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_tags', true );
$moduleConfigs['limit'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_limit', true );
$moduleConfigs['offset'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_offset', true );
$moduleConfigs['feature'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_feature', true );
$moduleConfigs['category_id'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_category', true );
$moduleConfigs['editor_pick'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_editor_pick', true );
$moduleConfigs['editor_exclude'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_editor_exclude', true );
$moduleConfigs['ajax_load_more'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_ajax_load_more', true );
$viewallButton = array();
if ($moduleConfigs['ajax_load_more'] == 'viewall') :
$viewallButton['view_all_link'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_view_all_link', true );
$viewallButton['view_all_text'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_view_all_text', true );
$viewallButton['view_all_target'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_view_all_target', true );
endif;
$moduleConfigs['heading_style'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_heading_style', true );
$moduleConfigs['heading_inverse'] = 'no';
if(isset($moduleConfigs['heading_style'])) {
$headingClass = atbs_core::bk_get_block_heading_class($moduleConfigs['heading_style'], $moduleConfigs['heading_inverse']);
}
//Post Source & Icon
$moduleConfigs['post_source'] = get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_post_source', true );
$moduleInfo = array(
'post_source' => $moduleConfigs['post_source'],
'post_icon' => get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_post_icon', true ),
'iconPosition' => 'top-right',
'meta' => get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_meta', true ),
'cat' => get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_cat_style', true ), // Category Style
'excerpt' => get_post_meta( $page_info['page_id'], $page_info['block_prefix'].'_excerpt', true ),
);
atbs_core::bk_add_buff('query', $moduleID, 'moduleInfo', $moduleInfo);
$the_query = bk_get_query::doris_query($moduleConfigs, $moduleID); //get query
$block_str .= '<div id="'.$moduleID.'" class="doris-block doris_posts_listing_grid">';
$block_str .= atbs_core::bk_get_doris_module_heading($moduleConfigs['sub_title'], $moduleConfigs['title']);
if($moduleConfigs['ajax_load_more'] == 'loadmore') {
$block_str .= '<div class="js-ajax-load-post" data-posts-to-load="'.$moduleConfigs['limit'].'">';
}
$block_str .= '<div class="posts-list doris-block--inner post-listing-grid small-post-vertical row">';
if ( $the_query->have_posts() ) :
$block_str .= $this->render_modules($the_query, $moduleInfo); //render modules
endif;
$block_str .= '</div>';
$dorisMaxPages = doris_ajax_function::max_num_pages_cal($the_query, $moduleConfigs['offset'], $moduleConfigs['limit']);
$block_str .= doris_ajax_function::ajax_load_buttons($moduleConfigs['ajax_load_more'], $dorisMaxPages, $viewallButton);
if($moduleConfigs['ajax_load_more'] == 'loadmore') {
$block_str .= '</div>';
}
$block_str .= '</div><!-- .doris-block -->';
unset($moduleConfigs); unset($the_query); //free
wp_reset_postdata();
return $block_str;
}
public function render_modules($the_query, $moduleInfo = ''){
$render_modules = '';
$currentPost = 0;
$postSource = $moduleInfo['post_source'];
$postIcon = $moduleInfo['post_icon'];
$iconPosition = 'top-right';
$iconSize = '';
$bypassPostIconDetech = 0;
$postIconAttr = array();
$postIconAttr['postIconClass'] = '';
$postIconAttr['iconType'] = '';
if($postIcon == 'disable') {
$bypassPostIconDetech = 1;
}else {
$bypassPostIconDetech = 0;
}
if ( $the_query->have_posts() ) :
$postVerticalHTML = new doris_vertical_4;
$postVerticalAttr = array (
'cat' => 1,
'catClass' => '',
'thumbSize' => 'doris-xs-4_3',
'typescale' => 'typescale-2',
'except_length' => 12,
'meta' => array('date_without_icon'),
);
while ( $the_query->have_posts() ): $the_query->the_post();
$currentPost = $the_query->current_post;
if($bypassPostIconDetech != 1) {
if($postSource != 'all') {
$postIconAttr['iconType'] = $postSource;
}else {
$postIconAttr['iconType'] = atbs_core::bk_post_format_detect(get_the_ID());
}
$postIconAttr['postIconClass'] = atbs_core::get_post_icon_class($postIconAttr['iconType'], $iconSize, $iconPosition);
$postVerticalAttr['postIcon'] = $postIconAttr;
}
$postVerticalAttr['postID'] = get_the_ID();
$render_modules .= '<div class="col-sm-6 small-post-vertical__item">';
$render_modules .= $postVerticalHTML->render($postVerticalAttr);
$render_modules .= '</div>';
endwhile;
endif;
return $render_modules;
}
}
}