PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.5.11.5
WpStream – Live Streaming, Video on Demand, Pay Per View v4.5.11.5
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 4.5.11.5, at admin/class-wpstream-admin.php

3,549 lines 176.7 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
74
75 $this->global_event_options = array(
76
77 'record' =>array(
78 'name' => esc_html__('Record Live Stream','wpstream'),
79 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'),
80 'defaults' => 'no',
81
82 ),
83 'view_count' =>array(
84 'name' => esc_html__('Display Viewer Count','wpstream'),
85 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'),
86 'defaults' => 'yes',
87 ),
88 'domain_lock'=>array(
89 'name' => esc_html__('Lock To Website','wpstream'),
90 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
91 'defaults' => 'no',
92 ),
93 'autoplay' =>array(
94 'name' => esc_html__('Autoplay','wpstream'),
95 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
96 'defaults' => 'yes',
97 ),
98 'mute' =>array(
99 'name' => esc_html__('Start Muted','wpstream'),
100 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'),
101 'defaults' => 'no',
102
103 ),
104 'low_latency' =>array(
105 'name' => esc_html__('Low Latency (beta)','wpstream'),
106 'details' => esc_html__('Shortens the live delay between streamer and viewers. Useful for interactive applications like gaming, auctions, trading etc. Low latency may worsen the viewer experience on some devices.','wpstream'),
107 'defaults' => 'no',
108 ),
109 'adaptive_bitrate' =>array(
110 'name' => esc_html__('Adaptive Bitrate (beta)','wpstream'),
111 'details' => esc_html__('Ensures a smooth and uninterrupted viewing experience by adjusting video quality for viewers with reduced network speed or device capabilities.','wpstream'),
112 'defaults' => 'no',
113 ),
114 'encrypt' =>array(
115 'name' => esc_html__('Encrypt Live Stream','wpstream'),
116 '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'),
117 'defaults' => 'no',
118 ),
119 'ses_encrypt'=>array(
120 'name' => esc_html__('Use Sessions with Encryption','wpstream'),
121 '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'),
122 'defaults' => 'no',
123 ),
124 'autostart' =>array(
125 'name' => esc_html__('Auto TURN ON','wpstream'),
126 'details' => esc_html__('If enabled, channel will TURN ON automatically when broadcasting with an External Streaming App (RTMP Encoder/Broadcaster)','wpstream'),
127 'defaults' => 'no',
128 ),
129
130
131 );
132
133 }
134
135 /**
136 * Register the stylesheets for the admin area.
137 *
138 * @since 3.0.1
139 */
140 public function enqueue_styles() {
141
142 /**
143 * This function is provided for demonstration purposes only.
144 *
145 * An instance of this class should be passed to the run() function
146 * defined in Wpstream_Loader as all of the hooks are defined
147 * in that particular class.
148 *
149 * The Wpstream_Loader will then create the relationship
150 * between the defined hooks and the functions defined in this
151 * class.
152 */
153 wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
154 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
155
156 wp_enqueue_style( 'wpstream-on-boarding-css', plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css', array(), rand(1,999999999999), 'all' );
157
158
159 }
160
161 /**
162 * Register the JavaScript for the admin area.
163 *
164 * @since 3.0.1
165 */
166 public function enqueue_scripts() {
167
168 wp_enqueue_script("jquery-ui-slider");
169 wp_enqueue_script("jquery-ui-datepicker");
170 wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
171 wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
172 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
173 array(
174 'admin_url' => get_admin_url(),
175 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
176 'download_mess' => esc_html__('Click to download!','wpstream'),
177 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
178 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
179 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
180 'upload_complete' => esc_html('Upload Complete!','wpstream'),
181 'no_band' => esc_html('Not enough streaming data.','wpsteam'),
182 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam')
183
184 ));
185
186
187
188 wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
189 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
190 array(
191 'admin_url' => get_admin_url(),
192 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
193 'download_mess' => esc_html__('Click to download!','wpstream'),
194 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
195 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
196 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
197 'upload_complete' => esc_html('Upload Complete!','wpstream'),
198 'no_band' => esc_html('Not enough streaming data.','wpsteam'),
199 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam'),
200
201 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'),
202 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'),
203 'start_streaming' => esc_html__('TURN ON','wpstream'),
204 'stop_streaming' => esc_html__('TURN OFF','wpstream'),
205 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'),
206 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'),
207 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'),
208 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'),
209 'error1' => esc_html__('You don\'t have enough data to start a new event!','wpstream'),
210 'failed_event_creation' => esc_html__('Failed to start the channel. Please try again in a few minutes.','wpstream'),
211 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'),
212 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'),
213 'channel_on' => esc_html__('Channel is ON','wpstream'),
214 'channel_off' => esc_html__('Channel is OFF','wpstream'),
215 'turn_off_confirm' => esc_html__('ARE YOU SURE you\'d like to TURN OFF the channel now? '.PHP_EOL.PHP_EOL.'Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).'.PHP_EOL.PHP_EOL.'Manual TURN OFF is only useful if you require to change the channel settings immediately.'.PHP_EOL.PHP_EOL.'Statistics may be unavailable or incomplete for up to an hour.'.PHP_EOL.PHP_EOL.'If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.','wpstream')
216 ));
217
218
219 wp_enqueue_script('wpstream-on-boarding-js', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
220 wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars',
221 array(
222 'admin_url' => get_admin_url(),
223 'plugin_url' => get_dashboard_url().'/plugins.php',
224 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings'
225
226 ));
227
228 }
229
230
231 /**
232 * Add Plugin Administation menu
233 *
234 * @since 3.0.1
235 */
236
237 public function wpstream_manage_admin_menu() {
238
239 add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials'), WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png',20 );
240 add_submenu_page( 'wpstream_credentials', __('WpStream Credentials','wpestream'), __('Credentials','wpestream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials') );
241 add_submenu_page( 'wpstream_credentials', __('WpStream Live Channels','wpestream'), __('All Channels','wpestream'), 'administrator', 'wpstream_live_channels', array( $this,'wpstream_new_general_set'));
242 add_submenu_page( 'wpstream_credentials', __('WpStream Recordings','wpestream'), __('Recordings','wpestream'), 'administrator', 'wpstream_recordings', array($this,'wpstream_media_management'));
243 add_submenu_page( 'wpstream_credentials', __('WpStream Settings','wpestream'), __('Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings'));
244
245 add_submenu_page( 'wpstream_credentials', __('WpStream Quick Start','wpestream'), __('WpStream Quick Start','wpestream'), 'administrator', 'wpstream_onboard', array($this,'wpstream_pre_onboard_display'));
246
247
248
249
250 }
251
252
253
254
255 /**
256 * Shows events wpstream
257 *
258 * @since 3.0.1
259 */
260
261 public function wpstream_new_general_set() {
262
263 $no_channel=1;
264
265 if(class_exists ('WC_Subscription')){
266
267 }
268
269 //event_passed
270 $args = array(
271 'posts_per_page' => -1,
272 'post_type' => 'product',
273 'post_status' => 'publish',
274 'meta_query' => array(
275 array(
276 'key' => 'event_passed',
277 'value' => 1,
278 'compare' => '!=',
279 )
280 ),
281
282 'tax_query' => array(
283 'relation' => 'AND',
284 array(
285 'taxonomy' => 'product_type',
286 'field' => 'slug',
287 'terms' => array('live_stream','subscription')
288 )
289 ),
290 );
291
292
293
294 $event_list = new WP_Query($args);
295 global $live_event_for_user;
296 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
297 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
298
299 $this->main->show_user_data($pack_details);
300 if( $event_list->have_posts()){
301
302
303 print '<div class="pack_details_wrapper_transparent">
304 <h3>'.__('Your Pay-Per-View Channel List','wpstream').'</h3>';
305
306
307 $link_new = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
308
309 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new Pay-Per-View channel.','wpstream').'</a>';
310 print '</div>';
311
312 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
313
314 while ($event_list->have_posts()): $event_list->the_post();
315
316 $the_id = get_the_ID();
317 $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true));
318 $term_list = wp_get_post_terms($the_id, 'product_type');
319
320 if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){
321 continue;
322 }
323
324 $this->wpstream_live_stream_unit($the_id);
325
326 endwhile;
327
328 print'</div>';
329 $no_channel=1;
330 }else{
331 $no_channel=0;
332 }
333
334
335 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
336 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
337 $current_user = wp_get_current_user();
338 $allowded_html = array();
339 $userID = $current_user->ID;
340 $user_live_streams = get_user_meta($userID,'live_shows');
341
342
343 wp_reset_postdata();
344
345
346
347
348 // free
349
350 $args_free = array(
351 'posts_per_page' => -1,
352 'post_type' => 'wpstream_product',
353 'post_status' => 'publish',
354
355
356 );
357 $event_list_free = new WP_Query($args_free);
358
359
360 if( $event_list_free->have_posts()){
361 print '<div class="pack_details_wrapper_transparent">
362 <h3>'.__('Free-To-View Channels','wpstream').'</h3>';
363
364 $link_new = admin_url('post-new.php?post_type=wpstream_product');
365 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new Free-To-View channel.','wpstream').'</a>';
366 print '</div>';
367 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
368
369 while ($event_list_free->have_posts()): $event_list_free->the_post();
370
371
372 $the_id = get_the_ID();
373
374 if( get_post_meta ($the_id,'event_passed',true)!=1){
375 $this->wpstream_live_stream_unit($the_id);
376 }
377
378 endwhile;
379
380 print'</div><div class="wpstream_modal_background"></div>';
381 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
382 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
383 </div>';
384 $no_channel=1;
385 }else{
386 $no_channel=0;
387 }
388
389
390
391
392 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
393 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
394 print '<div class="no_events_warning"> ';
395 if($event_list->found_posts==0){
396 print '<div class="no_events_warning_mes">'.__('* You do not have any Pay-Per-View channels!','wpstream').'</div>';
397 }
398 if($event_list_free->found_posts==0){
399 print '<div class="no_events_warning_mes">'. __('* You do not have any free channels!','wpstream').'</div>';
400 }
401
402 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new Free-To-View channel ','wpstream').'</a>';
403 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new Pay-Per-View channel ','wpstream').'</a>';
404
405 print '</div>';
406
407
408
409
410 }
411 // end wpstream_new_general_set
412
413
414 /**
415 * Social share
416 *
417 * @since 3.0.1
418 */
419
420 public function wpstream_social_share($the_id){
421 $protocol = is_ssl() ? 'https' : 'http';
422 $pinterest = wp_get_attachment_image_src(get_post_thumbnail_id($the_id), 'full');
423 $link = esc_url ( get_permalink($the_id) );
424 $title = get_the_title($the_id);
425 $twiter_status = urlencode( $title.' '.$link);
426 $email_link = 'subject='.urlencode ( $title ) .'&body='. urlencode( esc_url($link));
427
428 $facebook_link = esc_html($protocol).'://www.facebook.com/sharer.php?u='. esc_url($link) .'&amp;t='. urlencode(get_the_title());
429
430 ?>
431 <div class="wpstream_social_share_wrapper">
432
433 <a href="<?php print esc_url( $facebook_link); ?>" target="_blank" class="social_facebook wpstream_sharing_social">
434 <span class="dashicons dashicons-facebook-alt"></span>
435 </a>
436
437 <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">
438 <span class="dashicons dashicons-twitter"></span>
439 </a>
440
441 <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">
442 <span class="dashicons dashicons-pinterest"></span>
443 </a>
444
445 <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">
446 <span class="dashicons dashicons-whatsapp"></span>
447 </a>
448
449 <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">
450 <span class="dashicons dashicons-linkedin"></span>
451 </a>
452
453 <a href="<?php print esc_html($protocol);?>:///www.reddit.com/submit?url==<?php echo urlencode(esc_url($link)); ?>" class="social_linkedin wpstream_sharing_social" target="_blank">
454 <span class="dashicons dashicons-reddit"></span>
455 </a>
456
457 <a href="mailto:email@email.com?<?php echo trim(esc_html($email_link));?>" data-action="share email" class="social_email wpstream_sharing_social">
458 <span class="dashicons dashicons-email-alt"></span>
459 </a>
460
461 <div class="wpstream_modal_explanations"> <?php print esc_html__('Spread the word! To let people know about your channel, click on the corresponding icon and share on the social platforms of your choice. The more the merrier!','wpstream'); ?> </div>
462 <?php
463 print '</div>';
464 }
465
466
467
468
469 /**
470 * Shows event unit card in admin
471 *
472 * @since 3.0.1
473 */
474
475 public function wpstream_live_stream_unit($the_id,$is_front=''){
476 global $live_event_for_user;
477 global $wpstream_plugin;
478 $current_user = wp_get_current_user();
479
480 if( !current_user_can('administrator')){
481 if($is_front=='' ){
482 print '<div class="event_list_unit">';
483 esc_html_e('You are not allowed to broadcast.','wpstream');
484 print '</div>';
485 return;
486 }
487
488 }
489
490 if( !$this->main->wpstream_check_user_can_stream() ){
491 print '<div class="event_list_unit">';
492 esc_html_e('You are not allowed to broadcast','wpstream');
493 print '</div>';
494 return;
495 }
496
497
498 $live_class='';
499 if(isset($live_event_for_user[$the_id])) {
500 $live_class=" wpstream_show_started";
501 }
502
503
504 if(has_post_thumbnail($the_id)){
505 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
506 }else{
507 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
508 }
509
510 $pending_streaming_class = 'hide_stream_data';
511 $external_software_streaming_class = '';
512 $obs_uri = '';
513 $obs_stream = '';
514 $live_data_url = '';
515
516 if( $live_event_for_user=='' && $is_front=='front' ){
517 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
518 }
519 $channel_status = esc_html__('Channel is OFF','wpstream');
520 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
521 $pending_streaming_class = 'pending_trigger';
522 $live_data_url = get_post_meta($the_id,'qos_url',true);
523 // $channel_status = esc_html__('Channel is on','wpstream');
524 }
525
526 $server_id = get_post_meta($the_id,'server_id',true);
527 $obs_uri = get_post_meta($the_id,'obs_uri',true);
528 $obs_stream = get_post_meta($the_id,'obs_stream',true);
529 $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
530 $rtmp_ip_uri = '';
531
532 print '<div class="event_list_unit '.$live_class.' '.$pending_streaming_class.' event_unit_style_'.esc_attr($is_front).'" data-show-id="'.intval($the_id).'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'"">';
533
534 print '<div class="wpstream_channel_status">'.$channel_status.'</div>';
535
536 print '<div class="server_notification"></div>';
537
538 print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
539
540 print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10);
541
542
543 /* print '***</br>'.get_post_meta($the_id,'obs_uri',true) .'***</br>'.
544 get_post_meta($the_id,'obs_stream',true).'***</br>'.
545 get_post_meta($the_id,'broadcast_url',true);
546 */
547 print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
548 print '</div>';
549
550
551 print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream');
552 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
553 print '</div>';
554
555 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
556
557 print '<div class="wpstream_inactive_icon start_webcaster wpstream_stream_browser wpstream-button-icon wpstream_tooltip_wrapper" data-webcaster-url="'.$webcaster_url.'" data-show-id="'.$the_id.'"">';
558
559 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
560 print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
561
562 print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
563 <path d="M40.7646 44.2989C39.8782 41.4216 38.3361 38.7814 36.181 36.4522C35.7274 35.9619 35.1629 35.3518 34.4858 34.8356C34.0448 34.4996 33.4262 34.5281 33.0182 34.9035C29.358 38.2714 25.2628 39.9088 20.4979 39.9088H20.4853C15.7103 39.9059 11.6117 38.264 7.95648 34.889C7.52404 34.4896 6.85874 34.484 6.41953 34.8764C3.30565 37.6569 1.20501 40.9206 0.175434 44.5778C-0.276291 46.1833 0.15652 47.8497 1.33328 49.0353C2.22709 49.9362 3.39869 50.4173 4.61958 50.4173C5.0357 50.4173 5.45813 50.3613 5.87645 50.247C10.147 49.081 14.0772 48.4108 17.8916 48.1983C21.1954 48.014 24.4465 48.1323 27.5541 48.5495C29.9559 48.8718 32.4237 49.3888 35.0996 50.1299C36.823 50.6076 38.459 50.1562 39.7059 48.86C40.9268 47.5901 41.2933 46.0132 40.7651 44.2994L40.7646 44.2989ZM38.0572 47.274C37.3825 47.9754 36.6367 48.1823 35.7092 47.9257C32.9321 47.1565 30.3638 46.6187 27.8578 46.2827C24.6079 45.8465 21.2117 45.723 17.7643 45.9151C13.7874 46.1365 9.70183 46.8319 5.27439 48.041C4.43435 48.2706 3.5673 48.0403 2.9568 47.425C2.35932 46.8227 2.14793 46.0108 2.37712 45.1975C3.21567 42.2171 4.7982 39.6162 7.2018 37.2734C11.0641 40.5378 15.5276 42.193 20.4845 42.196H20.4978C25.4557 42.196 29.9251 40.5386 33.7967 37.2667C34.024 37.4904 34.254 37.7359 34.5032 38.0059C36.4236 40.0816 37.7951 42.4256 38.5799 44.9728C38.8603 45.8811 38.6941 46.6125 38.0581 47.274L38.0572 47.274ZM20.4954 30.7538C13.8088 30.7523 8.54664 25.4128 8.54379 18.6256C8.5412 12.2624 13.9961 6.83353 20.3776 6.84872C27.1094 6.86467 32.4526 12.1652 32.4488 18.8231C32.4447 25.4243 27.1038 30.7547 20.4954 30.7538V30.7538ZM29.4401 18.8383C29.5559 13.9512 25.4358 9.8445 20.5347 9.83671C15.5301 9.82892 11.6488 13.9279 11.5328 18.5667C11.4086 23.5202 15.344 27.7103 20.3381 27.7926C25.5542 27.8783 29.554 23.5758 29.4401 18.8383V18.8383ZM20.4917 25.1342C17.2131 25.2436 14.1541 22.4349 14.1567 18.8924C14.1593 15.2627 16.9642 12.4191 20.5858 12.4662C24.0109 12.5111 26.8269 15.2466 26.8362 18.8471C26.8451 22.4293 23.782 25.2436 20.4917 25.1342V25.1342ZM18.5119 13.9982C17.3006 13.9908 15.6202 15.656 15.6295 16.8543C15.6328 17.3209 15.961 17.661 16.3983 17.6513C17.5973 17.6246 19.2281 16.0169 19.2696 14.8205C19.2881 14.2742 19.0371 14.0016 18.5119 13.9982L18.5119 13.9982ZM20.4964 0.568359C10.4428 0.568359 2.26333 8.74761 2.26333 18.8014C2.26333 28.8551 10.4426 37.0345 20.4964 37.0345C30.5502 37.0345 38.7295 28.8553 38.7295 18.8014C38.7291 8.7478 30.5502 0.568359 20.4964 0.568359V0.568359ZM20.4964 33.3886C12.4528 33.3886 5.90919 26.8449 5.90919 18.8014C5.90919 11.3105 11.585 5.12093 18.8624 4.30631C18.8561 4.36009 18.8528 4.41423 18.8528 4.46912C18.8468 5.37368 19.6112 6.16064 20.4927 6.15846C21.3636 6.15586 22.1283 5.39706 22.142 4.52143C22.1431 4.44874 22.1372 4.3768 22.1279 4.30596C29.4067 5.11929 35.0849 11.3092 35.0849 18.802C35.0842 26.8456 28.5404 33.3892 20.4968 33.3892L20.4964 33.3886Z" fill="black"/>
564 </svg>';
565 print '</div>';
566
567
568 print '<div class="wpstream_inactive_icon wpstream_stream_pro wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_broadcast_modal" data-show-id="'.$the_id.'"">';
569
570 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
571 print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
572
573 print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
574 <path d="M48.1266 13.9634L41.891 17.5343V13.6438C41.891 10.8723 39.6525 8.63384 36.8811 8.63384H33.1504L30.1124 3.62393C28.7268 1.3324 26.2751 0 23.6103 0H10.2863C8.84722 0 7.67471 1.17251 7.67471 2.6116C7.67471 4.05068 8.84722 5.22319 10.2863 5.22319H23.6103C24.4631 5.22319 25.2093 5.64961 25.6888 6.3957L27.0744 8.63413L5.00991 8.63376C2.23843 8.63376 0 10.8722 0 13.6437V32.9901C0 35.7616 2.23843 38 5.00991 38H36.9342C39.7057 38 41.9441 35.7616 41.9441 32.9901V29.0461L48.1797 32.6169C49.2991 33.2564 50.6846 32.4571 50.6846 31.1778L50.6842 15.4022C50.6311 14.123 49.2455 13.3237 48.1261 13.9632L48.1266 13.9634ZM38.1603 32.9368C38.1603 33.6297 37.574 34.1625 36.9345 34.1625L5.01029 34.1629C4.31733 34.1629 3.78458 33.5766 3.78458 32.9372V13.5907C3.78458 12.8978 4.37086 12.365 5.01029 12.365H36.9345C37.6275 12.365 38.1603 12.9513 38.1603 13.5907V32.9368Z" fill="black"/>
575 <path d="M22.4917 21.585H9.70066C8.84784 21.585 8.15527 22.2779 8.15527 23.1304V28.247C8.15527 29.0998 8.84823 29.7923 9.70066 29.7923H22.4917C23.3445 29.7923 24.0371 29.0994 24.0371 28.247V23.1304C24.0371 22.2775 23.3445 21.585 22.4917 21.585Z" fill="black"/>
576 </svg>';
577 print '</div>';
578
579
580
581
582 print '<a href="'.esc_url($live_data_url).'" target="_blank" class="wpstream_inactive_icon wpstream_live_data wpstream_statistics_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" >';
583
584 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
585 print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
586
587 print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
588 <path fill-rule="evenodd" clip-rule="evenodd" d="M48.9001 9.02344H40.3342C39.7288 9.02344 39.2344 9.51791 39.2344 10.1233V40.4275C39.2344 41.033 39.7288 41.5274 40.3342 41.5274H48.9001C49.5055 41.5274 50 41.0329 50 40.4275V10.1233C50 9.51791 49.5055 9.02344 48.9001 9.02344V9.02344Z" fill="black"/>
589 <path fill-rule="evenodd" clip-rule="evenodd" d="M35.821 22.4067H27.2551C26.6497 22.4067 26.1553 22.9012 26.1553 23.5066V40.4277C26.1553 41.0332 26.6497 41.5276 27.2551 41.5276H35.821C36.4264 41.5276 36.9209 41.0332 36.9209 40.4277V23.5066C36.9209 22.9012 36.4264 22.4067 35.821 22.4067V22.4067Z" fill="black"/>
590 <path fill-rule="evenodd" clip-rule="evenodd" d="M22.7439 0H14.178C13.5726 0 13.0781 0.494478 13.0781 1.09989V40.4275C13.0781 41.0329 13.5726 41.5274 14.178 41.5274H22.7439C23.3493 41.5274 23.8438 41.0329 23.8438 40.4275V1.09989C23.8438 0.49447 23.3493 0 22.7439 0V0Z" fill="black"/>
591 <path fill-rule="evenodd" clip-rule="evenodd" d="M9.66573 15.2559H1.09987C0.49445 15.2559 -2.24584e-05 15.7512 -2.24584e-05 16.3558V40.4285C-2.24584e-05 41.0331 0.495325 41.5284 1.09987 41.5284H9.66573C10.2703 41.5284 10.7656 41.034 10.7656 40.4285V16.3558C10.7656 15.7503 10.2711 15.2559 9.66573 15.2559V15.2559Z" fill="black"/>
592 </svg>';
593 print '</a>';
594 print '</div>';
595
596 print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
597 if($is_front==''){
598 print '<div class="wpstream_show_settings wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_settings_modal" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">';
599
600 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
601 print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
602
603 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
604 <path d="M49.22 21.8648C48.82 21.6099 45.665 19.7247 44.415 19.15L42.8651 15.4C43.3251 14.1601 44.2099 10.6849 44.3652 10.0798H44.3649C44.4911 9.52035 44.3213 8.93514 43.9149 8.52987L41.47 6.09995C41.0658 5.69189 40.4795 5.52168 39.9201 5.65003C39.4601 5.75501 35.92 6.64994 34.5999 7.15012L30.8499 5.60021C30.3048 4.40012 28.4699 1.32529 28.1351 0.795199V0.79485C27.8337 0.301688 27.298 0.00069643 26.7201 0H23.2798C22.7057 0.000348769 22.1718 0.294715 21.8648 0.779859C21.6098 1.1799 19.7247 4.33487 19.15 5.58487L15.4 7.13478C14.1601 6.67476 10.6849 5.78996 10.0798 5.63469V5.63504C9.52035 5.50878 8.93513 5.67864 8.52987 6.08496L6.09995 8.52988C5.69189 8.9341 5.52168 9.52042 5.65003 10.0798C5.75501 10.5398 6.64994 14.0799 7.15012 15.4L5.60021 19.15C4.40012 19.6951 1.32529 21.53 0.795198 21.8648H0.79485C0.301688 22.1662 0.00069643 22.7019 0 23.2798V26.7149C0.000348751 27.2893 0.294715 27.8233 0.779858 28.1299C1.1799 28.3849 4.33486 30.27 5.58487 30.8448L7.13478 34.5948C6.67475 35.8347 5.78996 39.3099 5.63469 39.915H5.63504C5.50878 40.4747 5.67863 41.06 6.08496 41.4649L8.51487 43.8948V43.8951C8.9191 44.3032 9.50541 44.4731 10.0648 44.3451C10.5248 44.2401 14.0649 43.3451 15.385 42.845L19.135 44.3949C19.6801 45.595 21.515 48.6698 21.8498 49.1999C22.1525 49.6997 22.6956 50.0035 23.2798 50H26.7149C27.2893 49.9996 27.8233 49.7053 28.1299 49.2201C28.3849 48.8201 30.27 45.6651 30.8447 44.4151L34.5947 42.8652C35.8347 43.3252 39.3098 44.21 39.9149 44.3653V44.3649C40.4747 44.4912 41.0599 44.3213 41.4649 43.915L43.8948 41.4851H43.8951C44.3032 41.0809 44.473 40.4945 44.345 39.9352C44.2401 39.4751 43.3451 35.9351 42.8449 34.615L44.3949 30.865C45.5949 30.3198 48.6698 28.485 49.1999 28.1501C49.6997 27.8474 50.0034 27.3044 49.9999 26.7201V23.2799C50.0045 22.7047 49.7087 22.1683 49.2201 21.8649L49.22 21.8648ZM24.9995 35.8845C22.1099 35.882 19.3399 34.7314 17.2985 32.6866C15.2572 30.6414 14.1118 27.8694 14.1146 24.9798C14.1171 22.0903 15.2676 19.3199 17.3125 17.2785C19.3577 15.2372 22.1297 14.0921 25.0193 14.0946C27.9088 14.0974 30.6792 15.2477 32.7205 17.2928C34.7619 19.338 35.907 22.1101 35.9045 24.9996C35.8978 27.8879 34.7462 30.6557 32.7021 32.6964C30.6576 34.7367 27.8876 35.8834 24.9994 35.8845H24.9995Z" fill="black"/>
605 </svg>
606 </div>';
607
608
609 print '<a href="'.get_edit_post_link($the_id).'" class="wpstream_edit_channel wpstream-button-icon wpstream_tooltip_wrapper" target="_blank" data-show-id="'.$the_id.'"">';
610 print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
611 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
612 <path d="M44.8203 1.79549C42.4263 -0.598498 38.5591 -0.598498 36.1651 1.79549L4.67494 33.2246C4.55203 33.3475 4.49079 33.4088 4.42954 33.5317C4.42954 33.5317 4.42954 33.5929 4.36829 33.5929C4.30705 33.7159 4.24539 33.7771 4.24539 33.9V33.9613L0.0711091 47.5886C-0.113044 48.264 0.0711092 48.9389 0.500659 49.4301C0.868966 49.7984 1.29852 49.9826 1.78973 49.9826C1.97388 49.9826 2.15804 49.9826 2.34219 49.9213L15.9085 45.747H15.9697C16.0926 45.6858 16.2151 45.6858 16.2768 45.6241C16.2768 45.6241 16.338 45.6241 16.338 45.5629C16.4609 45.5016 16.5834 45.44 16.6451 45.3175L48.0742 13.8884C50.4682 11.4944 50.4682 7.62715 48.0742 5.23316L44.8203 1.79549Z" fill="black"/>
613 </svg>';
614 print '</a>';
615 }
616
617 print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
618 print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
619 print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
620 <path d="M18.6201 15.2828H21.8752C21.8752 14.069 22.8681 13.0207 24.1373 13.0207V9.76562C21.1032 9.76562 18.6201 12.2487 18.6201 15.2828Z" fill="black"/>
621 <path d="M24.855 0C12.9378 0 3.28272 10.9792 0.579292 14.3447C-0.193097 15.2826 -0.193097 16.662 0.579292 17.6553C3.28282 21.0208 12.9378 32 24.855 32C36.7722 32 46.4273 21.0208 49.1307 17.6553C49.9031 16.7174 49.9031 15.338 49.1307 14.3447C46.4275 10.9792 36.7722 0 24.855 0V0ZM24.855 25.8205C19.4482 25.8205 15.0344 21.4067 15.0344 15.9999C15.0344 10.5931 19.4482 6.17927 24.855 6.17927C30.2618 6.17927 34.6756 10.5931 34.6756 15.9999C34.6756 21.4067 30.2618 25.8205 24.855 25.8205Z" fill="black"/>
622 </svg>';
623 print '</a>';
624
625
626 print '<div class="wpstream_share_channel wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_share_modal" data-show-id="'.$the_id.'"">';
627 print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
628 print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
629 <path d="M20.0777 20.5087L24.3481 17.9427C26.6432 16.5645 29.4554 16.2443 31.96 17.198C33.443 17.7642 35.1166 17.9363 36.852 17.6105C40.3163 16.9521 43.1162 14.1831 43.8115 10.7248C45.0606 4.51597 39.7751 -0.910703 33.5907 0.12835C30.2924 0.682061 27.5604 3.16211 26.5942 6.36168C26.4405 6.86646 26.3418 7.35835 26.2804 7.84466C25.9482 10.5028 24.2498 12.8044 21.9547 14.1827L19.3458 15.7456C17.1061 17.0869 14.3986 17.1792 11.9494 16.2748C10.9956 15.9241 9.96159 15.7271 8.88507 15.7271C3.39004 15.7271 -0.960663 20.7607 0.184097 26.4527C0.879447 29.911 3.67936 32.68 7.14364 33.3384C8.87902 33.6706 10.5525 33.492 12.0356 32.9259C14.5402 31.9721 17.3461 32.2919 19.6475 33.6706L23.906 36.2241C25.346 37.0855 26.2195 38.6424 26.2195 40.3159V40.3403C26.2195 45.8229 31.2287 50.1611 36.9018 49.0472C40.3602 48.3703 43.1415 45.583 43.8244 42.1246C44.9383 36.451 40.6 31.4423 35.1175 31.4423C34.0406 31.4423 33.007 31.6394 32.0532 31.9901C29.604 32.8944 26.9029 32.8022 24.6627 31.4608L20.0721 28.7038C18.6445 27.8484 17.7706 26.304 17.7706 24.6364V24.5875C17.7642 22.9208 18.6441 21.37 20.0777 20.5085L20.0777 20.5087Z" fill="black"/>
630 </svg>';
631 print '</div>';
632 print '</div>';
633
634
635
636
637
638
639 $this->wpstream_display_modal_seetings($the_id);
640 $this->wpstream_display_modal_share($the_id);
641 $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
642
643 print '</div>';
644
645 }
646
647
648
649
650 /**
651 * Shows event unit card in admin - theme version
652 *
653 * @since 3.0.1
654 */
655 public function wpstream_live_stream_unit_for_theme($the_id,$is_front=''){
656 global $live_event_for_user;
657 global $wpstream_plugin;
658 $current_user = wp_get_current_user();
659
660 if( !current_user_can('administrator')){
661 if($is_front=='' ){
662 print '<div class="event_list_unit">';
663 esc_html_e('You are not allowed to broadcast.','wpstream');
664 print '</div>';
665 return;
666 }
667
668 }
669
670 if( !$this->main->wpstream_check_user_can_stream() ){
671 print '<div class="event_list_unit">';
672 esc_html_e('You are not allowed to broadcast','wpstream');
673 print '</div>';
674 return;
675 }
676
677
678 $live_class='';
679 if(isset($live_event_for_user[$the_id])) {
680 $live_class=" wpstream_show_started";
681 }
682
683
684 if(has_post_thumbnail($the_id)){
685 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
686 }else{
687 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
688 }
689
690 $pending_streaming_class = 'hide_stream_data';
691 $external_software_streaming_class = '';
692 $obs_uri = '';
693 $obs_stream = '';
694 $live_data_url = '';
695
696 if( $live_event_for_user=='' && $is_front=='front' ){
697 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
698 }
699 $channel_status = esc_html__('Channel is OFF','wpstream');
700 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
701 $pending_streaming_class = 'pending_trigger';
702 $live_data_url = get_post_meta($the_id,'qos_url',true);
703 // $channel_status = esc_html__('Channel is on','wpstream');
704 }
705
706 $server_id = get_post_meta($the_id,'server_id',true);
707 $obs_uri = get_post_meta($the_id,'obs_uri',true);
708 $obs_stream = get_post_meta($the_id,'obs_stream',true);
709 $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
710 $rtmp_ip_uri = '';
711
712 print '<div class="wpstream_theme_event_list_unit event_list_unit '.$live_class.' '.$pending_streaming_class.' event_unit_style_'.esc_attr($is_front).'" data-show-id="'.intval($the_id).'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'"">';
713
714 print '<div class="wpstream_channel_status">'.$channel_status.'</div>';
715
716 print '<div class="server_notification"></div>';
717
718 print '<div class="wpstream_theme_event_thumb_wrapper">';
719 print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
720 print '<div class="event_title" data-prodid="'.$the_id.'">remove: '.wp_trim_words(get_the_title($the_id),10);
721 print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
722 print '</div>';
723 print '</div>';
724
725 print '<div class="wpstream_theme_control_bar_wrapper">';
726
727
728 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
729
730 print '<div class="wpstream_inactive_icon start_webcaster wpstream_stream_browser wpstream-button-icon wpstream_tooltip_wrapper" data-webcaster-url="'.$webcaster_url.'" data-show-id="'.$the_id.'"">';
731
732 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
733 print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
734
735 print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
736 <path d="M40.7646 44.2989C39.8782 41.4216 38.3361 38.7814 36.181 36.4522C35.7274 35.9619 35.1629 35.3518 34.4858 34.8356C34.0448 34.4996 33.4262 34.5281 33.0182 34.9035C29.358 38.2714 25.2628 39.9088 20.4979 39.9088H20.4853C15.7103 39.9059 11.6117 38.264 7.95648 34.889C7.52404 34.4896 6.85874 34.484 6.41953 34.8764C3.30565 37.6569 1.20501 40.9206 0.175434 44.5778C-0.276291 46.1833 0.15652 47.8497 1.33328 49.0353C2.22709 49.9362 3.39869 50.4173 4.61958 50.4173C5.0357 50.4173 5.45813 50.3613 5.87645 50.247C10.147 49.081 14.0772 48.4108 17.8916 48.1983C21.1954 48.014 24.4465 48.1323 27.5541 48.5495C29.9559 48.8718 32.4237 49.3888 35.0996 50.1299C36.823 50.6076 38.459 50.1562 39.7059 48.86C40.9268 47.5901 41.2933 46.0132 40.7651 44.2994L40.7646 44.2989ZM38.0572 47.274C37.3825 47.9754 36.6367 48.1823 35.7092 47.9257C32.9321 47.1565 30.3638 46.6187 27.8578 46.2827C24.6079 45.8465 21.2117 45.723 17.7643 45.9151C13.7874 46.1365 9.70183 46.8319 5.27439 48.041C4.43435 48.2706 3.5673 48.0403 2.9568 47.425C2.35932 46.8227 2.14793 46.0108 2.37712 45.1975C3.21567 42.2171 4.7982 39.6162 7.2018 37.2734C11.0641 40.5378 15.5276 42.193 20.4845 42.196H20.4978C25.4557 42.196 29.9251 40.5386 33.7967 37.2667C34.024 37.4904 34.254 37.7359 34.5032 38.0059C36.4236 40.0816 37.7951 42.4256 38.5799 44.9728C38.8603 45.8811 38.6941 46.6125 38.0581 47.274L38.0572 47.274ZM20.4954 30.7538C13.8088 30.7523 8.54664 25.4128 8.54379 18.6256C8.5412 12.2624 13.9961 6.83353 20.3776 6.84872C27.1094 6.86467 32.4526 12.1652 32.4488 18.8231C32.4447 25.4243 27.1038 30.7547 20.4954 30.7538V30.7538ZM29.4401 18.8383C29.5559 13.9512 25.4358 9.8445 20.5347 9.83671C15.5301 9.82892 11.6488 13.9279 11.5328 18.5667C11.4086 23.5202 15.344 27.7103 20.3381 27.7926C25.5542 27.8783 29.554 23.5758 29.4401 18.8383V18.8383ZM20.4917 25.1342C17.2131 25.2436 14.1541 22.4349 14.1567 18.8924C14.1593 15.2627 16.9642 12.4191 20.5858 12.4662C24.0109 12.5111 26.8269 15.2466 26.8362 18.8471C26.8451 22.4293 23.782 25.2436 20.4917 25.1342V25.1342ZM18.5119 13.9982C17.3006 13.9908 15.6202 15.656 15.6295 16.8543C15.6328 17.3209 15.961 17.661 16.3983 17.6513C17.5973 17.6246 19.2281 16.0169 19.2696 14.8205C19.2881 14.2742 19.0371 14.0016 18.5119 13.9982L18.5119 13.9982ZM20.4964 0.568359C10.4428 0.568359 2.26333 8.74761 2.26333 18.8014C2.26333 28.8551 10.4426 37.0345 20.4964 37.0345C30.5502 37.0345 38.7295 28.8553 38.7295 18.8014C38.7291 8.7478 30.5502 0.568359 20.4964 0.568359V0.568359ZM20.4964 33.3886C12.4528 33.3886 5.90919 26.8449 5.90919 18.8014C5.90919 11.3105 11.585 5.12093 18.8624 4.30631C18.8561 4.36009 18.8528 4.41423 18.8528 4.46912C18.8468 5.37368 19.6112 6.16064 20.4927 6.15846C21.3636 6.15586 22.1283 5.39706 22.142 4.52143C22.1431 4.44874 22.1372 4.3768 22.1279 4.30596C29.4067 5.11929 35.0849 11.3092 35.0849 18.802C35.0842 26.8456 28.5404 33.3892 20.4968 33.3892L20.4964 33.3886Z" fill="black"/>
737 </svg>';
738 esc_html_e('Webcam','wpstream');
739 print '</div>';
740
741
742 print '<div class="wpstream_inactive_icon wpstream_stream_pro wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_broadcast_modal" data-show-id="'.$the_id.'"">';
743
744 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
745 print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
746
747 print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
748 <path d="M48.1266 13.9634L41.891 17.5343V13.6438C41.891 10.8723 39.6525 8.63384 36.8811 8.63384H33.1504L30.1124 3.62393C28.7268 1.3324 26.2751 0 23.6103 0H10.2863C8.84722 0 7.67471 1.17251 7.67471 2.6116C7.67471 4.05068 8.84722 5.22319 10.2863 5.22319H23.6103C24.4631 5.22319 25.2093 5.64961 25.6888 6.3957L27.0744 8.63413L5.00991 8.63376C2.23843 8.63376 0 10.8722 0 13.6437V32.9901C0 35.7616 2.23843 38 5.00991 38H36.9342C39.7057 38 41.9441 35.7616 41.9441 32.9901V29.0461L48.1797 32.6169C49.2991 33.2564 50.6846 32.4571 50.6846 31.1778L50.6842 15.4022C50.6311 14.123 49.2455 13.3237 48.1261 13.9632L48.1266 13.9634ZM38.1603 32.9368C38.1603 33.6297 37.574 34.1625 36.9345 34.1625L5.01029 34.1629C4.31733 34.1629 3.78458 33.5766 3.78458 32.9372V13.5907C3.78458 12.8978 4.37086 12.365 5.01029 12.365H36.9345C37.6275 12.365 38.1603 12.9513 38.1603 13.5907V32.9368Z" fill="black"/>
749 <path d="M22.4917 21.585H9.70066C8.84784 21.585 8.15527 22.2779 8.15527 23.1304V28.247C8.15527 29.0998 8.84823 29.7923 9.70066 29.7923H22.4917C23.3445 29.7923 24.0371 29.0994 24.0371 28.247V23.1304C24.0371 22.2775 23.3445 21.585 22.4917 21.585Z" fill="black"/>
750 </svg>';
751 esc_html_e('External App','wpstream');
752 print '</div>';
753
754
755
756
757 print '<a href="'.esc_url($live_data_url).'" target="_blank" class="wpstream_inactive_icon wpstream_live_data wpstream_statistics_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" >';
758
759 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
760 print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
761
762 print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
763 <path fill-rule="evenodd" clip-rule="evenodd" d="M48.9001 9.02344H40.3342C39.7288 9.02344 39.2344 9.51791 39.2344 10.1233V40.4275C39.2344 41.033 39.7288 41.5274 40.3342 41.5274H48.9001C49.5055 41.5274 50 41.0329 50 40.4275V10.1233C50 9.51791 49.5055 9.02344 48.9001 9.02344V9.02344Z" fill="black"/>
764 <path fill-rule="evenodd" clip-rule="evenodd" d="M35.821 22.4067H27.2551C26.6497 22.4067 26.1553 22.9012 26.1553 23.5066V40.4277C26.1553 41.0332 26.6497 41.5276 27.2551 41.5276H35.821C36.4264 41.5276 36.9209 41.0332 36.9209 40.4277V23.5066C36.9209 22.9012 36.4264 22.4067 35.821 22.4067V22.4067Z" fill="black"/>
765 <path fill-rule="evenodd" clip-rule="evenodd" d="M22.7439 0H14.178C13.5726 0 13.0781 0.494478 13.0781 1.09989V40.4275C13.0781 41.0329 13.5726 41.5274 14.178 41.5274H22.7439C23.3493 41.5274 23.8438 41.0329 23.8438 40.4275V1.09989C23.8438 0.49447 23.3493 0 22.7439 0V0Z" fill="black"/>
766 <path fill-rule="evenodd" clip-rule="evenodd" d="M9.66573 15.2559H1.09987C0.49445 15.2559 -2.24584e-05 15.7512 -2.24584e-05 16.3558V40.4285C-2.24584e-05 41.0331 0.495325 41.5284 1.09987 41.5284H9.66573C10.2703 41.5284 10.7656 41.034 10.7656 40.4285V16.3558C10.7656 15.7503 10.2711 15.2559 9.66573 15.2559V15.2559Z" fill="black"/>
767 </svg>';
768 esc_html_e('Statistics','wpstream');
769 print '</a>';
770 print '</div>';
771
772 print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
773 if($is_front==''){
774 print '<div class="wpstream_show_settings wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_settings_modal" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">';
775
776 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
777 print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
778
779 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
780 <path d="M49.22 21.8648C48.82 21.6099 45.665 19.7247 44.415 19.15L42.8651 15.4C43.3251 14.1601 44.2099 10.6849 44.3652 10.0798H44.3649C44.4911 9.52035 44.3213 8.93514 43.9149 8.52987L41.47 6.09995C41.0658 5.69189 40.4795 5.52168 39.9201 5.65003C39.4601 5.75501 35.92 6.64994 34.5999 7.15012L30.8499 5.60021C30.3048 4.40012 28.4699 1.32529 28.1351 0.795199V0.79485C27.8337 0.301688 27.298 0.00069643 26.7201 0H23.2798C22.7057 0.000348769 22.1718 0.294715 21.8648 0.779859C21.6098 1.1799 19.7247 4.33487 19.15 5.58487L15.4 7.13478C14.1601 6.67476 10.6849 5.78996 10.0798 5.63469V5.63504C9.52035 5.50878 8.93513 5.67864 8.52987 6.08496L6.09995 8.52988C5.69189 8.9341 5.52168 9.52042 5.65003 10.0798C5.75501 10.5398 6.64994 14.0799 7.15012 15.4L5.60021 19.15C4.40012 19.6951 1.32529 21.53 0.795198 21.8648H0.79485C0.301688 22.1662 0.00069643 22.7019 0 23.2798V26.7149C0.000348751 27.2893 0.294715 27.8233 0.779858 28.1299C1.1799 28.3849 4.33486 30.27 5.58487 30.8448L7.13478 34.5948C6.67475 35.8347 5.78996 39.3099 5.63469 39.915H5.63504C5.50878 40.4747 5.67863 41.06 6.08496 41.4649L8.51487 43.8948V43.8951C8.9191 44.3032 9.50541 44.4731 10.0648 44.3451C10.5248 44.2401 14.0649 43.3451 15.385 42.845L19.135 44.3949C19.6801 45.595 21.515 48.6698 21.8498 49.1999C22.1525 49.6997 22.6956 50.0035 23.2798 50H26.7149C27.2893 49.9996 27.8233 49.7053 28.1299 49.2201C28.3849 48.8201 30.27 45.6651 30.8447 44.4151L34.5947 42.8652C35.8347 43.3252 39.3098 44.21 39.9149 44.3653V44.3649C40.4747 44.4912 41.0599 44.3213 41.4649 43.915L43.8948 41.4851H43.8951C44.3032 41.0809 44.473 40.4945 44.345 39.9352C44.2401 39.4751 43.3451 35.9351 42.8449 34.615L44.3949 30.865C45.5949 30.3198 48.6698 28.485 49.1999 28.1501C49.6997 27.8474 50.0034 27.3044 49.9999 26.7201V23.2799C50.0045 22.7047 49.7087 22.1683 49.2201 21.8649L49.22 21.8648ZM24.9995 35.8845C22.1099 35.882 19.3399 34.7314 17.2985 32.6866C15.2572 30.6414 14.1118 27.8694 14.1146 24.9798C14.1171 22.0903 15.2676 19.3199 17.3125 17.2785C19.3577 15.2372 22.1297 14.0921 25.0193 14.0946C27.9088 14.0974 30.6792 15.2477 32.7205 17.2928C34.7619 19.338 35.907 22.1101 35.9045 24.9996C35.8978 27.8879 34.7462 30.6557 32.7021 32.6964C30.6576 34.7367 27.8876 35.8834 24.9994 35.8845H24.9995Z" fill="black"/>
781 </svg>
782 </div>';
783
784
785 print '<a href="'.get_edit_post_link($the_id).'" class="wpstream_edit_channel wpstream-button-icon wpstream_tooltip_wrapper" target="_blank" data-show-id="'.$the_id.'"">';
786 print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
787 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
788 <path d="M44.8203 1.79549C42.4263 -0.598498 38.5591 -0.598498 36.1651 1.79549L4.67494 33.2246C4.55203 33.3475 4.49079 33.4088 4.42954 33.5317C4.42954 33.5317 4.42954 33.5929 4.36829 33.5929C4.30705 33.7159 4.24539 33.7771 4.24539 33.9V33.9613L0.0711091 47.5886C-0.113044 48.264 0.0711092 48.9389 0.500659 49.4301C0.868966 49.7984 1.29852 49.9826 1.78973 49.9826C1.97388 49.9826 2.15804 49.9826 2.34219 49.9213L15.9085 45.747H15.9697C16.0926 45.6858 16.2151 45.6858 16.2768 45.6241C16.2768 45.6241 16.338 45.6241 16.338 45.5629C16.4609 45.5016 16.5834 45.44 16.6451 45.3175L48.0742 13.8884C50.4682 11.4944 50.4682 7.62715 48.0742 5.23316L44.8203 1.79549Z" fill="black"/>
789 </svg>';
790 print '</a>';
791 }
792
793 print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
794 print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
795 print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
796 <path d="M18.6201 15.2828H21.8752C21.8752 14.069 22.8681 13.0207 24.1373 13.0207V9.76562C21.1032 9.76562 18.6201 12.2487 18.6201 15.2828Z" fill="black"/>
797 <path d="M24.855 0C12.9378 0 3.28272 10.9792 0.579292 14.3447C-0.193097 15.2826 -0.193097 16.662 0.579292 17.6553C3.28282 21.0208 12.9378 32 24.855 32C36.7722 32 46.4273 21.0208 49.1307 17.6553C49.9031 16.7174 49.9031 15.338 49.1307 14.3447C46.4275 10.9792 36.7722 0 24.855 0V0ZM24.855 25.8205C19.4482 25.8205 15.0344 21.4067 15.0344 15.9999C15.0344 10.5931 19.4482 6.17927 24.855 6.17927C30.2618 6.17927 34.6756 10.5931 34.6756 15.9999C34.6756 21.4067 30.2618 25.8205 24.855 25.8205Z" fill="black"/>
798 </svg>';
799 esc_html_e('View','wpstream');
800 print '</a>';
801
802
803 print '<div class="wpstream_share_channel wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_share_modal" data-show-id="'.$the_id.'"">';
804 print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
805 print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
806 <path d="M20.0777 20.5087L24.3481 17.9427C26.6432 16.5645 29.4554 16.2443 31.96 17.198C33.443 17.7642 35.1166 17.9363 36.852 17.6105C40.3163 16.9521 43.1162 14.1831 43.8115 10.7248C45.0606 4.51597 39.7751 -0.910703 33.5907 0.12835C30.2924 0.682061 27.5604 3.16211 26.5942 6.36168C26.4405 6.86646 26.3418 7.35835 26.2804 7.84466C25.9482 10.5028 24.2498 12.8044 21.9547 14.1827L19.3458 15.7456C17.1061 17.0869 14.3986 17.1792 11.9494 16.2748C10.9956 15.9241 9.96159 15.7271 8.88507 15.7271C3.39004 15.7271 -0.960663 20.7607 0.184097 26.4527C0.879447 29.911 3.67936 32.68 7.14364 33.3384C8.87902 33.6706 10.5525 33.492 12.0356 32.9259C14.5402 31.9721 17.3461 32.2919 19.6475 33.6706L23.906 36.2241C25.346 37.0855 26.2195 38.6424 26.2195 40.3159V40.3403C26.2195 45.8229 31.2287 50.1611 36.9018 49.0472C40.3602 48.3703 43.1415 45.583 43.8244 42.1246C44.9383 36.451 40.6 31.4423 35.1175 31.4423C34.0406 31.4423 33.007 31.6394 32.0532 31.9901C29.604 32.8944 26.9029 32.8022 24.6627 31.4608L20.0721 28.7038C18.6445 27.8484 17.7706 26.304 17.7706 24.6364V24.5875C17.7642 22.9208 18.6441 21.37 20.0777 20.5085L20.0777 20.5087Z" fill="black"/>
807 </svg>';
808 esc_html_e('Share','wpstream');
809 print '</div>';
810 print '</div>';
811
812
813 print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream');
814 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
815 print '</div>';
816
817 print '</div>';
818
819
820
821
822 $this->wpstream_display_modal_seetings($the_id);
823 $this->wpstream_display_modal_share($the_id);
824 $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
825
826 print '</div>';
827
828 }
829
830
831 /*
832 *
833 * Close modal button
834 *
835 */
836
837 public function wpstream_close_modal_button(){
838 print '<div class="wpstream_close_modal"></div>';
839 }
840
841 /*
842 *
843 * Display modal settings
844 *
845 */
846
847 public function wpstream_display_modal_seetings($the_id){
848 print '<div class="wpstream_modal_form wpestate_settings_modal">';
849 $this->wpstream_close_modal_button();
850 print '<h3>';
851 printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id);
852 print '</h3>';
853 $local_event_options = get_post_meta($the_id,'local_event_options',true);
854 if(!is_array($local_event_options)){
855 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
856 }
857
858 $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt');
859
860 print '<div class="wpstream_event_streaming_local">';
861 $this->user_streaming_global_channel_options('',$local_event_options, $local_array_exclude);
862 print '</div>';
863 print '</div>';
864 }
865
866
867 /*
868 *
869 * Display share settings
870 *
871 */
872 public function wpstream_display_modal_share($the_id){
873 print '<div class="wpstream_modal_form wpestate_share_modal">';
874 $this->wpstream_close_modal_button();
875 print '<h3>'.esc_html__('Share your Channel','wpstream').'</h3>';
876 $this->wpstream_social_share($the_id);
877 print '</div>';
878 }
879
880
881 /*
882 *
883 * Display broadcast modal
884 *
885 */
886
887 public function wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream){
888 print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
889 $this->wpstream_close_modal_button();
890 print '<h3>'.esc_html__('Go Live with External Streaming App','wpstream').'</h3>';
891
892 print '<div class="wpstream_modal_explanations">'.esc_html__('Please choose your RTMP encoder/broadcaster','wpstream').'</div>';
893
894 print '<select class="wpstream_external_broadcast_options">';
895 print '<option value="wpstream_obs_settings">'.esc_html('OBS','wpstream').'</option>';
896 print '<option value="wpstream_streamyard_settings">'.esc_html('StreamYard','wpstream').'</option>';
897 print '<option value="wpstream_restream_settings">'.esc_html('Restream','wpstream').'</option>';
898 print '<option value="wpstream_wimx_settings">'.esc_html('vMix','wpstream').'</option>';
899 print '<option value="wpstream_wirecast_settings">'.esc_html('Wirecast','wpstream').'</option>';
900 print '<option value="wpstream_xplit_settings">'.esc_html('XSplit','wpstream').'</option>';
901 print '<option value="wpstream_larix_settings">'.esc_html('Larix Broadcaster','wpstream').'</option>';
902
903 print '</select>';
904
905 $this->wpstream_obs_settings($obs_uri,$obs_stream);
906 $this->wpstream_streamyard_settings($obs_uri,$obs_stream);
907 $this->wpstream_restream_settings($obs_uri,$obs_stream);
908 $this->wpstream_wmix_settings($obs_uri,$obs_stream);
909 $this->wpstream_wirecast_settings($obs_uri,$obs_stream);
910 $this->wpstream_xplit_settings($obs_uri,$obs_stream);
911 $this->wpstream_larix_settings($obs_uri,$obs_stream);
912
913 print '</div>';
914 }
915
916
917
918
919 /*
920 *
921 * Display OBS settings
922 *
923 */
924
925 public function wpstream_obs_settings($obs_uri,$obs_stream){
926
927 print '<div class="external_software_streaming wpstream_obs_settings" style="display:block;">';
928
929 print '<div class="external_software_streaming_details">';
930 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('Server:').' </strong>';
931 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
932 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
933
934 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
935 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
936 print '</div>';
937
938 print'</div>';
939
940 print ' <div class="wpstream_modal_explanations">';
941 print '<ul>
942 <li>1. Click Settings in the OBS Window and then Select Stream.</li>
943 <li>2. Choose Custom Streaming Server in the Stream Type dropdown menu.</li>
944 <li>3. In the URL box, type/paste your Server.</li>
945 <li>4. In the Stream key, type/paste your Stream key.</li>
946 <li>5. Save changes.Close the Settings window and click on the “Start Streaming” button in the main window of OBS.</li></ul>';
947
948 print '</div>';
949
950
951 print'</div>';
952 }
953
954 /*
955 *
956 * Display StreamYard settings
957 *
958 */
959
960 public function wpstream_streamyard_settings($obs_uri,$obs_stream){
961
962 print '<div class="external_software_streaming wpstream_streamyard_settings">';
963
964 print '<div class="external_software_streaming_details">';
965 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP server URL:').' </strong>';
966 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
967 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
968
969 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong>
970 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
971 print '</div>';
972
973 print'</div>';
974
975 print ' <div class="wpstream_modal_explanations">';
976 print '<ul>
977 <li>1. Set up your destination by going to your StreamYard account.</li>
978 <li>2. Choose "Custom RTMP" and add the RTMP server URL and Stream key from WpStream.</li>
979 <li>3. Go to "Broadcasts" then "create a broadcast".</li>
980 <li>4. Enter Live Studio.</li>
981 <li>5. Adjust all your preferred settings and Click on "Go Live".</li></ul>';
982
983 print '</div>';
984
985
986 print'</div>';
987 }
988
989
990
991 /*
992 *
993 * Display StreamYard settings
994 *
995 */
996
997 public function wpstream_restream_settings($obs_uri,$obs_stream){
998
999 print '<div class="external_software_streaming wpstream_restream_settings">';
1000
1001 print '<div class="external_software_streaming_details">';
1002 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP URL:').' </strong>';
1003 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1004 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1005
1006 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong>
1007 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1008 print '</div>';
1009
1010 print'</div>';
1011
1012 print ' <div class="wpstream_modal_explanations">';
1013 print '<ul>
1014 <li>1. Go to your Restream account and set up a destination or channel.</li>
1015 <li>2. Choose "Custom RTMP" and add the RTMP URL and Stream Key from WpStream.</li>
1016 <li>3. Click on "Add Channel".</li>
1017 <li>4. Enter Live Studio.</li>
1018 <li>5. Adjust your preferred settings and Go Live.</li></ul>';
1019
1020 print '</div>';
1021
1022
1023 print'</div>';
1024 }
1025
1026
1027
1028 /*
1029 *
1030 * Display Xplit settings
1031 *
1032 */
1033
1034
1035 public function wpstream_xplit_settings($obs_uri,$obs_stream){
1036 print '<div class="external_software_streaming wpstream_xplit_settings" style="display:none;">';
1037 print '<div class="external_software_streaming_details">';
1038 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP Url:').' </strong>';
1039 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1040 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1041
1042 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1043 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1044 print '</div>';
1045
1046 print'</div>';
1047
1048 print ' <div class="wpstream_modal_explanations">';
1049 print '<ul>
1050 <li>1. Click Broadcast in the XSplit Window and then click "Set up a new output".</li>
1051 <li>2. Choose Custom RTMP in the Set up a new output dropdown menu.</li>
1052 <li>3. In the URL box, type/paste your RTMP Url.</li>
1053 <li>4. In the Stream key, type/paste your Stream key.</li>
1054 <li>5. Save changes and click on the “Stream” button in the main window.</li></ul>';
1055 print '</div>';
1056
1057 print '</div>';
1058 }
1059
1060
1061
1062 /*
1063 *
1064 * Display WireCast settings
1065 *
1066 */
1067
1068
1069 public function wpstream_wirecast_settings($obs_uri,$obs_stream){
1070 print '<div class="external_software_streaming wpstream_wirecast_settings" style="display:none;">';
1071
1072 print '<div class="external_software_streaming_details">';
1073 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('Address:').' </strong>';
1074 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1075 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1076
1077 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream:').' </strong>
1078 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1079 print '</div>';
1080
1081 print'</div>';
1082
1083 print ' <div class="wpstream_modal_explanations">';
1084 print '<ul>
1085 <li>1. Click Output on the top of the screen and then Select Output Settings.</li>
1086 <li>2. In the destination, choose RTMP Server and click OK.</li>
1087 <li>3. In the Address box, type/paste your Address.</li>
1088 <li>4. In the Stream box, type/paste your Stream key.</li>
1089 <li>5. Click on OK to save changes just click the Output on the top of the screen and then Start/Stop Broadcasting.</li></ul>';
1090 print '</div>';
1091
1092 print '</div>';
1093 }
1094
1095
1096
1097 /*
1098 *
1099 * Display Larix settings
1100 *
1101 */
1102
1103
1104 public function wpstream_larix_settings($obs_uri,$obs_stream){
1105 print '<div class="external_software_streaming wpstream_larix_settings" style="display:none;">';
1106 $larix_rtmp=$obs_uri.$obs_stream;
1107 print '<div class="external_software_streaming_details">';
1108 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP:').'</strong>';
1109 print '<div class="wpstream_live_uri_text wpstream_larix_rtmp"></div>
1110 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1111
1112 print '</div>';
1113
1114 print'</div>';
1115
1116 print ' <div class="wpstream_modal_explanations">';
1117 print '<ul>
1118 <li>A. Scan the QR code.</li>
1119 <li>or</li>
1120 <li>B. Manually configure Larix with the above RTMP</li>';
1121 if(wp_is_mobile() ){
1122 print '
1123 <li>or</li>
1124 <li>C. Click on the button below </li></ul>';
1125 }
1126
1127
1128 print '</div>';
1129
1130
1131 print '<img class="print_qrcode" src="" />';
1132 if(wp_is_mobile() ){
1133 print '<a href="" class="wpstream_start_with_larix_mobile" >Start Streaming with Larix</a>';
1134 }
1135
1136
1137
1138 print '</div>';
1139 }
1140
1141
1142
1143
1144 /*
1145 *
1146 * Display Wmix settings
1147 *
1148 */
1149
1150
1151 public function wpstream_wmix_settings($obs_uri,$obs_stream){
1152 print '<div class="external_software_streaming wpstream_wimx_settings" style="display:none;">';
1153
1154 print '<div class="external_software_streaming_details">';
1155 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('URL:').' </strong>';
1156 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1157 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1158
1159 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1160 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1161 print '</div>';
1162
1163 print'</div>';
1164
1165 print ' <div class="wpstream_modal_explanations">';
1166 print '<ul>
1167 <li>1. Click on the gear icon near the stream button on the bottom.</li>
1168 <li>2. Choose a custom RTMP Server in destination.</li>
1169 <li>3. In the URL box, type/paste your URL.</li>
1170 <li>4. In the Stream key, type/paste your Stream key.</li>
1171 <li>5. Save changes. You can start streaming by clicking on the stream button at the bottom of the dashboard.</li></ul>';
1172 print '</div>';
1173
1174 print '</div>';
1175 }
1176
1177
1178
1179 /*
1180 * Set Settings
1181 *
1182 *
1183 */
1184
1185 public function wpstream_settings(){
1186
1187 if( !current_user_can('administrator') ){
1188 die('Only for administrators');
1189 }
1190
1191
1192 if($_SERVER['REQUEST_METHOD'] === 'POST'){
1193 if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){
1194 die('Security check');
1195 }
1196
1197 $allowed_html = array();
1198 $exclude_array = array();
1199 $allowed_html = array();
1200
1201
1202
1203 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
1204 update_option( sanitize_key('wpstream_stream_role'), '' );
1205 }
1206
1207 foreach($_POST as $variable=>$value){
1208 if ($variable!='submit'){
1209 if (!in_array($variable, $exclude_array) ){
1210 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
1211 }
1212
1213 if($variable=='stream_role'){
1214 update_option( sanitize_key('wpstream_stream_role'), $value );
1215 }
1216
1217 }
1218 }
1219
1220
1221 if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){
1222 $event_settings=array();
1223 foreach($this->global_event_options as $key=>$option){
1224 $event_settings[$key]='';
1225 if(isset($_POST['wpstream_event_set_'.$key]) && $_POST['wpstream_event_set_'.$key]=='on'){
1226 $event_settings[$key]=1;
1227 }else{
1228 $event_settings[$key]=0;
1229 }
1230 }
1231 update_option('wpstream_user_streaming_global_channel_options',$event_settings);
1232 }
1233
1234
1235
1236
1237
1238
1239 // reset permalinkgs
1240 global $wp_rewrite;
1241
1242 update_option( "rewrite_rules", FALSE );
1243 $wp_rewrite->flush_rules( true );
1244
1245 }
1246
1247 $wpstream_settings_array =array(
1248 1 => array(
1249 'tab' => 'general_options',
1250 'label' => esc_html__('Slug for free video/channel pages ','wpstream'),
1251 'name' => 'free_media_slug',
1252 'type' => 'text',
1253 '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'),
1254 ),
1255
1256 2 => array(
1257 'tab' => 'general_options',
1258 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'),
1259 'name' => 'stream_role',
1260 'type' => 'user_roles',
1261 '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'),
1262
1263 ),
1264 3 => array(
1265 'tab' => 'general_options',
1266 'label' => esc_html__('Non Admin Streamers Channel Type.','wpstream'),
1267 'name' => 'user_streaming_channel_type',
1268 'type' => 'select',
1269 'select_values'=>array(
1270 'free' => esc_html__('Free Live Channel','wpstream'),
1271 'paid' => esc_html__('Pay-Per-View','wpstream')
1272 ),
1273 'details' => esc_html__('Choose whether the channels assigned to non-admins are free-for-all or pay-per-view (WooCommerce product).','wpstream'),
1274 ),
1275
1276 4 => array(
1277 'tab' => 'general_options',
1278 'label' => esc_html__('Default Pay-Per-View Price','wpstream'),
1279 'name' => 'user_streaming_default_price',
1280 'type' => 'text',
1281 'details' => esc_html__('Default price of pay-per-view channels assigned to non-admins.','wpstream'),
1282 ),
1283
1284
1285
1286 6 => array(
1287 'tab' => 'subscription_options',
1288 'label' => esc_html__('Use Global Subscription Mode','wpstream'),
1289 'name' => 'global_sub',
1290 'type' => 'slidertoogle',
1291 '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'),
1292 ),
1293
1294 7 => array(
1295 'tab' => 'subscription_options',
1296 'label' => esc_html__('Subscription ID for Global Subscription Mode','wpstream'),
1297 'name' => 'global_sub_id',
1298 'type' => 'text',
1299 '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'),
1300 ),
1301 8 => array(
1302 'tab' => 'messages_options',
1303 'label' => esc_html__('PPV not logged in message','wpstream'),
1304 'name' => 'product_not_login',
1305 'type' => 'text',
1306 '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'),
1307 'default' => esc_html__('You must be logged in to watch this video.','wpstream'),
1308 ),
1309 9 => array(
1310 'tab' => 'messages_options',
1311 'label' => esc_html__('PPV not purchased message','wpstream'),
1312 'name' => 'product_not_bought',
1313 'type' => 'text',
1314 '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'),
1315 'default' => esc_html__('You did not yet purchase this item.','wpstream'),
1316 ),
1317 10 => array(
1318 'tab' => 'messages_options',
1319 'label' => esc_html__('Subscription not purchased message','wpstream'),
1320 'name' => 'product_not_subscribe',
1321 'type' => 'text',
1322 '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'),
1323 'default' => esc_html__(' You did not yet subscribe to this item.','wpstream'),
1324 ),
1325 11 => array(
1326 'tab' => 'messages_options',
1327 'label' => esc_html__('Thank you message','wpstream'),
1328 'name' => 'product_thankyou',
1329 'type' => 'text',
1330 'details' => esc_html__('This message will be displayed on the thank you page (after purchase) and the confirmation email.','wpstream'),
1331 'default' => esc_html__('Thanks for your purchase. You can access your item at any time by visiting the following page: {item_link}','wpstream'),
1332 ),
1333
1334 12 => array(
1335 'tab' => 'messages_options',
1336 'label' => esc_html__('Subscription Active message','wpstream'),
1337 'name' => 'subscription_active',
1338 'type' => 'text',
1339 'details' => esc_html__('This message will be displayed on subscription product page.','wpstream'),
1340 'default' => esc_html__('Your Subscription is Active','wpstream'),
1341 ),
1342 13 => array(
1343 'tab' => 'messages_options',
1344 'label' => esc_html__('You are not live message','wpstream'),
1345 'name' => 'you_are_not_live',
1346 'type' => 'text',
1347 'details' => esc_html__('This message will be displayed in player.','wpstream'),
1348 'default' => esc_html__('We are not live at this moment','wpstream'),
1349 ),
1350
1351
1352
1353
1354 99 => array(
1355 'tab' => 'default_options',
1356 'label' => esc_html__('Events Options ','wpstream'),
1357 'name' => 'user_streaming_global_channel_options',
1358 'type' => 'user_streaming_global_channel_options',
1359 'details' => esc_html__('Global Options for live events.','wpstream'),
1360 ),
1361
1362 100 => array(
1363 'tab' => 'default_options_vod',
1364 'label' => esc_html__('Autoplay','wpstream'),
1365 'name' => 'vod_autoplay',
1366 'type' => 'slidertoogle',
1367 'details' => esc_html__('If enabled, video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
1368 ),
1369
1370
1371 101 => array(
1372 'tab' => 'default_options_vod',
1373 'label' => esc_html__('Start Muted','wpstream'),
1374 'name' => 'vod_start_muted',
1375 'type' => 'slidertoogle',
1376 'details' => esc_html__('If enabled, video will start muted. This may increase the rate of autoplay in some browsers.','wpstream'),
1377 ),
1378
1379 102 => array(
1380 'tab' => 'default_options_vod',
1381 'label' => esc_html__('Lock To Website (former Video On Demand - Lock To Website)','wpstream'),
1382 'name' => 'vod_domain_lock',
1383 'type' => 'slidertoogle',
1384 'details' =>sprintf ( esc_html__('If enabled, video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
1385 ),
1386
1387 103 => array(
1388 'tab' => 'default_options_vod',
1389 'label' => esc_html__('Encrypt Video (former Encrypt Video on Demand)','wpstream'),
1390 'name' => 'vod_encrypt',
1391 'type' => 'slidertoogle',
1392 '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'),
1393 ),
1394
1395 /* 'vod_domain_lock' =>array(
1396 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'),
1397 'details' => sprintf ( esc_html__('If enabled, VODS will only display on %1$s, otherwise they can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
1398 'defaults' => 'no',
1399 ),
1400 'vod_encrypt' =>array(
1401 'name' => esc_html__('Encrypt Video on Demand','wpstream'),
1402 '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'),
1403 'defaults' => 'no',
1404 ),*/
1405
1406
1407 );
1408
1409 $active_tab = 'general_options';
1410 if( isset( $_GET[ 'tab' ] ) ) {
1411 $active_tab = $_GET[ 'tab' ];
1412 }
1413
1414
1415 print '<div class="theme_options_tab_wpstream" style="display:block;" >
1416 <h1>'.__('WpStream Settings','wpstream').'</h1>
1417 <form method="post" action="" >';
1418
1419 print '<h2 class="nav-tab-wrapper">
1420 <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('General Options','wpstream').'</a>
1421 <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Default Channel Settings','wpstream').'</a>
1422 <a href="?page=wpstream_settings&tab=default_options_vod" class="nav-tab '; echo $active_tab == 'default_options_vod' ? 'nav-tab-active' : ''; echo '">'.esc_html__('VOD Settings','wpstream').'</a>
1423 <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : '';echo '">'.esc_html__('Subscription Options','wpstream').'</a>
1424 <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Customize Messages','wpstream').'</a>
1425
1426 </h2>';
1427 $help_link='';
1428 print '<div class="wpstream_option_wrapper">';
1429
1430 switch ($active_tab) {
1431 case 'general_options':
1432 $help_link='https://docs.wpstream.net/docs/general-settings/';
1433 break;
1434 case 'default_options':
1435 $help_link='https://docs.wpstream.net/docs/default-settings/';
1436 break;
1437 case 'default_options':
1438 $help_link='';
1439 break;
1440 case 'subscription_options':
1441 $help_link='https://docs.wpstream.net/docs/subscription-options/';
1442 break;
1443 case 'messages_options':
1444 $help_link='https://docs.wpstream.net/docs/customize-messages/';
1445 break;
1446 }
1447
1448 if($help_link!==''){
1449 print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >'.esc_html__('Video Help','wpstream').'</a></div>';
1450 }
1451
1452 foreach ($wpstream_settings_array as $key=>$option){
1453 if($option['tab']!=$active_tab){
1454 continue;
1455 }
1456
1457 print '<div class="wpstream_option">';
1458 $options_value = get_option('wpstream_'.$option['name']) ;
1459
1460
1461 if($option['type']=='user_roles'){
1462
1463 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1464 print $this->wpstream_select_user_roles($option['name'],$options_value);
1465 print '<div class="settings_details">'.$option['details'].'</div>';
1466
1467 }else if($option['type']=='user_streaming_global_channel_options'){
1468
1469 $exclude_array=array();
1470 $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array);
1471
1472
1473 }else if($option['type']=='text'){
1474
1475 if($options_value==''){
1476 $options_value='';
1477 if(isset($option['default'])){
1478 $options_value=$option['default'];
1479 }
1480 }
1481
1482 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1483 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1484 print '<div class="settings_details">'.$option['details'].'</div>';
1485
1486 } else if($option['type']=='select'){
1487
1488 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1489 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
1490 foreach($option['select_values'] as $key=>$value){
1491 print '<option value="'.$key.'" ';
1492 if( $key == esc_html($options_value) ){
1493 print ' selected ';
1494 }
1495 print '>'.$value.'</option>';
1496 }
1497 print '</select>';
1498 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
1499 print '<div class="settings_details">'.$option['details'].'</div>';
1500
1501 } else if($option['type']=='slidertoogle'){
1502 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1503 print '<label class="wpstream_switch">
1504 <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" >
1505 <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" ';
1506
1507 if( intval($options_value) !==0 ){
1508 print ' checked ';
1509 }
1510
1511
1512
1513 print '> <span class="wpstream_slider round"></span>';
1514 print '</label>';
1515 print '<div class="settings_details">'.$option['details'].'</div>';
1516 }
1517 print '</div>';
1518 }
1519 print '</div>';
1520
1521
1522 print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1523
1524 print '<input name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> ';
1525 print '</form>';
1526 print '</div>';
1527
1528 }
1529
1530
1531
1532 /**
1533 * Set user roles
1534 *
1535 * @since 3.0.1
1536 */
1537
1538 public function user_streaming_global_channel_options($name,$value,$local_array=''){
1539
1540 foreach($this->global_event_options as $key=>$option){
1541
1542 if( is_array($local_array) && !in_array($key,$local_array)){
1543 print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">';
1544
1545 print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
1546
1547 print '
1548 <label class="wpstream_switch">
1549 <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
1550 if( isset($value[$key]) ){
1551 if( intval($value[$key]) !==0 ){
1552 print ' checked ';
1553 }
1554 }else{
1555 if($option['defaults']=='yes') {
1556 print ' checked ';
1557 }
1558 }
1559
1560
1561 print '> <span class="wpstream_slider round"></span>';
1562 print '</label>';
1563 print '<div class="settings_details">'.$option['details'].'</div>';
1564
1565
1566 print '</div>';
1567 }
1568 }
1569
1570
1571 }
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581 /*
1582 * Set user roles
1583 *
1584 * @since 3.0.1
1585 */
1586
1587 public function wpstream_select_user_roles($name,$value){
1588 if($value==''){
1589 $value=array();
1590 }
1591
1592 $roles = get_editable_roles();
1593 $return = '<select id="wpstream_user_roles" name="'.esc_html($name).'[]" multiple>';
1594 unset( $roles['administrator'] );
1595
1596 foreach ($roles as $key=>$role){
1597 $return .= '<option value="'.$key.'" ';
1598 if( in_array($key, $value) ){
1599 $return .= ' selected ';
1600 }
1601 $return .= '>'.$role['name'].'</option>';
1602 }
1603 $return .= '</select>';
1604
1605
1606 return $return;
1607 }
1608
1609
1610 /*
1611 * Set credential admin function
1612 *
1613 * @since 3.0.1
1614 */
1615 public function wpstream_set_wpstream_credentials(){
1616
1617 if($_SERVER['REQUEST_METHOD'] === 'POST'){
1618 $allowed_html = array();
1619 $exclude_array = array();
1620 $allowed_html = array();
1621
1622 foreach($_POST as $variable=>$value){
1623 if ($variable!='submit'){
1624 if (!in_array($variable, $exclude_array) ){
1625 update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
1626 }
1627 }
1628 }
1629
1630
1631
1632
1633 update_option('wp_estate_token_expire',0);
1634 update_option('wp_estate_curent_token',' ');
1635 delete_transient( 'wpstream_token_api');
1636 delete_transient('wpstream_token_request_30');
1637 delete_transient('wpstream_request_pack_data_per_user_transient');
1638 }
1639
1640
1641 $allowed_html = array();
1642
1643
1644
1645 $wpstream_options_array =array(
1646 2 => array(
1647 'label' => 'WpStream.net Username or Email',
1648 'name' => 'api_username',
1649 'type' => 'text',
1650 ),
1651 3 => array(
1652 'label' => 'WpStream.net Password',
1653 'name' => 'api_password',
1654 'type' => 'password',
1655 ),
1656
1657 );
1658
1659
1660 $token = $this->main->wpstream_live_connection->wpstream_get_token();
1661 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1662
1663 $this->main->show_user_data($pack_details);
1664
1665 print '<form method="post" action="" >';
1666 print '<div class="theme_options_tab_wpstream" style="display:block;" >
1667 <h1>'.__('WpStream Credentials','wpstream').'</h1>';
1668
1669
1670 if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== '' ){
1671 echo '<div class="api_not_conected wpstream_orange">';
1672 $admin_url_onboard=get_admin_url().'admin.php?page=wpstream_onboard';
1673 printf ( __('To connect your plugin, enter your WpStream credentials below or go <a href="%s" target="_blank">here</a> to create an account.','wpstream'),$admin_url_onboard);
1674 echo '</div>';
1675
1676 }else if($token==''){
1677 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>';
1678 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
1679 echo '<div class="api_conected">'.__('Connected to WpStream.net!','wpstream').'</div>';
1680 }else{
1681 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
1682 }
1683 print '<div class="wpstream_option_wrapper">';
1684 foreach ($wpstream_options_array as $key=>$option){
1685 print '<div class="wpstream_option">';
1686
1687 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
1688 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1689 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
1690
1691 print '</div>';
1692 }
1693 print '</div>';
1694
1695
1696 print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1697
1698 print '<h3>Video Tutorials</h3>';
1699
1700 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/9DQrxsKcpmQ">How to Live Stream to WordPress with OBS</a>';
1701 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>';
1702 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/h6myD_vhKcg">How to Live-Stream to WordPress using your iPhone</a>';
1703
1704 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>';
1705
1706
1707 print '</div>';
1708 print '</form>';
1709
1710 print '<div class="theme_options_tab_wpstream" style="display:block;" >';
1711 $link_new = admin_url('admin.php?page=wpstream_live_channels');
1712 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
1713 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
1714
1715
1716 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new Free-To-View channel','wpstream').'</a>';
1717 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create Pay-Per-View channel','wpstream').'</a>';
1718 print '<a href="'.esc_url($link_new).'" class="wpstream_no_chanel_add_channel">'.esc_html('My Channels','wpstream').'</a>';
1719 print '</div>';
1720
1721
1722 }
1723
1724
1725
1726 /**
1727 * Media Management
1728 *
1729 * @since 3.0.1
1730 */
1731
1732 public function wpstream_media_management(){
1733 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1734
1735 $this->main->show_user_data($pack_details);
1736
1737
1738 print '<div id="wpstream_media_upload"><h3>'.__('Upload New Recording','wpstream').'</h3>'.$this->wpstream_present_media_upload().'</div>';
1739
1740 print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Your Recordings','wpstream').'</h3>'.$this->wpstream_present_file_management().'</div>';
1741
1742
1743 }
1744
1745
1746
1747
1748 /**
1749 *
1750 *
1751 * WpStream Pagination
1752 *
1753 * @since 3.0.1
1754 *
1755 *
1756 */
1757
1758 public function wpstream_pagination($pages , $range = 2) {
1759 $return='';
1760 $showitems = ($range * 2) + 1;
1761 $paged = ( isset( $_GET['paged'] ) ) ? intval($_GET['paged']) : 1;
1762
1763
1764 if (1 != $pages && $pages != 0) {
1765 $return.= '<ul class="pagination wpstream_pagination">';
1766 $return.= "<li class=\"roundleft\"><a href='" . get_pagenum_link($paged - 1) . "'><</a></li>";
1767
1768 $last_page = get_pagenum_link($pages);
1769 for ($i = 1; $i <= $pages; $i++) {
1770 if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) {
1771 if ($paged == $i) {
1772 $return.= '<li class="active"><a href="' . esc_url(get_pagenum_link($i)) . '" >' . $i . '</a><li>';
1773 } else {
1774 $return.= '<li><a href="' . esc_url(get_pagenum_link($i)) . '" >' . $i . '</a><li>';
1775 }
1776 }
1777 }
1778
1779 $prev_page = get_pagenum_link($paged + 1);
1780 if (($paged + 1) > $pages) {
1781 $prev_page = get_pagenum_link($paged);
1782 } else {
1783 $prev_page = get_pagenum_link($paged + 1);
1784 }
1785
1786
1787 $return.= "<li class=\"roundright\"><a href='" . $prev_page . "'>></a><li>";
1788 $return.= "<li class=\"roundright\"><a href='" . $last_page . "'>>><li>";
1789 $return.= "</ul>";
1790 }
1791 return $return;
1792 }
1793
1794
1795
1796
1797
1798
1799 /**
1800 * Media upload
1801 *
1802 * @since 3.0.1
1803 */
1804 public function wpstream_present_media_upload(){
1805 $to_return='';
1806 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
1807
1808
1809
1810
1811 if( !$formInputs['success'] ){
1812 $to_return.='<div class="wpstream_upload_alert">'.esc_html__('There isn\'t enough storage space under your account to upload a new item. Please delete some videos or upgrade your subscription.','wpstream').'</div>';
1813 return $to_return;
1814 }
1815
1816 if($formInputs['success'] ===true){
1817
1818
1819
1820 $to_return.='<div class="wpstream_upload_container">';
1821 $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>';
1822 $to_return.='<form action="https://wpstream-video.s3.amazonaws.com/"
1823 method="POST"
1824 enctype="multipart/form-data"
1825 data-singleFileUploads="true"
1826 data-limitMultiFileUploads="1"
1827 data-limitConcurrentUploads="1"
1828 class="direct-upload">';
1829
1830 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
1831 $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>';
1832
1833
1834 $to_return.='<div class="wpstream_file_drop_color">';
1835 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
1836 $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:
1837
1838 Container: <strong>MP4</strong>,
1839 Video codec: <strong>H264</strong>,
1840 Audio codec: <strong>AAC</strong>. Media will fail to play if it does not follow the above settings.
1841 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>';
1842 if(is_array($formInputs)){
1843 foreach ($formInputs['ref'] as $name => $value) {
1844 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
1845 }
1846 }
1847
1848 $to_return.='
1849 <div class="progress-bar-area"></div></div>
1850 </form>';
1851
1852 $to_return.='</div>';
1853 }
1854
1855 return $to_return;
1856
1857 }
1858
1859
1860
1861
1862
1863 /**
1864 * Display movie list
1865 *
1866 * @since 3.0.1
1867 */
1868 public function wpstream_present_file_management(){
1869 $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api();
1870
1871 $video_list_raw_array=array();
1872 if(isset($video_list_raw['items'])){
1873 $video_list_raw_array=$video_list_raw['items'];
1874 }
1875
1876 $keys = array_column($video_list_raw_array, 'time');
1877 array_multisort($keys, SORT_DESC , $video_list_raw_array);
1878
1879 $to_return='';
1880
1881 if(is_array($video_list_raw['items'])){
1882 foreach ($video_list_raw_array as $key =>$video){
1883
1884
1885 $video_size = intval($video['size']/1048576);
1886 $video_name = esc_html($video['name']);
1887 if($video_name!=''):
1888 $to_return.='<div class="wpstream_video_wrapper">';
1889
1890 $to_return.='<div class="wpstream_video_title">';
1891 $to_return.='<div class="wpstream_video_notice"></div></div>';
1892 $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_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>';
1893 $to_return.=' <div class="wpstream_delete_media" ';
1894 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video_name.'?\')" data-filename="'.$video_name.'">'.esc_html__('delete file','wpstream').'</div>';
1895 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video_name.'">'.esc_html__('download','wpstream').'</div>';
1896 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
1897
1898 $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product_vod').'&new_video_name='. rawurlencode($video_name);
1899 $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video_name);
1900
1901
1902
1903 $to_return .='<a class="create_new_free_video" href="'.esc_url($add_free_video_url).'">'.esc_html__('Create new Free-To-View VOD from this recording').'</a>';
1904 $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create new Pay-Per-View VOD from this recording').'</a>';
1905
1906 $to_return.='</div>';
1907 endif;
1908
1909 }
1910 $current_page= get_current_screen();
1911
1912
1913 } else {
1914 $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
1915 }
1916 return $to_return;
1917 }
1918
1919
1920 /**
1921 * Set defualt channels values
1922 *
1923 * @since 3.0.1
1924 */
1925
1926
1927
1928
1929 public function wpstream_publish_wpstream_product($post_id,$post){
1930 if( $post->post_type == 'wpstream_product' ){
1931 update_post_meta ($post_id,'local_event_options_test','working_on_'.$post_id);
1932 $to_save_option=array();
1933
1934 $global_options= get_option('wpstream_user_streaming_global_channel_options');
1935
1936 $local_events = get_post_meta ($post_id ,'local_event_options',true) ;
1937
1938 if( $local_events =='' ){
1939 if( is_array($global_options) ){
1940 foreach($global_options as $key=>$value){
1941 $to_save_option[sanitize_key($key)]=sanitize_text_field($value);
1942 }
1943
1944 update_post_meta ($post_id,'local_event_options',$to_save_option);
1945
1946 }
1947 }
1948
1949
1950 }
1951 }
1952
1953 /**
1954 * save meta options
1955 *
1956 * @since 3.0.1
1957 */
1958 public function wpstream_free_product_update_post($post_id,$post){
1959
1960 if(!is_object($post) || !isset($post->post_type)) {
1961 return;
1962 }
1963
1964
1965
1966
1967
1968
1969
1970 if( $post->post_type == 'wpstream_product' ||
1971 $post->post_type == 'wpstream_product_vod' ):
1972
1973 $allowed_keys=array(
1974 'wpstream_product_type',
1975 'wpstream_free_video',
1976 'wpstream_free_video_external'
1977 );
1978
1979
1980 foreach ($_POST as $key => $value) {
1981 if( !is_array ($value) ){
1982 if (in_array ($key, $allowed_keys)) {
1983 $postmeta = sanitize_text_field ( $value );
1984 update_post_meta($post_id, sanitize_key($key), $postmeta );
1985 }
1986 }
1987 }
1988
1989 endif;
1990
1991 }
1992
1993
1994 /**
1995 * save meta options
1996 *
1997 * @since 3.0.1
1998 */
1999 public function add_wpstream_product_metaboxes() {
2000 global $post;
2001 $post_id = $post->ID;
2002 $product = wc_get_product( $post_id );
2003
2004
2005
2006 add_meta_box( 'add_wpstream_product_metaboxes-sectionid', esc_html__( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default');
2007 add_meta_box( 'custom_metabox_video_collection', esc_html__( 'Video Collection', 'wpstream' ), 'wpstream_bundle_custom_metabox_callback', 'wpstream_bundles', 'normal', 'high' );
2008 add_meta_box( 'woocommerce-product-data', esc_html__( 'Product Data', 'wpstream' ), 'woocommerce_product_data_box', 'product', 'normal', 'default' );
2009
2010 if ( $product ) {
2011
2012 if ( $product->get_type() === 'wpstream_bundle' ) {
2013 add_meta_box(
2014 'wpstream_woo_custom_metabox',
2015 esc_html__( 'Video Collection Options', 'wpstream' ),
2016 'wpstream_bundle_custom_metabox_callback',
2017 'product',
2018 'normal',
2019 'default'
2020 );
2021 }
2022 }
2023
2024 }
2025
2026
2027 /**
2028 * make woocomerce virtual products
2029 *
2030 * @since 3.0.1
2031 */
2032
2033
2034 public function wpstream_make_product_virtual($post_id,$post){
2035 global $post;
2036 if(isset($post->ID)){
2037 if ( $post->post_type !== 'product' ) return;
2038 $term_list = wp_get_post_terms($post->ID, 'product_type');
2039 if( $term_list[0]->name=='video_on_demand' ||
2040 $term_list[0]->name=='live_stream' ||
2041 $term_list[0]->name=='wpstream_bundle'){
2042 update_post_meta( $post->ID, '_virtual', 'yes' );
2043 }
2044 }
2045 }
2046
2047
2048
2049 /**
2050 * render meta options
2051 *
2052 * @since 3.0.1
2053 */
2054 public function display_meta_options( $post ) {
2055 wp_nonce_field( plugin_basename( __FILE__ ), 'estate_agent_noncename' );
2056 global $post;
2057
2058 $is_live = '';
2059 $is_video = '';
2060 $is_video_external = '';
2061 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
2062 $is_video = ' selected ';
2063 $wpstream_free_video = esc_html( $_GET['new_video_name']);
2064 }else{
2065 $wpstream_product_type = esc_html(get_post_meta($post->ID, 'wpstream_product_type', true));
2066 $wpstream_free_video = esc_html(get_post_meta($post->ID, 'wpstream_free_video', true));
2067
2068 if($wpstream_product_type==1){
2069 $is_live = ' selected ';
2070 }
2071
2072 if($wpstream_product_type==2){
2073 $is_video = ' selected ';
2074 }
2075
2076 if($wpstream_product_type==3){
2077 $is_video_external = ' selected ';
2078 }
2079 }
2080
2081 print'
2082 <p class="meta-options">
2083 <label for="wpstream_product_type">'.__('Media Type:','wpstream').' </label><br />
2084 <select id="wpstream_product_type" name="wpstream_product_type">
2085 <option value="2" '.$is_video.'>'.__('Recording','wpstream').'</option>
2086 <option value="3" '.$is_video_external.'>'.__('Self Hosted or External Video','wpstream').'</option>
2087 </select>
2088 </p>
2089 ';
2090
2091
2092 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2093
2094
2095 print '
2096 <p class="meta-options video_free">
2097 <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
2098 <select id="wpstream_free_video" name="wpstream_free_video">';
2099
2100 if(is_array($video_list)){
2101 foreach ($video_list as $key=>$value){
2102 print '<option value="'.$key.'"';
2103 if($wpstream_free_video === $key){
2104 print ' selected ';
2105 }
2106 print '>'.$value.'</option>';
2107 }
2108 }
2109
2110 print'
2111 </select>
2112 </p>
2113 ';
2114
2115 $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
2116 print '<p class="meta-options1 video_free_external">
2117 <label for="wpstream_free_video_external">'.__('Video:','wpstream').' </label><br />
2118
2119 <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
2120 <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />';
2121 if($wpstream_product_type==2){
2122 $show_recording='';
2123 $show_external='style="display:none"';
2124 }else{
2125 $show_recording='style="display:none"';
2126 $show_external='';
2127 }
2128 print '<p '.$show_recording.' class="wpstream_option_vod_source wpstream_show_recording">'.esc_html__('Choose one of your existing recordings.','wpstream').'</p>';
2129 print '<p '. $show_external.' class="wpstream_option_vod_source wpstream_show_external">'.esc_html__('Upload a video from your computer or paste the URL of a YouTube/external video.','wpstream').'</p>';
2130
2131 print '</p> ';
2132 }
2133
2134
2135
2136
2137
2138
2139
2140 /**
2141 * Add new product types to Woocommerce select product type
2142 *
2143 * @since 3.0.1
2144 */
2145 public function wpstream_add_products( $types ){
2146 $types[ 'live_stream' ] = __( 'Live Channel','wpestream' );
2147 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
2148
2149 return $types;
2150 }
2151
2152
2153
2154 /**
2155 * Js action to do when user pick live stream or video on demand
2156 *
2157 * @since 3.0.1
2158 */
2159
2160 public function wpstream_products_custom_js() {
2161 if ( 'product' != get_post_type() ) :
2162 return;
2163 endif;
2164
2165 ?>
2166 <script type='text/javascript'>
2167 jQuery( document ).ready( function() {
2168 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
2169 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
2170 jQuery('.options_group.pricing' ).addClass ( 'show_if_wpstream_bundle' ).show();
2171
2172 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
2173 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
2174 jQuery('._sold_individually_field').parent().addClass('show_if_wpstream_bundle').show();
2175
2176 jQuery('._sold_individually_field').show();
2177
2178 var selected = jQuery('#product-type').val();
2179 });
2180 </script>
2181 <?php
2182
2183 }
2184
2185
2186 /**
2187 * Add custom classes to the product types
2188 *
2189 * @since 3.0.1
2190 */
2191
2192 public function wpstream_hide_attributes_data_panel( $tabs) {
2193
2194 $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand hide_if_wpstream_bundle';
2195 $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand show_if_wpstream_bundle';
2196
2197 return $tabs;
2198 }
2199
2200
2201
2202 /**
2203 * Hide buy now on products if Netflix mode
2204 *
2205 * @since 3.12
2206 */
2207
2208
2209 public function wpstream_hide_buy_now_subscription_mode( $purchaseable_product_wpblog,$product){
2210 $product_id=$product->get_id();
2211
2212 $term_list = wp_get_post_terms($product_id, 'product_type');
2213
2214 $subscription_model = intval( get_option('wpstream_global_sub','')) ;
2215
2216 if($subscription_model==1){ // if we have Neflix mode
2217 if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='wpstream_bundle' ){
2218 return false;
2219 }
2220 }
2221
2222 return $purchaseable_product_wpblog;
2223 }
2224
2225
2226
2227
2228
2229
2230 /**
2231 * Add custom fields to custom product types
2232 *
2233 * @since 3.0.1
2234 */
2235
2236 public function wpstream_add_custom_general_fields() {
2237
2238 global $woocommerce, $post;
2239 if(function_exists('wcs_user_has_subscription')){
2240 echo '<div class="options_group show_if_subscription">';
2241 woocommerce_wp_select(
2242 array(
2243 'id' => '_subscript_live_event',
2244 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ),
2245 'options' => array("yes"=>"yes","no"=>"no")
2246 )
2247 );
2248 echo '</div>';
2249 }
2250
2251 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
2252 echo '<div class="options_group show_if_video_on_demand">';
2253 $selected='';
2254 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
2255 $selected=esc_html($_GET['new_video_name']);
2256 }
2257 if($selected==''){
2258 $selected= get_post_meta($post->ID,'_movie_url',true);
2259 }
2260
2261 woocommerce_wp_select(
2262 array(
2263 'id' => '_movie_url',
2264 'label' => __( 'Choose video', 'woocommerce' ),
2265 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
2266 'selected'=> true,
2267 'value' => $selected
2268 )
2269 );
2270
2271
2272
2273 echo '</div>';
2274
2275 if(function_exists('wcs_user_has_subscription')){
2276 $selected_sub='';
2277 echo '<div class="options_group show_if_video_on_demand show_if_live_stream">';
2278 if( isset( $_GET['wpstream_parent_sub']) && $_GET['wpstream_parent_sub']!='' ){
2279 $selected_sub=esc_html($_GET['wpstream_parent_sub']);
2280 }
2281 if($selected_sub==''){
2282 $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
2283 }
2284 woocommerce_wp_select(
2285 array(
2286 'id' => '_wpstream_parent_sub',
2287 'name' => '_wpstream_parent_sub[]',
2288 'label' => __( 'Attach to subscription', 'woocommerce' ),
2289 'options' => $this->wpstream_return_subscriptions_created(),
2290 'selected'=> true,
2291 'value' => $selected_sub,
2292 'custom_attributes' => array('multiple' => 'multiple')
2293 )
2294 );
2295
2296 echo '</div>';
2297
2298 }
2299 }
2300
2301
2302 public function wpstream_return_subscriptions_created(){
2303 $return=array('0'=>'none');
2304
2305 $args = array(
2306 'post_type' => 'product',
2307 'posts_per_page' => -1,
2308 'orderby' => 'title',
2309 'order' => 'ASC',
2310 'tax_query' => array(
2311 'relation' => 'AND',
2312 array(
2313 'taxonomy' => 'product_type',
2314 'field' => 'slug',
2315 'terms' => array( 'subscription'),
2316 )
2317 )
2318 );
2319
2320 $subscriptions = new WP_Query($args);
2321 if($subscriptions->have_posts()):
2322 while ($subscriptions->have_posts()): $subscriptions->the_post();
2323 $return[ get_the_ID() ] = get_the_title();
2324 endwhile;
2325 endif;
2326
2327 wp_reset_postdata();
2328 return $return;
2329
2330 }
2331
2332
2333
2334
2335
2336
2337 /**
2338 * Save custom fields
2339 *
2340 * @since 3.0.1
2341 */
2342
2343 public function wpstream_add_custom_general_fields_save( $post_id ){
2344
2345 $permited_values = array(
2346 '_movie_url',
2347 '_subscript_live_event',
2348 '_wpstream_parent_sub',
2349
2350 );
2351
2352
2353
2354 foreach($_POST as $key=>$value){
2355 update_post_meta( $post_id, 'event_passed', 0 );
2356 if( in_array($key, $permited_values) ){
2357 if( !empty( $_POST[$key] ) ){
2358 $key = sanitize_key($key);
2359 $value = sanitize_text_field($_POST[$key]);
2360
2361 if($key=='_wpstream_parent_sub'){
2362 $value= $_POST[$key];
2363 $value = array_map("sanitize_text_field", $value);
2364
2365 }
2366 update_post_meta( $post_id, $key, $value );
2367 }
2368 }
2369 }
2370 //die();
2371
2372 }
2373
2374 /**
2375 * Add to cart redirect
2376 *
2377 * @since 3.0.1
2378 */
2379
2380 public function wpstream_add_to_cart() {
2381 wc_get_template( 'single-product/add-to-cart/simple.php' );
2382 }
2383
2384
2385 /**
2386 * Replace add to cart button
2387 *
2388 * @since 3.0.1
2389 */
2390 public function replacing_add_to_cart_button( $button, $product ) {
2391 global $product;
2392 $product_type = $product->get_type();
2393
2394 if($product_type==='live_stream' || $product_type=='video_on_demand'){
2395 return $button = '<a class="button" href="'.get_site_url().'/shop/?add-to-cart=' .$product->get_id(). '&quantity=1">' . __( 'Add to Cart', 'woocommerce' ) . '</a>';
2396 }else{
2397 return $button;
2398 }
2399 }
2400
2401
2402 /**
2403 * Admin notices
2404 *
2405 * @since 3.0.1
2406 */
2407 public function wpstream_admin_notice() {
2408 global $pagenow;
2409 global $typenow;
2410
2411 $wpstream_notices = get_option('wpstream_notices');
2412
2413 /*
2414 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
2415 if( !is_array($wpstream_notices) ||
2416 !isset($wpstream_notices['wpstream_woo_notice']) ||
2417 ( isset($wpestate_notices['wpstream_woo_notice']) && $wpestate_notices['wpstream_woo_notice']!='yes') ){
2418
2419
2420 print '<div class="notice wpstream_notices notice-error is-dismissible" data-notice-type="wpstream_woo_notice" >
2421 <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>
2422 </div>';
2423 }
2424 }
2425 */
2426
2427 if( !in_array ('curl', get_loaded_extensions())) {
2428 print '<div class="notice notice-error is-dismissible">
2429 <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>
2430 </div>';
2431 }
2432
2433
2434 $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
2435 print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
2436
2437 }
2438
2439 /**
2440 * Admin notices
2441 *
2442 * @since 3.0.1
2443 */
2444 public function wpstream_update_cache_notice(){
2445
2446 //check_ajax_referer( 'wpstream_notice_nonce', 'security' );
2447
2448 $notice_type = esc_html($_POST['notice_type']);
2449 $notices = get_option('wp_stream_notices');
2450
2451 if(! is_array($notices) ){
2452 $notices=array();
2453 }
2454
2455 $notices[$notice_type]='yes';
2456
2457 update_option('wpstream_notices',$notices);
2458 die();
2459 }
2460
2461
2462
2463
2464 /**
2465 * Activate metaboxes for Streaming controls on sidebar
2466 *
2467 * @since 3.0.1
2468 */
2469 public function wpstream_startstreaming_sidebar_meta() {
2470 global $post;
2471 $term_list = wp_get_post_terms($post->ID, 'product_type');
2472
2473 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
2474
2475 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
2476 if(!is_wp_error( $term_list )){
2477 if( isset($term_list[0]->name) ){
2478 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
2479 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'product', 'side', 'high');
2480 }
2481 }
2482 }
2483
2484 }
2485
2486 /**
2487 * edited 4.0
2488 *
2489 * Show Streaming controls on sidebar
2490 *
2491 * @since 3.0.1
2492 */
2493 public function wpstream_start_stream_meta(){
2494 global $live_event_for_user;
2495 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
2496
2497 global $post;
2498 $local_event_options = get_post_meta ($post->ID,'local_event_options','');
2499
2500
2501
2502 if( get_post_status($post->ID)!='auto-draft' ){
2503 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
2504 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
2505
2506 $this->wpstream_live_stream_unit($post->ID);
2507 print '<div class="wpstream_modal_background"></div>';
2508 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
2509 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
2510 </div>';
2511 }else{
2512 esc_html_e('To Go Live, please publish your channel first !','wpstream');
2513 }
2514 }
2515
2516
2517
2518
2519
2520
2521 /**
2522 *
2523 *
2524 *
2525 */
2526 public function add_dashboard_page() {
2527 add_dashboard_page( '', '', 'administrator', 'wpstream-onboarding', '' );
2528 }
2529
2530
2531
2532
2533
2534 public function wpstream_load_onboarding_wizard() {
2535
2536 // Check for wizard-specific parameter
2537 // Allow plugins to disable the onboarding wizard
2538 // Check if current user is allowed to save settings.
2539
2540
2541 // Don't load the interface if doing an ajax call.
2542 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
2543 return;
2544 }
2545
2546 set_current_screen();
2547
2548 // Remove an action in the Gutenberg plugin ( not core Gutenberg ) which throws an error.
2549 remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );
2550
2551 $this->actual_load_onboarding_wizard();
2552
2553 }
2554
2555
2556 /*
2557 * Add on boarding to footer
2558 */
2559
2560
2561
2562 public function wpstream_admin_footer_onboarding(){
2563 if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
2564 $this->wpstream_onboard_display();
2565 }
2566 }
2567
2568
2569 /*
2570 * On Board Display
2571 *
2572 */
2573
2574 public function wpstream_pre_onboard_display(){
2575 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2576
2577 $this->main->show_user_data($pack_details);
2578
2579
2580 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
2581 ?>
2582
2583 <div class="wpstream_quick_start_wrapper">
2584 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
2585
2586 <h1><?php print esc_html__('WpStream','wpstream').' <span class="header_special">'.esc_html__('Quick Start','wpstream').'</span>';?></h1>
2587
2588
2589 <p>
2590 <?php esc_html_e('The quick start guide will help you set up Live Streaming, Video On Demand, and Monetization in a fun and interactive way. Give it a shot! ','wpstream');?>
2591 </p>
2592
2593 <div id="wpstream_trigger_quick_start" class="wpstream_button wpstream_button_action"><?php esc_html_e('Start the Guide','wpstream');?></div>
2594
2595
2596
2597 </div>
2598
2599
2600
2601 <script type="text/javascript">
2602 //<![CDATA[
2603 jQuery(document).ready(function(){
2604 jQuery(".wpstream_on_boarding_wrapper").show();
2605 jQuery(".wpstream_modal_background_onboard").show();
2606 });
2607
2608 //]]>
2609 </script>
2610
2611 <?php
2612
2613 }
2614
2615
2616
2617
2618
2619
2620
2621
2622 /*
2623 *
2624 * On Boarding Content
2625 *
2626 */
2627
2628
2629 public function wpstream_onboard_display() {
2630 $this->onboarding_wizard_header();
2631 $this->wpstream_onboarding_step1();
2632 $this->wpstream_onboarding_step2();
2633 $this->wpstream_onboarding_step3_live_streaming();
2634 $this->wpstream_onboarding_step_3_A_live_streaming_free_view();
2635 $this->wpstream_onboarding_step_3_B_live_streaming_pay_per_view();
2636 $this->wpstream_onboarding_step4_vod();
2637 $this->wpstream_onboarding_step_4_free_vod();
2638 $this->wpstream_onboarding_step_4_ppv_vod();
2639 $this->onboarding_wizard_footer();
2640 }
2641
2642
2643 /*
2644 *
2645 * On Boarding Step 1 - the login/register
2646 *
2647 */
2648
2649
2650 public function wpstream_onboarding_step1(){
2651
2652 $wpstream_options_array =array(
2653 2 => array(
2654 'label' => 'WpStream.net Username or Email',
2655 'name' => 'api_username',
2656 'type' => 'text',
2657 ),
2658 3 => array(
2659 'label' => 'WpStream.net Password',
2660 'name' => 'api_password',
2661 'type' => 'password',
2662 ),
2663
2664 );
2665 $token = $this->main->wpstream_live_connection->wpstream_get_token();
2666
2667 ?>
2668 <div class="wpstream_step_wrapper wpstream_step_1" id="wpstream_step_1">
2669 <div class="wpstream_has_credential">
2670 <h1><?php esc_html_e('WpStream Account','wpstream');?></h1>
2671
2672 <div class="wpstream_on_board_login_wrapper_explanations">
2673 <?php esc_html_e('A WpStream account is required to make use of the plugin.','wpstream');?>
2674 </div>
2675
2676
2677 <div class="wpstream_check_account_status">
2678 Checking if you are already logged.....
2679 </div>
2680
2681 <div class="wpstream_onboarding_notification"></div>
2682
2683 <div class="wpstream_option_wrapper wpstream_on_board_login_wrapper">
2684 <h2><?php esc_html_e('Login with your WpStream Account','wpstream');?></h2>
2685 <?php
2686
2687 foreach ($wpstream_options_array as $key=>$option){
2688 print '<div class="wpstream_option">';
2689
2690 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
2691 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
2692 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
2693
2694 print '</div>';
2695 }
2696 ?>
2697 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_login" value="<?php esc_html_e('Login','wpstream');?>" />
2698 </div>
2699
2700
2701
2702
2703 <div class="wpstream_on_board_register_wrapper">
2704 <h2><?php esc_html_e('Register for a WpStream Account','wpstream');?></h2>
2705 <div class="wpstream_option">
2706 <label for="wpstream_register_email"><?php esc_html_e('Your Email','wpstream');?></label>
2707 <input id="wpstream_register_email" type="text" size="36" name="wpstream_register_email" value="<?php echo get_option('admin_email'); ?>" />
2708
2709 </div>
2710
2711 <div class="wpstream_option">
2712 <label for="wpstream_register_password"><?php esc_html_e('Your Password','wpstream');?></label>
2713 <input id="wpstream_register_password" type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
2714 </div>
2715
2716
2717 <?php
2718
2719 $curl_response_decoded['capthca']='';
2720 $curl_response_decoded['capthca_id']='';
2721
2722
2723 if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
2724 $url = 'user/getcapthca';
2725 $curl_post_fields = array();
2726 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
2727 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
2728
2729 }
2730
2731 ?>
2732 <div class="wpstream_option">
2733 <?php print '<div id="wpstream_capthca">'.$curl_response_decoded['capthca'].'</div>';?>
2734 <label for="wpstream_register_captcha"><?php esc_html_e('Type the characters above','wpstream');?></label>
2735
2736 <input id="wpstream_register_captcha" type="text" size="36" name="wpstream_register_captcha" />
2737 <input id="wpstream_register_captcha_id" type="hidden" size="36" name="wpstream_register_captcha_id" value="<?php echo esc_html($curl_response_decoded['capthca_id']); ?>" />
2738 </div>
2739
2740
2741
2742 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_register" value="<?php esc_html_e('register','wpstream');?>" />
2743 </div>
2744
2745
2746 <div id="wpstream_onboarding_action_login"><?php esc_html_e('I already have a WpStream Account','wpstream');?></div>
2747
2748 <div id="wpstream_onboarding_action_register"><?php esc_html_e('Back to Registration','wpstream');?></div>
2749
2750 </div>
2751
2752
2753 <?php
2754 $ajax_nonce = wp_create_nonce( "wpstream_onboarding_nonce");
2755 print'<input type="hidden" id="wpstream_onboarding_nonce" value="'.esc_html($ajax_nonce).'" /> ';
2756
2757 ?>
2758
2759
2760 <div id="wpstream_on_board" class="wpstream_action_next_step" data-nextthing="wpstream_step_2" style="display:none;" >Move to step 2</div>
2761 </div>
2762 <?php
2763
2764 if(trim($token)!==''){
2765 print '<div id="wpstream_have_token"></div>';
2766 }
2767 }
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778 /*
2779 *
2780 * Generate random pass
2781 *
2782 */
2783
2784 public function randomPassword() {
2785 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
2786 $pass = array(); //remember to declare $pass as an array
2787 $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
2788 for ($i = 0; $i < 8; $i++) {
2789 $n = rand(0, $alphaLength);
2790 $pass[] = $alphabet[$n];
2791 }
2792 return implode($pass); //turn the array into a string
2793 }
2794
2795
2796 /*
2797 *
2798 *
2799 *
2800 */
2801
2802 public function wpstream_onboarding_step2(){
2803 ?>
2804
2805 <div class="wpstream_step_wrapper wpstream_step_2" id="wpstream_step_2">
2806 <h1>Welcome to <span class="header_special">WpStream</span>! How would you like to start?</h1>
2807
2808 <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
2809 <div class="wpstram_or">or</div>
2810 <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_4" ><?php esc_html_e('Create a Video-On-Demand (VOD)','wpstream');?></div>
2811
2812 </div>
2813
2814
2815 <?php
2816 }
2817
2818 /*
2819 *
2820 *
2821 *
2822 */
2823
2824 public function wpstream_onboarding_step3_live_streaming(){
2825 ?>
2826
2827 <div class="wpstream_step_wrapper wpstream_step_3 wpstream_onboarding_live" id="wpstream_step_3">
2828 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream'); ?></h1>
2829
2830 <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3a"><?php esc_html_e('No - Free-To-View (FTV)','wpstream');?></div>
2831 <div class="wpstram_or">or</div>
2832 <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream');?></div>
2833
2834 <div class="wpstream_initial_onboarding_controls_wrapper">
2835 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2836 </div>
2837
2838 </div>
2839
2840
2841 <?php
2842 }
2843
2844
2845 /*
2846 *
2847 *
2848 *
2849 */
2850 public function wpstream_onboarding_step_3_A_live_streaming_free_view(){
2851 ?>
2852
2853 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3a">
2854 <h1><?php esc_html_e('Let’s create your first FTV live channel','wpstream');?></h1>
2855
2856 <div id="wpstream_onboard_live_notice" class="wpstream_onboarding_notification"></div>
2857 <div id="wpstream_onboard_live" class="wpstream_accordion_container">
2858 <label>Name your first Free-To-View channel</label>
2859 <input type="text" name="channel_name" id="wpstream_onboarding_channel_name" class="wpstream_onboarding_channel_name" value="<?php esc_html_e('My first FTV channel','wpstream');?>" >
2860 <input type="submit" name="submit" id="wpstream_on_board_create_channel" class="wpstream_button wpstream_button_action wpstream_onboard_live_action" value="<?php esc_html_e('Create Channel','wpstream');?>" />
2861
2862 </div>
2863
2864 <div class="wpstream_initial_onboarding_controls_wrapper">
2865 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
2866 </div>
2867
2868 </div>
2869
2870
2871 <?php
2872 }
2873
2874
2875 /*
2876 *
2877 *
2878 *
2879 */
2880
2881 public function wpstream_onboarding_step_3_B_live_streaming_pay_per_view(){
2882 ?>
2883
2884 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3b">
2885 <h1><?php esc_html_e('Make your live stream Pay Per View','wpstream');?></h1>
2886 <?php
2887 if ( class_exists( 'WooCommerce' ) ) {
2888 ?>
2889 <div id="wpstream_onboard_live_ppv_notice" class="wpstream_onboarding_notification"></div>
2890 <div id="wpstream_onboard_live_ppv" class="wpstream_accordion_container">
2891 <label><?php esc_html_e('Choose a name for your channel','wpstream');?></label>
2892 <input type="text" name="channel_name" id="wpstream_onboarding_channel_name_ppv" class="wpstream_onboarding_channel_name" value="<?php esc_html_e('My First PPV Channel','wpstream');?>">
2893 <label><?php esc_html_e('Pay-Per-View Price ($)','wpstream');?></label>
2894 <input type="text" name="channel_name" id="wpstream_onboarding_event_price_ppv" class="wpstream_onboarding_event_price" value="10">
2895 <input type="submit" name="submit" id="wpstream_onboard_live_ppv_action" class="wpstream_button wpstream_button_action wpstream_onboard_live_ppv_action" value="<?php esc_html_e('Create Channel','wpstream');?>" />
2896
2897 </div>
2898 <?php
2899 } else {
2900 $this->wpstream_onboarding_woo_warning();
2901 } ?>
2902
2903
2904 <div class="wpstream_initial_onboarding_controls_wrapper">
2905 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
2906 </div>
2907 </div>
2908 <?php
2909 }
2910
2911
2912
2913
2914
2915
2916 /*
2917 * WooCommerce not installed Warning
2918 *
2919 *
2920 */
2921
2922 public function wpstream_onboarding_woo_warning(){
2923 print'<div class="wpstream_warning_onboarding">
2924 '.esc_html__('Pay-Per-View streaming requires WooCommerce. Please install the WooCommerce plugin and try again.','wpstream').'
2925 </br>
2926 <div class="wpstream_install_plugin">'. esc_html__('Install WooCommerce','wpstream').'</div>
2927
2928 <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
2929 </div>';
2930 }
2931
2932
2933 /*
2934 *
2935 *
2936 *
2937 */
2938
2939 public function wpstream_onboarding_step4_vod(){
2940 ?>
2941 <div class="wpstream_step_wrapper wpstream_step_4 wpstream_onboarding_vod" id="wpstream_step_4">
2942 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream');?></h1>
2943
2944 <div class="wpstream_accordion_header wpstream_action_next_step" data-control="wpstream_onboard_vod_free" data-nextthing="wpstream_step_4a" ><?php esc_html_e('No - Free-To-View (FTV)','wpstream'); ?></div>
2945 <div class="wpstram_or">or</div>
2946 <div class="wpstream_accordion_header wpstream_action_next_step" data-control="wpstream_onboard_vod_ppv" data-nextthing="wpstream_step_4b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream'); ?></div>
2947
2948
2949 <div class="wpstream_initial_onboarding_controls_wrapper">
2950 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2951 </div>
2952
2953 </div>
2954 <?php
2955 }
2956
2957
2958 /*
2959 *
2960 *
2961 *
2962 */
2963 public function wpstream_onboarding_step_4_free_vod(){
2964
2965 $current_screen=get_current_screen();
2966 if($current_screen->base !=='wpstream_page_wpstream_onboard'){
2967 return;
2968 }
2969
2970 $token = $this->main->wpstream_live_connection->wpstream_get_token();
2971 $video_list = array();
2972 if($token!=''){
2973 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2974 }
2975
2976 ?>
2977
2978 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4a">
2979 <h1><?php esc_html_e('Let’s create your first Free-To-View VOD','wpstream');?></h1>
2980
2981
2982
2983 <?php
2984 if( count($video_list) !== 0 ) {
2985 ?>
2986 <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div>
2987 <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
2988 <label><?php esc_html_e('Name your FTV Video-On-Demand','wpstream')?></label>
2989 <input type="text" name="channel_name" class="wpstream_onboarding_vod_name" id="wpstream_onboarding_vod_name" value="<?php esc_html_e('My First FTV VOD','wpstream');?>" >
2990 <?php $this->wpstream_show_vod_dropdown_onboarding($video_list); ?>
2991 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_free_action" id="wpstream_onboard_vod_free_action" value="<?php esc_html_e('Create FTV VOD','wpstream');?>" />
2992 </div>
2993
2994 <?php }else{
2995 $this->wpstream_obboarding_file_warning();
2996 } ?>
2997
2998
2999
3000 <div class="wpstream_initial_onboarding_controls_wrapper">
3001 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
3002 </div>
3003
3004 </div>
3005
3006
3007 <?php
3008 }
3009
3010 /*
3011 *
3012 *
3013 *
3014 */
3015
3016 public function wpstream_show_vod_dropdown_onboarding($video_list,$appendix=''){
3017
3018 print '<label>'.esc_html__('Choose Recording','wpstream').'</label>
3019 <select name="wpstream_free_vod_file_name" id="wpstream_free_vod_file_name'.$appendix.'">
3020 <option value="">'.esc_html__('Please select a recording from the list','wpstream').'</option>';
3021
3022 if(is_array($video_list)){
3023 foreach ($video_list as $key=>$value){
3024 print '<option value="'.$key.'"';
3025 print '>'.$value.'</option>';
3026 }
3027 }
3028 print'</select>';
3029
3030 }
3031
3032
3033
3034 /*
3035 *
3036 *
3037 *
3038 */
3039 public function wpstream_obboarding_file_warning(){
3040 print '<div class="wpstream_warning_onboarding">
3041 '.esc_html__('A recording is needed to create a VOD from. There are no recordings under your account. You can create new recordings by recording a live channel or uploading video files directly.','wpstream').'
3042 </br>
3043 <div class="wpstream_upload_video">'.esc_html__('Upload Video','wpstream').'</div>
3044
3045 <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
3046 </div>';
3047 }
3048
3049
3050
3051
3052 /*
3053 *
3054 *
3055 *
3056 */
3057 public function wpstream_onboarding_step_4_ppv_vod(){
3058 $current_screen=get_current_screen();
3059
3060 if($current_screen->base !=='wpstream_page_wpstream_onboard'){
3061 return;
3062 }
3063
3064 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3065 $video_list = array();
3066 if($token!=''){
3067 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
3068 }
3069 ?>
3070
3071 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4b">
3072 <h1><?php esc_html_e('Let\'s create your first Pay-Per-View VOD','wpstream');?></h1>
3073
3074 <div id="wpstream_onboard_vod_ppv_notice" class="wpstream_onboarding_notification"></div>
3075 <?php
3076 if( count($video_list) !== 0 ) {
3077 if ( class_exists( 'WooCommerce' ) ) {
3078 ?>
3079 <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
3080 <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
3081 <input type="text" name="channel_name" class="wpstream_onboarding_ppv_vod_name" id="wpstream_onboarding_ppv_vod_name" value="<?php esc_html_e('My First PPV VOD','wpstream');?>">
3082
3083 <?php $this->wpstream_show_vod_dropdown_onboarding($video_list,'_for_ppv'); ?>
3084
3085 <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
3086 <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
3087 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_ppv_action" id="wpstream_onboard_vod_ppv_action" value="<?php esc_html_e('Create PPV VOD','wpstream');?>" />
3088
3089 </div>
3090 <?php }else{
3091 $this->wpstream_onboarding_woo_warning();
3092 }
3093
3094
3095 }else{
3096 $this->wpstream_obboarding_file_warning();
3097 }
3098 ?>
3099
3100
3101 <div class="wpstream_initial_onboarding_controls_wrapper">
3102 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
3103 </div>
3104
3105 </div>
3106
3107
3108 <?php
3109 }
3110
3111
3112
3113
3114 /*
3115 *
3116 * On boarding Header
3117 *
3118 */
3119 public function onboarding_wizard_header() {
3120 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3121 ?>
3122
3123 <div class="wpstream_on_boarding_wrapper">
3124 <div class="wpstream_close_onboarding wpstream_close_initial_onboarding"></div>
3125 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
3126 <div class="wpstream_close_onboarding_warning"></div>
3127
3128 <?php
3129 }
3130
3131
3132
3133
3134
3135 /*
3136 *
3137 * On Boarding Footer
3138 *
3139 */
3140 public function onboarding_wizard_footer() {
3141 ?>
3142 <div class="wpstream_modal_back"></div>
3143 </div>
3144 <div class="wpstream_modal_background_onboard"></div>
3145 <?php
3146 }
3147
3148
3149
3150 /*
3151 *
3152 * On Boarding create PPV channel
3153 *
3154 */
3155
3156
3157 public function wpstream_on_board_create_channel_ppv(){
3158 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3159 $current_user = wp_get_current_user();
3160
3161 if(current_user_can('administrator')){
3162 $channel_name = sanitize_text_field($_POST['channel_name']);
3163 $channel_price = floatval($_POST['channel_price']);
3164 $my_post = array(
3165 'post_title' => $channel_name,
3166 'post_content' => '',
3167 'post_status' => 'publish',
3168 'post_type' => 'product',
3169 'post_author' => $current_user->ID
3170 );
3171
3172 // Insert the post into the database
3173 $post_id = wp_insert_post( $my_post );
3174
3175 if(is_wp_error($post_id)){
3176 echo json_encode( array('succes'=>false) );
3177 }else{
3178
3179 $product = wc_get_product($post_id);
3180 $price = wc_format_decimal($channel_price);
3181
3182 $product = wc_get_product( $post_id );
3183 $product->set_price( $price );
3184 $product->set_regular_price( $price ); // To be sure
3185 $product->save();
3186 update_post_meta ($post_id,'event_passed',0);
3187 wp_set_object_terms( $post_id, 'live_stream', 'product_type' );
3188
3189
3190
3191
3192 $permalink = get_edit_post_link($post_id);
3193
3194 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3195 $permalink= add_query_arg( 'branch', '2', $permalink );
3196
3197
3198 echo json_encode( array(
3199 'success'=> true,
3200 'link' => ($permalink)
3201 ));
3202 }
3203
3204 }
3205 die();
3206 }
3207
3208 /*
3209 *
3210 * On Boarding create channel
3211 *
3212 */
3213
3214
3215 public function wpstream_on_board_create_channel(){
3216 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3217 $current_user = wp_get_current_user();
3218
3219 if(current_user_can('administrator')){
3220 $channel_name=sanitize_text_field($_POST['channel_name']);
3221 $my_post = array(
3222 'post_title' => $channel_name,
3223 'post_content' => '',
3224 'post_status' => 'publish',
3225 'post_type' => 'wpstream_product',
3226 'post_author' => $current_user->ID
3227 );
3228
3229 // Insert the post into the database
3230 $post_id = wp_insert_post( $my_post );
3231
3232 if(is_wp_error($post_id)){
3233 echo json_encode( array('succes'=>false) );
3234 }else{
3235 $permalink = get_edit_post_link($post_id);
3236
3237 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3238 $permalink= add_query_arg( 'branch', '1', $permalink );
3239
3240
3241 echo json_encode( array(
3242 'success'=> true,
3243 'link' => ($permalink)
3244 ));
3245 }
3246
3247 }
3248 die();
3249 }
3250
3251
3252
3253 /*
3254 *
3255 * On Boarding create free vod
3256 *
3257 */
3258
3259
3260 public function wpstream_on_board_create_free_vod(){
3261 $current_user = wp_get_current_user();
3262 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3263 if(current_user_can('administrator')){
3264 $channel_name =sanitize_text_field($_POST['channel_name']);
3265 $file_name =sanitize_text_field($_POST['file_name']);
3266 $my_post = array(
3267 'post_title' => $channel_name,
3268 'post_content' => '',
3269 'post_status' => 'publish',
3270 'post_type' => 'wpstream_product_vod',
3271 'post_author' => $current_user->ID
3272 );
3273
3274 // Insert the post into the database
3275 $post_id = wp_insert_post( $my_post );
3276
3277 if(is_wp_error($post_id)){
3278 echo json_encode( array('succes'=>false) );
3279 }else{
3280 update_post_meta($post_id, 'wpstream_product_type', 2);
3281 update_post_meta($post_id, 'wpstream_free_video', $file_name);
3282
3283
3284 $permalink = get_edit_post_link($post_id);
3285
3286 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3287 $permalink= add_query_arg( 'branch', '3', $permalink );
3288
3289
3290 echo json_encode( array(
3291 'success'=> true,
3292 'link' => ($permalink)
3293 ));
3294 }
3295
3296 }
3297 die();
3298 }
3299
3300
3301 /*
3302 *
3303 * On Boarding create ppv vod
3304 *
3305 */
3306
3307
3308 public function wpstream_on_board_create_ppv_vod(){
3309 $current_user = wp_get_current_user();
3310 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3311
3312 if(current_user_can('administrator')){
3313 $channel_name = sanitize_text_field($_POST['channel_name']);
3314 $vod_price = floatval($_POST['vod_price']);
3315 $file_name = sanitize_text_field($_POST['file_name']);
3316
3317 $my_post = array(
3318 'post_title' => $channel_name,
3319 'post_content' => '',
3320 'post_status' => 'publish',
3321 'post_type' => 'product',
3322 'post_author' => $current_user->ID
3323 );
3324
3325 // Insert the post into the database
3326 $post_id = wp_insert_post( $my_post );
3327
3328 if(is_wp_error($post_id)){
3329 echo json_encode( array('succes'=>false) );
3330 }else{
3331
3332 $product = wc_get_product($post_id);
3333 $price = wc_format_decimal($vod_price);
3334
3335 $product = wc_get_product( $post_id );
3336 $product->set_price( $price );
3337 $product->set_regular_price( $price ); // To be sure
3338 $product->save();
3339 update_post_meta ($post_id,'event_passed',0);
3340 update_post_meta ($post_id,'_movie_url', $file_name);
3341 wp_set_object_terms( $post_id, 'video_on_demand', 'product_type' );
3342
3343
3344
3345
3346 $permalink = get_edit_post_link($post_id);
3347
3348 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3349 $permalink= add_query_arg( 'branch', '4', $permalink );
3350
3351
3352 echo json_encode( array(
3353 'success'=> true,
3354 'link' => ($permalink) ,
3355 ' $file_name'=> $file_name,
3356 ));
3357 }
3358
3359 }
3360 die();
3361 }
3362
3363
3364 /*
3365 *
3366 * On Boarding login
3367 *
3368 */
3369 public function wpstream_on_board_login(){
3370 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3371
3372 if(current_user_can('administrator')){
3373 $username = sanitize_text_field($_POST['api_username']);
3374 $password = sanitize_text_field($_POST['api_password']);
3375 update_option('wpstream_api_username',$username);
3376 update_option('wpstream_api_password',$password);
3377
3378 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3379
3380 echo json_encode( array(
3381 'success'=> true,
3382 'token' => ($token)
3383 ));
3384
3385 }else{
3386 echo json_encode( array(
3387 'success'=> false,
3388 'token' => esc_html('You are not an administrator','wpstream')
3389 ));
3390 }
3391 die();
3392 }
3393
3394
3395 public function wpstream_register_refresh_capthca(){
3396
3397 if(current_user_can('administrator')){
3398
3399 }
3400 }
3401
3402 /*
3403 *
3404 * On Boarding login
3405 *
3406 */
3407 public function wpstream_on_board_register(){
3408
3409 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3410
3411 if(current_user_can('administrator')){
3412 $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']);
3413 $wpstream_register_password = sanitize_text_field($_POST['wpstream_register_password']);
3414 $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']);
3415 $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']);
3416
3417 $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password);
3418 if(!$validate['success']){
3419 echo json_encode($validate);
3420 die();
3421 }
3422
3423 $url='user/create';
3424 $curl_post_fields=array(
3425 'email' => $wpstream_register_email,
3426 'password' => $wpstream_register_password,
3427 'captcha' => $wpstream_register_captcha,
3428 'captcha_id' => $wpstream_register_captcha_id,
3429 );
3430
3431
3432
3433 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
3434 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
3435
3436
3437
3438 if($curl_response_decoded['success']){
3439
3440 if($curl_response_decoded['request']['registred']){
3441 // we are registerd
3442
3443 update_option('wpstream_api_username',$wpstream_register_email);
3444 update_option('wpstream_api_password',$wpstream_register_password);
3445
3446 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3447
3448 echo json_encode( array(
3449 'success' => true,
3450 'token' => $token ,
3451 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'),
3452
3453 ));
3454 die();
3455 }else{
3456
3457 echo json_encode( array(
3458 'success'=> false,
3459 'message'=> $curl_response_decoded['request']['message'],
3460 'curl'=>$curl_response_decoded,
3461
3462 ));
3463 die();
3464 }
3465
3466
3467
3468
3469 }else{
3470
3471 echo json_encode( array(
3472 'success'=> false,
3473 'message'=> esc_html__('Register action could not be completed. Please register on wpstream.net','wpstream'),
3474
3475 ));
3476 die();
3477 }
3478
3479
3480
3481
3482
3483
3484
3485
3486 }else{
3487 echo json_encode( array(
3488 'success'=> false,
3489 'message' => esc_html('You are not an administrator','wpstream')
3490 ));
3491 die();
3492 }
3493
3494 die();
3495 }
3496
3497
3498 /*
3499 *
3500 * Validate for register
3501 *
3502 */
3503
3504
3505 public function wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password){
3506
3507 $return= array(
3508 'success'=>true
3509 );
3510
3511 if ($wpstream_register_email=='' ){
3512 $return= array(
3513 'success'=> false,
3514 'message' => esc_html('The email Field is Empty','wpstream')
3515 );
3516 return $return;die();
3517 }
3518
3519 if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) {
3520 $return= array(
3521 'success'=> false,
3522 'message' => esc_html('The email doesn\'t look right !','wpstream')
3523 );
3524 return $return;die();
3525 }
3526
3527
3528 $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1);
3529 if( $domain!='' && !checkdnsrr ($domain) ){
3530 $return= array(
3531 'success'=> false,
3532 'message' => esc_html('The email doesn\'t look right !','wpstream')
3533 );
3534 return $return;die();
3535 }
3536
3537
3538
3539 if(strlen($wpstream_register_password)<5){
3540 $return= array(
3541 'success'=> false,
3542 'message' => esc_html('The password is too short. Please use at least 5 characters.','wpstream')
3543 );
3544 return $return;die();
3545 }
3546
3547 return $return;die();
3548 }
3549 }