PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.12.1
WpStream – Live Streaming, Video on Demand, Pay Per View v3.12.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
wpstream / admin / class-wpstream-admin.php

class-wpstream-admin.php in WpStream – Live Streaming, Video on Demand, Pay Per View 3.12.1, at admin/class-wpstream-admin.php

1,726 lines 83.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link http://wpstream.net
7 * @since 3.0.1
8 *
9 * @package Wpstream
10 * @subpackage Wpstream/admin
11 */
12
13 /**
14 * The admin-specific functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the admin-specific stylesheet and JavaScript.
18 *
19 * @package Wpstream
20 * @subpackage Wpstream/admin
21 * @author wpstream <office@wpstream.net>
22 */
23 class Wpstream_Admin {
24
25
26 /**
27 * Store plugin main class to allow public access.
28 *
29 * @since 20180622
30 * @var object The main class.
31 */
32 public $main;
33
34
35 /**
36 * The ID of this plugin.
37 *
38 * @since 3.0.1
39 * @access private
40 * @var string $plugin_name The ID of this plugin.
41 */
42 private $plugin_name;
43
44 /**
45 * The version of this plugin.
46 *
47 * @since 3.0.1
48 * @access private
49 * @var string $version The current version of this plugin.
50 */
51 private $version;
52
53 /**
54 * Initialize the class and set its properties.
55 *
56 * @since 3.0.1
57 * @param string $plugin_name The name of this plugin.
58 * @param string $version The version of this plugin.
59 */
60
61 public $global_event_options ;
62
63
64
65
66
67 public function __construct( $plugin_name, $version,$plugin_main ) {
68
69 $this->plugin_name = $plugin_name;
70 $this->version = $version;
71 $this->main = $plugin_main;
72
73 $this->global_event_options = array(
74
75 'record' =>array(
76 'name' => esc_html__('Record Live Stream','wpstream'),
77 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'),
78 'defaults' => 'no',
79
80 ),
81 'view_count' =>array(
82 'name' => esc_html__('Display Viewer Count','wpstream'),
83 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'),
84 'defaults' => 'yes',
85 ),
86 'domain_lock'=>array(
87 'name' => esc_html__('Lock To Website','wpstream'),
88 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),home_url() ),
89 'defaults' => 'yes',
90 ),
91 'autoplay' =>array(
92 'name' => esc_html__('Autoplay','wpstream'),
93 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
94 'defaults' => 'yes',
95 ),
96 'mute' =>array(
97 'name' => esc_html__('Start Muted','wpstream'),
98 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'),
99 'defaults' => 'no',
100
101 ),
102
103 'encrypt' =>array(
104 'name' => esc_html__('Encrypt Live Stream','wpstream'),
105 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'),
106 'defaults' => 'no',
107 ),
108 'ses_encrypt'=>array(
109 'name' => esc_html__('Use Sessions with Encryption','wpstream'),
110 'details' => esc_html__('If enabled, encryption key distribution will be checked against valid user sessions. Setting may malfunction or lead to reduced website performance under certain configurations. ','wpstream'),
111 'defaults' => 'no',
112 ),
113 );
114
115 }
116
117 /**
118 * Register the stylesheets for the admin area.
119 *
120 * @since 3.0.1
121 */
122 public function enqueue_styles() {
123
124 /**
125 * This function is provided for demonstration purposes only.
126 *
127 * An instance of this class should be passed to the run() function
128 * defined in Wpstream_Loader as all of the hooks are defined
129 * in that particular class.
130 *
131 * The Wpstream_Loader will then create the relationship
132 * between the defined hooks and the functions defined in this
133 * class.
134 */
135 wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
136 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
137
138 }
139
140 /**
141 * Register the JavaScript for the admin area.
142 *
143 * @since 3.0.1
144 */
145 public function enqueue_scripts() {
146
147 wp_enqueue_script("jquery-ui-slider");
148 wp_enqueue_script("jquery-ui-datepicker");
149 wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js',array(), WPSTREAM_PLUGIN_VERSION, true);
150 wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js',array(), WPSTREAM_PLUGIN_VERSION, true);
151 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
152 array(
153 'admin_url' => get_admin_url(),
154 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
155 'download_mess' => esc_html__('Click to download!','wpstream'),
156 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
157 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
158 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
159 'upload_complete' => esc_html('Upload Complete!','wpstream'),
160 'no_band' => esc_html('Not enough bandwidth.','wpsteam'),
161 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
162
163 ));
164
165
166
167 wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js',array(), WPSTREAM_PLUGIN_VERSION, true);
168 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
169 array(
170 'admin_url' => get_admin_url(),
171 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
172 'download_mess' => esc_html__('Click to download!','wpstream'),
173 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
174 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
175 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
176 'upload_complete' => esc_html('Upload Complete!','wpstream'),
177 'no_band' => esc_html('Not enough bandwidth.','wpsteam'),
178 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
179
180 ));
181
182 }
183
184
185 /**
186 * Add Plugin Administation menu
187 *
188 * @since 3.0.1
189 */
190
191 public function wpstream_manage_admin_menu() {
192
193 add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
194 add_submenu_page( 'wpstream_plugin_options', __('WpStream Credentials','wpestream'), __('WpStream Credentials','wpestream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
195 add_submenu_page( 'wpstream_plugin_options', __('WpStream Channels','wpestream'), __('WpStream Channels','wpestream'), 'administrator', 'wpstream_new_general_set', array( $this,'wpstream_new_general_set'));
196 add_submenu_page( 'wpstream_plugin_options', __('WpStream Media Management','wpestream'), __('WpStream Media Management','wpestream'), 'administrator', 'wpstream_media_management', array($this,'wpstream_media_management'));
197 add_submenu_page( 'wpstream_plugin_options', __('WpStream Settings','wpestream'), __('WpStream Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings'));
198
199 }
200
201
202
203 /**
204 * Shows events wpstream
205 *
206 * @since 3.0.1
207 */
208
209 public function wpstream_new_general_set() {
210
211 $no_channel=1;
212
213 if(class_exists ('WC_Subscription')){
214
215 }
216
217 //event_passed
218 $args = array(
219 'posts_per_page' => -1,
220 'post_type' => 'product',
221 'post_status' => 'publish',
222 'meta_query' => array(
223 array(
224 'key' => 'event_passed',
225 'value' => 1,
226 'compare' => '!=',
227 )
228 ),
229
230 'tax_query' => array(
231 'relation' => 'AND',
232 array(
233 'taxonomy' => 'product_type',
234 'field' => 'slug',
235 'terms' => array('live_stream','subscription')
236 )
237 ),
238 );
239
240
241
242 $event_list = new WP_Query($args);
243 global $live_event_for_user;
244 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
245 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
246
247 $this->main->show_user_data($pack_details);
248
249
250
251
252 if( $event_list->have_posts()){
253
254
255 print '<div class="pack_details_wrapper_transparent">
256 <h3>'.__('Your Pay-Per-View Channel List','wpstream').'</h3>';
257
258
259 $link_new = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
260
261 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new pay-per-view channel.','wpstream').'</a>';
262 print '</div>';
263
264 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
265
266 while ($event_list->have_posts()): $event_list->the_post();
267
268 $the_id = get_the_ID();
269 $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true));
270 $term_list = wp_get_post_terms($the_id, 'product_type');
271
272 if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){
273 continue;
274 }
275
276 $this->wpstream_live_stream_unit($the_id);
277
278 endwhile;
279
280 print'</div>';
281 $no_channel=1;
282 }else{
283 $no_channel=0;
284 }
285
286
287 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
288 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
289 $current_user = wp_get_current_user();
290 $allowded_html = array();
291 $userID = $current_user->ID;
292 $user_live_streams = get_user_meta($userID,'live_shows');
293
294
295 wp_reset_postdata();
296
297
298
299
300 // free
301
302 $args_free = array(
303 'posts_per_page' => -1,
304 'post_type' => 'wpstream_product',
305 'post_status' => 'publish',
306 'meta_query' => array(
307 'relation' => 'AND',
308 array(
309 'key' => 'wpstream_product_type',
310 'value' => 1,
311 'compare' => '==',
312 ),
313
314 ),
315
316
317 );
318 $event_list_free = new WP_Query($args_free);
319
320
321 if( $event_list_free->have_posts()){
322 print '<div class="pack_details_wrapper_transparent">
323 <h3>'.__('Your Free Channel List','wpstream').'</h3>';
324
325 $link_new = admin_url('post-new.php?post_type=wpstream_product');
326 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new free channel.','wpstream').'</a>';
327 print '</div>';
328 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
329
330 while ($event_list_free->have_posts()): $event_list_free->the_post();
331
332
333 $the_id = get_the_ID();
334
335 if( get_post_meta ($the_id,'event_passed',true)!=1){
336 $this->wpstream_live_stream_unit($the_id);
337 }
338
339 endwhile;
340
341 print'</div>';
342 $no_channel=1;
343 }else{
344 $no_channel=0;
345 }
346
347
348
349
350 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
351 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
352 print '<div class="no_events_warning"> ';
353 if($event_list->found_posts==0){
354 print '<div class="no_events_warning_mes">'.__('* You don\'t have any paid channels!','wpstream').'</div>';
355 }
356 if($event_list_free->found_posts==0){
357 print '<div class="no_events_warning_mes">'. __('* You don\'t have any free channels!','wpstream').'</div>';
358 }
359
360 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new free channel ','wpstream').'</a>';
361 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new pay-per-view channel ','wpstream').'</a>';
362
363 print '</div>';
364
365
366
367
368 }
369 // end wpstream_new_general_set
370
371
372 /**
373 * Social share
374 *
375 * @since 3.0.1
376 */
377
378 public function wpstream_social_share($the_id){
379 $protocol = is_ssl() ? 'https' : 'http';
380 $pinterest = wp_get_attachment_image_src(get_post_thumbnail_id($the_id), 'full');
381 $link = esc_url ( get_permalink($the_id) );
382 $title = get_the_title($the_id);
383 $twiter_status = urlencode( $title.' '.$link);
384 $email_link = 'subject='.urlencode ( $title ) .'&body='. urlencode( esc_url($link));
385
386 print '<div class="wpstream_social_share_wrapper">';
387 print 'Share on: ';?>
388
389 <a href="<?php print esc_html($protocol);?>://www.facebook.com/sharer.php?u=<?php echo esc_url($link); ?>&amp;t=<?php echo urlencode(get_the_title()); ?>" target="_blank" class="social_facebook wpstream_sharing_social">
390 <span class="dashicons dashicons-facebook-alt"></span>
391 </a>
392
393 <a href="<?php print esc_html($protocol);?>://twitter.com/intent/tweet?text=<?php echo esc_html($twiter_status); ?>" class="social_tweet wpstream_sharing_social" target="_blank">
394 <span class="dashicons dashicons-twitter"></span>
395 </a>
396
397 <a href="<?php print esc_html($protocol);?>://pinterest.com/pin/create/button/?url=<?php echo esc_url($link); ?>&amp;media=<?php if (isset( $pinterest[0])){ echo esc_url($pinterest[0]); }?>&amp;description=<?php echo urlencode(get_the_title()); ?>" target="_blank" class="social_pinterest wpstream_sharing_social">
398 <span class="dashicons dashicons-pinterest"></span>
399 </a>
400
401 <a href="<?php print esc_html($protocol);?>://api.whatsapp.com/send?text=<?php echo urlencode( get_the_title().' '. esc_url( $link )); ?>" class="social_whatsup wpstream_sharing_social" target="_blank">
402 <span class="dashicons dashicons-whatsapp"></span>
403 </a>
404
405 <a href="<?php print esc_html($protocol);?>://www.linkedin.com/sharing/share-offsite/?url=<?php echo urlencode(esc_url($link)); ?>" class="social_linkedin wpstream_sharing_social" target="_blank">
406 <span class="dashicons dashicons-linkedin"></span>
407 </a>
408
409 <a href="mailto:email@email.com?<?php echo trim(esc_html($email_link));?>" data-action="share email" class="social_email wpstream_sharing_social">
410 <span class="dashicons dashicons-email-alt"></span>
411 </a>
412
413 <?php
414
415 print '</div>';
416 }
417
418
419
420
421 /**
422 * Shows event unit card in admin
423 *
424 * @since 3.0.1
425 */
426 public function wpstream_live_stream_unit($the_id,$is_front=''){
427 global $live_event_for_user;
428 $current_user = wp_get_current_user();
429
430 if(!current_user_can('administrator')){
431 if($is_front=='' ){
432 print '<div class="event_list_unit">';
433 esc_html_e('You are not allowed to broadcast.','wpstream');
434 print '</div>';
435 return;
436 }
437
438 }
439
440 if( !$this->main->wpstream_check_user_can_stream() ){
441 print '<div class="event_list_unit">';
442 esc_html_e('You are not allowed to broadcast','wpstream');
443 print '</div>';
444 return;
445
446 }
447
448
449 $live_class='';
450 if(isset($live_event_for_user[$the_id])) {
451 $live_class=" wpstream_show_started";
452 }
453
454
455 print '<div class="event_list_unit '.$live_class.' event_unit_style_'.esc_attr($is_front).'">';
456 if(has_post_thumbnail($the_id)){
457 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
458 }else{
459 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_150.png';
460 }
461
462 global $wpstream_plugin;
463
464
465 print '<div class="event_thumb_wrapper"><img class="event_thumb" src="'.$thumb.'" alt="show_imagge"></div>';
466 print '<div class="event_title" data-prodid="'.$the_id.'">'.get_the_title($the_id).' - '.esc_html__('Id','wpstream').': '.$the_id;
467 print '<a class="view_channel" href="'.get_permalink($the_id).'" target="_blank">'.esc_html__('View Channel','wprentals').'</a> ';
468 $this->wpstream_social_share($the_id);
469 print '</div>';
470
471
472 $live_event_stream_name = get_post_meta($the_id,'live_event_stream_name',true);
473 $live_event_array = get_post_meta($the_id,'live_event_uri',true);
474 $live_event_uri = '';
475
476
477 $pending_streaming_class = '';
478 $wpstream_ready_to_stream_class = '';
479 $external_software_streaming_class = '';
480 $wpstream_no_stream_class = '';
481 $carnat_key1 = '';
482 $carnat_key2 = '';
483 $uri = '';
484 $webcaster_url = '';
485 $rtmp_ip_uri = '';
486 $uri_ip = '';
487 $server_id = '';
488 $obs_uri = '';
489 $obs_stream = '';
490 $webCasterUrl = '';
491
492 if( $live_event_for_user=='' && $is_front=='front' ){
493 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
494 }
495
496
497
498 $live_data_url='';
499 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
500
501 $pending_streaming_class = 'show_stream_data pending_trigger';
502 $wpstream_ready_to_stream_class = 'hide_stream_data';
503 $external_software_streaming_class = 'show_stream_data';
504 $wpstream_no_stream_class = 'hide_stream_data';
505 if(isset($live_event_for_user[$the_id]['live_uri'])){
506 $explode = explode('wpstream.net/', $live_event_for_user[$the_id]['live_uri']);
507 $uri = $explode[0].'wpstream.net/wpstream/';
508 $stream_name = get_post_meta($the_id,'live_event_stream_name',true);
509 $carnat_key1 = $live_event_for_user[$the_id]['carnat1'];
510 $carnat_key2 = $live_event_for_user[$the_id]['carnat2'];
511 $webcaster_url = 'https://'.$live_event_for_user[$the_id]['subdomain_key'].'.live.streamer.wpstream.net:8443/'.$live_event_for_user[$the_id]['carnat2'];
512
513 $rtmp_ip_uri = 'http://'.$live_event_for_user[$the_id]['ip'].':8444';
514 $uri_ip= 'rtmp://'.$live_event_for_user[$the_id]['ip'].'/wpstream/';
515
516 // starting from 2.0
517 $server_id = get_post_meta($the_id,'server_id',true);
518 $obs_uri = get_post_meta($the_id,'obs_uri',true);
519 $obs_stream = get_post_meta($the_id,'obs_stream',true);
520 $webCasterUrl= get_post_meta($the_id,'webCasterUrl',true);
521
522 // if local server id diffrens than wpstream server id it means call was made via api and we use wpstream ip
523 if( $server_id != $live_event_for_user[$the_id]['api20_event_id'] && $live_event_for_user[$the_id]['api20_event_id']!='' ){
524
525 $server_id=esc_html($live_event_for_user[$the_id]['api20_event_id']);
526 }
527
528 $live_data_url='https://handy.wpstream.net/liveqos/?datasource='.$server_id.'.live.streamer.wpstream.net&key='.$live_event_for_user[$the_id]['streamKey'];
529 }
530
531 }else{
532
533 $pending_streaming_class = 'hide_stream_data';
534 $wpstream_ready_to_stream_class = 'hide_stream_data';
535 $external_software_streaming_class = 'hide_stream_data';
536 $wpstream_no_stream_class = 'show_stream_data';
537 }
538
539
540
541
542 print' <div class="pending_streaming '.$pending_streaming_class.' " data-show-id="'.$the_id.'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'">';
543 print'<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'.esc_html__('Your Event is starting. Please wait...','wprentals').' ';
544 print '<img class="server_loading_new" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/loading.gif" alt="loading" /></div>';
545 print '<div class="multiple_warning_events"> '.esc_html__('To go Live on a Channel, you need to start an Event. It will stop automatically after an hour of inactivity.','wpstream').'</div>';
546 print '</div>';
547
548
549 print '<div class="wpstream_ready_to_stream '.$wpstream_ready_to_stream_class.'">';
550 print '<div class="wpstream_channel_status"><span class="dashicons dashicons-yes"></span>'.esc_html__('Ready to Go Live !','wpstream').'</div>';
551 print '<div class="start_webcaster wpstream_button" data-webcaster-url="'.$webCasterUrl.'" >'.esc_html__('Go Live from Browser','wpstream').'</div>';
552 print '<div class="start_external wpstream_button" >'.esc_html__('Go Live with External Broadcaster','wpstream').'</div>';
553 print '<a href="'.esc_url($live_data_url).'" class="wpstream_live_data wpstream_button" target="_blank">'.esc_html__('Live Metrics','wpstream').'</a>';
554 print '<div class="stop_server wpstream_button" data-show-id="'.$the_id.'">'.esc_html__('Turn Off Channel','wpstream').'</div>';
555 $ajax_nonce_stop = wp_create_nonce( "wpstream_stop_event_nonce" );
556 print '<input type="hidden" id="wpstream_stop_event_nonce" value="'.$ajax_nonce_stop.'">';
557 print '</div>';
558
559
560
561 print '<div class="external_software_streaming '. $external_software_streaming_class.' ">';
562 print '<div class="event_list_unit_notificationx"><strong>'.__('Server:').' </strong> <div class="wpstream_live_uri_text">' . $obs_uri.'</div><div class="copy_live_uri">'.__('copy to clipboard','wpstream').'</div>';
563 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong><div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy to clipboard','wpstream').'</div></div>';
564 print '<div class="warning_stream">'.
565 sprintf(esc_html__('Use %s on your Windows or Mac computer, or the Larix Broadcaster app on your %s or %s smartphone/tablet. Various other Apps and devices are compatible. See %s for more details.','wpstream'),'<a href="https://obsproject.com/download" target="_blank">OBS Studio</a>','<a href="https://apps.apple.com/us/app/larix-broadcaster/id1042474385" target="_blank"> iOS</a>','<a href="https://play.google.com/store/apps/details?id=com.wmspanel.larix_broadcaster&hl=en" target="_blank">Android</a>','<a href="https://wpstream.net/external-broadcasters/" target="_blank">this page</a>').'</div>';
566 print ' <img class="how_to" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/how_to_obs.jpg" alt="show_imagge">';
567 print'</div>';
568 print'</div>';
569
570
571
572
573 print '<div class="wpstream_no_stream '.$wpstream_no_stream_class.' ">';
574 print '<div class="event_list_unit_notificationx"><span class="server_notification">'.__('Broadcast Offline.','wpestream').' <img class="server_loading" src="'.plugins_url().'/wpstream/img/loading.gif" alt="loading" /></span></div>';
575
576 print '<input class="start_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Start Live Event','wpstream').'">';
577
578 if($is_front==''){
579 // print '<input class="close_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Delete Channel','wpstream').'">';
580 print '<input class="wpstream_show_settings wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">';
581 }
582
583 print '<div class="multiple_warning_events"> '.esc_html__('To go Live on a Channel, you need to start an Event. It will stop automatically after an hour of inactivity.','wpstream').'</div>';
584
585
586
587
588 if($is_front==''){
589
590 $local_event_options = get_post_meta($the_id,'local_event_options',true);
591
592 if(!is_array($local_event_options)){
593 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
594 }
595
596
597 print '<div class="wpstream_event_streaming_local">';
598
599 $this->user_streaming_global_channel_options('',$local_event_options,'ses_encrypt');
600 print '</div>';
601
602
603
604 print '<div class="wpstream_social_media_broadcast">';
605
606 print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_facebook" id="wpstream_on_facebook'.$the_id.'"><label for="wpstream_on_facebook'.$the_id.'">'.esc_html__('Stream on Facebook','wpstream').'</label>';
607 print '</div>';
608
609 print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_youtube" id="wpstream_on_youtube'.$the_id.'"><label for="wpstream_on_youtube'.$the_id.'">'.esc_html__('Stream on Youtube','wpstream').'</label>';
610 print '</div>';
611
612
613 print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_twich" id="wpstream_on_twich'.$the_id.'"><label for="wpstream_on_twich'.$the_id.'">'.esc_html__('Stream on Twich','wpstream').'</label>';
614 print '</div>';
615
616 print '<div class="wpstream_on_facebook_container wpstream_social_stream_container">';
617 print 'Some Facebook Settings for event '.$the_id;
618 print '</div>';
619
620 print '<div class="wpstream_on_youtube_container wpstream_social_stream_container">';
621 print '<label for="wpstream_youtube_rtmp'.$the_id.'">'.esc_html__('Youtube RTMP','wpstream').'</label>';
622 print '<input type="text" class="wpstream_youtube_rtmp" id="wpstream_youtube_rtmp'.$the_id.'" value="'.esc_html(get_post_meta($the_id,'wpstream_youtube_rtmp',true )).'">';
623 print '</div>';
624
625 print '<div class="wpstream_on_twich_container wpstream_social_stream_container">';
626 print '<label for="wpstream_twich_rtmp'.$the_id.'">'.esc_html__('Twich RTMP','wpstream').'</label>';
627 print '<input type="text" class="wpstream_twich_rtmp" id="wpstream_twich_rtmp'.$the_id.'" value="'.esc_html(get_post_meta($the_id,'wpstream_twich_rtmp',true )).'">';
628 print '</div>';
629
630
631 print '</div>';
632 }
633 print '</div>';
634
635
636 print '</div>';
637 }
638
639
640
641 public function wpstream_show_settings_per_event(){
642
643 }
644
645
646
647 /**
648 * Set Settings
649 *
650 *
651 */
652
653 public function wpstream_settings(){
654
655 if($_SERVER['REQUEST_METHOD'] === 'POST'){
656 $allowed_html = array();
657 $exclude_array = array();
658 $allowed_html = array();
659
660
661
662 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
663 update_option( sanitize_key('wpstream_stream_role'), '' );
664 }
665
666 foreach($_POST as $variable=>$value){
667 if ($variable!='submit'){
668 if (!in_array($variable, $exclude_array) ){
669 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
670 }
671
672 if($variable=='stream_role'){
673 update_option( sanitize_key('wpstream_stream_role'), $value );
674 }
675
676 }
677 }
678
679
680 if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){
681 $event_settings=array();
682 foreach($this->global_event_options as $key=>$option){
683 $event_settings[$key]='';
684 if(isset($_POST['wpstream_event_set_'.$key]) && $_POST['wpstream_event_set_'.$key]=='on'){
685 $event_settings[$key]=1;
686 }else{
687 $event_settings[$key]=0;
688 }
689 }
690 update_option('wpstream_user_streaming_global_channel_options',$event_settings);
691 }
692
693
694
695
696 // reset permalinkgs
697 global $wp_rewrite;
698
699 update_option( "rewrite_rules", FALSE );
700 $wp_rewrite->flush_rules( true );
701
702 }
703
704 $wpstream_settings_array =array(
705 1 => array(
706 'tab' => 'general_options',
707 'label' => esc_html__('Slug for free video/channel pages ','wpstream'),
708 'name' => 'free_media_slug',
709 'type' => 'text',
710 'details' => esc_html__('This will replace the default "wpstream" of all your free video/channel urls. Special characters like "&" are not permitted. To have your new slug show up you need to re-save the "Permalinks Settings" under Settings -> Permalinks, even if not making any changes.','wpstream'),
711 ),
712
713 2 => array(
714 'tab' => 'general_options',
715 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'),
716 'name' => 'stream_role',
717 'type' => 'user_roles',
718 'details' => esc_html__('These types of users can stream via frontend shortcodes / blocks. Single individual channels are automaticlally created for streaming by non-admins.','wpstream'),
719
720 ),
721 3 => array(
722 'tab' => 'general_options',
723 'label' => esc_html__('Non Admin Streamers Channel Type.','wpstream'),
724 'name' => 'user_streaming_channel_type',
725 'type' => 'select',
726 'select_values'=>array(
727 'free' => esc_html__('Free Live Channel','wpstream'),
728 'paid' => esc_html__('Pay-Per-View','wpstream')
729 ),
730 'details' => esc_html__('Choose whether the channels assigned to non-admins are free-for-all or pay-per-view (WooCommerce product).','wpstream'),
731 ),
732
733 4 => array(
734 'tab' => 'general_options',
735 'label' => esc_html__('Default Pay-Per-View Price','wpstream'),
736 'name' => 'user_streaming_default_price',
737 'type' => 'text',
738 'details' => esc_html__('Default price of pay-per-view channels assigned to non-admins.','wpstream'),
739 ),
740
741
742
743 6 => array(
744 'tab' => 'subscription_options',
745 'label' => esc_html__('Use Global Subscription Mode','wpstream'),
746 'name' => 'global_sub',
747 'type' => 'slidertoogle',
748 'details' => esc_html__('If enabled, a client can access all the media products (live and VOD) by purchasing a single subscription. The "WooCommerce Subscriptions" plugin is required.','wpstream'),
749 ),
750
751 7 => array(
752 'tab' => 'subscription_options',
753 'label' => esc_html__('Subscription ID for Global Subscription Mode','wpstream'),
754 'name' => 'global_sub_id',
755 'type' => 'text',
756 'details' => esc_html__('ID of the subscription product to be purchased for global access to media. All non-subscription video products that are not already attached to a subscription will be accessible to users that have purchased it.','wpstream'),
757 ),
758 8 => array(
759 'tab' => 'messages_options',
760 'label' => esc_html__('PPV not logged in message','wpstream'),
761 'name' => 'product_not_login',
762 'type' => 'text',
763 'details' => esc_html__('This message will be displayed on top of the media player for pay-per-view items when user is not logged in.','wpstream'),
764 'default' => esc_html__('You must be logged in to watch this video.','wpstream'),
765 ),
766 9 => array(
767 'tab' => 'messages_options',
768 'label' => esc_html__('PPV not purchased message','wpstream'),
769 'name' => 'product_not_bought',
770 'type' => 'text',
771 'details' => esc_html__('This message will be displayed on top of the media player for common pay-per-view items that have not been purchased.','wpstream'),
772 'default' => esc_html__('You did not yet purchase this item.','wpstream'),
773 ),
774 10 => array(
775 'tab' => 'messages_options',
776 'label' => esc_html__('Subscription not purchased message','wpstream'),
777 'name' => 'product_not_subscribe',
778 'type' => 'text',
779 'details' => esc_html__('This message will be displayed on top of the media player for subscription-type pay-per-view items that have not been purchased.','wpstream'),
780 'default' => esc_html__(' You did not yet subscribe to this item.','wpstream'),
781 ),
782 11 => array(
783 'tab' => 'messages_options',
784 'label' => esc_html__('Thank you message','wpstream'),
785 'name' => 'product_thankyou',
786 'type' => 'text',
787 'details' => esc_html__('This message will be displayed on the thank you page (after purchase) and the confirmation email.','wpstream'),
788 'default' => esc_html__('Thanks for your purchase. You can access your item at any time by visiting the following page: {item_link}','wpstream'),
789 ),
790
791 12 => array(
792 'tab' => 'messages_options',
793 'label' => esc_html__('Thank you message','wpstream'),
794 'name' => 'subscription_active',
795 'type' => 'text',
796 'details' => esc_html__('This message will be displayed on subscription product page.','wpstream'),
797 'default' => esc_html__('Your Subscription is Active','wpstream'),
798 ),
799
800 99 => array(
801 'tab' => 'default_options',
802 'label' => esc_html__('Events Options ','wpstream'),
803 'name' => 'user_streaming_global_channel_options',
804 'type' => 'user_streaming_global_channel_options',
805 'details' => esc_html__('Global Options for live events.','wpstream'),
806 ),
807 );
808
809 $active_tab = 'general_options';
810 if( isset( $_GET[ 'tab' ] ) ) {
811 $active_tab = $_GET[ 'tab' ];
812 }
813
814
815 print '<div class="theme_options_tab_wpstream" style="display:block;" >
816 <h1>'.__('WpStream Settings','wpstream').'</h1>
817 <form method="post" action="" >';
818
819 print '<h2 class="nav-tab-wrapper">
820 <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">General Options</a>
821 <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">Default Channel Settings</a>
822 <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : ''; echo '">Subscription Options</a>
823 <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">Customize Messages</a>
824
825 </h2>';
826
827 print '<div class="wpstream_option_wrapper">';
828 foreach ($wpstream_settings_array as $key=>$option){
829 if($option['tab']!=$active_tab){
830 continue;
831 }
832
833 print '<div class="wpstream_option">';
834 $options_value = get_option('wpstream_'.$option['name']) ;
835
836
837 if($option['type']=='user_roles'){
838
839 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
840 print $this->wpstream_select_user_roles($option['name'],$options_value);
841 print '<div class="settings_details">'.$option['details'].'</div>';
842
843 }else if($option['type']=='user_streaming_global_channel_options'){
844
845 // print '<label style="margin:20px 0px;font-size:20px;" >'.esc_html('Default Channel Settings','wpstream').'</label>';
846 $this->user_streaming_global_channel_options($option['name'],$options_value);
847
848
849 }else if($option['type']=='text'){
850
851 if($options_value==''){
852 $options_value=$option['default'];
853 }
854
855 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
856 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
857 print '<div class="settings_details">'.$option['details'].'</div>';
858
859 } else if($option['type']=='select'){
860
861 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
862 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
863 foreach($option['select_values'] as $key=>$value){
864 print '<option value="'.$key.'" ';
865 if( $key == esc_html($options_value) ){
866 print ' selected ';
867 }
868 print '>'.$value.'</option>';
869 }
870 print '</select>';
871 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
872 print '<div class="settings_details">'.$option['details'].'</div>';
873
874 } else if($option['type']=='slidertoogle'){
875 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
876 print '<label class="wpstream_switch">
877 <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" >
878 <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" ';
879
880 if( intval($options_value) !==0 ){
881 print ' checked ';
882 }
883
884
885
886 print '> <span class="slider round"></span>';
887 print '</label>';
888 print '<div class="settings_details">'.$option['details'].'</div>';
889 }
890 print '</div>';
891 }
892 print '</div>';
893
894
895 print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
896
897
898 print '</form>';
899 print '</div>';
900
901 }
902
903
904
905 /**
906 * Set user roles
907 *
908 * @since 3.0.1
909 */
910 public function user_streaming_global_channel_options($name,$value,$local=''){
911
912
913
914 foreach($this->global_event_options as $key=>$option){
915
916 if( $local != $key){
917 print '<div class="wpstream_setting_event_unit_wrapper">';
918
919 print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
920
921 print '
922 <label class="wpstream_switch">
923 <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
924 if( isset($value[$key]) ){
925 if( intval($value[$key]) !==0 ){
926 print ' checked ';
927 }
928 }else{
929 if($option['defaults']=='yes') {
930 print ' checked ';
931 }
932 }
933
934
935 print '> <span class="slider round"></span>';
936 print '</label>';
937 print '<div class="settings_details">'.$option['details'].'</div>';
938
939
940 print '</div>';
941 }
942 }
943
944
945 }
946
947
948
949 /**
950 * Set user roles
951 *
952 * @since 3.0.1
953 */
954 public function wpstream_select_user_roles($name,$value){
955 if($value==''){
956 $value=array();
957 }
958
959 $roles = get_editable_roles();
960 $return = '<select id="wpstream_user_roles" name="'.esc_html($name).'[]" multiple>';
961 unset( $roles['administrator'] );
962
963 foreach ($roles as $key=>$role){
964 $return .= '<option value="'.$key.'" ';
965 if( in_array($key, $value) ){
966 $return .= ' selected ';
967 }
968 $return .= '>'.$role['name'].'</option>';
969 }
970 $return .= '</select>';
971
972
973 return $return;
974 }
975
976
977 /**
978 * Set credential admin function
979 *
980 * @since 3.0.1
981 */
982 public function wpstream_set_wpstream_credentials(){
983
984 if($_SERVER['REQUEST_METHOD'] === 'POST'){
985 $allowed_html = array();
986 $exclude_array = array();
987 $allowed_html = array();
988
989 foreach($_POST as $variable=>$value){
990 if ($variable!='submit'){
991 if (!in_array($variable, $exclude_array) ){
992 update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
993 }
994 }
995 }
996
997
998
999
1000 update_option('wp_estate_token_expire',0);
1001 update_option('wp_estate_curent_token',' ');
1002 delete_transient( 'wpstream_token_request');
1003
1004 }
1005
1006
1007 $allowed_html = array();
1008 $api_key = esc_html( get_option('wpstream_api_key','') );
1009
1010
1011 $wpstream_options_array =array(
1012 2 => array(
1013 'label' => 'WpStream.net Username or Email',
1014 'name' => 'api_username',
1015 'type' => 'text',
1016 ),
1017 3 => array(
1018 'label' => 'WpStream.net Password',
1019 'name' => 'api_password',
1020 'type' => 'password',
1021 ),
1022
1023 );
1024
1025
1026 $token = $this->main->wpstream_live_connection->wpstream_get_token();
1027 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1028
1029 $this->main->show_user_data($pack_details);
1030
1031 print '<form method="post" action="" >';
1032 print '<div class="theme_options_tab_wpstream" style="display:block;" >
1033 <h1>'.__('WpStream Credentials','wpstream').'</h1>';
1034
1035
1036 if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== ' '){
1037 echo '<div class="api_not_conected wpstream_orange">'.__('To connect your plugin, enter your WpStream credentials below or go <a href="https://wpstream.net/my-account/" target="_blank">here</a> to create an account.','wpstream').'</div>';
1038 }else if($token==''){
1039 echo '<div class="api_not_conected">'.__(' Incorrect username or password. Please check your credentials or go <a href="https://wpstream.net/my-account/edit-account/" target="_blank">here</a> to reset your password.','wpstream').'</div>';
1040 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
1041 echo '<div class="api_conected">'.__('Conected to WpStream.net!','wpstream').'</div>';
1042 }else{
1043 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
1044 }
1045 print '<div class="wpstream_option_wrapper">';
1046 foreach ($wpstream_options_array as $key=>$option){
1047 print '<div class="wpstream_option">';
1048
1049 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
1050 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1051 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
1052
1053 print '</div>';
1054 }
1055 print '</div>';
1056
1057
1058 print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
1059
1060 print '<h3>Video Tutorials</h3>';
1061
1062 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/9DQrxsKcpmQ">How to Live Stream to WordPress with OBS</a>';
1063 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/qMSjJCskAfM">How to Live Stream to WordPress in less than 3 Minutes</a>';
1064 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/h6myD_vhKcg">How to Live-Stream to WordPress using your iPhone</a>';
1065
1066 print '<a style="margin-top:10px;" href="https://www.youtube.com/channel/UCIjItiJc4Z7aJApj3W6ArJA" target="_blank" class="how_to_videos">More Tutorials On Our YouTube Channel</a>';
1067
1068
1069 print '</div>';
1070 print '</form>';
1071
1072 print '<div class="theme_options_tab_wpstream" style="display:block;" >';
1073 $link_new = admin_url('admin.php?page=wpstream_new_general_set');
1074 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
1075 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
1076
1077
1078 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new free channel','wpstream').'</a>';
1079 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create pay-per-view channel','wpstream').'</a>';
1080 print '<a href="'.esc_url($link_new).'" class="wpstream_no_chanel_add_channel">'.esc_html('My Channels','wpstream').'</a>';
1081 print '</div>';
1082
1083
1084 }
1085
1086
1087
1088 /**
1089 * Media Management
1090 *
1091 * @since 3.0.1
1092 */
1093 public function wpstream_media_management(){
1094 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1095
1096 $this->main->show_user_data($pack_details);
1097
1098
1099 print '<div id="wpstream_media_upload"><h3>'.__('Media Upload','wpstream').'</h3>'.$this->wpstream_present_media_upload().'</div>';
1100
1101 print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Video Management','wpstream').'</h3>'.$this->wpstream_present_file_management().'</div>';
1102
1103 }
1104
1105
1106
1107 /**
1108 * Media upload
1109 *
1110 * @since 3.0.1
1111 */
1112 public function wpstream_present_media_upload(){
1113 $to_return='';
1114 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
1115
1116 if($formInputs === 'notenough'){
1117 $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough bandwidth or storage to upload a video!','wpstream').'</div>';
1118 return $to_return;
1119 }
1120
1121
1122 $to_return.='<div class="wpstream_upload_container">';
1123 $to_return.='<div id="wpstream_uploaded_mes">'.esc_html__('Please select or drop a video file. Do not close this window during the upload!','wpstream').'</div>';
1124 $to_return.='<form action="https://wpstream-videos.s3.amazonaws.com/"
1125 method="POST"
1126 enctype="multipart/form-data"
1127 class="direct-upload">';
1128
1129 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
1130 $to_return.='<label for="wpstream_upload"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span id="wpstream_label_action">Choose a file&hellip;</span></label>';
1131
1132
1133 $to_return.='<div class="wpstream_file_drop_color">';
1134 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
1135 $to_return.='<div class="wpstream_form_ex_details">'.esc_html__('The Video File must be encoded with the following settings:
1136
1137 Container: MP4,
1138 Video codec: H264,
1139 Audio codec: AAC. Media will fail to play back if it does not follow the above settings.
1140 You may use a tool like MediaInfo to verify your file. Also you may convert it with specialized software like HandBrake.','wpstream').'<strong>'.esc_html__('Accepted file extensions: .mp4, .mov .','wpstream').'</strong></div>';
1141 if(is_array($formInputs)){
1142 foreach ($formInputs as $name => $value) {
1143 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
1144 }
1145 }
1146
1147 $to_return.='
1148 <div class="progress-bar-area"></div></div>
1149 </form>';
1150
1151 $to_return.='</div>';
1152 return $to_return;
1153
1154 }
1155
1156
1157
1158 /**
1159 * Display movie list
1160 *
1161 * @since 3.0.1
1162 */
1163 public function wpstream_present_file_management(){
1164 $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_storage_raw_data();
1165
1166 $to_return='';
1167
1168 if(is_array($video_list_raw)){
1169 foreach ($video_list_raw as $key =>$video){
1170
1171
1172 $video_size = intval($video['size']/1048576);
1173 $to_return.='<div class="wpstream_video_wrapper">';
1174
1175 $to_return.='<div class="wpstream_video_title">';
1176 $to_return.='<div class="wpstream_video_notice"></div></div>';
1177 $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video['video_name_storage'].'</span><span class="storage_file_size">'.$video_size.' MB </span></div>';
1178 $to_return.=' <div class="wpstream_delete_media" ';
1179 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video['video_name_storage'].'?\')" data-filename="'.$video['video_name_storage'].'">'.esc_html__('delete file','wpstream').'</div>';
1180 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video['video_name_storage'].'">'.esc_html__('get download link','wpstream').'</div>';
1181 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
1182
1183 $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product').'&new_video_name='. rawurlencode($video['video_name_storage']);
1184 $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video['video_name_storage']);
1185
1186
1187
1188 $to_return .='<a class="create_new_free_video" href="'.esc_url($add_free_video_url).'">'.esc_html__('Create new free VOD from this video').'</a>';
1189 $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create pay-per-view VOD from this video').'</a>';
1190
1191 $to_return.='</div>';
1192
1193 }
1194 } else {
1195 $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
1196 }
1197 return $to_return;
1198 }
1199
1200
1201
1202
1203
1204 /**
1205 * save meta options
1206 *
1207 * @since 3.0.1
1208 */
1209 public function wpstream_free_product_update_post($post_id,$post){
1210
1211 if(!is_object($post) || !isset($post->post_type)) {
1212 return;
1213 }
1214
1215 if($post->post_type!='wpstream_product'){
1216 return;
1217 }
1218
1219
1220 $allowed_keys=array(
1221 'wpstream_product_type',
1222 'wpstream_free_video',
1223 'wpstream_free_video_external'
1224 );
1225
1226 $allowed_html=array();
1227
1228 foreach ($_POST as $key => $value) {
1229 if( !is_array ($value) ){
1230 if (in_array ($key, $allowed_keys)) {
1231 $postmeta = wp_kses ( $value,$allowed_html );
1232 update_post_meta($post_id, sanitize_key($key), $postmeta );
1233 }
1234 }
1235 }
1236 }
1237
1238
1239 /**
1240 * save meta options
1241 *
1242 * @since 3.0.1
1243 */
1244 public function add_wpstream_product_metaboxes() {
1245 add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Live Channel/Video Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product' ,'normal','default');
1246 }
1247
1248
1249 /**
1250 * make woocomerce virtual products
1251 *
1252 * @since 3.0.1
1253 */
1254
1255
1256 public function wpstream_make_product_virtual($post_id,$post){
1257 global $post;
1258 if(isset($post->ID)){
1259 if ( $post->post_type !== 'product' ) return;
1260 $term_list = wp_get_post_terms($post->ID, 'product_type');
1261 if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
1262 update_post_meta( $post->ID, '_virtual', 'yes' );
1263 }
1264 }
1265 }
1266
1267
1268
1269 /**
1270 * render meta options
1271 *
1272 * @since 3.0.1
1273 */
1274 public function display_meta_options( $post ) {
1275 wp_nonce_field( plugin_basename( __FILE__ ), 'estate_agent_noncename' );
1276 global $post;
1277
1278 $is_live = '';
1279 $is_video = '';
1280 $is_video_external = '';
1281 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
1282 $is_video = ' selected ';
1283 $wpstream_free_video = esc_html( $_GET['new_video_name']);
1284 }else{
1285 $wpstream_product_type = esc_html(get_post_meta($post->ID, 'wpstream_product_type', true));
1286 $wpstream_free_video = esc_html(get_post_meta($post->ID, 'wpstream_free_video', true));
1287
1288 if($wpstream_product_type==1){
1289 $is_live = ' selected ';
1290 }
1291
1292 if($wpstream_product_type==2){
1293 $is_video = ' selected ';
1294 }
1295
1296 if($wpstream_product_type==3){
1297 $is_video_external = ' selected ';
1298 }
1299 }
1300
1301 print'
1302 <p class="meta-options">
1303 <label for="wpstream_product_type">'.__('Media Type:','wpstream').' </label><br />
1304 <select id="wpstream_product_type" name="wpstream_product_type">
1305 <option value="1" '.$is_live.'>'.__('Free Live Channel - encrypted streaming & copy protection','wpstream').'</option>
1306 <option value="2" '.$is_video.'>'.__('Free Video - encrypted streaming & copy protection','wpstream').'</option>
1307 <option value="3" '.$is_video_external.'>'.__('Free Video - unprotected','wpstream').'</option>
1308 </select>
1309 </p>
1310 ';
1311
1312
1313
1314 print '
1315 <p class="meta-options video_free">
1316 <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
1317 <select id="wpstream_free_video" name="wpstream_free_video">';
1318 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
1319
1320 if(is_array($video_list)){
1321 foreach ($video_list as $key=>$value){
1322 print '<option value="'.$key.'"';
1323 if($wpstream_free_video === $key){
1324 print ' selected ';
1325 }
1326 print '>'.$value.'</option>';
1327 }
1328 }
1329 print'
1330 </select>
1331 </p>
1332 ';
1333
1334 $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
1335 print '<p class="meta-options1 video_free_external">
1336 <label for="wpstream_free_video_external">'.__('Choose video:','wpstream').' </label><br />
1337
1338 <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
1339 <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />
1340
1341 <p>'.esc_html__('You can choose a video from your computer or use the url from external source or use the url of a YouTube Video or use the url from a Vimeo video.','wpstream').'</p>
1342
1343 </p> ';
1344 }
1345
1346
1347
1348
1349
1350
1351
1352 /**
1353 * Add new product types to Woocommerce select product type
1354 *
1355 * @since 3.0.1
1356 */
1357 public function wpstream_add_products( $types ){
1358 $types[ 'live_stream' ] = __( 'Live Channel','wpestream' );
1359 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
1360
1361 return $types;
1362 }
1363
1364
1365
1366 /**
1367 * Js action to do when user pick live stream or video on demand
1368 *
1369 * @since 3.0.1
1370 */
1371
1372 public function wpstream_products_custom_js() {
1373 if ( 'product' != get_post_type() ) :
1374 return;
1375 endif;
1376
1377 ?>
1378 <script type='text/javascript'>
1379 jQuery( document ).ready( function() {
1380 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
1381 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
1382 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
1383 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
1384 jQuery('._sold_individually_field').show();
1385
1386 var selected = jQuery('#product-type').val();
1387 });
1388 </script>
1389 <?php
1390
1391 }
1392
1393
1394 /**
1395 * Add custom classes to the product types
1396 *
1397 * @since 3.0.1
1398 */
1399
1400 public function wpstream_hide_attributes_data_panel( $tabs) {
1401
1402 $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand';
1403 $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1404 // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1405
1406 return $tabs;
1407 }
1408
1409
1410
1411 /**
1412 * Hide buy now on products if Netflix mode
1413 *
1414 * @since 3.12
1415 */
1416
1417
1418 public function wpstream_hide_buy_now_subscription_mode( $purchaseable_product_wpblog,$product){
1419 $product_id=$product->get_id();
1420
1421 $term_list = wp_get_post_terms($product_id, 'product_type');
1422
1423 $subscription_model = esc_html( get_option('wpstream_global_sub',true)) ;
1424
1425 if($subscription_model==1){ // if we have Neflix mode
1426 if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' ){
1427 return false;
1428 }
1429 }
1430
1431 return $purchaseable_product_wpblog;
1432 }
1433
1434
1435
1436
1437
1438
1439 /**
1440 * Add custom fields to custom product types
1441 *
1442 * @since 3.0.1
1443 */
1444
1445 public function wpstream_add_custom_general_fields() {
1446
1447 global $woocommerce, $post;
1448 if(function_exists('wcs_user_has_subscription')){
1449 echo '<div class="options_group show_if_subscription">';
1450 woocommerce_wp_select(
1451 array(
1452 'id' => '_subscript_live_event',
1453 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ),
1454 'options' => array("yes"=>"yes","no"=>"no")
1455 )
1456 );
1457 echo '</div>';
1458 }
1459
1460 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
1461 echo '<div class="options_group show_if_video_on_demand">';
1462 $selected='';
1463 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
1464 $selected=esc_html($_GET['new_video_name']);
1465 }
1466 if($selected==''){
1467 $selected= get_post_meta($post->ID,'_movie_url',true);
1468 }
1469
1470 woocommerce_wp_select(
1471 array(
1472 'id' => '_movie_url',
1473 'label' => __( 'Library video file', 'woocommerce' ),
1474 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
1475 'selected'=> true,
1476 'value' => $selected
1477 )
1478 );
1479
1480
1481
1482 echo '</div>';
1483
1484 if(function_exists('wcs_user_has_subscription')){
1485 $selected_sub='';
1486 echo '<div class="options_group show_if_video_on_demand show_if_live_stream">';
1487 if( isset( $_GET['wpstream_parent_sub']) && $_GET['wpstream_parent_sub']!='' ){
1488 $selected_sub=esc_html($_GET['wpstream_parent_sub']);
1489 }
1490 if($selected_sub==''){
1491 $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
1492 }
1493 woocommerce_wp_select(
1494 array(
1495 'id' => '_wpstream_parent_sub',
1496 'name' => '_wpstream_parent_sub[]',
1497 'label' => __( 'Attach to subscription', 'woocommerce' ),
1498 'options' => $this->wpstream_return_subscriptions_created(),
1499 'selected'=> true,
1500 'value' => $selected_sub,
1501 'custom_attributes' => array('multiple' => 'multiple')
1502 )
1503 );
1504
1505 echo '</div>';
1506
1507 }
1508 }
1509
1510
1511 public function wpstream_return_subscriptions_created(){
1512 $return=array('0'=>'none');
1513
1514 $args = array(
1515 'post_type' => 'product',
1516 'posts_per_page' => -1,
1517 'orderby' => 'title',
1518 'order' => 'ASC',
1519 'tax_query' => array(
1520 'relation' => 'AND',
1521 array(
1522 'taxonomy' => 'product_type',
1523 'field' => 'slug',
1524 'terms' => array( 'subscription'),
1525 )
1526 )
1527 );
1528
1529 $subscriptions = new WP_Query($args);
1530 if($subscriptions->have_posts()):
1531 while ($subscriptions->have_posts()): $subscriptions->the_post();
1532 $return[ get_the_ID() ] = get_the_title();
1533 endwhile;
1534 endif;
1535
1536 wp_reset_postdata();
1537 return $return;
1538
1539 }
1540
1541
1542
1543
1544
1545
1546 /**
1547 * Save custom fields
1548 *
1549 * @since 3.0.1
1550 */
1551
1552 public function wpstream_add_custom_general_fields_save( $post_id ){
1553
1554 $permited_values = array(
1555 '_movie_url',
1556 '_subscript_live_event',
1557 '_wpstream_parent_sub',
1558
1559 );
1560
1561
1562
1563 foreach($_POST as $key=>$value){
1564 update_post_meta( $post_id, 'event_passed', 0 );
1565 if( in_array($key, $permited_values) ){
1566 if( !empty( $_POST[$key] ) ){
1567 $key = sanitize_key($key);
1568 $value = sanitize_text_field($_POST[$key]);
1569
1570 if($key=='_wpstream_parent_sub'){
1571 $value= $_POST[$key];
1572 $value = array_map("sanitize_text_field", $value);
1573
1574 }
1575 update_post_meta( $post_id, $key, $value );
1576 }
1577 }
1578 }
1579 //die();
1580
1581 }
1582
1583 /**
1584 * Add to cart redirect
1585 *
1586 * @since 3.0.1
1587 */
1588
1589 public function wpstream_add_to_cart() {
1590 wc_get_template( 'single-product/add-to-cart/simple.php' );
1591 }
1592
1593
1594 /**
1595 * Replace add to cart button
1596 *
1597 * @since 3.0.1
1598 */
1599 public function replacing_add_to_cart_button( $button, $product ) {
1600 global $product;
1601 $product_type = $product->get_type();
1602
1603 if($product_type==='live_stream' || $product_type=='video_on_demand'){
1604 return $button = '<a class="button" href="'.get_site_url().'/shop/?add-to-cart=' .$product->get_id(). '&quantity=1">' . __( 'Add to Cart', 'woocommerce' ) . '</a>';
1605 }else{
1606 return $button;
1607 }
1608 }
1609
1610
1611 /**
1612 * Admin notices
1613 *
1614 * @since 3.0.1
1615 */
1616 public function wpstream_admin_notice() {
1617 global $pagenow;
1618 global $typenow;
1619
1620 $wpstream_notices = get_option('wpstream_notices');
1621
1622
1623 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
1624 if( !is_array($wpstream_notices) ||
1625 !isset($wpstream_notices['wpstream_woo_notice']) ||
1626 ( isset($wpestate_notices['wpstream_woo_notice']) && $wpestate_notices['wpstream_woo_notice']!='yes') ){
1627
1628
1629 print '<div class="notice wpstream_notices notice-error is-dismissible" data-notice-type="wpstream_woo_notice" >
1630 <p>'.__( 'WpStream Pay-Per-View Live Streaming and VOD only works with WooCommerce - Please enable and activate the WooCommerce plugin if you want to monetize your Live Events or Recorded Videos', 'wpstream' ).'</p>
1631 </div>';
1632 }
1633 }
1634
1635 if( !in_array ('curl', get_loaded_extensions())) {
1636 print '<div class="notice notice-error is-dismissible">
1637 <p>'.__( 'The php CURL library is not enabled on your server. WpStream plugin needs this library in order to work. Please address this issue with your hosting provider.', 'wpstream' ).'</p>
1638 </div>';
1639 }
1640
1641
1642 $wpestate_notices = get_option('wp_stream_notices');
1643
1644 if( !is_array($wpestate_notices) ||
1645 !isset($wpestate_notices['wpstream_update_1021']) ||
1646 ( isset($wpestate_notices['wpstream_update_1021']) && $wpestate_notices['wpstream_update_1021']!='yes') ){
1647
1648 print '<div id ="setting-error-wprentals-cache" data-notice-type="wpstream_update_1021" data-dismissible="disable-done-notice-forever" class="wpestate_notices updated settings-error notice is-dismissible">
1649 <p>'.esc_html__('New! We just released WpStream WordPress Theme - a turn key solution for video delivery & live streaming. This theme is built around WpStream plugin and is the perfect solution for video streaming or rentals platform. ','wpstream').'<a href="https://wpstream.net/wpstream-theme-a-live-streaming-wordpress-theme" target="_blank">'.esc_html__('Download Theme','wpstream').'</a></p>
1650 </div>';
1651 }
1652
1653
1654
1655
1656
1657 $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
1658 print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
1659
1660 }
1661
1662 /**
1663 * Admin notices
1664 *
1665 * @since 3.0.1
1666 */
1667 public function wpstream_update_cache_notice(){
1668
1669 //check_ajax_referer( 'wpstream_notice_nonce', 'security' );
1670
1671 $notice_type = esc_html($_POST['notice_type']);
1672 $notices = get_option('wp_stream_notices');
1673
1674 if(! is_array($notices) ){
1675 $notices=array();
1676 }
1677
1678 $notices[$notice_type]='yes';
1679
1680 update_option('wpstream_notices',$notices);
1681 die();
1682 }
1683
1684
1685
1686 /**
1687 * Activate metaboxes for Streaming controls on sidebar
1688 *
1689 * @since 3.0.1
1690 */
1691 public function wpstream_startstreaming_sidebar_meta() {
1692 global $post;
1693 $term_list = wp_get_post_terms($post->ID, 'product_type');
1694 if( get_post_meta($post->ID, 'wpstream_product_type', true)==1 ){
1695 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
1696 }
1697
1698 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
1699
1700
1701 if(!is_wp_error( $term_list )){
1702 if( isset($term_list[0]->name) ){
1703 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
1704 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'product', 'side', 'high');
1705 }
1706 }
1707 }
1708
1709 }
1710
1711 /**
1712 * Show Streaming controls on sidebar
1713 *
1714 * @since 3.0.1
1715 */
1716 public function wpstream_start_stream_meta(){
1717 global $live_event_for_user;
1718 global $post;
1719
1720 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
1721 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
1722 $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user();
1723 $this->wpstream_live_stream_unit($post->ID);
1724
1725 }
1726 }