rendered paste body<?php
class front_page{
static $adds = true;
static function get_categories( $nr = -1 ){
$categories = get_categories();
$result = array();
foreach($categories as $key => $category){
if( $key == $nr ){
break;
}
if( $nr > 0 ){
$result[ $category -> term_id ] = $category -> term_id;
}else{
$result[ $category -> term_id ] = $category -> cat_name;
}
}
return $result;
}
static function get_pages(){
$pages = get_pages();
$result = array();
foreach($pages as $page){
$result[ $page -> ID ] = $page -> post_title;
}
return $result;
}
static function get_front_page_content( ){
$result = '';
switch( admin_options::get_values('front_page' , 'resources') ){
case 'categories' :{
$result = self::get_content_categories();
if( empty( $result ) ){
$result = self::get_null_content();
}
break;
}
case 'page' :{
$result = self::get_content_page();
break;
}
case 'selected_posts' : {
$result = self::get_content_selected_posts( );
$result .= self::get_content_latest_posts( );
break;
}
default :{
$result = self::get_content_latest_posts( );
break;
}
}
return $result;
}
static function get_front_page_layout( ){
$result = '<div class="breadcrumbs">';
$result .= '<p>'.__('You are here:','cosmotheme').'</p>';
$result .= '<ul>';
$result .= '<li>';
$result .= '<a href="'.home_url().'">' . __('Home' , 'cosmotheme') . '</a>';
$result .= '</li>';
$result .= '</ul>';
$result .= '</div>';
if( strlen( admin_options::get_values('advertising','zone_1' ) ) ){
$result .= '<div class="cosmo-ads">';
$result .= admin_options::get_values('advertising','zone_1' );
$result .= '</div>';
}
switch( admin_options::get_values('front_page' , 'layout') ){
case 'full-width' :{
$result .= '<div class="b w_940 b_page_c" id="content">';
$result .= self::get_front_page_content();
$result .= '</div>';
break;
}
case 'right-sidebar' :{
$result .= '<div class="b w_620 b_page_c" id="content">';
$result .= self::get_front_page_content();
$result .= '</div>';
$result .= '<div class="b w_300 full b_right_area widget-area b_right_area" id="primary" role="complementary">';
ob_start();
ob_clean();
de_load_sidebar( );
$result .= ob_get_clean();
$result .= '</div>';
break;
}
case 'left-sidebar' :{
$result .= '<div class="b w_300 full b_right_area widget-area b_right_area" id="primary" role="complementary">';
ob_start();
ob_clean();
de_load_sidebar( );
$result .= ob_get_clean();
$result .= '</div>';
$result .= '<div class="b w_620" id="content">';
$result .= self::get_front_page_content();
$result .= '</div>';
break;
}
}
echo $result;
}
static function get_content_categories( ){
$categories = admin_options::get_values( 'front_page' , 'categories' );
$result = '';
$i = 1;
if( !empty( $categories ) ){
foreach( $categories as $id){
$cat = get_category( $id );
if( admin_options::get_values( 'front_page' , 'layout' ) == 'full-width'){
$nr = 3;
}else{
$nr = 2;
}
if( $i % $nr == 0 ){
$i = 1;
$classes = 'last';
}else{
$i++;
$classes = '';
}
$posts = query_posts('cat='.$id.'&posts_per_page='.admin_options::get_values( 'front_page' , 'nr_post_cat' ) );
$j = 1;
$result .= '<div class="b w_300 cosmo-category '.$classes.'">';
foreach( $posts as $index => $post ){
if( $j == 1 ){
$result .= '<h3 class="title"><a href="' . get_category_link( $cat -> term_id ) . '" title="' . __('Permalink to','cosmotheme') . ' ' . $cat -> cat_name . '">' . $cat -> cat_name . '</a></h3>';
$result .= '<div class="cosmo-category-content cosmo-swap fade">';
if( has_post_thumbnail( $post -> ID ) ){
$result .= '<a href="' . get_permalink( $post -> ID ) . '" rel="bookmark" class="cosmo-image">';
$args = array(
'numberposts' => -1,
'post_type' => 'attachment',
'status' => 'publish',
'post_mime_type' => 'image',
'post_parent' => $post -> ID
);
$images = &get_children($args);
if( isset( $images[ get_post_thumbnail_id( $post -> ID ) ] ) ){
$text = $images[ get_post_thumbnail_id( $post -> ID ) ] -> post_excerpt;
}else{
$args = array(
'numberposts' => -1,
'post_type' => 'attachment',
'status' => 'publish',
'post_mime_type' => 'image',
'post_parent' => 0
);
$images = &get_children($args);
if( isset( $images[ get_post_thumbnail_id( $post -> ID ) ] ) ){
$text = $images[ get_post_thumbnail_id( $post -> ID ) ] -> post_excerpt;
}else{
$text = '';
}
}
$result .= '<span class="mosaic-overlay details">' . $text . '</span>';
$result .= '<span>' . wp_get_attachment_image( get_post_thumbnail_id( $post -> ID ) , '270x100' ) . '</span>';
$result .= '</a>';
}else{
$result .= '<a href="' . get_permalink( $post -> ID ) . '" rel="bookmark" class="cosmo-image no-image">';
$result .= '<span></span>';
$result .= '</a>';
}
if('open' == $post->comment_status)
{
$result .= '<p class="cosmo-comments"><a href="' . get_comments_link( $post -> ID ) . '"> '. get_comments_number( $post -> ID ) .' </a></p>';
}
$result .= '<a href="' . get_permalink( $post -> ID ) . '" title="' . $post -> post_title . '">';
$result .= '<h4 class="cosmo-category-content-h4">';
$result .= $post -> post_title ;
$result .= '</h4>';
$result .= '<p>';
$result .= de_excerpt( $post -> post_excerpt , $post -> post_content , CAT_CNT_LN );
$result .= '</p>';
$result .= '</a>';
$result .= '<div class="blog-meta">';
$result .= '<p class="time">' . date('F j, Y' , strtotime($post -> post_date ) ) . '</p>';
$result .= '<p class="user"><a href="' . get_author_posts_url( $post-> post_author ) . '">'. get_the_author_meta( 'display_name' , $post-> post_author ) .'</a></p>';
$result .= '</div>';
$result .= '</div>';
$result .= '<ul class="cosmo-posts-more">';
}else{
$result .= '<li><a href="' . get_permalink( $post -> ID ) . '" title="' . $post-> post_title . '">'.$post-> post_title.'</a></li>';
}
$j++;
}
$result .= '</ul>';
$result .= '</div>';
if( $classes == 'last' ){
$result .= '<div class="clearfix border-bottom"></div>';
if( self::$adds ){
if( strlen( admin_options::get_values('advertising','zone_2' ) ) ){
$result .= '<div class="cosmo-ads">';
$result .= admin_options::get_values('advertising','zone_2' );
$result .= '</div>';
self::$adds = false;
}
}
}
}
}
return $result;
}
static function get_content_selected_posts( ){
$query = array();
$query['paged'] = self::get_page();
$query['meta_key'] = 'front_page';
$query['post__not_in'] = get_option( 'sticky_posts' );
$wp_query = new WP_Query( $query );
$result = '';
foreach( $wp_query -> posts as $post ){
$result .= '<div class="post" id="post-' . $post -> ID . '">';
$result .= '<h2 class="entry-title"><a rel="bookmark" title="' . __('Permalink to','cosmotheme') .' '. $post -> post_title . '" href="' . get_permalink( $post -> ID ) . '">' . $post -> post_title . '</a></h2>';
$result .= '<div class="blog-meta">';
$result .= '<p class="time">'.get_the_time( 'j F Y, H:i').'</p>';
$result .= '<p class="user"><a href="'.get_author_posts_url( $post-> post_author ).'">'.get_the_author_meta( 'display_name' , $post-> post_author ).'</a></p>';
$result .= '<p class="cosmo-comments"><a href="'.get_comments_link( $post -> ID ).'">'.get_comments_number( $post -> ID ).' </a></p>';
$result .= '</div>';
$result .= '<div class="b_text">';
if( has_post_thumbnail( $post -> ID ) ){
$result .= '<div class="b_img">';
$result .= wp_get_attachment_image( get_post_thumbnail_id( $post -> ID ) , '160x120' );
$args = array(
'numberposts' => -1,
'post_type' => 'attachment',
'status' => 'publish',
'post_mime_type' => 'image',
'post_parent' => $post -> ID
);
$images = &get_children($args);
if( isset( $images[ get_post_thumbnail_id( $post -> ID ) ] ) ){
$text = $images[ get_post_thumbnail_id( $post -> ID ) ] -> post_excerpt;
}else{
$args = array(
'numberposts' => -1,
'post_type' => 'attachment',
'status' => 'publish',
'post_mime_type' => 'image',
'post_parent' => 0
);
$images = &get_children($args);
if( isset( $images[ get_post_thumbnail_id( $post -> ID ) ] ) ){
$text = $images[ get_post_thumbnail_id( $post -> ID ) ] -> post_excerpt;
}else{
$text = '';
}
}
$result .= '<span class="img_text">' . $text . '</span>';
$result .= '</div>';
}
$result .= '<p>';
$result .= do_shortcode( $post -> post_content );
$result .= '</p>';
$result .= '</div>';
$tags = wp_get_post_tags( $post -> ID );
if( !empty( $tags ) ){
$result .= '<div class="b_tag clearfix">';
foreach( $tags as $tag ){
$result .= '<a href="' . get_tag_link( $tag -> term_id ) .'" title="' . __('Permalink to','cosmotheme') .' '. $tag -> name . '"><span>'. $tag -> name .'</span></a>';
}
$result .= '</div>';
}
$result .= '</div>';
if( self::$adds ){
if( strlen( admin_options::get_values('advertising','zone_2' ) ) ){
$result .= '<div class="cosmo-ads">';
$result .= admin_options::get_values('advertising','zone_2' );
$result .= '</div>';
self::$adds = false;
}
}
}
wp_reset_query();
return $result;
}
static function get_content_latest_posts( ){
$query = array();
$query['paged'] = self::get_page();
$query['post__not_in'] = self::get_exclude_posts();
$query['posts_per_page'] = get_option('posts_per_page');
$wp_query = new WP_Query( $query );
$result = '';