<?php
/*
plugin Name:WP SociLine
Plugin URI:http://www.teknikforce.com
DESCRIPTION:Get all your tweets from your twitter timeline and display it in your site in the form of popup
AUTHOR:TEKNIKFORCE
Version:1.0
*/
if(!defined('ABSPATH')) exit;
if (!class_exists('wpsocilinemaincls')) {
	
	class wpsocilinemaincls
	{

		var $pref;

		function __construct()
		{
			$this->pref='wpsociline_';

			self::wpactiveunichatBox();

			add_action('admin_enqueue_scripts',array($this,'wpsociline_admin_scripts'));
			add_action('wp_enqueue_scripts',array($this,'wpsocilineusersitescript'));
			add_action('wp_footer',array($this,'wpsociline_usersighttwitter'));

			register_activation_hook(__FILE__,array($this,'wpsociline_install_userprfofiletable'));
			
			register_deactivation_hook(__FILE__,array($this,'wpsociline_drop_userprofiletable'));
			self::wpsocilineallajax();

			
		}
		function wpsociline_admin_scripts()
		{
			wp_enqueue_script('jquery');

			wp_register_style('sociline_style',plugins_url('assets/css/sociline.css',__FILE__));
			wp_enqueue_style('sociline_style');
			wp_register_style('sociline_bootstrap',plugins_url('assets/bootstrap/css/bootstrap.min.css',__FILE__));
			wp_enqueue_style('sociline_bootstrap');
			
			wp_register_script('sociline_bootstrapjs',plugins_url('assets/bootstrap/js/bootstrap.min.js',__FILE__));
			wp_enqueue_script('sociline_bootstrapjs');
			
			wp_register_style('sociline_all',plugins_url('assets/fontawesome/css/all.min.css',__FILE__));
			wp_enqueue_style('sociline_all');

		}
		function wpsocilineallajax()
{

	add_action('wp_ajax_sociline_edit',array($this,'sociline_edit_editdatarequest'));
	add_action('wp_ajax_tweetlineactionresponse_adminajxlcnc',array($this,'wpsocilinelicenseAjaxRun'));	
	add_action('wp_ajax_nopriv_sociline_edit',array($this,'sociline_edit_editdatarequest'));
	
		add_action('wp_ajax_sociline_delete',array($this,'sociline_delete_deletedatarequest'));


	add_action('wp_ajax_nopriv_sociline_delete',array($this,'sociline_delete_deletedatarequest'));

}
	
		function wpsociline_admin_page()
		{
			add_menu_page('WP_SociLine','WP SociLine','manage_options','wp_sociline_dashboard',array($this,'SociLine_dashboard'),'dashicons-twitter',110);
			add_submenu_page('wp_sociline_dashboard','dashboard_submenu','Dashboard','manage_options','wp_sociline_dashboard',array($this,'SociLine_dashboard'));
			add_submenu_page('wp_sociline_dashboard','dashboard_submenu','Add Profile','manage_options','wp_sociline_addprofile',array($this,'SociLine_addProfile'));
			add_submenu_page('wp_sociline_dashboard','dashboard_submenu','Template Settings','manage_options','wp_sociline_settings',array($this,'SociLine_settings'));
		}
		


		function wpsocilineusersitescript()
		{
wp_enqueue_script( 'jquery' );

		}
		function SociLine_dashboard()
		{
			require_once 'sociline_dashboard.php';
		}
		function SociLine_addProfile()
		{
			require_once 'sociline_profile_table.php' ;
		}
		function SociLine_settings()
		{
			require_once 'sociline_template_settings.php' ;
		}
		function wpsociline_install_userprfofiletable ()
		{	
			global $wpdb;
			$prefix='wpsociline_';
			$table_name=$prefix.'user_profile';
			$sql_create_table="CREATE TABLE $table_name (
							 id int(110) NOT NULL AUTO_INCREMENT,
							 username varchar(100) NOT NULL,
							 created_at datetime(0) NOT NULL,
							 PRIMARY KEY (id)
							)";
							 $wpdb->query($sql_create_table );

							$this->wpsociline_settingoption(); 
				
		}
		 function wpsociline_settingoption()
		 {
		 	
		 			add_option('wpsociline_fonts','Roboto');
					add_option('wpsociline_popupbox_height','420px');
					add_option('wpsociline_popupbox_border','0px');
					add_option('wpsociline_popupbox_bordercolor','#f1f1f1');

					add_option('wpsociline_popupbox_borderradius','5px');

					add_option('wpsociline_popupbox_icon','bell');

					add_option('wpsociline_notification_icon_bgcolor','#00A6FF');
						// offset
					add_option('wpsociline_popupbox_rightoffset','10px');			
					//addshadow offset
					add_option('wpsociline_boxshadow_offset','2px');
					add_option('wpsociline_blurradius','3px');

					add_option('wpsociline_spreadraius','5px');

					add_option('wpsociline_boxshadow_color','#f1f1f1');
					
					
					
					add_option('wpsociline_popup_state','no');

					
		 }

		function wpsociline_drop_userprofiletable ()
		 	{
		 		global $wpdb;
				$prefix='wpsociline_';
				$table_name=$prefix.'user_profile';
		 		$wpdb->query("DROP table $table_name");
		 	}
		   
			 function wpactiveunichatBox()
			 {
					 require_once("unichatbox/plugin.php");
			 $SociLinevar=new \SociLine\license\wpsocilinelicense(array('wpsociline',$this->pref));
			 if($SociLinevar->validate()==1)
			 {
				 
				add_action('admin_menu',array($this,'wpsociline_admin_page'));
			}
			 else
			 {
			 new \SociLine\license\socilineactivationpage(array('wpsociline',$this->pref));
			 }
			 }


			 function wpsocilinelicenseAjaxRun()
{
	if(isset($_POST['reverifyjkmvhblicense']) && isset($_POST['rvryfyplugin']) && isset($_POST['rvryfypluginpref']) && isset($_POST["pluginnonce"]) && wp_verify_nonce($_POST["pluginnonce"],$this->pref))
	{
	
	$ob=new \SociLine\license\wpsocilinelicense(array(sanitize_text_field($_POST['rvryfyplugin']),sanitize_text_field($_POST['rvryfypluginpref'])));
	$ob->reValidate("server");
	}
	wp_die();
}	
 function sociline_edit_editdatarequest()
{
  require_once("wpsociline_ajax_update.php");
  wp_die();
}

function sociline_delete_deletedatarequest()
{
  require_once("wpsociline_ajax_delete.php");
  wp_die();
}
		 	function wpsociline_usersighttwitter()
		 	{
			require_once("wpsocilineusersitepopup.php");
	         $ob = new wpsocilineusersitepopup();
		 	}
		
	}
}


	$twit_obj=new wpsocilinemaincls();


?>