__('A widget that show lastest posts, popular post and latest comments', 'gdl_back_office'))); } // Output of the widget function widget($args, $instance) { global $gdl_widget_date_format;; extract( $args ); $num_fetch = $instance['num_fetch']; $category = $instance['category']; if($category == "All"){ $category = ''; } echo $before_widget; $query_arrays = array( array('id'=>'gdl-widget-latest-post', 'title'=> __('RECENT','gdl_front_end'), 'type'=>'post', 'condition'=>'showposts=' . $num_fetch . '&category_name=' . $category), array('id'=>'gdl-widget-popular-post', 'title'=> __('POPULAR','gdl_front_end'), 'type'=>'post', 'condition'=>'showposts=' . $num_fetch . '&category_name=' . $category . '&orderby=comment_count'), array('id'=>'gdl-widget-latest-comment', 'title'=> __('COMMENTS','gdl_front_end'), 'type'=>'comment' ) ); echo '
'; // Tab header $current_tab = ' active '; echo '
'; foreach( $query_arrays as $query_array ){ echo '

'; echo ''; echo $query_array['title']; echo ''; echo '

'; $current_tab = ''; } echo '
'; echo '
'; // gdl-tab-widget-header-wrapper // Tab content $current_tab = ' active '; echo '
'; foreach( $query_arrays as $query_array ){ echo '
'; if( $query_array['type'] == 'post'){ $custom_posts = get_posts($query_array['condition']); echo '
'; foreach( $custom_posts as $custom_post ){ ?>
ID ); $thumbnail = wp_get_attachment_image_src( $thumbnail_id , '75x55' ); if( $thumbnail_id ){ echo '
'; echo ''; $alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true); if( !empty($thumbnail) ){ echo ''. $alt_text .''; } echo ''; echo '
'; } ?>

post_title, 'gdl_front_end'); ?>

ID), get_the_time('m', $custom_post->ID), get_the_time('d', $custom_post->ID)) . '" >'; echo __('Posted On' , 'gdl_front_end') . ' '; echo get_the_time($gdl_widget_date_format, $custom_post->ID); echo ''; ?>
'; }else{ $posts_in_cat = get_post_title_id($category); $recent_comments = get_comments( array('post_id__in'=>$posts_in_cat, 'number'=>$num_fetch, 'status'=>'approve') ); echo '
'; foreach( $recent_comments as $recent_comment ){ $comment_permalink = get_permalink( $recent_comment->comment_post_ID ) . '#comment-' . $recent_comment->comment_ID ?> '; } echo '
'; $current_tab = ''; } echo '
'; // gdl-tab-widget-content-wrapper echo '
'; echo '
'; // gdl-widget-tab echo $after_widget; wp_deregister_script('gdl-tab-widget'); wp_register_script('gdl-tab-widget', GOODLAYERS_PATH.'/javascript/gdl-tab-widget.js', false, '1.0', true); wp_enqueue_script('gdl-tab-widget'); } // Widget Form function form($instance) { if ( $instance ) { $num_fetch = esc_attr( $instance[ 'num_fetch' ] ); $category = esc_attr( $instance[ 'category' ] ); } else { $num_fetch = '3'; $category = ''; } ?>