0) {
$args = array( 'posts_per_page' => $options['mbdslp_number'] );
// v1.2 added category option
if (array_key_exists('mbdslp_category', $options) && $options['mbdslp_category'] != -1) {
$args['category'] = $options['mbdslp_category'];
}
//v1.3 added number of words
if (array_key_exists('mbdslp_words', $options) && intval($options['mbdslp_words']) > 0) {
$num_words = $options['mbdslp_words'];
} else {
$num_words = 55;
}
$lastposts = get_posts( $args );
if (count($lastposts)==0) {
wp_reset_postdata();
return $content;
}
$width = floor(100/$options['mbdslp_number']);
$content .= '
' . esc_html($options['mbdslp_title']) . '
';
//
';
if ($options['mbdslp_display'] == 'horizontal') {
$content .= '
';
$counter = 0;
}
// v1.2 removed 2nd call to get_posts
//$args = array( 'posts_per_page' => $options['mbdslp_number'] );
//$lastposts = get_posts( $args );
foreach($lastposts as $post) {
// v1.2 removed setup_postdata
//setup_postdata($post);
if ($options['mbdslp_display'] == 'horizontal') {
$content .= '';
}
$content .= '';
// v1.2 used post object instead
$content .= $post->post_title; //get_the_title();
$content .= '';
// v1.2 used post object instead
//$content .= wp_trim_words( esc_attr(strip_shortcodes(strip_tags( stripslashes( get_the_content())))), $num_words = 55, $more = NULL ) ;
// v1.3 added number of words
$cleaned_content = esc_attr(strip_shortcodes(strip_tags( stripslashes( $post->post_content ))));
$content .= wp_trim_words( $cleaned_content, $num_words ) ;
// v1.2 used post object instead
//$content .= ' ' . esc_html($options['mbdslp_readmore']) . '';
$content .= ' ' . esc_html($options['mbdslp_readmore']) . '';
if ($options['mbdslp_display'] == 'horizontal') {
$content .= ' | ';
$counter++;
if ($counter == 3) {
$content .= '
';
$counter = 0;
}
}
}
if ($options['mbdslp_display'] == 'horizontal') {
$content .= '
';
}
//$content .= '
';
$content .= '
';
$content .= '';
wp_reset_postdata();
}
}
return $content;
}