/** * User Init * * @since 1.1.0 * @return void * @author Alberto Ruggiero */ public function user_init() { $this->session = new YLC_Session(); if (current_user_can('answer_chat') && is_admin()) { define('YLC_OPERATOR', true); } else { define('YLC_GUEST', true); } $display_name = ''; $user_email = ''; if (is_user_logged_in()) { global $current_user; get_currentuserinfo(); $user_id = $current_user->ID; $display_name = $current_user->display_name; $user_email = $current_user->user_email; } else { $user_id = $this->session->get('visitor_id'); if (empty($user_id)) { $user_id = uniqid(rand(), false); $this->session->set('visitor_id', $user_id); } } $this->user = (object) array('ID' => $user_id, 'display_name' => $display_name, 'user_email' => $user_email, 'user_ip' => ylc_get_ip_address(), 'current_page' => ylc_get_current_page_url()); }
/** * Plugin Init * * @since 1.0.0 * @return void * @author Alberto Ruggiero */ public function init() { $this->current_page = ylc_get_current_page_url(); $this->ip = ylc_get_ip_address(); if (current_user_can('answer_chat')) { define('YLC_OPERATOR', true); } else { define('YLC_GUEST', true); } if (!is_admin() || defined('DOING_AJAX')) { add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); } add_action('wp_ajax_ylc_ajax_callback', 'ylc_ajax_callback'); add_action('wp_ajax_nopriv_ylc_ajax_callback', 'ylc_ajax_callback'); if (is_user_logged_in()) { global $current_user; get_currentuserinfo(); $this->user = $current_user; } else { $visitor_id = $this->session->get('visitor_id'); if (empty($visitor_id)) { $visitor_id = uniqid(rand(), false); $this->session->set('visitor_id', $visitor_id); } $this->user = (object) array('ID' => $visitor_id, 'display_name' => null, 'user_email' => null); } add_action('wp_footer', array(&$this, 'show_chat')); }