prefix."allvideogallery_videos WHERE published=1"; if( isset($_GET['slg']) ) { $slug = $_GET['slg']; $query .= " AND slug!='$slug'"; } if($arr['category']) { $gallery = $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."allvideogallery_categories WHERE id=".$arr['category']); $query .= " AND category='$gallery->name'"; $arr_params['catid'] = $gallery->slug; } $arr_params['sort'] = $arr['gallery']; switch($arr['gallery']) { case 'latest' : $query .= ' ORDER BY id DESC'; break; case 'popular' : $query .= ' ORDER BY hits DESC'; break; case 'random' : $query .= ' ORDER BY RAND()'; break; case 'featured' : $query .= ' AND featured=1 ORDER BY ordering'; break; default : unset( $arr_params['sort'] ); $query .= ' ORDER BY ordering'; break; } $videos = $wpdb->get_results($query); $custid = ( $arr['custom_id'] ) ? $arr['custom_id']: 'avs_widget_gallery'; $limit = (int) $arr['count']; if(count($videos) < $limit) { $limit = count($videos); $arr['more'] = 0; } $output = ''; $output .= '
'; for ($i=0, $n=$limit; $i < $n; $i++) { $arr_params['slg'] = $videos[$i]->slug; $output .= '
'; $output .= ''; $output .= '
'; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= '' . $videos[$i]->title . ''; $output .= 'No. of Hits : ' . $videos[$i]->hits . ''; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
'; } if($arr['more'] == 1) { unset($arr_params['slg']); $output .= '
more...
'; } $output .= '
'; return $output; } } ?>