
<?php 
if (!class_exists('wpsocilineusersitepopup')) {

class  wpsocilineusersitepopup
{
  
  function __construct()
  {
    
    $wpsociline_activechaticon = esc_url(plugins_url('assets/images/popupicon.png',__FILE__));
$wpsociline_closeicon = esc_url(plugins_url('assets/images/closechat.png',__FILE__));
$wpsociline_notifiction = esc_url(plugins_url('assets/images/bell.png',__FILE__));


global $wpdb;

  $prefix='wpsociline_';
         $table_name=$prefix.'user_profile'; 
 $wpsocilineid = get_option('wpsociline_userid');
  $result= $wpdb->get_results("SELECT `username` FROM ".$table_name." WHERE id='".$wpsocilineid."'"); 
  foreach ($result as $res) 
  {
                echo '
  
  <img src="'.$wpsociline_activechaticon.'" onclick="wpsociline_open_popup()" class="wpsociline_single" id="wpsociline_active"
>
  
  <style>
  .wpsociline_single{
    padding:14px ;background-color:#00A6FF ;border:1px solid #00A6FF;
    max-height:70px;max-width:70px;z-index:999999;bottom:10px;right:10px;position:fixed;border-radius:40px;
    cursor: pointer;}
    .wpsociline_single:hover{transform:rotatex(360deg);}
    
}

  </style>
  '; 
?>

<style type="text/css">
img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.wpsociline_notifictionicon
{
  max-width:25px;

}

  .wpsociline_body {
  overflow: auto;
  max-height:<?php echo esc_html(get_option('wpsociline_popupbox_height'));?>;
}
.twitter-timeline{
  font-size: 15px;
}

.wpsociline_form_popup {
  margin-right:<?php echo esc_html(get_option('wpsociline_popupbox_rightoffset'));?>;
  margin-bottom:90px;
  padding-bottom: 0px;
  display: none;
  position: fixed;
  bottom: 0;
  background-color: white;
  right: 15px;
  border:<?php echo esc_html(get_option('wpsociline_popupbox_border'));?> solid <?php echo esc_html(get_option('wpsociline_popupbox_bordercolor'));?>;
  z-index:9999;
  border-radius:<?php echo esc_html(get_option('wpsociline_popupbox_borderradius'));?>;
  box-shadow:<?php echo esc_html(get_option('wpsociline_boxshadow_offset'));?> <?php echo esc_html(get_option('wpsociline_spreadraius'));?> <?php echo esc_html(get_option('wpsociline_blurradius'));?><?php echo esc_html(get_option('wpsociline_boxshadow_color'));?>;
}
.wpsociline_uni-widget-close{
    right: 5px;
    top: -10px;
    position: absolute;
  cursor:pointer;
}
.wpsociline_notification{
  background-color: <?php echo esc_html(get_option('wpsociline_notification_icon_bgcolor'));?>;
padding: .75rem 1.25rem;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(0,0,0,.125);
border-radius:0px;

}
</style>


<div class="wpsociline_form_popup" id="wpsociline_popup">
  
  <script type="text/javascript">

function wpsociline_closepopuptwiiter()
{
  document.getElementById("wpsociline_popup").style.display="none";
}
</script>
   <div class="wpsociline_notification" style="color: white;">
   <span style='font-size:30px;' onclick="wpsociline_closepopuptwiiter();" class="wpsociline_uni-widget-close">&#215;</span>

   <img src="<?php 
   if(get_option('wpsociline_popupbox_icon') == 'bell')
   {
     echo $wpsociline_notifiction; 
   }
   else{
     echo $wpsociline_activechaticon;
   }
   ?>" class="wpsociline_notifictionicon"> 
    </div>
 
<?php
if(get_option('wpsociline_popup_state') && trim(get_option('wpsociline_popup_state'))=='yes')
{
  echo "<script>
  jQuery(document).ready(($)=>{
    $('.wpsociline_single').click();
  });
  </script>";
}
?>

<div class="container">
      <div class="col-md-4 ">


            <div class="wpsociline_body">

               <a class="twitter-timeline" href="https://twitter.com/<?php echo esc_attr($res->username);?>" >Tweets by </a>
            </div>
            <script>window.twttr = (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return t;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);

  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };

  return t;
}(document, "script", "twitter-wjs"));
</script>

         </div>
      </div>
   </div>

<script>
  let socilinegotifr=false;
  function sociLineCheckifrmake()
{
  try
  {
    let doc=document.querySelectorAll(".wpsociline_form_popup iframe")[0];
    if(doc===undefined)
    {
      setTimeout(function(){sociLineCheckifrmake()},500);
    }
    else if(socilinegotifr===false)
    {
      socilinegotifr=true;
      let win=doc.contentDocument||doc.contentWindow;
      let twt=win.body.querySelectorAll(".timeline-Widget")[0];
      twt.style.fontFamily="<?php echo esc_html(get_option('wpsociline_fonts')); ?>";
    }
  }catch(err)
  {
    console.log(err);
  }
};
sociLineCheckifrmake();
</script>
<script>
function wpsociline_open_popup() {
  let doc=document.getElementById("wpsociline_popup").style;
      if(doc.display==="block")
      {
        doc.display="none";
      }
      else
      {
        doc.display="block";
      }
}
</script>

<?php
}

                      }

                    }
                  }
                  ?>
