function top_stories($atts, $content = null) { esc_attr(extract(shortcode_atts(array('title' => '', 'rcat' => '0', 'show_nb' => '10'), $atts))); if ($title == '') { $title = __('Top Stories', 'cb-getrends'); } $args = array('post_type' => array('post', 'page'), 'posts_per_page' => $show_nb, 'orderby' => 'meta_value', 'cat' => $rcat, 'meta_key' => 'cb_vote_nb_vote', 'meta_query' => array(array('key' => 'cb_vote_allow', 'value' => 'yes'), array('key' => 'cb_vote_nb_vote'))); query_posts($args); if (have_posts()) { ob_start(); ?> <script type="text/javascript"> jQuery(function(){ jQuery('.top_list li').live('click', function(){ jQuery(this).closest('.top_list').find('.current').removeClass('current'); jQuery(this).addClass('current'); jQuery(this).closest('.top_content').find('.top_images .current_top').hide().removeClass('current_top'); jQuery(this).closest('.top_content').find('#'+jQuery(this).attr('id')+'_con').fadeIn('fast').addClass('current_top'); jQuery(this).closest('.top_content').find('.top_thumbs .current_thums').hide().removeClass('current_thums'); jQuery(this).closest('.top_content').find('#'+jQuery(this).attr('id')+'_thumbs').slideDown('400').addClass('current_thums'); }); jQuery('.top_prev').live('click', function(){ var $current =jQuery(this).closest('.top_list_con').find('ul li.current'); var $prev = $current.prev(); if ($prev.length==0) $prev = jQuery(this).closest('.top_list_con').find('ul li:last'); $current.removeClass('current'); $prev.addClass('current'); jQuery(this).closest('.top_content').find('.top_images .current_top').hide().removeClass('current_top'); jQuery(this).closest('.top_content').find('#'+$prev.attr('id')+'_con').fadeIn('fast').addClass('current_top'); jQuery(this).closest('.top_content').find('.top_thumbs .current_thums').hide().removeClass('current_thums'); jQuery(this).closest('.top_content').find('#'+$prev.attr('id')+'_thumbs').slideDown('400').addClass('current_thums'); return false; }); jQuery('.top_next').live('click', function(){ var $current =jQuery(this).closest('.top_list_con').find('ul li.current'); var $next = $current.next(); if ($next.length==0) $next = jQuery(this).closest('.top_list_con').find('ul li:first'); $current.removeClass('current'); $next.addClass('current'); jQuery(this).closest('.top_content').find('.top_images .current_top').hide().removeClass('current_top'); jQuery(this).closest('.top_content').find('#'+$next.attr('id')+'_con').fadeIn('fast').addClass('current_top'); jQuery(this).closest('.top_content').find('.top_thumbs .current_thums').hide().removeClass('current_thums'); jQuery(this).closest('.top_content').find('#'+$next.attr('id')+'_thumbs').slideDown('400').addClass('current_thums'); return false; }); }); </script> <?php $i = 1; $cc = 0; $pp = ''; $pn = ''; $post_a = array(); echo '<div class="top_content"><div class="top_images">'; while (have_posts()) { the_post(); array_push($post_a, get_the_ID()); } while (have_posts()) { the_post(); $cc++; $isrc = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'large'); $nb_vote = esc_attr(get_post_meta(get_the_ID(), 'cb_vote_nb_vote', true)); $place = $cc; $pref = ''; if ($place == 1) { $pref = 'st'; } if ($place == 2) { $pref = 'nd'; } if ($place == 3) { $pref = 'rd'; } if ($place > 3) { $pref = 'th'; } $votes = ' Vote'; if ($nb_vote > 1) { $votes = ' Votes'; } ?> <div id="top_story_<?php echo get_the_ID(); ?> _con" class="top_story_con fade <?php if ($i == 1) { echo 'current_top'; } ?> " style="display:<?php if ($i == 1) { echo 'block'; } else { echo 'none'; } ?> "> <div class="fade_c"> <div class="see_more_wrap"><div class="see_wrap2"><a href="<?php echo get_permalink(); ?> "><span class="arr_wrap"><img src="<?php echo WP_THEME_URL; ?> /img/icons/arr_r.png" class="fade-s fade_arr_r" alt="<?php _e('see more', 'cb-getrends'); ?> "/></span><h1><span class="fade_see"><?php _e('see more', 'cb-getrends'); ?> </span></h1></a></div></div><div class="cl"></div> </div><img src="<?php echo $isrc[0]; ?> " alt="image"/> <div class="hottest_vote"><h3 class="first_post"><?php echo $place; ?> <sup><?php echo $pref; ?> </sup><span class="votenb"><?php echo $nb_vote . $votes; ?> <span class="arrv"></span></span></h3></div> <div class="top_story_details"> <h3><a href="<?php echo get_permalink(); ?> "><?php echo get_the_title(); ?> </a></h3> <div class="top_story_short"><?php echo strip_cn_i(get_the_content(), 300); ?> </div> <div class="top_story_info"><?php the_time('F j, Y'); ?> | <?php the_author_meta('user_nicename'); ?> </div> <a href="<?php echo get_permalink(); ?> "><i class="icon-plus-sign-alt"></i><?php echo __('Read More', 'cb-getrends'); ?> </a> </div> </div> <?php $cb_vote_nb_vote = get_post_meta(get_the_ID(), 'cb_vote_nb_vote', true); if ($i == 1) { $add = 'current'; } else { $add = ''; } $add1 = ''; $add2 = ''; if (!isset($list)) { $list = ''; } $list .= '<li id="top_story_' . get_the_ID() . '" class="' . $add . '">' . get_the_title() . '</li>'; foreach ($post_a as $posty_k => $posty) { if ($posty == get_the_ID()) { if ($posty_k > 0) { $add1 = $posty_k - 1; } $add2 = $posty_k + 1; if (!isset($post_a[$add1])) { $post_a[$add1] = ''; } if (!isset($post_a[$add2])) { $post_a[$add2] = ''; } if ($post_a[$add1] != '') { $isy = wp_get_attachment_image_src(get_post_thumbnail_id($post_a[$add1]), 'large'); $add1 = '<div class="fade_c"> <div class="see_more_wrap"><div class="see_wrap2"><a href="' . get_permalink($post_a[$add1]) . '"><span class="arr_wrap"><img src="' . WP_THEME_URL . '/img/icons/arr_r.png" class="fade-s fade_arr_r" alt="' . __('see more', 'cb-getrends') . '"/></span><h1><span class="fade_see">' . __('see more', 'cb-getrends') . '</span></h1></a></div></div><div class="cl"></div> </div><a href="' . get_permalink($post_a[$add1]) . '"><img src="' . bfi_thumb($isy[0], array('height' => '130', 'width' => '130', 'crop' => true)) . '" alt="thumb"/></a>'; } else { $add1 = ''; } if ($post_a[$add2] != '') { $isy2 = wp_get_attachment_image_src(get_post_thumbnail_id($post_a[$add2]), 'large'); $add2 = '<div class="fade_c"> <div class="see_more_wrap"><div class="see_wrap2"><a href="' . get_permalink($post_a[$add2]) . '"><span class="arr_wrap"><img src="' . WP_THEME_URL . '/img/icons/arr_r.png" class="fade-s fade_arr_r" alt="' . __('see more', 'cb-getrends') . '"/></span><h1><span class="fade_see">' . __('see more', 'cb-getrends') . '</span></h1></a></div></div><div class="cl"></div> </div><a href="' . get_permalink($post_a[$add2]) . '"><img src="' . bfi_thumb($isy2[0], array('height' => '130', 'width' => '130', 'crop' => true)) . '" alt="thumb"/></a>'; } else { $add2 = ''; } } } $add_class = ""; if ($i == 1) { $add_class = 'current_thums'; $add_style = 'block'; } else { $add_style = 'none'; } $add_n = ''; $add1_n = ''; if ($add2 != '') { $add_n = '<span class="votenb">Next<span class="arrv"></span></span>'; } if ($add1 != '') { $add1_n = '<span class="votenb">Prev<span class="arrv"></span></span>'; } if (!isset($thums)) { $thums = ''; } $thums .= '<div id="top_story_' . get_the_ID() . '_thumbs" class="' . $add_class . '" style="display:' . $add_style . '"> <div class="top_thumb fade">' . $add1 . $add1_n . '</div> <div class="top_thumb top_thumb_def fade">' . $add2 . $add_n . '</div></div>'; $i++; } // Reset Query wp_reset_query(); echo '</div><div class="top_thumbs">' . $thums . '</div><div class="top_list_con"><h3 class="top_title titles">' . $title . '</h3><div class="top_pag_buttons"><a class="top_prev transi" href="#"><i class="icon-angle-left"></i></a><a class="top_next transi" href="#"><i class="icon-angle-right"></i></a></div><ul class="top_list">' . $list . '</ul></div></div>'; $return_html = ob_get_contents(); ob_end_clean(); } return apply_filters('top_stories', $return_html); }
function widget($args, $instance) { extract($args, EXTR_SKIP); $tit = empty($instance['tit']) ? ' ' : apply_filters('widget_tit', $instance['tit']); $magni = empty($instance['magni']) ? ' ' : apply_filters('widget_magni', $instance['magni']); $no = empty($instance['no']) ? ' ' : apply_filters('widget_no', $instance['no']); $cols = empty($instance['cols']) ? ' ' : apply_filters('widget_cols', $instance['cols']); $textyy = empty($instance['text']) ? ' ' : apply_filters('widget_text', $instance['text']); $lg = empty($instance['lg']) ? ' ' : apply_filters('widget_lg', $instance['lg']); $frame = empty($instance['frame']) ? ' ' : apply_filters('widget_frame', $instance['frame']); $plink = empty($instance['plink']) ? ' ' : apply_filters('widget_plink', $instance['plink']); $st = empty($instance['st']) ? ' ' : apply_filters('widget_st', $instance['st']); $st2 = empty($instance['st2']) ? ' ' : apply_filters('widget_st2', $instance['st2']); $im = empty($instance['im']) ? ' ' : apply_filters('widget_im', $instance['im']); $ord = empty($instance['ord']) ? ' ' : apply_filters('widget_ord', $instance['ord']); $stit = empty($instance['stit']) ? ' ' : apply_filters('widget_stit', $instance['stit']); $side = 'no'; $plink2 = $plink; ?> <li><div class="cb4_more_posts widget <?php if ($side == 'yes') { ?> side<?php } ?> " style="<?php echo $st; ?> "> <?php require 'cb-general-options.php'; $rcategory = get_the_category(); $rcat = ''; $rcat = $rcategory[0]->cat_ID; if ($rcat == '') { $rcat = '0'; } $columns = $cols; $sidebar = 'no'; $sidebar_name = 'sidebar'; $s_beh = 'no'; require 'cb-little-head.php'; if ($frame == 'yes') { $fr = 'frame'; $frin = 'framein'; } else { $fr = ''; $frin = ''; } $side = 'no'; if ($side == 'yes') { $ss = '1'; $w = '690'; $h = '250'; $hei = '286px'; $hgf = '355'; $slider_res = 'width:693px;height:330px;'; $con_lg = '358'; $headi = '<h1 class="mbimp">'; $headi_end = '</h1>'; $w = '693'; $h = '450'; $col_width = '695'; $gw = '30'; $hei = '358px'; if ($columns == '2') { $slider_res = 'width:333px;height:210px;'; $con_lg = '100'; $headi = '<h2 class="mbimp">'; $headi_end = '</h2>'; $w = '333'; $h = '238'; $col_width = '333'; $gw = '28'; $hei = '240px'; $hgf = '500'; } if ($columns == '3') { $slider_res = 'width:212px;height:170px;'; $con_lg = '80'; $headi = '<h3 class="mbimp">'; $headi_end = '</h3>'; $w = '210'; $h = '198'; $col_width = '212'; $hei = '200px'; $gw = '28'; $hgf = '545'; } if ($columns == '4') { $slider_res = 'width:152px;height:160px;'; $con_lg = '53'; $headi = '<h4 class="mbimp">'; $headi_end = '</h4>'; $w = '150'; $h = '188'; $col_width = '152'; $hei = '190px'; $hgf = '640'; $gw = '28'; } $col_v = 'col' . $columns . 's'; $coll = $columns; } else { $w = '940'; $h = '350'; $hei = '217px'; $hgf = '456'; $slider_res = 'width:958px;height:420px;'; $con_lg = '520'; $headi = '<h1 class="mbimp">'; $headi_end = '</h1>'; $w = '958'; $h = '550'; $col_width = '940'; $gw = '28'; $hei = '458px'; if ($columns == '2') { $slider_res = 'width:466px;height:250px;'; $con_lg = '210'; $headi = '<h2 class="mbimp">'; $headi_end = '</h2>'; $w = '464'; $h = '178'; $col_width = '466'; $gw = '28'; $hei = '280px'; $hgf = '468'; } if ($columns == '3') { $slider_res = 'width:301px;height:200px;'; $con_lg = '130'; $headi = '<h3 class="mbimp">'; $headi_end = '</h3>'; $w = '299'; $h = '128'; $col_width = '301'; $hei = '230px'; $gw = '28'; $hgf = '510'; } if ($columns == '4') { $slider_res = 'width:219px;height:170px;'; $con_lg = '62'; $headi = '<h4 class="mbimp">'; $headi_end = '</h4>'; $col_width = '219'; $hei = '200px'; $gw = '28'; $w = '219'; $h = '98'; $hgf = '530'; } $col_v = 'col' . $columns; $coll = $columns; } if (strlen($tit) > 6) { echo '<h3 class="tit">' . $tit . '</h3>'; } $cc = 1; query_posts('cat=' . $rcat . '&posts_per_page=' . $no . '&order=' . $ord . '&post_status=publish&paged=' . get_query_var('paged')); if (have_posts()) { while (have_posts()) { the_post(); ?> <?php global $post; ?> <div id="post-<?php echo $post->ID; ?> " class="<?php echo $col_v; ?> " style="<?php if ($coll != 1 && $cc % $coll == 0 && $cc != 0) { echo 'margin-right:0!important;'; } ?> <?php echo $st2; ?> "> <?php if ($stit == 'yes') { ?> <h4 class="tit inr tr"> <a href="<?php echo get_permalink(); ?> "><?php echo get_the_title(); ?> </a> </h4> <?php } ?> <?php require 'cb-post-options.php'; $con = get_the_content(); ?> <?php $murl = ''; $video = ''; $video = ''; $sl_space = ''; // reset values in the loop $post_type = get_post_meta($post->ID, 'cb4_cb_type', $single = true); $isrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large'); $imgs = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID); if ($isrc == '') { $isrc = wp_get_attachment_image_src(array_shift(array_keys($imgs)), 'large'); } if ($isrc && $im == 'yes') { ?> <div class="<?php echo $fr; ?> round"> <div class="<?php echo $frin; ?> round "> <a href="<?php if ($plink2 == 'page') { echo get_permalink(); } else { echo $isrc[0]; } ?> " <?php if ($plink2 == 'pp') { echo 'data-rel="pp"'; } ?> ><img src="<?php echo bfi_thumb($isrc[0], array('width' => 940, 'height' => 555, 'crop' => true)); ?> " class="round" alt="<?php echo get_the_title(); ?> " /> </a> <div class="cl"></div> </div> </div> <?php } ?> <div class="cl"></div> <?php if ($textyy == 'yes') { echo strip_cn_i($con, $lg); ?> <p style="margin-top: 0px;"></p> <a href="<?php echo get_permalink(); ?> " class="more">» <?php _e('read more', 'cb-getrends'); ?> </a> <?php } ?> <div class="cl"></div> </div> <!-- post end --> <?php $cc++; } } wp_reset_query(); ?> <div class="cl"></div> </div></li> <?php }