/**
 * Generates the recent comments markup.
 */
function cwp_get_recent_comments($args = array())
{
    // Set up a default, empty variable.
    $html = '';
    // Merge the input arguments and the defaults.
    $args = wp_parse_args($args, cwp_get_default_args());
    // Extract the array to allow easy use of variables.
    extract($args);
    // Allow devs to hook in stuff before the recent comments.
    do_action('cwp_before_loop');
    // Recent comments query.
    $comments = cwp_get_comments($args);
    if (is_array($comments) && $comments) {
        $html = '<ul class="cwp-ul ' . (!empty($args['css_class']) ? '' . sanitize_html_class($args['css_class']) . '' : '') . '">';
        foreach ($comments as $comment) {
            $html .= '<li class="recentcomments cwp-li">';
            if ($args['avatar']) {
                $html .= '<a class="comment-link cwp-comment-link" href="' . esc_url(get_comment_link($comment->comment_ID)) . '">';
                $html .= '<span class="comment-avatar cwp-avatar">' . get_avatar($comment->comment_author_email, $args['avatar_size']) . '</span>';
                $html .= '</a>';
            }
            $html .= '<span class="cwp-comment-title">';
            /* translators: comments widget: 1: comment author, 4: post link */
            $html .= sprintf(_x('%1$s %2$son%3$s %4$s', 'widgets', 'comments-widget-plus'), '<span class="comment-author-link cwp-author-link">' . get_comment_author_link($comment->comment_ID) . '</span>', '<span class="cwp-on-text">', '</span>', '<a class="comment-link cwp-comment-link" href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>');
            $html .= '</span>';
            if ($args['excerpt']) {
                $html .= '<span class="comment-excerpt cwp-comment-excerpt">' . wp_html_excerpt($comment->comment_content, $args['excerpt_limit'], '&hellip;') . '</span>';
            }
            $html .= '</li>';
        }
        $html .= '</ul>';
    }
    // Allow devs to hook in stuff after the loop.
    do_action('cwp_after_loop');
    // Return the  posts markup.
    return $html;
}
 /**
  * Displays the widget control options in the Widgets admin screen.
  */
 function form($instance)
 {
     // Merge the user-selected arguments with the defaults.
     $instance = wp_parse_args((array) $instance, cwp_get_default_args());
     // Extract the array to allow easy use of variables.
     extract($instance);
     // Loads the widget form.
     include CWP_INCLUDES . 'form.php';
 }