__('A widget that show lastest posts in slider', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$post_cat = $instance['post_cat'];
$show_num = $instance['show_num'];
if($post_cat == "All"){ $post_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
wp_reset_query();
$current_post = array(get_the_ID());
$custom_posts = get_posts( array('showposts'=>$show_num, 'category_name'=>$post_cat,
'post__not_in'=>$current_post) );
if( !empty($custom_posts) ){
echo "
";
echo "
";
foreach($custom_posts as $custom_post) {
?>
ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , '400x270' );
if( $thumbnail_id ){
echo '
';
}
?>
'; // gdl-recent-post-slider-widget
echo '
';
echo '
';
echo '
';
echo '
'; // recent-post-slider-nav
echo '
'; // gdl-recent-post-slider-widget-wrapper
}
// Closing of widget
echo $after_widget;
wp_deregister_script('jquery-cycle');
wp_register_script('jquery-cycle', GOODLAYERS_PATH.'/javascript/jquery.cycle.js', false, '1.0', true);
wp_enqueue_script('jquery-cycle');
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$post_cat = esc_attr( $instance[ 'post_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$post_cat = '';
$show_num = '3';
}
?>