PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.0.1
WpStream – Live Streaming, Video on Demand, Pay Per View v3.0.1
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
← All changes | includes/class-wpstream.php +30 -560 4.5.13.0.1 View file →
@@ -77,14 +77,14 @@
77 77
78 78 public $wpstream_live_connection;
79 79 public $wpstream_player;
80 80 public $xtest;
81 - public $plugin_admin;
82 81
82 +
83 83 public function __construct() {
84 84 $this->main = $this;
85 - if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) {
86 - $this->version = WPSTREAM_PLUGIN_VERSION;
85 + if ( defined( 'WPSTREAM_VERSION' ) ) {
86 + $this->version = WPSTREAM_VERSION;
87 87 } else {
88 88 $this->version = '3.0.1';
89 89 }
90 90 $this->plugin_name = 'wpstream';
@@ -93,9 +93,9 @@
93 93 $this->set_locale();
94 94 $this->define_admin_hooks();
95 95 $this->define_public_hooks();
96 96
97 -
97 + $this->xtest = "this is test2";
98 98 $this->wpstream_conection();
99 99 $this->wpstream_player();
100 100
101 101 }
@@ -208,12 +208,12 @@
208 208 * @access private
209 209 */
210 210 private function define_admin_hooks() {
211 211
212 - $this->admin= $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
213 -
214 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
215 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
212 + $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
213 +
214 + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
215 + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
216 216 $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999);
217 217
218 218 $plugin_post_types = new Wpstream_Product();
219 219 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
@@ -219,39 +219,17 @@
219 219 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
220 220
221 221 // save and render metaboxed
222 222 $this->loader->add_action( 'admin_init', $plugin_admin, 'add_wpstream_product_metaboxes' );
223 - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
224 - $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 );
225 -
226 -
227 -
228 - // make product virtual
229 - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 );
230 -
231 -
232 -
223 + $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
224 +
233 225 // show streaming controls on sidebar
234 226 $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta');
235 -
236 - // on boarding actions
237 - $this->loader->add_action('admin_footer',$plugin_admin, 'wpstream_admin_footer_onboarding');
238 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel', $plugin_admin,'wpstream_on_board_create_channel' );
239 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' );
240 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' );
241 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' );
242 -
243 -
244 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' );
245 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_register', $plugin_admin,'wpstream_on_board_register' );
246 227
247 -
248 - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
249 - $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
250 228
251 -
252 -
253 -
229 + $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
230 + $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
231 +
254 232 // add and save category extra fields
255 233 $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
256 234 $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
257 235 $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
@@ -286,9 +264,8 @@
286 264
287 265 $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' );
288 266 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
289 267 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
290 - $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2);
291 268
292 269 $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
293 270 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
294 271 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
@@ -302,12 +279,8 @@
302 279
303 280
304 281 }
305 282
306 -
307 -
308 -
309 -
310 283 /**
311 284 * Register all of the hooks related to the public-facing functionality
312 285 * of the plugin.
313 286 *
@@ -324,19 +297,16 @@
324 297 $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
325 298 $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
326 299
327 300 //live stream action
328 - $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
329 301 $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
330 302 $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
331 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10);
303 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod');
332 304 // woo action
333 305
334 306 $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
335 307 $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
336 - $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 );
337 - $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 );
338 -
308 +
339 309 $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
340 310 $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
341 311 $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
342 312
@@ -342,11 +312,19 @@
342 312
343 313
344 314 $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
345 315 $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
346 - $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes');
316 +
317 +// // rewrite urls
318 +// $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_tag', 10, 0);
319 +// $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_rule', 10, 0);
320 +//
321 +// $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_userkey_page_template' );
322 +// $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_vodkey_page_template' );
347 323
348 -
324 + //api
325 +
326 +
349 327 $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
350 328
351 329
352 330
@@ -394,285 +372,16 @@
394 372
395 373
396 374
397 375 public function show_user_data($pack_details){
398 - if( isset($pack_details['available_data_mb']) && isset( $pack_details['available_storage_mb']) ){
399 - $wpstream_convert_band = $this->wpstream_convert_band($pack_details['available_data_mb']);
400 - if($wpstream_convert_band<0)$wpstream_convert_band=0;
401 -
402 - $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['available_storage_mb']);
403 - if($wpstream_convert_storage<0)$wpstream_convert_storage=0;
404 -
405 - print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.$wpstream_convert_band.' Gb</strong> '.__('available streaming data and','wpstream').' <strong>'.$wpstream_convert_storage.' Gb</strong> '.__('available recording storage','wpstream');
406 - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">'.esc_html__('Upgrade Subscription','wpstream').'</a>';
407 - print '</div>';
408 - print'<input type="hidden" id="wpstream_band" value="'.$pack_details['available_data_mb'].'">';
409 - print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['available_storage_mb'].'">';
376 + if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
377 + print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.$this->wpstream_convert_band($pack_details['band']).' Gb</strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.$this->wpstream_convert_band($pack_details['storage']).' Gb</strong> '.__('available media storage','wpstream').'.</div>';
378 + print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
379 + print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
410 380
411 381 }
412 382 }
413 383
414 -
415 - /**
416 - * help function for media list elementor widget
417 - *
418 - * @since 3.0.1
419 - * @return string
420 - */
421 -
422 - public function wpstream_media_list_elementor_function($attributes, $content = null){
423 -
424 -
425 - $media_number=3;
426 - if ( isset($attributes['media_number']) ){
427 - $media_number=$attributes['media_number'];
428 - }
429 -
430 -
431 - $row_number=3;
432 - if ( isset($attributes['row_number']) ){
433 - $row_number=$attributes['row_number'];
434 - }
435 - if($row_number>4){
436 - $row_number=4;
437 - }
438 -
439 -
440 - ob_start();
441 -
442 - // check if is vod or live stream
443 - $meta_query = array();
444 - $tax_query_array= array();
445 - $tax_query = array();
446 -
447 - // check if the media is paid or free
448 - $event_types = array();
449 - $product_type_free_paid = 0;
450 - if ( isset($attributes['product_type_free_paid']) ){
451 - $product_type_free_paid=$attributes['product_type_free_paid'];
452 -
453 - if($product_type_free_paid==0){
454 - $event_types=array('wpstream_product');
455 -
456 - if ( isset($attributes['product_type']) && intval($attributes['product_type'])==2){
457 - $event_types=array('wpstream_product_vod');
458 - }
459 -
460 - }else{
461 - $event_types=array('product');
462 - if ( isset($attributes['product_type']) ){
463 - $product_type = $attributes['product_type'];
464 - $product_type_slug = 'video_on_demand';
465 - if($product_type==1){
466 - $product_type_slug ='live_stream';
467 - }
468 -
469 - $tax_query_array = array(
470 - 'taxonomy' => 'product_type',
471 - 'field' => 'slug',
472 - 'terms' => $product_type_slug
473 - );
474 -
475 - $tax_query= array(
476 - 'relation' => 'AND',
477 - $tax_query_array
478 - );
479 -
480 - }
481 - }
482 -
483 - }
484 - $see_product='';
485 - if(isset($attributes['free_label'])){
486 - $see_product=$attributes['free_label'];
487 - }
488 -
489 - // pagination
490 - $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
491 - if( is_front_page() ){
492 - $paged= (get_query_var('page')) ? get_query_var('page') : 1;
493 - }
494 -
495 -
496 - //order
497 - $orderby='ID';
498 - $order ='ASC';
499 - if ( isset($attributes['order_by']) ){
500 - $order_by=intval($attributes['order_by']);
501 - switch ($order_by) {
502 - case 0:
503 - $orderby='ID';
504 - $order ='ASC';
505 - break;
506 - case 1:
507 - $orderby='ID';
508 - $order ='DESC';
509 - break;
510 - case 2:
511 - $orderby='title';
512 - $order ='ASC';
513 - break;
514 - case 3:
515 - $orderby='title';
516 - $order ='DESC';
517 - break;
518 - }
519 - }
520 -
521 - // building wp_query arg array
522 - $args = array(
523 - 'post_type' => $event_types,
524 - 'post_status' => 'publish',
525 - 'meta_query' => $meta_query,
526 - 'posts_per_page' => $media_number,
527 - 'paged' => $paged,
528 - 'orderby' => $orderby,
529 - 'order' => $order,
530 - 'tax_query' => $tax_query
531 - );
532 -
533 -
534 -
535 - // show live events
536 - if ( isset($attributes['product_show_live']) && $attributes['product_show_live']=='yes'){
537 - $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user_for_shortcode('shortcode');
538 -
539 -
540 - if( is_array($live_event_for_user) ){
541 - $live_event_for_user[]=0;
542 -
543 - $args['post__in']=$live_event_for_user;
544 - }
545 - }
546 -
547 -
548 -
549 -
550 - $media_list= new WP_Query($args);
551 - if($media_list->have_posts()){
552 - print '<ul class="wpstream_media_list_wrapper products columns-'.esc_attr($row_number).'" >';
553 - while($media_list->have_posts()):$media_list->the_post();
554 - if($product_type_free_paid==0 ){
555 -
556 - $thumb=wp_get_attachment_image_src(get_post_thumbnail_id(),'medium');
557 -
558 - $thumb_src='';
559 - if( isset($thumb[0]) ){
560 - $thumb_src=$thumb[0];
561 - }
562 -
563 - if(($thumb_src)==''){
564 - $thumb_src= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_300.png';
565 - }
566 - print '<li class="wpstream_product_unit">'
567 - .'<a href="'.get_permalink().'" class="product_title" ><div class="product_image" style="background-image:url('.esc_url($thumb_src).')"></div></a>'
568 - .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>';
569 -
570 - if($see_product!=''){
571 - print '<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>';
572 - }
573 - print '</li>';
574 - }else{
575 - wc_get_template_part( 'content', 'product' );
576 - }
577 - endwhile;
578 - print '</ul>';
579 - }else{
580 - print esc_html__('No media found! ','wpstream');
581 - }
582 -
583 -
584 - wp_reset_query();
585 - wp_reset_postdata();
586 -
587 - $this->wpstream_pagination($media_list->max_num_pages,$range=2);
588 - $return_string= ob_get_contents();
589 - ob_end_clean();
590 -
591 - return $return_string;
592 - }
593 -
594 -
595 -
596 -
597 -
598 -
599 - /*
600 - *
601 - *
602 - * Pagination for media lista
603 - *
604 - *
605 - *
606 - */
607 -
608 -
609 -
610 -
611 - function wpstream_pagination($pages = '', $range = 2){
612 -
613 - $showitems = ($range * 2)+1;
614 - global $paged;
615 - if(empty($paged)) $paged = 1;
616 -
617 -
618 - if($pages == ''){
619 - global $wp_query;
620 - $pages = $wp_query->max_num_pages;
621 - if(!$pages)
622 - {
623 - $pages = 1;
624 - }
625 - }
626 -
627 - if(1 != $pages){
628 - print '<ul class="wpstream_pagination ">';
629 - print '<li class="roundleft"><a href="'.get_pagenum_link($paged - 1).'"> < </a></li>';
630 -
631 - for ($i=1; $i <= $pages; $i++)
632 - {
633 - if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
634 - {
635 - if ($paged == $i){
636 - print '<li class="active"><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>';
637 - }else{
638 - print '<li><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>';
639 - }
640 - }
641 - }
642 -
643 - $prev_page= get_pagenum_link($paged + 1);
644 - if ( ($paged +1) > $pages){
645 - $prev_page= get_pagenum_link($paged );
646 - }else{
647 - $prev_page= get_pagenum_link($paged + 1);
648 - }
649 -
650 -
651 - print '<li class="roundright"><a href="'.$prev_page.'"> > </a><li>';
652 - print '</ul>';
653 - }
654 - }
655 -
656 -
657 -
658 -
659 -
660 -
661 -
662 -
663 -
664 -
665 -
666 -
667 -
668 - /**
669 - * help function for player elementr widget
670 - *
671 - * @since 3.0.1
672 - * @return string
673 - */
674 -
675 384 public function wpstream_insert_player_elementor($attributes, $content = null){
676 385 $product_id = '';
677 386 $return_string = '';
678 387 $attributes = shortcode_atts(
@@ -677,9 +386,8 @@
677 386 $return_string = '';
678 387 $attributes = shortcode_atts(
679 388 array(
680 389 'id' => 0,
681 - 'user_id' => 0,
682 390 ), $attributes) ;
683 391
684 392
685 393 if ( isset($attributes['id']) ){
@@ -684,19 +392,9 @@
684 392
685 393 if ( isset($attributes['id']) ){
686 394 $product_id=$attributes['id'];
687 395 }
688 - if ( isset($attributes['user_id']) ){
689 - $user_id = intval( $attributes['user_id'] );
690 - }
691 -
692 - if(intval($product_id)==0 && $user_id!=0 ){
693 - $product_id= $this->wpstream_player_retrive_first_id($user_id);
694 - }
695 -
696 -
697 -
698 -
396 +
699 397 ob_start();
700 398 $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
701 399 $return_string= ob_get_contents();
702 400 ob_end_clean();
@@ -703,236 +401,8 @@
703 401
704 402 return $return_string;
705 403 }
706 404
707 - /**
708 - * help function for player low latency elementor widget
709 - *
710 - * @since 3.0.1
711 - * @return string
712 - */
713 405
714 - public function wpstream_insert_player__low_latency_elementor($attributes, $content = null){
715 - $product_id = '';
716 - $return_string = '';
717 - $attributes = shortcode_atts(
718 - array(
719 - 'id' => 0,
720 - 'user_id' => 0,
721 - ), $attributes) ;
722 -
723 -
724 - if ( isset($attributes['id']) ){
725 - $product_id=$attributes['id'];
726 - }
727 -
728 - if ( isset($attributes['user_id']) ){
729 - $user_id = intval( $attributes['user_id'] );
730 - }
731 -
732 - if(intval($product_id)==0 && $user_id!=0){
733 - $product_id= $this->wpstream_player_retrive_first_id($user_id);
734 - }
735 -
736 -
737 - ob_start();
738 - $this->main->wpstream_player->wpstream_video_player_shortcode_low_latency($product_id);
739 - $return_string= ob_get_contents();
740 - ob_end_clean();
741 -
742 - return $return_string;
743 - }
744 406
745 -
746 -
747 - public function wpstream_player_retrive_first_id($received_user_id=''){
748 - $channel_type = get_option ('wpstream_user_streaming_channel_type');
749 - $product_id = $this->wpstream_get_current_event_per_author($received_user_id,$channel_type);
750 - return $product_id;
751 - }
752 -
753 -
754 -
755 - /**
756 - * help function for chat elementor widget
757 - *
758 - * @since 3.0.1
759 - * @return string
760 - */
761 -
762 - public function wpstream_insert_chat_elementor($attributes, $content = null){
763 - $product_id = '';
764 - $return_string = '';
765 - $attributes = shortcode_atts(
766 - array(
767 - 'id' => 0,
768 - ), $attributes) ;
769 407
770 -
771 - if ( isset($attributes['id']) ){
772 - $product_id=$attributes['id'];
773 - }
774 -
775 - $return_string.= '<div class="wpstream_plugin_chat_wrapper">';
776 - ob_start();
777 - $this->main->wpstream_player->wpstream_chat_wrapper($product_id);
778 - $return_string.= ob_get_contents();
779 - ob_end_clean();
780 - $return_string.='</div>';
781 - $this->main->wpstream_player->wpstream_connect_to_chat($product_id);
782 -
783 - return $return_string;
784 - }
785 -
786 -
787 - /**
788 - * edited 4.0
789 - *
790 - * Check if user is allowed to stream
791 - *
792 - * @since 3.7
793 - */
794 -
795 - public function wpstream_check_user_can_stream(){
796 - $current_user = wp_get_current_user();
797 -
798 - if( !is_user_logged_in() ){
799 - return false;
800 - exit('user not logged in');
801 - }
802 -
803 - if(current_user_can('administrator')){
804 - // admins can always brodcast
805 - return true;
806 - }
807 -
808 - $extra_roles = get_option( 'wpstream_stream_role', true );
809 - $user_role = $current_user->roles[0];
810 -
811 - if (is_array($extra_roles) && in_array($user_role, $extra_roles)){
812 - return true;
813 - }
814 -
815 - if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){
816 - return true;
817 - }
818 -
819 - return false;
820 - }
821 -
822 -
823 - /**
824 - * Start Streaming wrapper
825 - *
826 - * @since 3.7
827 - */
828 -
829 - public function wpstream_live_stream_unit_wrapper($item_id,$type){
830 - $item_id = intval($item_id);
831 -
832 - if($item_id == 0){
833 - //retrive or create channel for front end streamers
834 - $item_id=$this->wpstream_retrive_front_end_channel();
835 - }
836 - print'<div class="wpstream_modal_background"></div>';
837 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
838 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
839 - </div>';
840 - $this->admin->wpstream_live_stream_unit( $item_id,$type );
841 - }
842 -
843 -
844 -
845 -
846 -
847 - /**
848 - * retrive channel for front end streaming
849 - *
850 - * @since 3.7
851 - */
852 - public function wpstream_retrive_front_end_channel(){
853 -
854 - $current_user = wp_get_current_user();
855 - $channel_type = get_option ('wpstream_user_streaming_channel_type');
856 - $channel_price = floatval( get_option ('wpstream_user_streaming_default_price') );
857 -
858 - $front_end_streamin_channel = $this->wpstream_get_current_event_per_author($current_user->ID,$channel_type);
859 -
860 - if(intval($front_end_streamin_channel) == 0){
861 - $front_end_streamin_channel= $this->wpstrea_create_front_end_event($current_user->ID,$current_user->user_login ,$channel_type,$channel_price);
862 - }
863 - return $front_end_streamin_channel;
864 -
865 - }
866 -
867 - /**
868 - * create the event from front end
869 - *
870 - * @since 3.7
871 - */
872 -
873 - public function wpstrea_create_front_end_event($userID,$userLogin,$channel_type,$channel_price){
874 -
875 - if( !$this->wpstream_check_user_can_stream() ){
876 - return;
877 - }
878 -
879 - $post_type='wpstream_product';
880 - if($channel_type=='paid'){
881 - $post_type='product';
882 - }
883 -
884 - $post = array(
885 - 'post_title' => sprintf( esc_html__('%s Channel','wpstream'),$userLogin),
886 - 'post_content' => '',
887 - 'post_type' => $post_type ,
888 - 'post_author' => $userID,
889 - 'post_status' => 'publish',
890 - );
891 - $post_id = wp_insert_post($post );
892 - if($channel_type=='paid'){
893 - $product = wc_get_product($post_id);
894 - $price = wc_format_decimal($channel_price);
895 -
896 - $product = wc_get_product( $post_id );
897 - // Set the product active price (regular)
898 - $product->set_price( $price );
899 - $product->set_regular_price( $price ); // To be sure
900 - $product->save();
901 - update_post_meta ($post_id,'event_passed',0);
902 - wp_set_object_terms( $post_id, 'live_stream', 'product_type' );
903 - }
904 - update_post_meta($post_id,'wpstream_product_type',1);
905 -
906 - return $post_id;
907 - }
908 -
909 -
910 - public function wpstream_get_current_event_per_author($userID,$channel_type){
911 -
912 - $post_type='wpstream_product';
913 - if($channel_type=='paid'){
914 - $post_type='product';
915 - }
916 -
917 - $args = array(
918 -
919 - 'post_type' => $post_type,
920 - 'author' => $userID,
921 - 'posts_per_page' => 1,
922 - 'fields' => 'ids'
923 - )
924 - ;
925 - $author_posts = new WP_Query( $args );
926 - if( $author_posts->have_posts() ) {
927 - $author_posts->the_post();
928 - $the_id= get_the_ID();
929 - }else{
930 - $the_id= 0;
931 - }
932 -
933 - wp_reset_query();
934 - wp_reset_postdata();
935 - return $the_id;
936 - }
937 -
938 408 }