function widget($args, $instance)
 {
     extract($args);
     // these are the widget options
     $post_title = apply_filters('widget_title', $instance['title']);
     $agent = 1;
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo '';
         echo $args['before_title'];
         echo apply_filters('widget_title', $post_title, $instance, $this->id_base);
         echo $args['after_title'];
         echo '';
     }
     $user_number = 1;
     $users = get_user_by_meta_data('popular', 'Popular');
     if (!empty($users)) {
         foreach ($users as $user) {
             $User_Pic = get_user_meta($user->ID, 'agent-image', true);
             if (!empty($User_Pic)) {
                 $userLoadedImgSrc = wp_get_attachment_image_src($User_Pic, '600-400-size');
                 $userImgSrc = $userLoadedImgSrc[0];
                 echo '<a href="' . get_author_posts_url($user->ID) . '"><img src="' . $User_Pic . '" alt="" class="img-thumbnail"></a>';
             }
             echo '<a href="' . get_author_posts_url($user->ID) . '" class="btn btn-sm btn-primary pull-right">' . __('more details', 'framework') . '</a>
          	  <h4><a href="' . get_author_posts_url($user->ID) . '">' . $user->display_name . '</a></h4>';
             if (++$user_number > $agent) {
                 break;
             }
         }
     } else {
         echo '<h4>There is no popular agent.</h4>';
     }
     echo $args['after_widget'];
 }
function imic_agents($atts, $content = null)
{
    extract(shortcode_atts(array("number" => ""), $atts));
    $output = '';
    $user_number = 1;
    $users = get_user_by_meta_data('popular', 'Popular');
    if (!empty($users)) {
        foreach ($users as $user) {
            $User_Phone = get_user_meta($user->ID, 'mobile-phone', true);
            $User_Pic = get_user_meta($user->ID, 'agent-image', true);
            if (!empty($User_Pic)) {
                $userLoadedImgSrc = wp_get_attachment_image_src($User_Pic, '600-400-size');
                $userImgSrc = $userLoadedImgSrc[0];
                $output .= '<a href="' . get_author_posts_url($user->ID) . '"><img src="' . $userImgSrc . '" alt="" class="img-thumbnail"></a>';
            }
            $output .= '<div class="row">
                      <div class="col-md-6 col-sm-6 col-xs-6">
                          <h4><a href="' . get_author_posts_url($user->ID) . '">' . $user->display_name . '</a></h4>
                              <a href="' . get_author_posts_url($user->ID) . '" class="btn btn-sm btn-primary">' . __('more details', 'framework') . '</a>
                       </div>
                       <div class="col-md-6 col-sm-6 col-xs-6">
                              <ul class="contact-info">
                                  <li><i class="fa fa-phone"></i> ' . $User_Phone . '</li>
                               <li><i class="fa fa-envelope"></i> ' . $user->user_email . '</li>
                           </ul>
                       </div>
                    </div>';
            if (++$user_number > $number) {
                break;
            }
        }
    } else {
        $output .= '<div class="row">
                      <div class="col-md-6 col-sm-6 col-xs-6">
                          <h4>' . __('There is no popular agent.', 'framework') . '</h4></div></div>';
    }
    return $output;
}