File: /home/aprilnet/public_html/sciohost.org/wp-content/themes/doris/inc/blocks/posts_grid_b.php
<?php
if (!class_exists('doris_posts_grid_b')) {
class doris_posts_grid_b {
static $pageInfo=0;
public function render( $page_info ) {
$block_str = '';
$moduleID = uniqid('doris_posts_grid_b-');
$moduleConfigs = array();
$moduleData = array();
self::$pageInfo = $page_info;
//get config
$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'] = 2;
$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['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',
);
$the_query = bk_get_query::doris_query($moduleConfigs); //get query
if ( $the_query->have_posts()) :
$block_str .= '<div id="'.$moduleID.'" class="doris-block doris-block--fullwidth doris-post-grid-b">';
$block_str .= '<div class="container"><div class="post-grid-b__inner">';
$block_str .= atbs_core::bk_get_doris_module_heading('', $moduleConfigs['title']);
if ( $the_query->have_posts() ) :
$block_str .= $this->render_modules($the_query, $moduleInfo); //render modules
endif; //render modules
$block_str .= '</div></div><!-- .container -->';
$block_str .= '</div><!-- .doris-block -->';
endif;
unset($moduleConfigs); unset($the_query); //free
wp_reset_postdata();
return $block_str;
}
public function render_modules($the_query, $moduleInfo = ''){
$render_modules = '';
$postSource = $moduleInfo['post_source'];
$postIcon = $moduleInfo['post_icon'];
$iconPosition = 'top-right';
$bypassPostIconDetech = 0;
$postIconAttr = array();
$postIconAttr['postIconClass'] = '';
$postIconAttr['iconType'] = '';
if($postIcon == 'disable') {
$bypassPostIconDetech = 1;
}else {
$bypassPostIconDetech = 0;
}
if ( $the_query->have_posts() ) :
$postHorizontalHTML = new doris_horizontal_2;
$postVerticalHTML = new doris_vertical_2;
$postVerticalAttr = array (
'additionalClass' => '',
'cat' => 1,
'catClass' => '',
'thumbSize' => 'doris-xs-2_1',
'typescale' => 'typescale-1',
'additionalExcerptClass' => 'post__excerpt--lg',
'postIcon' => $postIconAttr,
);
$postHorizontalAttr = array (
'additionalClass' => 'post--horizontal-sm post-horizontal-mobile',
'cat' => 1,
'catClass' => '',
'thumbSize' => 'doris-m-4_3',
'typescale' => 'typescale-2',
'except_length' => 15,
'postIcon' => $postIconAttr,
);
$render_modules .= '<div class="post-grid-b__wrap">';
while ( $the_query->have_posts() ): $the_query->the_post();
if($the_query->current_post == 0) :
$postHorizontalAttr['postID'] = get_the_ID();
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'], 'medium', $iconPosition);
$postHorizontalAttr['postIcon'] = $postIconAttr;
}
$render_modules .= '<div class="big-post-horizontal-b">';
$render_modules .= $postHorizontalHTML->render($postHorizontalAttr);
$render_modules .= '</div>';
$currentPost = $the_query->current_post;
else:
$postVerticalAttr['postID'] = get_the_ID();
if($bypassPostIconDetech != 1) {
$addClass = 'overlay-item--sm-p';
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'], '', $iconPosition, $addClass);
$postVerticalAttr['postIcon'] = $postIconAttr;
}
$render_modules .= '<div class="small-post-vertical-b">';
$render_modules .= $postVerticalHTML->render($postVerticalAttr);
$render_modules .= '</div>';
$currentPost = $the_query->current_post;
endif;
endwhile;
$render_modules .= '</div>';
endif;
return $render_modules;
}
}
}