PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.5.3
WpStream – Live Streaming, Video on Demand, Pay Per View v3.5.3
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / includes / class-wpstream-player.php

class-wpstream-player.php in WpStream – Live Streaming, Video on Demand, Pay Per View 3.5.3, at includes/class-wpstream-player.php

778 lines 29.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * To change this license header, choose License Headers in Project Properties.
5 * To change this template file, choose Tools | Templates
6 * and open the template in the editor.
7 */
8
9
10 /**
11 * Description of class-wpstream-player
12 *
13 * @author cretu
14 */
15 class Wpstream_Player{
16 public function __construct($plugin_main) {
17 $this->main = $plugin_main;
18
19 add_filter( 'the_content',array($this, 'wpstream_filter_the_title') );
20 add_action( 'woocommerce_before_single_product', array($this,'wpstream_user_logged_in_product_already_bought') );
21
22 add_action( 'wp_ajax_wpstream_player_check_status', array($this,'wpstream_player_check_status') );
23 add_action('wp_ajax_nopriv_wpstream_player_check_status', array($this,'wpstream_player_check_status'));
24
25
26 add_action( 'wp_ajax_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient') );
27 add_action('wp_ajax_nopriv_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient'));
28
29
30 }
31
32
33
34 /**
35 * clear status transients
36 *
37 * @author cretu
38 */
39
40
41 public function wpstream_force_clear_transient($event_id){
42
43 $transient_name = 'event_data_to_return_'.$event_id;
44 delete_transient($transient_name);
45 update_post_meta($event_id,'statsUrl','');
46 update_post_meta($event_id,'chatUrl','');
47
48 }
49
50
51
52 /**
53 * check player status
54 *
55 * @author cretu
56 */
57
58 public function wpstream_player_check_status(){
59 $event_id = intval($_POST['event_id']);
60 $show_id=$event_id;
61 $transient_name = 'event_data_to_return_'.$event_id;
62 $event_data_for_transient = get_transient( $transient_name );
63
64
65
66 if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
67
68 $server_id = ''; // server id IS blank - need to retrive it
69 $token = $this->main->wpstream_live_connection->wpstream_get_token();
70
71 if($server_id==''){
72 update_post_meta($show_id,'server_id', '' );
73
74 $server_id =$this->main->wpstream_live_connection->retrive_server_id_based_on_show_id($show_id);
75
76 }
77
78
79
80 update_post_meta($show_id,'server_id', $server_id );
81 $values_array=array(
82 "server_id" => esc_html($server_id),
83 'from_where' => 'wpstream_check_event_status_front_player'
84 );
85
86 if($server_id==''){
87 $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
88 //print 'failed connection';
89 return;
90 }
91
92
93
94 $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/event_status/?access_token=".$token;
95 $arguments = array(
96 'method' => 'GET',
97 'timeout' => 45,
98 'redirection' => 5,
99 'httpversion' => '1.0',
100 'blocking' => true,
101 'headers' => array(),
102 'body' => $values_array,
103 'cookies' => array()
104 );
105
106 $response = wp_remote_post($url,$arguments);
107 $received_data = wp_remote_retrieve_body($response);
108
109 if( isset($response['response']['code']) && $response['response']['code']=='200'){
110 $received_data_encoded=json_decode($received_data,true);
111
112 if( isset($received_data_encoded['success']) && intval( $received_data_encoded['success'] ) ==1 ){
113
114 /*
115 * we set transient and return the array saved
116 * false if no data
117 *
118 * */
119 $event_data_for_transient= $this->main->wpstream_live_connection->api20_wpstream_update_event($received_data_encoded,$show_id,$server_id);
120 }else{
121 $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
122 }
123
124 }else{
125 $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
126 }
127
128
129
130
131 if ( false === $event_data_for_transient || $event_data_for_transient=='' ){
132 //we are not live
133 $event_data_for_transient=array();
134 $event_data_for_transient['hlsPlaybackUrl']='';
135
136 }
137 }
138
139
140
141 // 1==2 &&
142
143 if( $event_data_for_transient['hlsPlaybackUrl']!=''){
144 echo json_encode( array(
145
146 'started' => 'yes',
147 'server_id' => $event_data_for_transient['server_id'],
148 'event_id' => $event_id,
149 'event_uri' => $event_data_for_transient['hlsPlaybackUrl'],
150 'live_conect_views' => $event_data_for_transient['statsUrl'],
151 'chat_url' => $event_data_for_transient['chatUrl'],
152
153 ));
154 }else{
155 echo json_encode( array(
156 'started' => 'no',
157 'server_id' => $server_id,
158 'event_id' => $event_id,
159 'event_uri' => '',
160 'live_conect_views' => '',
161 'chat_url' => '',
162
163 ));
164 $this->wpstream_force_clear_transient($event_id);
165 }
166 die();
167 }
168
169
170
171 /**
172 * Insert player in page
173 *
174 * @author cretu
175 */
176 public function wpstream_filter_the_title( $content ) {
177 if( is_singular('wpstream_product')){
178 global $post;
179 $args=array('id'=>$post->ID);
180 $custom_content = $this->wpstream_insert_player_inpage($args);
181 $content = '<div class="wpestream_inserted_player">'.$custom_content.'</div>'.$content;
182 return $content;
183 }else{
184 return $content;
185 }
186 }
187
188 /**
189 * Insert player in page
190 *
191 * @author cretu
192 */
193
194 public function wpstream_insert_player_inpage($attributes, $content = null){
195 $product_id = '';
196 $return_string = '';
197 $attributes = shortcode_atts(
198 array(
199 'id' => 0,
200 ), $attributes) ;
201
202
203 if ( isset($attributes['id']) ){
204 $product_id=$attributes['id'];
205 }
206
207 ob_start();
208 $this->wpstream_video_player_shortcode($product_id);
209 $return_string= ob_get_contents();
210 ob_end_clean();
211
212 return $return_string;
213 }
214
215
216
217
218 /**
219 * Video Player shortcode
220 *
221 * @author cretu
222 */
223
224 public function wpstream_video_player_shortcode($from_sh_id='') {
225
226 if ( is_user_logged_in() ) {
227 global $product;
228 $current_user = wp_get_current_user();
229 $product_id = intval($from_sh_id);
230
231
232 if ( ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ) || get_post_type($product_id)=='wpstream_product' ){
233 global $product;
234 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
235
236
237 if( get_post_type($product_id) == 'wpstream_product' ){
238
239 $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
240 if($wpstream_product_type==1){
241 $this->wpstream_live_event_player($product_id);
242 } else if($wpstream_product_type==2 || $wpstream_product_type==3){
243 $this->wpstream_video_on_demand_player($product_id);
244 }
245
246 }else{
247 $term_list = wp_get_post_terms($product_id, 'product_type');
248 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
249
250 if( $term_list[0]->name=='live_stream' || ( $term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
251 $this->wpstream_live_event_player($product_id);
252 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
253 $this->wpstream_video_on_demand_player($product_id);
254 }
255 }
256
257
258 echo '</div></div>';
259 }else{
260
261 if( get_post_type($product_id) == 'wpstream_product' ){
262 $thumb_id = get_post_thumbnail_id($product_id);
263 $thumb = wp_get_attachment_image_src($thumb_id,'medium_large');
264
265 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
266 echo '<div class="wpstream_notice">'.__('You did not buy this product!','wpstream').
267 '</div><img src="'.$thumb[0].'" alt="product_thumb">';
268 echo '</div></div>';
269 }
270 }
271
272
273 }else{
274 $product_id = intval($from_sh_id);
275 if( get_post_type($product_id) == 'wpstream_product' ){
276
277 $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
278 if($wpstream_product_type==1){
279 $this->wpstream_live_event_player($product_id);
280 } else if($wpstream_product_type==2 || $wpstream_product_type==3){
281 $this->wpstream_video_on_demand_player($product_id);
282 }
283
284 }
285 }
286 }
287
288
289
290
291
292
293 /**
294 * Live Event Player
295 *
296 * @author cretu
297 */
298 function remove_http($url) {
299 $disallowed = array('http://', 'https://');
300 foreach($disallowed as $d) {
301 if(strpos($url, $d) === 0) {
302 return str_replace($d, '', $url);
303 }
304 }
305 return $url;
306 }
307
308
309 /**
310 * Live Event Player
311 *
312 * @author cretu
313 */
314
315 function wpstream_live_event_player($product_id,$poster_show='',$use_chat=''){
316 $live_event_uri = get_post_meta($product_id,'live_event_uri',true);
317 $api20_event_id = get_post_meta($product_id,'server_id',true);
318
319 $thumb_id = get_post_thumbnail_id($product_id);
320 $thumb = wp_get_attachment_image_src($thumb_id,'small');
321
322 $chatUrl= get_post_meta($product_id,'statsUrl',true);
323
324
325 $live_event_uri_final = $this->wpstream_request_hls_player_dynamic('',$product_id);// buleala lu Gabi
326 $now = time().rand(0,10);
327 $live_conect_array = explode('live.streamer.wpstream.net',$live_event_uri_final);
328 $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
329 $live_conect_views = $this->remove_http($live_conect_views);
330 $usernamestream = esc_html ( get_option('wpstream_api_username','') );
331
332 echo '<div class="wpstream_live_player_wrapper" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" id="wpstream_live_player_wrapper'.$now.'" > '
333 . '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
334
335
336
337
338 $show_wpstream_not_live_mess=' style="display:none;" ';
339 if(trim($live_event_uri_final) ==''){
340 $show_wpstream_not_live_mess='';
341 }else{
342 print '<script type="text/javascript">
343 //<![CDATA[
344 jQuery(document).ready(function(){
345 wpstream_count_connect_plugin("wpstream_live_player_wrapper'.$now.'" ,"'.$chatUrl.'");
346 });
347 //]]>
348 </script>';
349 }
350
351
352 print '<div class="wpstream_not_live_mess " '.$show_wpstream_not_live_mess.' ><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html__('We are not live at this moment. Please check back later.','wpstream').'</div></div>';
353
354
355 $poster_data=' poster="'.$thumb[0].'" ';
356 if($poster_show=='no'){
357 $poster_data='';
358 }
359
360 echo'
361 <video id="wpstream-video'.$now.'" '.$poster_data.' class="video-js vjs-default-skin vjs-16-9" playsinline="true" controls>
362 <source
363 src="'.$live_event_uri_final.'"
364 type="application/x-mpegURL">
365 </video>';
366
367 print '<script type="text/javascript">
368 //<![CDATA[
369 jQuery(document).ready(function(){
370 wpstream_player_initialize("'.$now.'","'.$live_event_uri_final.'","'.$live_conect_views.'");';
371
372 if(trim($live_event_uri_final) !==''){
373 print 'wpstream_player_play("'.$now.'","'.$live_event_uri_final.'","'.$live_conect_views.'");';
374
375 }
376
377 print'});
378 //]]>
379 </script>';
380
381
382
383 print '</div>';
384 if($use_chat=="yes"){
385 $this->wpstream_connect_to_chat($product_id);
386 }
387
388 usleep (10000);
389
390 }
391
392
393 /**
394 * Request dynamic data
395 *
396 * @author cretu
397 */
398
399 // public function wpstream_request_hls_player_dynamic_data($server_id,$product_id){
400 //
401 // $transient_name = 'event_data_to_return_'.$product_id;
402 // $event_data_to_return = get_transient( $transient_name );
403 //
404 // if ( false === $event_data_to_return || $event_data_to_return=='' ) { //ws || $hls_to_return==''
405 // $this->main->wpstream_live_connection->wpstream_check_event_status_front_player($product_id,$server_id);
406 //
407 // return;
408 // }else{
409 // return '';
410 // }
411 //
412 // }
413
414
415
416 /**
417 * HLS PLAYER
418 *
419 * @author cretu
420 */
421 public function wpstream_request_hls_player_dynamic($server_id,$product_id){
422
423 $transient_name = 'hls_to_return_'.$product_id;
424 $hls_to_return = get_transient( $transient_name );
425
426 if ( false === $hls_to_return || $hls_to_return=='' ) { //ws || $hls_to_return==''
427
428 $token = $this->main->wpstream_live_connection->wpstream_get_token();
429 $values_array = array();
430 $values_array['server_id'] = $server_id;
431
432 if($server_id==''){
433 $this->main->wpstream_live_connection->wpstream_check_event_status_front_player($product_id,$server_id);
434 $server_id = get_post_meta($product_id,'server_id', true );
435 $values_array['server_id'] = $server_id;
436 }
437
438
439 if($server_id==''){
440 delete_transient($transient_name);
441 return '';exit();
442 }
443
444 $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/ap20_get_player_hls_dynamic/?access_token=".$token;
445
446
447 $arguments = array(
448 'method' => 'GET',
449 'timeout' => 45,
450 'redirection' => 5,
451 'httpversion' => '1.0',
452 'blocking' => true,
453 'headers' => array(),
454 'body' => $values_array,
455 'cookies' => array()
456 );
457 $response = wp_remote_post($url,$arguments);
458
459 $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
460
461
462
463
464 if( isset($response['response']['code']) && $response['response']['code']=='200'){
465 $hls_to_return = trim($received_data);
466
467
468 set_transient( $transient_name, $hls_to_return, 60 );
469 return $hls_to_return;
470 }else{
471 return 'failed connection';
472 }
473 exit();
474 }else{
475 return $hls_to_return;
476 }
477
478 }
479
480
481
482 /**
483 * HLS PLAYER
484 *
485 * @author cretu
486 */
487
488
489 public function wpstream_request_hls_player($product_id){
490
491 $transient_name = 'hls_to_return_'.$product_id;
492 $hls_to_return = get_transient( $transient_name );
493
494 if ( false === $hls_to_return || $hls_to_return=='' ) {
495
496 $show_id = intval($product_id);
497 $token = $this->main->wpstream_live_connection->wpstream_get_token();
498 $values_array = array();
499 $values_array['show_id'] = $show_id;
500
501 $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/videos/ap20_get_player_hls/?access_token=".$token;
502
503
504 $arguments = array(
505 'method' => 'GET',
506 'timeout' => 45,
507 'redirection' => 5,
508 'httpversion' => '1.0',
509 'blocking' => true,
510 'headers' => array(),
511 'body' => $values_array,
512 'cookies' => array()
513 );
514 $response = wp_remote_post($url,$arguments);
515
516 $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
517
518
519
520 if( isset($response['response']['code']) && $response['response']['code']=='200'){
521 $hls_to_return = trim($received_data);
522 set_transient( $transient_name, $hls_to_return, 60 );
523 return $hls_to_return = trim($received_data);
524 }else{
525 return 'failed connection';
526 }
527 exit();
528 }else{
529 return $hls_to_return;
530 }
531
532 }
533
534
535
536 /**
537 * VODPlayer uri details
538 *
539 * @author cretu
540 */
541 public function wpstream_video_on_demand_player_uri_request($product_id){
542
543 $wpstream_data_setup = ' data-setup="{}" ';
544
545 /* free_video_type
546 * 1 - free live channel
547 * 2 - free video encrypted
548 * 3 - free video -not encrypted
549 */
550 $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
551
552
553 if($free_video_type==2 || get_post_type($product_id)=='product' ){
554
555 /* IF vide is encrypted- readed from vod,streaner
556 */
557
558 $video_type = 'application/x-mpegURL';
559 $video_path = get_post_meta($product_id,'_movie_url',true);
560 if(get_post_type($product_id)=='wpstream_product'){
561 $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true));
562 }
563
564 $username = esc_html ( get_option('wpstream_api_username','') );
565 if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
566 $username = $this->wpstream_retrive_username();
567 }
568
569 if(strpos($username,'@')!=false){
570 $username_array= explode('@', $username);
571 $username=$username_array[0];
572 }
573
574 $video_path_final = 'https://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
575 if(!is_ssl()){
576 $video_path_final = 'http://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
577 }
578
579 }else if($free_video_type==3){
580
581 /* Video is unecrypted - read from local or youtube / vimeo
582 */
583
584 $video_type = 'video/mp4';
585 $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true));
586
587 if (strpos($video_path_final, 'www.youtube') !== false) {
588 $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "'.$video_path_final.'"}] }\' ';
589 $video_path_final='';
590 }
591 if (strpos($video_path_final, 'vimeo.com') !== false) {
592 $wpstream_data_setup= ' data-setup=\'{"techOrder": ["vimeo"], "sources": [{ "type": "video/vimeo", "src": "'.$video_path_final.'"}], "vimeo": { "color": "#fbc51b"} }\' ';
593 $video_path_final='';
594 }
595
596 }
597
598 $return_array=array();
599 $return_array['video_path_final'] = $video_path_final;
600 $return_array['wpstream_data_setup']= $wpstream_data_setup;
601 $return_array['video_type'] = $video_type;
602 return $return_array;
603 }
604
605
606
607 /**
608 * VODPlayer url
609 *
610 * @author cretu
611 */
612
613 public function wpstream_video_on_demand_player($product_id){
614
615 $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
616 $video_path_final = $uri_details['video_path_final'];
617 $wpstream_data_setup = $uri_details['wpstream_data_setup'];
618 $video_type = $uri_details['video_type'];
619
620 $thumb_id = get_post_thumbnail_id($product_id);
621 $thumb = wp_get_attachment_image_src($thumb_id,'small');
622 $usernamestream = esc_html ( get_option('wpstream_api_username','') );
623
624 $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
625
626 if($pack['band']>0){
627 echo '<video id="wpstream-video'.time().'" class="video-js vjs-default-skin vjs-16-9 kuk wpstream_video_on_demand" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" controls preload="auto"
628 poster="'.$thumb[0].'" '.$wpstream_data_setup.'>
629
630 <source src="'.trim($video_path_final).'" type="'.$video_type.'">
631 <p class="vjs-no-js">
632 To view this video please enable JavaScript, and consider upgrading to a web browser that
633 <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
634 </p>
635 </video>';
636 }else{
637 print esc_html_e('Insufficient resources to stream this title','wpstream');
638 }
639
640 }
641
642
643
644
645
646
647 /**
648 * Retreive username for vod path
649 *
650 * @author cretu
651 */
652 private function wpstream_retrive_username(){
653 $token = $this->main->wpstream_live_connection->wpstream_get_token();
654
655 $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/return_login/?access_token=".$token;
656 $arguments = array(
657 'method' => 'GET',
658 'timeout' => 45,
659 'redirection' => 5,
660 'httpversion' => '1.0',
661 'blocking' => true,
662 'headers' => array(),
663 'cookies' => array()
664 );
665 $response = wp_remote_post($url,$arguments);
666 $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
667 if( isset($response['response']['code']) && $response['response']['code']=='200'){
668 return ($received_data); die();
669 }else{
670 print 'Failed to conbect media server';
671 die();
672 }
673 }
674
675
676
677
678
679 /**
680 * check if the user bought the product and display the player - TO REDo
681 *
682 * @since 3.0.1
683 * returns html of the player
684 */
685 public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
686
687 if ( is_user_logged_in() ) {
688 global $product;
689 $current_user = wp_get_current_user();
690 $product_id = $product->get_id();
691
692
693 if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) || ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
694
695
696 echo '<div class="wpstream_player_wrapper"><div class="wpstream_player_container">';
697
698 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
699 $term_list = wp_get_post_terms($product_id, 'product_type');
700
701
702 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
703 $this->wpstream_live_event_player($product_id);
704 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
705 $this->wpstream_video_on_demand_player($product_id);
706 }
707 echo '</div></div>';
708 }else{
709 if( get_post_type($product_id) == 'wpstream_product' ){
710 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
711 echo '<div class="wpstream_notice">'.__('You did not buy this product!','wpstream').'</div>';
712 echo '</div></div>';
713 }
714 }
715
716
717 }
718 }
719
720 /**
721 * check if the user bought the product and display the player - TO REDo
722 *
723 * @since 3.0.1
724 * returns html of the player
725 */
726
727 public function wpstream_chat_wrapper($product_id){
728 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php';
729 }
730
731
732
733 public function wpstream_connect_to_chat($product_id){
734 $current_user = wp_get_current_user();
735 $userID = $current_user->ID;
736 $user_login = $current_user->user_login;
737
738 $key='';
739
740 $chatUrl = get_post_meta($product_id,'chatUrl',true);
741
742
743 wp_enqueue_script( 'sockjs-0.3.min' );
744 wp_enqueue_script( 'emojione.min.js' );
745 wp_enqueue_script( "jquery-effects-core");
746 wp_enqueue_script( 'jquery.linkify.min.js');
747 wp_enqueue_script( 'ripples.min.js');
748 wp_enqueue_script( 'material.min.js');
749 wp_enqueue_script( 'chat.js');
750
751
752
753 wp_enqueue_style( 'chat.css');
754 wp_enqueue_style( 'ripples.css');
755 wp_enqueue_style( 'emojione.min.css');
756
757
758
759
760 if(!is_user_logged_in()){
761 $user_login='';
762 $chatUrl='';
763 }
764
765
766 print '<script type="text/javascript">
767 //<![CDATA[
768 jQuery(document).ready(function(){
769 username = "'.$user_login.'";
770 key="'.$key.'";
771 connect("'.$chatUrl.'");
772 });
773 //]]>
774 </script>';
775
776 }
777 }
778