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

3,474 lines 172.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link http://wpstream.net
7 * @since 3.0.1
8 *
9 * @package Wpstream
10 * @subpackage Wpstream/admin
11 */
12
13 /**
14 * The admin-specific functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the admin-specific stylesheet and JavaScript.
18 *
19 * @package Wpstream
20 * @subpackage Wpstream/admin
21 * @author wpstream <office@wpstream.net>
22 */
23 class Wpstream_Admin {
24
25
26 /**
27 * Store plugin main class to allow public access.
28 *
29 * @since 20180622
30 * @var object The main class.
31 */
32 public $main;
33
34
35 /**
36 * The ID of this plugin.
37 *
38 * @since 3.0.1
39 * @access private
40 * @var string $plugin_name The ID of this plugin.
41 */
42 private $plugin_name;
43
44 /**
45 * The version of this plugin.
46 *
47 * @since 3.0.1
48 * @access private
49 * @var string $version The current version of this plugin.
50 */
51 private $version;
52
53 /**
54 * Initialize the class and set its properties.
55 *
56 * @since 3.0.1
57 * @param string $plugin_name The name of this plugin.
58 * @param string $version The version of this plugin.
59 */
60
61 public $global_event_options ;
62
63
64
65
66
67 public function __construct( $plugin_name, $version,$plugin_main ) {
68
69 $this->plugin_name = $plugin_name;
70 $this->version = $version;
71 $this->main = $plugin_main;
72
73 $this->global_event_options = array(
74
75 'record' =>array(
76 'name' => esc_html__('Record Live Stream','wpstream'),
77 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'),
78 'defaults' => 'no',
79
80 ),
81 'view_count' =>array(
82 'name' => esc_html__('Display Viewer Count','wpstream'),
83 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'),
84 'defaults' => 'yes',
85 ),
86 'domain_lock'=>array(
87 'name' => esc_html__('Lock To Website','wpstream'),
88 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
89 'defaults' => 'no',
90 ),
91 'autoplay' =>array(
92 'name' => esc_html__('Autoplay','wpstream'),
93 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
94 'defaults' => 'yes',
95 ),
96 'mute' =>array(
97 'name' => esc_html__('Start Muted','wpstream'),
98 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'),
99 'defaults' => 'no',
100
101 ),
102 'low_latency' =>array(
103 'name' => esc_html__('Low Latency (beta)','wpstream'),
104 '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'),
105 'defaults' => 'no',
106 ),
107 'adaptive_bitrate' =>array(
108 'name' => esc_html__('Adaptive Bitrate (beta)','wpstream'),
109 'details' => esc_html__('Ensures a smooth and uninterrupted viewing experience by adjusting video quality for viewers with reduced network speed or device capabilities.','wpstream'),
110 'defaults' => 'no',
111 ),
112 'encrypt' =>array(
113 'name' => esc_html__('Encrypt Live Stream','wpstream'),
114 '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'),
115 'defaults' => 'no',
116 ),
117 'ses_encrypt'=>array(
118 'name' => esc_html__('Use Sessions with Encryption','wpstream'),
119 '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'),
120 'defaults' => 'no',
121 ),
122 'autostart' =>array(
123 'name' => esc_html__('Auto TURN ON','wpstream'),
124 'details' => esc_html__('If enabled, channel will TURN ON automatically when broadcasting with an External Streaming App (RTMP Encoder/Broadcaster)','wpstream'),
125 'defaults' => 'no',
126 ),
127
128 'vod_domain_lock' =>array(
129 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'),
130 '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') ),
131 'defaults' => 'no',
132 ),
133 'vod_encrypt' =>array(
134 'name' => esc_html__('Encrypt Video on Demand','wpstream'),
135 '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'),
136 'defaults' => 'no',
137 ),
138 );
139
140 }
141
142 /**
143 * Register the stylesheets for the admin area.
144 *
145 * @since 3.0.1
146 */
147 public function enqueue_styles() {
148
149 /**
150 * This function is provided for demonstration purposes only.
151 *
152 * An instance of this class should be passed to the run() function
153 * defined in Wpstream_Loader as all of the hooks are defined
154 * in that particular class.
155 *
156 * The Wpstream_Loader will then create the relationship
157 * between the defined hooks and the functions defined in this
158 * class.
159 */
160 wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
161 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
162
163 wp_enqueue_style( 'wpstream-on-boarding-css', plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css', array(), rand(1,999999999999), 'all' );
164
165
166 }
167
168 /**
169 * Register the JavaScript for the admin area.
170 *
171 * @since 3.0.1
172 */
173 public function enqueue_scripts() {
174
175 wp_enqueue_script("jquery-ui-slider");
176 wp_enqueue_script("jquery-ui-datepicker");
177 wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
178 wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
179 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
180 array(
181 'admin_url' => get_admin_url(),
182 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
183 'download_mess' => esc_html__('Click to download!','wpstream'),
184 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
185 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
186 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
187 'upload_complete' => esc_html('Upload Complete!','wpstream'),
188 'no_band' => esc_html('Not enough streaming data.','wpsteam'),
189 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam')
190
191 ));
192
193
194
195 wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
196 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
197 array(
198 'admin_url' => get_admin_url(),
199 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
200 'download_mess' => esc_html__('Click to download!','wpstream'),
201 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
202 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
203 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
204 'upload_complete' => esc_html('Upload Complete!','wpstream'),
205 'no_band' => esc_html('Not enough streaming data.','wpsteam'),
206 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam'),
207
208 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'),
209 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'),
210 'start_streaming' => esc_html__('TURN ON','wpstream'),
211 'stop_streaming' => esc_html__('TURN OFF','wpstream'),
212 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'),
213 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'),
214 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'),
215 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'),
216 'error1' => esc_html__('You don\'t have enough data to start a new event!','wpstream'),
217 'failed_event_creation' => esc_html__('Failed to start the channel. Please try again in a few minutes.','wpstream'),
218 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'),
219 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'),
220 'channel_on' => esc_html__('Channel is ON','wpstream'),
221 'channel_off' => esc_html__('Channel is OFF','wpstream'),
222 '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')
223 ));
224
225
226 wp_enqueue_script('wpstream-on-boarding-js', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
227 wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars',
228 array(
229 'admin_url' => get_admin_url(),
230 'plugin_url' => get_dashboard_url().'/plugins.php',
231 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings'
232
233 ));
234
235 }
236
237
238 /**
239 * Add Plugin Administation menu
240 *
241 * @since 3.0.1
242 */
243
244 public function wpstream_manage_admin_menu() {
245
246 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 );
247 add_submenu_page( 'wpstream_credentials', __('WpStream Credentials','wpestream'), __('Credentials','wpestream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials') );
248 add_submenu_page( 'wpstream_credentials', __('WpStream Live Channels','wpestream'), __('All Channels','wpestream'), 'administrator', 'wpstream_live_channels', array( $this,'wpstream_new_general_set'));
249 add_submenu_page( 'wpstream_credentials', __('WpStream Recordings','wpestream'), __('Recordings','wpestream'), 'administrator', 'wpstream_recordings', array($this,'wpstream_media_management'));
250 add_submenu_page( 'wpstream_credentials', __('WpStream Settings','wpestream'), __('Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings'));
251
252 add_submenu_page( 'wpstream_credentials', __('WpStream Quick Start','wpestream'), __('WpStream Quick Start','wpestream'), 'administrator', 'wpstream_onboard', array($this,'wpstream_pre_onboard_display'));
253
254
255
256
257 }
258
259
260
261
262 /**
263 * Shows events wpstream
264 *
265 * @since 3.0.1
266 */
267
268 public function wpstream_new_general_set() {
269
270 $no_channel=1;
271
272 if(class_exists ('WC_Subscription')){
273
274 }
275
276 //event_passed
277 $args = array(
278 'posts_per_page' => -1,
279 'post_type' => 'product',
280 'post_status' => 'publish',
281 'meta_query' => array(
282 array(
283 'key' => 'event_passed',
284 'value' => 1,
285 'compare' => '!=',
286 )
287 ),
288
289 'tax_query' => array(
290 'relation' => 'AND',
291 array(
292 'taxonomy' => 'product_type',
293 'field' => 'slug',
294 'terms' => array('live_stream','subscription')
295 )
296 ),
297 );
298
299
300
301 $event_list = new WP_Query($args);
302 global $live_event_for_user;
303 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
304 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
305
306 $this->main->show_user_data($pack_details);
307 if( $event_list->have_posts()){
308
309
310 print '<div class="pack_details_wrapper_transparent">
311 <h3>'.__('Your Pay-Per-View Channel List','wpstream').'</h3>';
312
313
314 $link_new = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
315
316 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new Pay-Per-View channel.','wpstream').'</a>';
317 print '</div>';
318
319 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
320
321 while ($event_list->have_posts()): $event_list->the_post();
322
323 $the_id = get_the_ID();
324 $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true));
325 $term_list = wp_get_post_terms($the_id, 'product_type');
326
327 if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){
328 continue;
329 }
330
331 $this->wpstream_live_stream_unit($the_id);
332
333 endwhile;
334
335 print'</div>';
336 $no_channel=1;
337 }else{
338 $no_channel=0;
339 }
340
341
342 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
343 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
344 $current_user = wp_get_current_user();
345 $allowded_html = array();
346 $userID = $current_user->ID;
347 $user_live_streams = get_user_meta($userID,'live_shows');
348
349
350 wp_reset_postdata();
351
352
353
354
355 // free
356
357 $args_free = array(
358 'posts_per_page' => -1,
359 'post_type' => 'wpstream_product',
360 'post_status' => 'publish',
361
362
363 );
364 $event_list_free = new WP_Query($args_free);
365
366
367 if( $event_list_free->have_posts()){
368 print '<div class="pack_details_wrapper_transparent">
369 <h3>'.__('Free-To-View Channels','wpstream').'</h3>';
370
371 $link_new = admin_url('post-new.php?post_type=wpstream_product');
372 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new Free-To-View channel.','wpstream').'</a>';
373 print '</div>';
374 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
375
376 while ($event_list_free->have_posts()): $event_list_free->the_post();
377
378
379 $the_id = get_the_ID();
380
381 if( get_post_meta ($the_id,'event_passed',true)!=1){
382 $this->wpstream_live_stream_unit($the_id);
383 }
384
385 endwhile;
386
387 print'</div><div class="wpstream_modal_background"></div>';
388 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
389 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
390 </div>';
391 $no_channel=1;
392 }else{
393 $no_channel=0;
394 }
395
396
397
398
399 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
400 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
401 print '<div class="no_events_warning"> ';
402 if($event_list->found_posts==0){
403 print '<div class="no_events_warning_mes">'.__('* You do not have any Pay-Per-View channels!','wpstream').'</div>';
404 }
405 if($event_list_free->found_posts==0){
406 print '<div class="no_events_warning_mes">'. __('* You do not have any free channels!','wpstream').'</div>';
407 }
408
409 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new Free-To-View channel ','wpstream').'</a>';
410 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new Pay-Per-View channel ','wpstream').'</a>';
411
412 print '</div>';
413
414
415
416
417 }
418 // end wpstream_new_general_set
419
420
421 /**
422 * Social share
423 *
424 * @since 3.0.1
425 */
426
427 public function wpstream_social_share($the_id){
428 $protocol = is_ssl() ? 'https' : 'http';
429 $pinterest = wp_get_attachment_image_src(get_post_thumbnail_id($the_id), 'full');
430 $link = esc_url ( get_permalink($the_id) );
431 $title = get_the_title($the_id);
432 $twiter_status = urlencode( $title.' '.$link);
433 $email_link = 'subject='.urlencode ( $title ) .'&body='. urlencode( esc_url($link));
434
435 $facebook_link = esc_html($protocol).'://www.facebook.com/sharer.php?u='. esc_url($link) .'&amp;t='. urlencode(get_the_title());
436
437 ?>
438 <div class="wpstream_social_share_wrapper">
439
440 <a href="<?php print esc_url( $facebook_link); ?>" target="_blank" class="social_facebook wpstream_sharing_social">
441 <span class="dashicons dashicons-facebook-alt"></span>
442 </a>
443
444 <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">
445 <span class="dashicons dashicons-twitter"></span>
446 </a>
447
448 <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">
449 <span class="dashicons dashicons-pinterest"></span>
450 </a>
451
452 <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">
453 <span class="dashicons dashicons-whatsapp"></span>
454 </a>
455
456 <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">
457 <span class="dashicons dashicons-linkedin"></span>
458 </a>
459
460 <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">
461 <span class="dashicons dashicons-reddit"></span>
462 </a>
463
464 <a href="mailto:email@email.com?<?php echo trim(esc_html($email_link));?>" data-action="share email" class="social_email wpstream_sharing_social">
465 <span class="dashicons dashicons-email-alt"></span>
466 </a>
467
468 <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>
469 <?php
470 print '</div>';
471 }
472
473
474
475
476 /**
477 * Shows event unit card in admin
478 *
479 * @since 3.0.1
480 */
481
482 public function wpstream_live_stream_unit($the_id,$is_front=''){
483 global $live_event_for_user;
484 global $wpstream_plugin;
485 $current_user = wp_get_current_user();
486
487 if( !current_user_can('administrator')){
488 if($is_front=='' ){
489 print '<div class="event_list_unit">';
490 esc_html_e('You are not allowed to broadcast.','wpstream');
491 print '</div>';
492 return;
493 }
494
495 }
496
497 if( !$this->main->wpstream_check_user_can_stream() ){
498 print '<div class="event_list_unit">';
499 esc_html_e('You are not allowed to broadcast','wpstream');
500 print '</div>';
501 return;
502 }
503
504
505 $live_class='';
506 if(isset($live_event_for_user[$the_id])) {
507 $live_class=" wpstream_show_started";
508 }
509
510
511 if(has_post_thumbnail($the_id)){
512 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
513 }else{
514 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
515 }
516
517 $pending_streaming_class = 'hide_stream_data';
518 $external_software_streaming_class = '';
519 $obs_uri = '';
520 $obs_stream = '';
521 $live_data_url = '';
522
523 if( $live_event_for_user=='' && $is_front=='front' ){
524 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
525 }
526 $channel_status = esc_html__('Channel is OFF','wpstream');
527 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
528 $pending_streaming_class = 'pending_trigger';
529 $live_data_url = get_post_meta($the_id,'qos_url',true);
530 // $channel_status = esc_html__('Channel is on','wpstream');
531 }
532
533 $server_id = get_post_meta($the_id,'server_id',true);
534 $obs_uri = get_post_meta($the_id,'obs_uri',true);
535 $obs_stream = get_post_meta($the_id,'obs_stream',true);
536 $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
537 $rtmp_ip_uri = '';
538
539 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.'"">';
540
541 print '<div class="wpstream_channel_status">'.$channel_status.'</div>';
542
543 print '<div class="server_notification"></div>';
544
545 print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
546
547 print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10);
548
549
550 /* print '***</br>'.get_post_meta($the_id,'obs_uri',true) .'***</br>'.
551 get_post_meta($the_id,'obs_stream',true).'***</br>'.
552 get_post_meta($the_id,'broadcast_url',true);
553 */
554 print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
555 print '</div>';
556
557
558 print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream');
559 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
560 print '</div>';
561
562 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
563
564 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.'"">';
565
566 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
567 print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
568
569 print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
570 <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"/>
571 </svg>';
572 print '</div>';
573
574
575 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.'"">';
576
577 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
578 print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
579
580 print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
581 <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"/>
582 <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"/>
583 </svg>';
584 print '</div>';
585
586
587
588
589 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.'" >';
590
591 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
592 print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
593
594 print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
595 <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"/>
596 <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"/>
597 <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"/>
598 <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"/>
599 </svg>';
600 print '</a>';
601 print '</div>';
602
603 print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
604 if($is_front==''){
605 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').'">';
606
607 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
608 print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
609
610 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
611 <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"/>
612 </svg>
613 </div>';
614
615
616 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.'"">';
617 print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
618 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
619 <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"/>
620 </svg>';
621 print '</a>';
622 }
623
624 print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
625 print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
626 print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
627 <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"/>
628 <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"/>
629 </svg>';
630 print '</a>';
631
632
633 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.'"">';
634 print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
635 print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
636 <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"/>
637 </svg>';
638 print '</div>';
639 print '</div>';
640
641
642
643
644
645
646 $this->wpstream_display_modal_seetings($the_id);
647 $this->wpstream_display_modal_share($the_id);
648 $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
649
650 print '</div>';
651
652 }
653
654
655
656
657 /**
658 * Shows event unit card in admin - theme version
659 *
660 * @since 3.0.1
661 */
662 public function wpstream_live_stream_unit_for_theme($the_id,$is_front=''){
663 global $live_event_for_user;
664 global $wpstream_plugin;
665 $current_user = wp_get_current_user();
666
667 if( !current_user_can('administrator')){
668 if($is_front=='' ){
669 print '<div class="event_list_unit">';
670 esc_html_e('You are not allowed to broadcast.','wpstream');
671 print '</div>';
672 return;
673 }
674
675 }
676
677 if( !$this->main->wpstream_check_user_can_stream() ){
678 print '<div class="event_list_unit">';
679 esc_html_e('You are not allowed to broadcast','wpstream');
680 print '</div>';
681 return;
682 }
683
684
685 $live_class='';
686 if(isset($live_event_for_user[$the_id])) {
687 $live_class=" wpstream_show_started";
688 }
689
690
691 if(has_post_thumbnail($the_id)){
692 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
693 }else{
694 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
695 }
696
697 $pending_streaming_class = 'hide_stream_data';
698 $external_software_streaming_class = '';
699 $obs_uri = '';
700 $obs_stream = '';
701 $live_data_url = '';
702
703 if( $live_event_for_user=='' && $is_front=='front' ){
704 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
705 }
706 $channel_status = esc_html__('Channel is OFF','wpstream');
707 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
708 $pending_streaming_class = 'pending_trigger';
709 $live_data_url = get_post_meta($the_id,'qos_url',true);
710 // $channel_status = esc_html__('Channel is on','wpstream');
711 }
712
713 $server_id = get_post_meta($the_id,'server_id',true);
714 $obs_uri = get_post_meta($the_id,'obs_uri',true);
715 $obs_stream = get_post_meta($the_id,'obs_stream',true);
716 $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
717 $rtmp_ip_uri = '';
718
719 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.'"">';
720
721 print '<div class="wpstream_channel_status">'.$channel_status.'</div>';
722
723 print '<div class="server_notification"></div>';
724
725 print '<div class="wpstream_theme_event_thumb_wrapper">';
726 print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
727 print '<div class="event_title" data-prodid="'.$the_id.'">remove: '.wp_trim_words(get_the_title($the_id),10);
728 print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
729 print '</div>';
730 print '</div>';
731
732 print '<div class="wpstream_theme_control_bar_wrapper">';
733
734
735 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
736
737 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.'"">';
738
739 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
740 print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
741
742 print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
743 <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"/>
744 </svg>';
745 esc_html_e('Webcam','wpstream');
746 print '</div>';
747
748
749 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.'"">';
750
751 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
752 print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
753
754 print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
755 <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"/>
756 <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"/>
757 </svg>';
758 esc_html_e('External App','wpstream');
759 print '</div>';
760
761
762
763
764 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.'" >';
765
766 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
767 print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
768
769 print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
770 <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"/>
771 <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"/>
772 <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"/>
773 <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"/>
774 </svg>';
775 esc_html_e('Statistics','wpstream');
776 print '</a>';
777 print '</div>';
778
779 print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
780 if($is_front==''){
781 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').'">';
782
783 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
784 print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
785
786 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
787 <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"/>
788 </svg>
789 </div>';
790
791
792 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.'"">';
793 print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
794 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
795 <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"/>
796 </svg>';
797 print '</a>';
798 }
799
800 print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
801 print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
802 print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
803 <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"/>
804 <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"/>
805 </svg>';
806 esc_html_e('View','wpstream');
807 print '</a>';
808
809
810 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.'"">';
811 print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
812 print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
813 <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"/>
814 </svg>';
815 esc_html_e('Share','wpstream');
816 print '</div>';
817 print '</div>';
818
819
820 print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream');
821 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
822 print '</div>';
823
824 print '</div>';
825
826
827
828
829 $this->wpstream_display_modal_seetings($the_id);
830 $this->wpstream_display_modal_share($the_id);
831 $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
832
833 print '</div>';
834
835 }
836
837
838 /*
839 *
840 * Close modal button
841 *
842 */
843
844 public function wpstream_close_modal_button(){
845 print '<div class="wpstream_close_modal"></div>';
846 }
847
848 /*
849 *
850 * Display modal settings
851 *
852 */
853
854 public function wpstream_display_modal_seetings($the_id){
855 print '<div class="wpstream_modal_form wpestate_settings_modal">';
856 $this->wpstream_close_modal_button();
857 print '<h3>';
858 printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id);
859 print '</h3>';
860 $local_event_options = get_post_meta($the_id,'local_event_options',true);
861 if(!is_array($local_event_options)){
862 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
863 }
864
865 $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt');
866
867 print '<div class="wpstream_event_streaming_local">';
868 $this->user_streaming_global_channel_options('',$local_event_options, $local_array_exclude);
869 print '</div>';
870 print '</div>';
871 }
872
873
874 /*
875 *
876 * Display share settings
877 *
878 */
879 public function wpstream_display_modal_share($the_id){
880 print '<div class="wpstream_modal_form wpestate_share_modal">';
881 $this->wpstream_close_modal_button();
882 print '<h3>'.esc_html__('Share your Channel','wpstream').'</h3>';
883 $this->wpstream_social_share($the_id);
884 print '</div>';
885 }
886
887
888 /*
889 *
890 * Display broadcast modal
891 *
892 */
893
894 public function wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream){
895 print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
896 $this->wpstream_close_modal_button();
897 print '<h3>'.esc_html__('Go Live with External Streaming App','wpstream').'</h3>';
898
899 print '<div class="wpstream_modal_explanations">'.esc_html__('Please choose your RTMP encoder/broadcaster','wpstream').'</div>';
900
901 print '<select class="wpstream_external_broadcast_options">';
902 print '<option value="wpstream_obs_settings">'.esc_html('OBS','wpstream').'</option>';
903 print '<option value="wpstream_streamyard_settings">'.esc_html('StreamYard','wpstream').'</option>';
904 print '<option value="wpstream_restream_settings">'.esc_html('Restream','wpstream').'</option>';
905 print '<option value="wpstream_wimx_settings">'.esc_html('vMix','wpstream').'</option>';
906 print '<option value="wpstream_wirecast_settings">'.esc_html('Wirecast','wpstream').'</option>';
907 print '<option value="wpstream_xplit_settings">'.esc_html('XSplit','wpstream').'</option>';
908 print '<option value="wpstream_larix_settings">'.esc_html('Larix Broadcaster','wpstream').'</option>';
909
910 print '</select>';
911
912 $this->wpstream_obs_settings($obs_uri,$obs_stream);
913 $this->wpstream_streamyard_settings($obs_uri,$obs_stream);
914 $this->wpstream_restream_settings($obs_uri,$obs_stream);
915 $this->wpstream_wmix_settings($obs_uri,$obs_stream);
916 $this->wpstream_wirecast_settings($obs_uri,$obs_stream);
917 $this->wpstream_xplit_settings($obs_uri,$obs_stream);
918 $this->wpstream_larix_settings($obs_uri,$obs_stream);
919
920 print '</div>';
921 }
922
923
924
925
926 /*
927 *
928 * Display OBS settings
929 *
930 */
931
932 public function wpstream_obs_settings($obs_uri,$obs_stream){
933
934 print '<div class="external_software_streaming wpstream_obs_settings" style="display:block;">';
935
936 print '<div class="external_software_streaming_details">';
937 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('Server:').' </strong>';
938 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
939 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
940
941 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
942 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
943 print '</div>';
944
945 print'</div>';
946
947 print ' <div class="wpstream_modal_explanations">';
948 print '<ul>
949 <li>1. Click Settings in the OBS Window and then Select Stream.</li>
950 <li>2. Choose Custom Streaming Server in the Stream Type dropdown menu.</li>
951 <li>3. In the URL box, type/paste your Server.</li>
952 <li>4. In the Stream key, type/paste your Stream key.</li>
953 <li>5. Save changes.Close the Settings window and click on the “Start Streaming” button in the main window of OBS.</li></ul>';
954
955 print '</div>';
956
957
958 print'</div>';
959 }
960
961 /*
962 *
963 * Display StreamYard settings
964 *
965 */
966
967 public function wpstream_streamyard_settings($obs_uri,$obs_stream){
968
969 print '<div class="external_software_streaming wpstream_streamyard_settings">';
970
971 print '<div class="external_software_streaming_details">';
972 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP server URL:').' </strong>';
973 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
974 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
975
976 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong>
977 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
978 print '</div>';
979
980 print'</div>';
981
982 print ' <div class="wpstream_modal_explanations">';
983 print '<ul>
984 <li>1. Set up your destination by going to your StreamYard account.</li>
985 <li>2. Choose "Custom RTMP" and add the RTMP server URL and Stream key from WpStream.</li>
986 <li>3. Go to "Broadcasts" then "create a broadcast".</li>
987 <li>4. Enter Live Studio.</li>
988 <li>5. Adjust all your preferred settings and Click on "Go Live".</li></ul>';
989
990 print '</div>';
991
992
993 print'</div>';
994 }
995
996
997
998 /*
999 *
1000 * Display StreamYard settings
1001 *
1002 */
1003
1004 public function wpstream_restream_settings($obs_uri,$obs_stream){
1005
1006 print '<div class="external_software_streaming wpstream_restream_settings">';
1007
1008 print '<div class="external_software_streaming_details">';
1009 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP URL:').' </strong>';
1010 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1011 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1012
1013 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong>
1014 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1015 print '</div>';
1016
1017 print'</div>';
1018
1019 print ' <div class="wpstream_modal_explanations">';
1020 print '<ul>
1021 <li>1. Go to your Restream account and set up a destination or channel.</li>
1022 <li>2. Choose "Custom RTMP" and add the RTMP URL and Stream Key from WpStream.</li>
1023 <li>3. Click on "Add Channel".</li>
1024 <li>4. Enter Live Studio.</li>
1025 <li>5. Adjust your preferred settings and Go Live.</li></ul>';
1026
1027 print '</div>';
1028
1029
1030 print'</div>';
1031 }
1032
1033
1034
1035 /*
1036 *
1037 * Display Xplit settings
1038 *
1039 */
1040
1041
1042 public function wpstream_xplit_settings($obs_uri,$obs_stream){
1043 print '<div class="external_software_streaming wpstream_xplit_settings" style="display:none;">';
1044 print '<div class="external_software_streaming_details">';
1045 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP Url:').' </strong>';
1046 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1047 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1048
1049 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1050 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1051 print '</div>';
1052
1053 print'</div>';
1054
1055 print ' <div class="wpstream_modal_explanations">';
1056 print '<ul>
1057 <li>1. Click Broadcast in the XSplit Window and then click "Set up a new output".</li>
1058 <li>2. Choose Custom RTMP in the Set up a new output dropdown menu.</li>
1059 <li>3. In the URL box, type/paste your RTMP Url.</li>
1060 <li>4. In the Stream key, type/paste your Stream key.</li>
1061 <li>5. Save changes and click on the “Stream” button in the main window.</li></ul>';
1062 print '</div>';
1063
1064 print '</div>';
1065 }
1066
1067
1068
1069 /*
1070 *
1071 * Display WireCast settings
1072 *
1073 */
1074
1075
1076 public function wpstream_wirecast_settings($obs_uri,$obs_stream){
1077 print '<div class="external_software_streaming wpstream_wirecast_settings" style="display:none;">';
1078
1079 print '<div class="external_software_streaming_details">';
1080 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('Address:').' </strong>';
1081 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1082 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1083
1084 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream:').' </strong>
1085 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1086 print '</div>';
1087
1088 print'</div>';
1089
1090 print ' <div class="wpstream_modal_explanations">';
1091 print '<ul>
1092 <li>1. Click Output on the top of the screen and then Select Output Settings.</li>
1093 <li>2. In the destination, choose RTMP Server and click OK.</li>
1094 <li>3. In the Address box, type/paste your Address.</li>
1095 <li>4. In the Stream box, type/paste your Stream key.</li>
1096 <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>';
1097 print '</div>';
1098
1099 print '</div>';
1100 }
1101
1102
1103
1104 /*
1105 *
1106 * Display Larix settings
1107 *
1108 */
1109
1110
1111 public function wpstream_larix_settings($obs_uri,$obs_stream){
1112 print '<div class="external_software_streaming wpstream_larix_settings" style="display:none;">';
1113 $larix_rtmp=$obs_uri.$obs_stream;
1114 print '<div class="external_software_streaming_details">';
1115 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP:').'</strong>';
1116 print '<div class="wpstream_live_uri_text wpstream_larix_rtmp"></div>
1117 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1118
1119 print '</div>';
1120
1121 print'</div>';
1122
1123 print ' <div class="wpstream_modal_explanations">';
1124 print '<ul>
1125 <li>A. Scan the QR code.</li>
1126 <li>or</li>
1127 <li>B. Manually configure Larix with the above RTMP</li>';
1128 if(wp_is_mobile() ){
1129 print '
1130 <li>or</li>
1131 <li>C. Click on the button below </li></ul>';
1132 }
1133
1134
1135 print '</div>';
1136
1137
1138 print '<img class="print_qrcode" src="" />';
1139 if(wp_is_mobile() ){
1140 print '<a href="" class="wpstream_start_with_larix_mobile" >Start Streaming with Larix</a>';
1141 }
1142
1143
1144
1145 print '</div>';
1146 }
1147
1148
1149
1150
1151 /*
1152 *
1153 * Display Wmix settings
1154 *
1155 */
1156
1157
1158 public function wpstream_wmix_settings($obs_uri,$obs_stream){
1159 print '<div class="external_software_streaming wpstream_wimx_settings" style="display:none;">';
1160
1161 print '<div class="external_software_streaming_details">';
1162 print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('URL:').' </strong>';
1163 print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1164 <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1165
1166 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1167 <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1168 print '</div>';
1169
1170 print'</div>';
1171
1172 print ' <div class="wpstream_modal_explanations">';
1173 print '<ul>
1174 <li>1. Click on the gear icon near the stream button on the bottom.</li>
1175 <li>2. Choose a custom RTMP Server in destination.</li>
1176 <li>3. In the URL box, type/paste your URL.</li>
1177 <li>4. In the Stream key, type/paste your Stream key.</li>
1178 <li>5. Save changes. You can start streaming by clicking on the stream button at the bottom of the dashboard.</li></ul>';
1179 print '</div>';
1180
1181 print '</div>';
1182 }
1183
1184
1185
1186 /*
1187 * Set Settings
1188 *
1189 *
1190 */
1191
1192 public function wpstream_settings(){
1193
1194 if( !current_user_can('administrator') ){
1195 die('Only for administrators');
1196 }
1197
1198
1199 if($_SERVER['REQUEST_METHOD'] === 'POST'){
1200 if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){
1201 die('Security check');
1202 }
1203
1204 $allowed_html = array();
1205 $exclude_array = array();
1206 $allowed_html = array();
1207
1208
1209
1210 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
1211 update_option( sanitize_key('wpstream_stream_role'), '' );
1212 }
1213
1214 foreach($_POST as $variable=>$value){
1215 if ($variable!='submit'){
1216 if (!in_array($variable, $exclude_array) ){
1217 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
1218 }
1219
1220 if($variable=='stream_role'){
1221 update_option( sanitize_key('wpstream_stream_role'), $value );
1222 }
1223
1224 }
1225 }
1226
1227
1228 if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){
1229 $event_settings=array();
1230 foreach($this->global_event_options as $key=>$option){
1231 $event_settings[$key]='';
1232 if(isset($_POST['wpstream_event_set_'.$key]) && $_POST['wpstream_event_set_'.$key]=='on'){
1233 $event_settings[$key]=1;
1234 }else{
1235 $event_settings[$key]=0;
1236 }
1237 }
1238 update_option('wpstream_user_streaming_global_channel_options',$event_settings);
1239 }
1240
1241
1242
1243
1244 // reset permalinkgs
1245 global $wp_rewrite;
1246
1247 update_option( "rewrite_rules", FALSE );
1248 $wp_rewrite->flush_rules( true );
1249
1250 }
1251
1252 $wpstream_settings_array =array(
1253 1 => array(
1254 'tab' => 'general_options',
1255 'label' => esc_html__('Slug for free video/channel pages ','wpstream'),
1256 'name' => 'free_media_slug',
1257 'type' => 'text',
1258 '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'),
1259 ),
1260
1261 2 => array(
1262 'tab' => 'general_options',
1263 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'),
1264 'name' => 'stream_role',
1265 'type' => 'user_roles',
1266 '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'),
1267
1268 ),
1269 3 => array(
1270 'tab' => 'general_options',
1271 'label' => esc_html__('Non Admin Streamers Channel Type.','wpstream'),
1272 'name' => 'user_streaming_channel_type',
1273 'type' => 'select',
1274 'select_values'=>array(
1275 'free' => esc_html__('Free Live Channel','wpstream'),
1276 'paid' => esc_html__('Pay-Per-View','wpstream')
1277 ),
1278 'details' => esc_html__('Choose whether the channels assigned to non-admins are free-for-all or pay-per-view (WooCommerce product).','wpstream'),
1279 ),
1280
1281 4 => array(
1282 'tab' => 'general_options',
1283 'label' => esc_html__('Default Pay-Per-View Price','wpstream'),
1284 'name' => 'user_streaming_default_price',
1285 'type' => 'text',
1286 'details' => esc_html__('Default price of pay-per-view channels assigned to non-admins.','wpstream'),
1287 ),
1288
1289
1290
1291 6 => array(
1292 'tab' => 'subscription_options',
1293 'label' => esc_html__('Use Global Subscription Mode','wpstream'),
1294 'name' => 'global_sub',
1295 'type' => 'slidertoogle',
1296 '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'),
1297 ),
1298
1299 7 => array(
1300 'tab' => 'subscription_options',
1301 'label' => esc_html__('Subscription ID for Global Subscription Mode','wpstream'),
1302 'name' => 'global_sub_id',
1303 'type' => 'text',
1304 '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'),
1305 ),
1306 8 => array(
1307 'tab' => 'messages_options',
1308 'label' => esc_html__('PPV not logged in message','wpstream'),
1309 'name' => 'product_not_login',
1310 'type' => 'text',
1311 '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'),
1312 'default' => esc_html__('You must be logged in to watch this video.','wpstream'),
1313 ),
1314 9 => array(
1315 'tab' => 'messages_options',
1316 'label' => esc_html__('PPV not purchased message','wpstream'),
1317 'name' => 'product_not_bought',
1318 'type' => 'text',
1319 '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'),
1320 'default' => esc_html__('You did not yet purchase this item.','wpstream'),
1321 ),
1322 10 => array(
1323 'tab' => 'messages_options',
1324 'label' => esc_html__('Subscription not purchased message','wpstream'),
1325 'name' => 'product_not_subscribe',
1326 'type' => 'text',
1327 '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'),
1328 'default' => esc_html__(' You did not yet subscribe to this item.','wpstream'),
1329 ),
1330 11 => array(
1331 'tab' => 'messages_options',
1332 'label' => esc_html__('Thank you message','wpstream'),
1333 'name' => 'product_thankyou',
1334 'type' => 'text',
1335 'details' => esc_html__('This message will be displayed on the thank you page (after purchase) and the confirmation email.','wpstream'),
1336 'default' => esc_html__('Thanks for your purchase. You can access your item at any time by visiting the following page: {item_link}','wpstream'),
1337 ),
1338
1339 12 => array(
1340 'tab' => 'messages_options',
1341 'label' => esc_html__('Subscription Active message','wpstream'),
1342 'name' => 'subscription_active',
1343 'type' => 'text',
1344 'details' => esc_html__('This message will be displayed on subscription product page.','wpstream'),
1345 'default' => esc_html__('Your Subscription is Active','wpstream'),
1346 ),
1347 13 => array(
1348 'tab' => 'messages_options',
1349 'label' => esc_html__('You are not live message','wpstream'),
1350 'name' => 'you_are_not_live',
1351 'type' => 'text',
1352 'details' => esc_html__('This message will be displayed in player.','wpstream'),
1353 'default' => esc_html__('We are not live at this moment','wpstream'),
1354 ),
1355
1356
1357
1358
1359 99 => array(
1360 'tab' => 'default_options',
1361 'label' => esc_html__('Events Options ','wpstream'),
1362 'name' => 'user_streaming_global_channel_options',
1363 'type' => 'user_streaming_global_channel_options',
1364 'details' => esc_html__('Global Options for live events.','wpstream'),
1365 ),
1366 );
1367
1368 $active_tab = 'general_options';
1369 if( isset( $_GET[ 'tab' ] ) ) {
1370 $active_tab = $_GET[ 'tab' ];
1371 }
1372
1373
1374 print '<div class="theme_options_tab_wpstream" style="display:block;" >
1375 <h1>'.__('WpStream Settings','wpstream').'</h1>
1376 <form method="post" action="" >';
1377
1378 print '<h2 class="nav-tab-wrapper">
1379 <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">General Options</a>
1380 <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">Default Channel Settings</a>
1381 <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : ''; echo '">Subscription Options</a>
1382 <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">Customize Messages</a>
1383
1384 </h2>';
1385
1386 print '<div class="wpstream_option_wrapper">';
1387
1388 switch ($active_tab) {
1389 case 'general_options':
1390 $help_link='https://docs.wpstream.net/docs/general-settings/';
1391 break;
1392 case 'default_options':
1393 $help_link='https://docs.wpstream.net/docs/default-settings/';
1394 break;
1395 case 'subscription_options':
1396 $help_link='https://docs.wpstream.net/docs/subscription-options/';
1397 break;
1398 case 'messages_options':
1399 $help_link='https://docs.wpstream.net/docs/customize-messages/';
1400 break;
1401 }
1402
1403 print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >Video Help</a></div>';
1404
1405 foreach ($wpstream_settings_array as $key=>$option){
1406 if($option['tab']!=$active_tab){
1407 continue;
1408 }
1409
1410 print '<div class="wpstream_option">';
1411 $options_value = get_option('wpstream_'.$option['name']) ;
1412
1413
1414 if($option['type']=='user_roles'){
1415
1416 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1417 print $this->wpstream_select_user_roles($option['name'],$options_value);
1418 print '<div class="settings_details">'.$option['details'].'</div>';
1419
1420 }else if($option['type']=='user_streaming_global_channel_options'){
1421
1422 $exclude_array=array();
1423 $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array);
1424
1425
1426 }else if($option['type']=='text'){
1427
1428 if($options_value==''){
1429 $options_value='';
1430 if(isset($option['default'])){
1431 $options_value=$option['default'];
1432 }
1433 }
1434
1435 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1436 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1437 print '<div class="settings_details">'.$option['details'].'</div>';
1438
1439 } else if($option['type']=='select'){
1440
1441 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1442 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
1443 foreach($option['select_values'] as $key=>$value){
1444 print '<option value="'.$key.'" ';
1445 if( $key == esc_html($options_value) ){
1446 print ' selected ';
1447 }
1448 print '>'.$value.'</option>';
1449 }
1450 print '</select>';
1451 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
1452 print '<div class="settings_details">'.$option['details'].'</div>';
1453
1454 } else if($option['type']=='slidertoogle'){
1455 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1456 print '<label class="wpstream_switch">
1457 <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" >
1458 <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" ';
1459
1460 if( intval($options_value) !==0 ){
1461 print ' checked ';
1462 }
1463
1464
1465
1466 print '> <span class="wpstream_slider round"></span>';
1467 print '</label>';
1468 print '<div class="settings_details">'.$option['details'].'</div>';
1469 }
1470 print '</div>';
1471 }
1472 print '</div>';
1473
1474
1475 print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1476
1477 print '<input name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> ';
1478 print '</form>';
1479 print '</div>';
1480
1481 }
1482
1483
1484
1485 /**
1486 * Set user roles
1487 *
1488 * @since 3.0.1
1489 */
1490
1491 public function user_streaming_global_channel_options($name,$value,$local_array=''){
1492
1493 foreach($this->global_event_options as $key=>$option){
1494
1495 if( is_array($local_array) && !in_array($key,$local_array)){
1496 print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">';
1497
1498 print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
1499
1500 print '
1501 <label class="wpstream_switch">
1502 <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
1503 if( isset($value[$key]) ){
1504 if( intval($value[$key]) !==0 ){
1505 print ' checked ';
1506 }
1507 }else{
1508 if($option['defaults']=='yes') {
1509 print ' checked ';
1510 }
1511 }
1512
1513
1514 print '> <span class="wpstream_slider round"></span>';
1515 print '</label>';
1516 print '<div class="settings_details">'.$option['details'].'</div>';
1517
1518
1519 print '</div>';
1520 }
1521 }
1522
1523
1524 }
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534 /*
1535 * Set user roles
1536 *
1537 * @since 3.0.1
1538 */
1539
1540 public function wpstream_select_user_roles($name,$value){
1541 if($value==''){
1542 $value=array();
1543 }
1544
1545 $roles = get_editable_roles();
1546 $return = '<select id="wpstream_user_roles" name="'.esc_html($name).'[]" multiple>';
1547 unset( $roles['administrator'] );
1548
1549 foreach ($roles as $key=>$role){
1550 $return .= '<option value="'.$key.'" ';
1551 if( in_array($key, $value) ){
1552 $return .= ' selected ';
1553 }
1554 $return .= '>'.$role['name'].'</option>';
1555 }
1556 $return .= '</select>';
1557
1558
1559 return $return;
1560 }
1561
1562
1563 /*
1564 * Set credential admin function
1565 *
1566 * @since 3.0.1
1567 */
1568 public function wpstream_set_wpstream_credentials(){
1569
1570 if($_SERVER['REQUEST_METHOD'] === 'POST'){
1571 $allowed_html = array();
1572 $exclude_array = array();
1573 $allowed_html = array();
1574
1575 foreach($_POST as $variable=>$value){
1576 if ($variable!='submit'){
1577 if (!in_array($variable, $exclude_array) ){
1578 update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
1579 }
1580 }
1581 }
1582
1583
1584
1585
1586 update_option('wp_estate_token_expire',0);
1587 update_option('wp_estate_curent_token',' ');
1588 delete_transient( 'wpstream_token_api');
1589 delete_transient('wpstream_token_request_30');
1590 delete_transient('wpstream_request_pack_data_per_user_transient');
1591 }
1592
1593
1594 $allowed_html = array();
1595
1596
1597
1598 $wpstream_options_array =array(
1599 2 => array(
1600 'label' => 'WpStream.net Username or Email',
1601 'name' => 'api_username',
1602 'type' => 'text',
1603 ),
1604 3 => array(
1605 'label' => 'WpStream.net Password',
1606 'name' => 'api_password',
1607 'type' => 'password',
1608 ),
1609
1610 );
1611
1612
1613 $token = $this->main->wpstream_live_connection->wpstream_get_token();
1614 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1615
1616 $this->main->show_user_data($pack_details);
1617
1618 print '<form method="post" action="" >';
1619 print '<div class="theme_options_tab_wpstream" style="display:block;" >
1620 <h1>'.__('WpStream Credentials','wpstream').'</h1>';
1621
1622
1623 if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== '' ){
1624 echo '<div class="api_not_conected wpstream_orange">';
1625 $admin_url_onboard=get_admin_url().'admin.php?page=wpstream_onboard';
1626 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);
1627 echo '</div>';
1628
1629 }else if($token==''){
1630 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>';
1631 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
1632 echo '<div class="api_conected">'.__('Connected to WpStream.net!','wpstream').'</div>';
1633 }else{
1634 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
1635 }
1636 print '<div class="wpstream_option_wrapper">';
1637 foreach ($wpstream_options_array as $key=>$option){
1638 print '<div class="wpstream_option">';
1639
1640 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
1641 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1642 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
1643
1644 print '</div>';
1645 }
1646 print '</div>';
1647
1648
1649 print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1650
1651 print '<h3>Video Tutorials</h3>';
1652
1653 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/9DQrxsKcpmQ">How to Live Stream to WordPress with OBS</a>';
1654 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>';
1655 print '<a class="how_to_videos" target="_blank" href="https://youtu.be/h6myD_vhKcg">How to Live-Stream to WordPress using your iPhone</a>';
1656
1657 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>';
1658
1659
1660 print '</div>';
1661 print '</form>';
1662
1663 print '<div class="theme_options_tab_wpstream" style="display:block;" >';
1664 $link_new = admin_url('admin.php?page=wpstream_live_channels');
1665 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
1666 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
1667
1668
1669 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new Free-To-View channel','wpstream').'</a>';
1670 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create Pay-Per-View channel','wpstream').'</a>';
1671 print '<a href="'.esc_url($link_new).'" class="wpstream_no_chanel_add_channel">'.esc_html('My Channels','wpstream').'</a>';
1672 print '</div>';
1673
1674
1675 }
1676
1677
1678
1679 /**
1680 * Media Management
1681 *
1682 * @since 3.0.1
1683 */
1684
1685 public function wpstream_media_management(){
1686 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1687
1688 $this->main->show_user_data($pack_details);
1689
1690
1691 print '<div id="wpstream_media_upload"><h3>'.__('Upload New Recording','wpstream').'</h3>'.$this->wpstream_present_media_upload().'</div>';
1692
1693 print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Your Recordings','wpstream').'</h3>'.$this->wpstream_present_file_management().'</div>';
1694
1695
1696 }
1697
1698
1699
1700
1701 /**
1702 *
1703 *
1704 * WpStream Pagination
1705 *
1706 * @since 3.0.1
1707 *
1708 *
1709 */
1710
1711 public function wpstream_pagination($pages , $range = 2) {
1712 $return='';
1713 $showitems = ($range * 2) + 1;
1714 $paged = ( isset( $_GET['paged'] ) ) ? intval($_GET['paged']) : 1;
1715
1716
1717 if (1 != $pages && $pages != 0) {
1718 $return.= '<ul class="pagination wpstream_pagination">';
1719 $return.= "<li class=\"roundleft\"><a href='" . get_pagenum_link($paged - 1) . "'><</a></li>";
1720
1721 $last_page = get_pagenum_link($pages);
1722 for ($i = 1; $i <= $pages; $i++) {
1723 if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) {
1724 if ($paged == $i) {
1725 $return.= '<li class="active"><a href="' . esc_url(get_pagenum_link($i)) . '" >' . $i . '</a><li>';
1726 } else {
1727 $return.= '<li><a href="' . esc_url(get_pagenum_link($i)) . '" >' . $i . '</a><li>';
1728 }
1729 }
1730 }
1731
1732 $prev_page = get_pagenum_link($paged + 1);
1733 if (($paged + 1) > $pages) {
1734 $prev_page = get_pagenum_link($paged);
1735 } else {
1736 $prev_page = get_pagenum_link($paged + 1);
1737 }
1738
1739
1740 $return.= "<li class=\"roundright\"><a href='" . $prev_page . "'>></a><li>";
1741 $return.= "<li class=\"roundright\"><a href='" . $last_page . "'>>><li>";
1742 $return.= "</ul>";
1743 }
1744 return $return;
1745 }
1746
1747
1748
1749
1750
1751
1752 /**
1753 * Media upload
1754 *
1755 * @since 3.0.1
1756 */
1757 public function wpstream_present_media_upload(){
1758 $to_return='';
1759 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
1760
1761
1762
1763
1764 if( !$formInputs['success'] ){
1765 $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>';
1766 return $to_return;
1767 }
1768
1769 if($formInputs['success'] ===true){
1770
1771
1772
1773 $to_return.='<div class="wpstream_upload_container">';
1774 $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>';
1775 $to_return.='<form action="https://wpstream-video.s3.amazonaws.com/"
1776 method="POST"
1777 enctype="multipart/form-data"
1778 data-singleFileUploads="true"
1779 data-limitMultiFileUploads="1"
1780 data-limitConcurrentUploads="1"
1781 class="direct-upload">';
1782
1783 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
1784 $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>';
1785
1786
1787 $to_return.='<div class="wpstream_file_drop_color">';
1788 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
1789 $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:
1790
1791 Container: <strong>MP4</strong>,
1792 Video codec: <strong>H264</strong>,
1793 Audio codec: <strong>AAC</strong>. Media will fail to play if it does not follow the above settings.
1794 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>';
1795 if(is_array($formInputs)){
1796 foreach ($formInputs['ref'] as $name => $value) {
1797 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
1798 }
1799 }
1800
1801 $to_return.='
1802 <div class="progress-bar-area"></div></div>
1803 </form>';
1804
1805 $to_return.='</div>';
1806 }
1807
1808 return $to_return;
1809
1810 }
1811
1812
1813
1814
1815
1816 /**
1817 * Display movie list
1818 *
1819 * @since 3.0.1
1820 */
1821 public function wpstream_present_file_management(){
1822 $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api();
1823
1824 $video_list_raw_array=array();
1825 if(isset($video_list_raw['items'])){
1826 $video_list_raw_array=$video_list_raw['items'];
1827 }
1828
1829 $keys = array_column($video_list_raw_array, 'time');
1830 array_multisort($keys, SORT_DESC , $video_list_raw_array);
1831
1832 $to_return='';
1833
1834 if(is_array($video_list_raw['items'])){
1835 foreach ($video_list_raw_array as $key =>$video){
1836
1837
1838 $video_size = intval($video['size']/1048576);
1839 $video_name = esc_html($video['name']);
1840 if($video_name!=''):
1841 $to_return.='<div class="wpstream_video_wrapper">';
1842
1843 $to_return.='<div class="wpstream_video_title">';
1844 $to_return.='<div class="wpstream_video_notice"></div></div>';
1845 $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>';
1846 $to_return.=' <div class="wpstream_delete_media" ';
1847 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video_name.'?\')" data-filename="'.$video_name.'">'.esc_html__('delete file','wpstream').'</div>';
1848 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video_name.'">'.esc_html__('download','wpstream').'</div>';
1849 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
1850
1851 $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product_vod').'&new_video_name='. rawurlencode($video_name);
1852 $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video_name);
1853
1854
1855
1856 $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>';
1857 $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>';
1858
1859 $to_return.='</div>';
1860 endif;
1861
1862 }
1863 $current_page= get_current_screen();
1864
1865
1866 } else {
1867 $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
1868 }
1869 return $to_return;
1870 }
1871
1872
1873 /**
1874 * Set defualt channels values
1875 *
1876 * @since 3.0.1
1877 */
1878
1879
1880
1881
1882 public function wpstream_publish_wpstream_product($post_id,$post){
1883 if( $post->post_type == 'wpstream_product' ){
1884 update_post_meta ($post_id,'local_event_options_test','working_on_'.$post_id);
1885 $to_save_option=array();
1886
1887 $global_options= get_option('wpstream_user_streaming_global_channel_options');
1888
1889 $local_events = get_post_meta ($post_id ,'local_event_options',true) ;
1890
1891 if( $local_events =='' ){
1892 if( is_array($global_options) ){
1893 foreach($global_options as $key=>$value){
1894 $to_save_option[sanitize_key($key)]=sanitize_text_field($value);
1895 }
1896
1897 update_post_meta ($post_id,'local_event_options',$to_save_option);
1898
1899 }
1900 }
1901
1902
1903 }
1904 }
1905
1906 /**
1907 * save meta options
1908 *
1909 * @since 3.0.1
1910 */
1911 public function wpstream_free_product_update_post($post_id,$post){
1912
1913 if(!is_object($post) || !isset($post->post_type)) {
1914 return;
1915 }
1916
1917
1918
1919
1920
1921
1922
1923 if( $post->post_type == 'wpstream_product' ||
1924 $post->post_type == 'wpstream_product_vod' ):
1925
1926 $allowed_keys=array(
1927 'wpstream_product_type',
1928 'wpstream_free_video',
1929 'wpstream_free_video_external'
1930 );
1931
1932
1933 foreach ($_POST as $key => $value) {
1934 if( !is_array ($value) ){
1935 if (in_array ($key, $allowed_keys)) {
1936 $postmeta = sanitize_text_field ( $value );
1937 update_post_meta($post_id, sanitize_key($key), $postmeta );
1938 }
1939 }
1940 }
1941
1942 endif;
1943
1944 }
1945
1946
1947 /**
1948 * save meta options
1949 *
1950 * @since 3.0.1
1951 */
1952 public function add_wpstream_product_metaboxes() {
1953 add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default');
1954 }
1955
1956
1957 /**
1958 * make woocomerce virtual products
1959 *
1960 * @since 3.0.1
1961 */
1962
1963
1964 public function wpstream_make_product_virtual($post_id,$post){
1965 global $post;
1966 if(isset($post->ID)){
1967 if ( $post->post_type !== 'product' ) return;
1968 $term_list = wp_get_post_terms($post->ID, 'product_type');
1969 if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
1970 update_post_meta( $post->ID, '_virtual', 'yes' );
1971 }
1972 }
1973 }
1974
1975
1976
1977 /**
1978 * render meta options
1979 *
1980 * @since 3.0.1
1981 */
1982 public function display_meta_options( $post ) {
1983 wp_nonce_field( plugin_basename( __FILE__ ), 'estate_agent_noncename' );
1984 global $post;
1985
1986 $is_live = '';
1987 $is_video = '';
1988 $is_video_external = '';
1989 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
1990 $is_video = ' selected ';
1991 $wpstream_free_video = esc_html( $_GET['new_video_name']);
1992 }else{
1993 $wpstream_product_type = esc_html(get_post_meta($post->ID, 'wpstream_product_type', true));
1994 $wpstream_free_video = esc_html(get_post_meta($post->ID, 'wpstream_free_video', true));
1995
1996 if($wpstream_product_type==1){
1997 $is_live = ' selected ';
1998 }
1999
2000 if($wpstream_product_type==2){
2001 $is_video = ' selected ';
2002 }
2003
2004 if($wpstream_product_type==3){
2005 $is_video_external = ' selected ';
2006 }
2007 }
2008
2009 print'
2010 <p class="meta-options">
2011 <label for="wpstream_product_type">'.__('Media Type:','wpstream').' </label><br />
2012 <select id="wpstream_product_type" name="wpstream_product_type">
2013 <option value="2" '.$is_video.'>'.__('Recording','wpstream').'</option>
2014 <option value="3" '.$is_video_external.'>'.__('Self Hosted or External Video','wpstream').'</option>
2015 </select>
2016 </p>
2017 ';
2018
2019
2020 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2021
2022
2023 print '
2024 <p class="meta-options video_free">
2025 <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
2026 <select id="wpstream_free_video" name="wpstream_free_video">';
2027
2028 if(is_array($video_list)){
2029 foreach ($video_list as $key=>$value){
2030 print '<option value="'.$key.'"';
2031 if($wpstream_free_video === $key){
2032 print ' selected ';
2033 }
2034 print '>'.$value.'</option>';
2035 }
2036 }
2037
2038 print'
2039 </select>
2040 </p>
2041 ';
2042
2043 $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
2044 print '<p class="meta-options1 video_free_external">
2045 <label for="wpstream_free_video_external">'.__('Video:','wpstream').' </label><br />
2046
2047 <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
2048 <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />';
2049 if($wpstream_product_type==2){
2050 $show_recording='';
2051 $show_external='style="display:none"';
2052 }else{
2053 $show_recording='style="display:none"';
2054 $show_external='';
2055 }
2056 print '<p '.$show_recording.' class="wpstream_option_vod_source wpstream_show_recording">'.esc_html__('Choose one of your existing recordings.','wpstream').'</p>';
2057 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>';
2058
2059 print '</p> ';
2060 }
2061
2062
2063
2064
2065
2066
2067
2068 /**
2069 * Add new product types to Woocommerce select product type
2070 *
2071 * @since 3.0.1
2072 */
2073 public function wpstream_add_products( $types ){
2074 $types[ 'live_stream' ] = __( 'Live Channel','wpestream' );
2075 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
2076
2077 return $types;
2078 }
2079
2080
2081
2082 /**
2083 * Js action to do when user pick live stream or video on demand
2084 *
2085 * @since 3.0.1
2086 */
2087
2088 public function wpstream_products_custom_js() {
2089 if ( 'product' != get_post_type() ) :
2090 return;
2091 endif;
2092
2093 ?>
2094 <script type='text/javascript'>
2095 jQuery( document ).ready( function() {
2096 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
2097 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
2098 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
2099 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
2100 jQuery('._sold_individually_field').show();
2101
2102 var selected = jQuery('#product-type').val();
2103 });
2104 </script>
2105 <?php
2106
2107 }
2108
2109
2110 /**
2111 * Add custom classes to the product types
2112 *
2113 * @since 3.0.1
2114 */
2115
2116 public function wpstream_hide_attributes_data_panel( $tabs) {
2117
2118 $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand';
2119 $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand';
2120 // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand';
2121
2122 return $tabs;
2123 }
2124
2125
2126
2127 /**
2128 * Hide buy now on products if Netflix mode
2129 *
2130 * @since 3.12
2131 */
2132
2133
2134 public function wpstream_hide_buy_now_subscription_mode( $purchaseable_product_wpblog,$product){
2135 $product_id=$product->get_id();
2136
2137 $term_list = wp_get_post_terms($product_id, 'product_type');
2138
2139 $subscription_model = intval( get_option('wpstream_global_sub','')) ;
2140
2141 if($subscription_model==1){ // if we have Neflix mode
2142 if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' ){
2143 return false;
2144 }
2145 }
2146
2147 return $purchaseable_product_wpblog;
2148 }
2149
2150
2151
2152
2153
2154
2155 /**
2156 * Add custom fields to custom product types
2157 *
2158 * @since 3.0.1
2159 */
2160
2161 public function wpstream_add_custom_general_fields() {
2162
2163 global $woocommerce, $post;
2164 if(function_exists('wcs_user_has_subscription')){
2165 echo '<div class="options_group show_if_subscription">';
2166 woocommerce_wp_select(
2167 array(
2168 'id' => '_subscript_live_event',
2169 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ),
2170 'options' => array("yes"=>"yes","no"=>"no")
2171 )
2172 );
2173 echo '</div>';
2174 }
2175
2176 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
2177 echo '<div class="options_group show_if_video_on_demand">';
2178 $selected='';
2179 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
2180 $selected=esc_html($_GET['new_video_name']);
2181 }
2182 if($selected==''){
2183 $selected= get_post_meta($post->ID,'_movie_url',true);
2184 }
2185
2186 woocommerce_wp_select(
2187 array(
2188 'id' => '_movie_url',
2189 'label' => __( 'Choose video', 'woocommerce' ),
2190 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
2191 'selected'=> true,
2192 'value' => $selected
2193 )
2194 );
2195
2196
2197
2198 echo '</div>';
2199
2200 if(function_exists('wcs_user_has_subscription')){
2201 $selected_sub='';
2202 echo '<div class="options_group show_if_video_on_demand show_if_live_stream">';
2203 if( isset( $_GET['wpstream_parent_sub']) && $_GET['wpstream_parent_sub']!='' ){
2204 $selected_sub=esc_html($_GET['wpstream_parent_sub']);
2205 }
2206 if($selected_sub==''){
2207 $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
2208 }
2209 woocommerce_wp_select(
2210 array(
2211 'id' => '_wpstream_parent_sub',
2212 'name' => '_wpstream_parent_sub[]',
2213 'label' => __( 'Attach to subscription', 'woocommerce' ),
2214 'options' => $this->wpstream_return_subscriptions_created(),
2215 'selected'=> true,
2216 'value' => $selected_sub,
2217 'custom_attributes' => array('multiple' => 'multiple')
2218 )
2219 );
2220
2221 echo '</div>';
2222
2223 }
2224 }
2225
2226
2227 public function wpstream_return_subscriptions_created(){
2228 $return=array('0'=>'none');
2229
2230 $args = array(
2231 'post_type' => 'product',
2232 'posts_per_page' => -1,
2233 'orderby' => 'title',
2234 'order' => 'ASC',
2235 'tax_query' => array(
2236 'relation' => 'AND',
2237 array(
2238 'taxonomy' => 'product_type',
2239 'field' => 'slug',
2240 'terms' => array( 'subscription'),
2241 )
2242 )
2243 );
2244
2245 $subscriptions = new WP_Query($args);
2246 if($subscriptions->have_posts()):
2247 while ($subscriptions->have_posts()): $subscriptions->the_post();
2248 $return[ get_the_ID() ] = get_the_title();
2249 endwhile;
2250 endif;
2251
2252 wp_reset_postdata();
2253 return $return;
2254
2255 }
2256
2257
2258
2259
2260
2261
2262 /**
2263 * Save custom fields
2264 *
2265 * @since 3.0.1
2266 */
2267
2268 public function wpstream_add_custom_general_fields_save( $post_id ){
2269
2270 $permited_values = array(
2271 '_movie_url',
2272 '_subscript_live_event',
2273 '_wpstream_parent_sub',
2274
2275 );
2276
2277
2278
2279 foreach($_POST as $key=>$value){
2280 update_post_meta( $post_id, 'event_passed', 0 );
2281 if( in_array($key, $permited_values) ){
2282 if( !empty( $_POST[$key] ) ){
2283 $key = sanitize_key($key);
2284 $value = sanitize_text_field($_POST[$key]);
2285
2286 if($key=='_wpstream_parent_sub'){
2287 $value= $_POST[$key];
2288 $value = array_map("sanitize_text_field", $value);
2289
2290 }
2291 update_post_meta( $post_id, $key, $value );
2292 }
2293 }
2294 }
2295 //die();
2296
2297 }
2298
2299 /**
2300 * Add to cart redirect
2301 *
2302 * @since 3.0.1
2303 */
2304
2305 public function wpstream_add_to_cart() {
2306 wc_get_template( 'single-product/add-to-cart/simple.php' );
2307 }
2308
2309
2310 /**
2311 * Replace add to cart button
2312 *
2313 * @since 3.0.1
2314 */
2315 public function replacing_add_to_cart_button( $button, $product ) {
2316 global $product;
2317 $product_type = $product->get_type();
2318
2319 if($product_type==='live_stream' || $product_type=='video_on_demand'){
2320 return $button = '<a class="button" href="'.get_site_url().'/shop/?add-to-cart=' .$product->get_id(). '&quantity=1">' . __( 'Add to Cart', 'woocommerce' ) . '</a>';
2321 }else{
2322 return $button;
2323 }
2324 }
2325
2326
2327 /**
2328 * Admin notices
2329 *
2330 * @since 3.0.1
2331 */
2332 public function wpstream_admin_notice() {
2333 global $pagenow;
2334 global $typenow;
2335
2336 $wpstream_notices = get_option('wpstream_notices');
2337
2338 /*
2339 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
2340 if( !is_array($wpstream_notices) ||
2341 !isset($wpstream_notices['wpstream_woo_notice']) ||
2342 ( isset($wpestate_notices['wpstream_woo_notice']) && $wpestate_notices['wpstream_woo_notice']!='yes') ){
2343
2344
2345 print '<div class="notice wpstream_notices notice-error is-dismissible" data-notice-type="wpstream_woo_notice" >
2346 <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>
2347 </div>';
2348 }
2349 }
2350 */
2351
2352 if( !in_array ('curl', get_loaded_extensions())) {
2353 print '<div class="notice notice-error is-dismissible">
2354 <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>
2355 </div>';
2356 }
2357
2358
2359 $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
2360 print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
2361
2362 }
2363
2364 /**
2365 * Admin notices
2366 *
2367 * @since 3.0.1
2368 */
2369 public function wpstream_update_cache_notice(){
2370
2371 //check_ajax_referer( 'wpstream_notice_nonce', 'security' );
2372
2373 $notice_type = esc_html($_POST['notice_type']);
2374 $notices = get_option('wp_stream_notices');
2375
2376 if(! is_array($notices) ){
2377 $notices=array();
2378 }
2379
2380 $notices[$notice_type]='yes';
2381
2382 update_option('wpstream_notices',$notices);
2383 die();
2384 }
2385
2386
2387
2388
2389 /**
2390 * Activate metaboxes for Streaming controls on sidebar
2391 *
2392 * @since 3.0.1
2393 */
2394 public function wpstream_startstreaming_sidebar_meta() {
2395 global $post;
2396 $term_list = wp_get_post_terms($post->ID, 'product_type');
2397
2398 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
2399
2400 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
2401 if(!is_wp_error( $term_list )){
2402 if( isset($term_list[0]->name) ){
2403 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
2404 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'product', 'side', 'high');
2405 }
2406 }
2407 }
2408
2409 }
2410
2411 /**
2412 * edited 4.0
2413 *
2414 * Show Streaming controls on sidebar
2415 *
2416 * @since 3.0.1
2417 */
2418 public function wpstream_start_stream_meta(){
2419 global $live_event_for_user;
2420 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
2421
2422 global $post;
2423 $local_event_options = get_post_meta ($post->ID,'local_event_options','');
2424
2425
2426
2427 if( get_post_status($post->ID)!='auto-draft' ){
2428 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
2429 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
2430
2431 $this->wpstream_live_stream_unit($post->ID);
2432 print '<div class="wpstream_modal_background"></div>';
2433 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
2434 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
2435 </div>';
2436 }else{
2437 esc_html_e('To Go Live, please publish your channel first !','wpstream');
2438 }
2439 }
2440
2441
2442
2443
2444
2445
2446 /**
2447 *
2448 *
2449 *
2450 */
2451 public function add_dashboard_page() {
2452 add_dashboard_page( '', '', 'administrator', 'wpstream-onboarding', '' );
2453 }
2454
2455
2456
2457
2458
2459 public function wpstream_load_onboarding_wizard() {
2460
2461 // Check for wizard-specific parameter
2462 // Allow plugins to disable the onboarding wizard
2463 // Check if current user is allowed to save settings.
2464
2465
2466 // Don't load the interface if doing an ajax call.
2467 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
2468 return;
2469 }
2470
2471 set_current_screen();
2472
2473 // Remove an action in the Gutenberg plugin ( not core Gutenberg ) which throws an error.
2474 remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );
2475
2476 $this->actual_load_onboarding_wizard();
2477
2478 }
2479
2480
2481 /*
2482 * Add on boarding to footer
2483 */
2484
2485
2486
2487 public function wpstream_admin_footer_onboarding(){
2488 if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
2489 $this->wpstream_onboard_display();
2490 }
2491 }
2492
2493
2494 /*
2495 * On Board Display
2496 *
2497 */
2498
2499 public function wpstream_pre_onboard_display(){
2500 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2501
2502 $this->main->show_user_data($pack_details);
2503
2504
2505 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
2506 ?>
2507
2508 <div class="wpstream_quick_start_wrapper">
2509 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
2510
2511 <h1><?php print esc_html__('WpStream','wpstream').' <span class="header_special">'.esc_html__('Quick Start','wpstream').'</span>';?></h1>
2512
2513
2514 <p>
2515 <?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');?>
2516 </p>
2517
2518 <div id="wpstream_trigger_quick_start" class="wpstream_button wpstream_button_action"><?php esc_html_e('Start the Guide','wpstream');?></div>
2519
2520
2521
2522 </div>
2523
2524
2525
2526 <script type="text/javascript">
2527 //<![CDATA[
2528 jQuery(document).ready(function(){
2529 jQuery(".wpstream_on_boarding_wrapper").show();
2530 jQuery(".wpstream_modal_background_onboard").show();
2531 });
2532
2533 //]]>
2534 </script>
2535
2536 <?php
2537
2538 }
2539
2540
2541
2542
2543
2544
2545
2546
2547 /*
2548 *
2549 * On Boarding Content
2550 *
2551 */
2552
2553
2554 public function wpstream_onboard_display() {
2555 $this->onboarding_wizard_header();
2556 $this->wpstream_onboarding_step1();
2557 $this->wpstream_onboarding_step2();
2558 $this->wpstream_onboarding_step3_live_streaming();
2559 $this->wpstream_onboarding_step_3_A_live_streaming_free_view();
2560 $this->wpstream_onboarding_step_3_B_live_streaming_pay_per_view();
2561 $this->wpstream_onboarding_step4_vod();
2562 $this->wpstream_onboarding_step_4_free_vod();
2563 $this->wpstream_onboarding_step_4_ppv_vod();
2564 $this->onboarding_wizard_footer();
2565 }
2566
2567
2568 /*
2569 *
2570 * On Boarding Step 1 - the login/register
2571 *
2572 */
2573
2574
2575 public function wpstream_onboarding_step1(){
2576
2577 $wpstream_options_array =array(
2578 2 => array(
2579 'label' => 'WpStream.net Username or Email',
2580 'name' => 'api_username',
2581 'type' => 'text',
2582 ),
2583 3 => array(
2584 'label' => 'WpStream.net Password',
2585 'name' => 'api_password',
2586 'type' => 'password',
2587 ),
2588
2589 );
2590 $token = $this->main->wpstream_live_connection->wpstream_get_token();
2591
2592 ?>
2593 <div class="wpstream_step_wrapper wpstream_step_1" id="wpstream_step_1">
2594 <div class="wpstream_has_credential">
2595 <h1><?php esc_html_e('WpStream Account','wpstream');?></h1>
2596
2597 <div class="wpstream_on_board_login_wrapper_explanations">
2598 <?php esc_html_e('A WpStream account is required to make use of the plugin.','wpstream');?>
2599 </div>
2600
2601
2602 <div class="wpstream_check_account_status">
2603 Checking if you are already logged.....
2604 </div>
2605
2606 <div class="wpstream_onboarding_notification"></div>
2607
2608 <div class="wpstream_option_wrapper wpstream_on_board_login_wrapper">
2609 <h2><?php esc_html_e('Login with your WpStream Account','wpstream');?></h2>
2610 <?php
2611
2612 foreach ($wpstream_options_array as $key=>$option){
2613 print '<div class="wpstream_option">';
2614
2615 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
2616 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
2617 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
2618
2619 print '</div>';
2620 }
2621 ?>
2622 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_login" value="<?php esc_html_e('Login','wpstream');?>" />
2623 </div>
2624
2625
2626
2627
2628 <div class="wpstream_on_board_register_wrapper">
2629 <h2><?php esc_html_e('Register for a WpStream Account','wpstream');?></h2>
2630 <div class="wpstream_option">
2631 <label for="wpstream_register_email"><?php esc_html_e('Your Email','wpstream');?></label>
2632 <input id="wpstream_register_email" type="text" size="36" name="wpstream_register_email" value="<?php echo get_option('admin_email'); ?>" />
2633
2634 </div>
2635
2636 <div class="wpstream_option">
2637 <label for="wpstream_register_password"><?php esc_html_e('Your Password','wpstream');?></label>
2638 <input id="wpstream_register_password" type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
2639 </div>
2640
2641
2642 <?php
2643
2644 $curl_response_decoded['capthca']='';
2645 $curl_response_decoded['capthca_id']='';
2646
2647
2648 if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
2649 $url = 'user/getcapthca';
2650 $curl_post_fields = array();
2651 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
2652 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
2653
2654 }
2655
2656 ?>
2657 <div class="wpstream_option">
2658 <?php print '<div id="wpstream_capthca">'.$curl_response_decoded['capthca'].'</div>';?>
2659 <label for="wpstream_register_captcha"><?php esc_html_e('Type the characters above','wpstream');?></label>
2660
2661 <input id="wpstream_register_captcha" type="text" size="36" name="wpstream_register_captcha" />
2662 <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']); ?>" />
2663 </div>
2664
2665
2666
2667 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_register" value="<?php esc_html_e('register','wpstream');?>" />
2668 </div>
2669
2670
2671 <div id="wpstream_onboarding_action_login"><?php esc_html_e('I already have a WpStream Account','wpstream');?></div>
2672
2673 <div id="wpstream_onboarding_action_register"><?php esc_html_e('Back to Registration','wpstream');?></div>
2674
2675 </div>
2676
2677
2678 <?php
2679 $ajax_nonce = wp_create_nonce( "wpstream_onboarding_nonce");
2680 print'<input type="hidden" id="wpstream_onboarding_nonce" value="'.esc_html($ajax_nonce).'" /> ';
2681
2682 ?>
2683
2684
2685 <div id="wpstream_on_board" class="wpstream_action_next_step" data-nextthing="wpstream_step_2" style="display:none;" >Move to step 2</div>
2686 </div>
2687 <?php
2688
2689 if(trim($token)!==''){
2690 print '<div id="wpstream_have_token"></div>';
2691 }
2692 }
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703 /*
2704 *
2705 * Generate random pass
2706 *
2707 */
2708
2709 public function randomPassword() {
2710 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
2711 $pass = array(); //remember to declare $pass as an array
2712 $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
2713 for ($i = 0; $i < 8; $i++) {
2714 $n = rand(0, $alphaLength);
2715 $pass[] = $alphabet[$n];
2716 }
2717 return implode($pass); //turn the array into a string
2718 }
2719
2720
2721 /*
2722 *
2723 *
2724 *
2725 */
2726
2727 public function wpstream_onboarding_step2(){
2728 ?>
2729
2730 <div class="wpstream_step_wrapper wpstream_step_2" id="wpstream_step_2">
2731 <h1>Welcome to <span class="header_special">WpStream</span>! How would you like to start?</h1>
2732
2733 <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
2734 <div class="wpstram_or">or</div>
2735 <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>
2736
2737 </div>
2738
2739
2740 <?php
2741 }
2742
2743 /*
2744 *
2745 *
2746 *
2747 */
2748
2749 public function wpstream_onboarding_step3_live_streaming(){
2750 ?>
2751
2752 <div class="wpstream_step_wrapper wpstream_step_3 wpstream_onboarding_live" id="wpstream_step_3">
2753 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream'); ?></h1>
2754
2755 <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>
2756 <div class="wpstram_or">or</div>
2757 <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>
2758
2759 <div class="wpstream_initial_onboarding_controls_wrapper">
2760 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2761 </div>
2762
2763 </div>
2764
2765
2766 <?php
2767 }
2768
2769
2770 /*
2771 *
2772 *
2773 *
2774 */
2775 public function wpstream_onboarding_step_3_A_live_streaming_free_view(){
2776 ?>
2777
2778 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3a">
2779 <h1><?php esc_html_e('Let’s create your first FTV live channel','wpstream');?></h1>
2780
2781 <div id="wpstream_onboard_live_notice" class="wpstream_onboarding_notification"></div>
2782 <div id="wpstream_onboard_live" class="wpstream_accordion_container">
2783 <label>Name your first Free-To-View channel</label>
2784 <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');?>" >
2785 <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');?>" />
2786
2787 </div>
2788
2789 <div class="wpstream_initial_onboarding_controls_wrapper">
2790 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
2791 </div>
2792
2793 </div>
2794
2795
2796 <?php
2797 }
2798
2799
2800 /*
2801 *
2802 *
2803 *
2804 */
2805
2806 public function wpstream_onboarding_step_3_B_live_streaming_pay_per_view(){
2807 ?>
2808
2809 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3b">
2810 <h1><?php esc_html_e('Make your live stream Pay Per View','wpstream');?></h1>
2811 <?php
2812 if ( class_exists( 'WooCommerce' ) ) {
2813 ?>
2814 <div id="wpstream_onboard_live_ppv_notice" class="wpstream_onboarding_notification"></div>
2815 <div id="wpstream_onboard_live_ppv" class="wpstream_accordion_container">
2816 <label><?php esc_html_e('Choose a name for your channel','wpstream');?></label>
2817 <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');?>">
2818 <label><?php esc_html_e('Pay-Per-View Price ($)','wpstream');?></label>
2819 <input type="text" name="channel_name" id="wpstream_onboarding_event_price_ppv" class="wpstream_onboarding_event_price" value="10">
2820 <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');?>" />
2821
2822 </div>
2823 <?php
2824 } else {
2825 $this->wpstream_onboarding_woo_warning();
2826 } ?>
2827
2828
2829 <div class="wpstream_initial_onboarding_controls_wrapper">
2830 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
2831 </div>
2832 </div>
2833 <?php
2834 }
2835
2836
2837
2838
2839
2840
2841 /*
2842 * WooCommerce not installed Warning
2843 *
2844 *
2845 */
2846
2847 public function wpstream_onboarding_woo_warning(){
2848 print'<div class="wpstream_warning_onboarding">
2849 '.esc_html__('Pay-Per-View streaming requires WooCommerce. Please install the WooCommerce plugin and try again.','wpstream').'
2850 </br>
2851 <div class="wpstream_install_plugin">'. esc_html__('Install WooCommerce','wpstream').'</div>
2852
2853 <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
2854 </div>';
2855 }
2856
2857
2858 /*
2859 *
2860 *
2861 *
2862 */
2863
2864 public function wpstream_onboarding_step4_vod(){
2865 ?>
2866 <div class="wpstream_step_wrapper wpstream_step_4 wpstream_onboarding_vod" id="wpstream_step_4">
2867 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream');?></h1>
2868
2869 <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>
2870 <div class="wpstram_or">or</div>
2871 <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>
2872
2873
2874 <div class="wpstream_initial_onboarding_controls_wrapper">
2875 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2876 </div>
2877
2878 </div>
2879 <?php
2880 }
2881
2882
2883 /*
2884 *
2885 *
2886 *
2887 */
2888 public function wpstream_onboarding_step_4_free_vod(){
2889
2890 $current_screen=get_current_screen();
2891 if($current_screen->base !=='wpstream_page_wpstream_onboard'){
2892 return;
2893 }
2894
2895 $token = $this->main->wpstream_live_connection->wpstream_get_token();
2896 $video_list = array();
2897 if($token!=''){
2898 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2899 }
2900
2901 ?>
2902
2903 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4a">
2904 <h1><?php esc_html_e('Let’s create your first Free-To-View VOD','wpstream');?></h1>
2905
2906
2907
2908 <?php
2909 if( count($video_list) !== 0 ) {
2910 ?>
2911 <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div>
2912 <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
2913 <label><?php esc_html_e('Name your FTV Video-On-Demand','wpstream')?></label>
2914 <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');?>" >
2915 <?php $this->wpstream_show_vod_dropdown_onboarding($video_list); ?>
2916 <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');?>" />
2917 </div>
2918
2919 <?php }else{
2920 $this->wpstream_obboarding_file_warning();
2921 } ?>
2922
2923
2924
2925 <div class="wpstream_initial_onboarding_controls_wrapper">
2926 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
2927 </div>
2928
2929 </div>
2930
2931
2932 <?php
2933 }
2934
2935 /*
2936 *
2937 *
2938 *
2939 */
2940
2941 public function wpstream_show_vod_dropdown_onboarding($video_list,$appendix=''){
2942
2943 print '<label>'.esc_html__('Choose Recording','wpstream').'</label>
2944 <select name="wpstream_free_vod_file_name" id="wpstream_free_vod_file_name'.$appendix.'">
2945 <option value="">'.esc_html__('Please select a recording from the list','wpstream').'</option>';
2946
2947 if(is_array($video_list)){
2948 foreach ($video_list as $key=>$value){
2949 print '<option value="'.$key.'"';
2950 print '>'.$value.'</option>';
2951 }
2952 }
2953 print'</select>';
2954
2955 }
2956
2957
2958
2959 /*
2960 *
2961 *
2962 *
2963 */
2964 public function wpstream_obboarding_file_warning(){
2965 print '<div class="wpstream_warning_onboarding">
2966 '.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').'
2967 </br>
2968 <div class="wpstream_upload_video">'.esc_html__('Upload Video','wpstream').'</div>
2969
2970 <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
2971 </div>';
2972 }
2973
2974
2975
2976
2977 /*
2978 *
2979 *
2980 *
2981 */
2982 public function wpstream_onboarding_step_4_ppv_vod(){
2983 $current_screen=get_current_screen();
2984
2985 if($current_screen->base !=='wpstream_page_wpstream_onboard'){
2986 return;
2987 }
2988
2989 $token = $this->main->wpstream_live_connection->wpstream_get_token();
2990 $video_list = array();
2991 if($token!=''){
2992 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2993 }
2994 ?>
2995
2996 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4b">
2997 <h1><?php esc_html_e('Let\'s create your first Pay-Per-View VOD','wpstream');?></h1>
2998
2999 <div id="wpstream_onboard_vod_ppv_notice" class="wpstream_onboarding_notification"></div>
3000 <?php
3001 if( count($video_list) !== 0 ) {
3002 if ( class_exists( 'WooCommerce' ) ) {
3003 ?>
3004 <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
3005 <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
3006 <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');?>">
3007
3008 <?php $this->wpstream_show_vod_dropdown_onboarding($video_list,'_for_ppv'); ?>
3009
3010 <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
3011 <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
3012 <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');?>" />
3013
3014 </div>
3015 <?php }else{
3016 $this->wpstream_onboarding_woo_warning();
3017 }
3018
3019
3020 }else{
3021 $this->wpstream_obboarding_file_warning();
3022 }
3023 ?>
3024
3025
3026 <div class="wpstream_initial_onboarding_controls_wrapper">
3027 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
3028 </div>
3029
3030 </div>
3031
3032
3033 <?php
3034 }
3035
3036
3037
3038
3039 /*
3040 *
3041 * On boarding Header
3042 *
3043 */
3044 public function onboarding_wizard_header() {
3045 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3046 ?>
3047
3048 <div class="wpstream_on_boarding_wrapper">
3049 <div class="wpstream_close_onboarding wpstream_close_initial_onboarding"></div>
3050 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
3051 <div class="wpstream_close_onboarding_warning"></div>
3052
3053 <?php
3054 }
3055
3056
3057
3058
3059
3060 /*
3061 *
3062 * On Boarding Footer
3063 *
3064 */
3065 public function onboarding_wizard_footer() {
3066 ?>
3067 <div class="wpstream_modal_back"></div>
3068 </div>
3069 <div class="wpstream_modal_background_onboard"></div>
3070 <?php
3071 }
3072
3073
3074
3075 /*
3076 *
3077 * On Boarding create PPV channel
3078 *
3079 */
3080
3081
3082 public function wpstream_on_board_create_channel_ppv(){
3083 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3084 $current_user = wp_get_current_user();
3085
3086 if(current_user_can('administrator')){
3087 $channel_name = sanitize_text_field($_POST['channel_name']);
3088 $channel_price = floatval($_POST['channel_price']);
3089 $my_post = array(
3090 'post_title' => $channel_name,
3091 'post_content' => '',
3092 'post_status' => 'publish',
3093 'post_type' => 'product',
3094 'post_author' => $current_user->ID
3095 );
3096
3097 // Insert the post into the database
3098 $post_id = wp_insert_post( $my_post );
3099
3100 if(is_wp_error($post_id)){
3101 echo json_encode( array('succes'=>false) );
3102 }else{
3103
3104 $product = wc_get_product($post_id);
3105 $price = wc_format_decimal($channel_price);
3106
3107 $product = wc_get_product( $post_id );
3108 $product->set_price( $price );
3109 $product->set_regular_price( $price ); // To be sure
3110 $product->save();
3111 update_post_meta ($post_id,'event_passed',0);
3112 wp_set_object_terms( $post_id, 'live_stream', 'product_type' );
3113
3114
3115
3116
3117 $permalink = get_edit_post_link($post_id);
3118
3119 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3120 $permalink= add_query_arg( 'branch', '2', $permalink );
3121
3122
3123 echo json_encode( array(
3124 'success'=> true,
3125 'link' => ($permalink)
3126 ));
3127 }
3128
3129 }
3130 die();
3131 }
3132
3133 /*
3134 *
3135 * On Boarding create channel
3136 *
3137 */
3138
3139
3140 public function wpstream_on_board_create_channel(){
3141 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3142 $current_user = wp_get_current_user();
3143
3144 if(current_user_can('administrator')){
3145 $channel_name=sanitize_text_field($_POST['channel_name']);
3146 $my_post = array(
3147 'post_title' => $channel_name,
3148 'post_content' => '',
3149 'post_status' => 'publish',
3150 'post_type' => 'wpstream_product',
3151 'post_author' => $current_user->ID
3152 );
3153
3154 // Insert the post into the database
3155 $post_id = wp_insert_post( $my_post );
3156
3157 if(is_wp_error($post_id)){
3158 echo json_encode( array('succes'=>false) );
3159 }else{
3160 $permalink = get_edit_post_link($post_id);
3161
3162 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3163 $permalink= add_query_arg( 'branch', '1', $permalink );
3164
3165
3166 echo json_encode( array(
3167 'success'=> true,
3168 'link' => ($permalink)
3169 ));
3170 }
3171
3172 }
3173 die();
3174 }
3175
3176
3177
3178 /*
3179 *
3180 * On Boarding create free vod
3181 *
3182 */
3183
3184
3185 public function wpstream_on_board_create_free_vod(){
3186 $current_user = wp_get_current_user();
3187 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3188 if(current_user_can('administrator')){
3189 $channel_name =sanitize_text_field($_POST['channel_name']);
3190 $file_name =sanitize_text_field($_POST['file_name']);
3191 $my_post = array(
3192 'post_title' => $channel_name,
3193 'post_content' => '',
3194 'post_status' => 'publish',
3195 'post_type' => 'wpstream_product_vod',
3196 'post_author' => $current_user->ID
3197 );
3198
3199 // Insert the post into the database
3200 $post_id = wp_insert_post( $my_post );
3201
3202 if(is_wp_error($post_id)){
3203 echo json_encode( array('succes'=>false) );
3204 }else{
3205 update_post_meta($post_id, 'wpstream_product_type', 2);
3206 update_post_meta($post_id, 'wpstream_free_video', $file_name);
3207
3208
3209 $permalink = get_edit_post_link($post_id);
3210
3211 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3212 $permalink= add_query_arg( 'branch', '3', $permalink );
3213
3214
3215 echo json_encode( array(
3216 'success'=> true,
3217 'link' => ($permalink)
3218 ));
3219 }
3220
3221 }
3222 die();
3223 }
3224
3225
3226 /*
3227 *
3228 * On Boarding create ppv vod
3229 *
3230 */
3231
3232
3233 public function wpstream_on_board_create_ppv_vod(){
3234 $current_user = wp_get_current_user();
3235 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3236
3237 if(current_user_can('administrator')){
3238 $channel_name = sanitize_text_field($_POST['channel_name']);
3239 $vod_price = floatval($_POST['vod_price']);
3240 $file_name = sanitize_text_field($_POST['file_name']);
3241
3242 $my_post = array(
3243 'post_title' => $channel_name,
3244 'post_content' => '',
3245 'post_status' => 'publish',
3246 'post_type' => 'product',
3247 'post_author' => $current_user->ID
3248 );
3249
3250 // Insert the post into the database
3251 $post_id = wp_insert_post( $my_post );
3252
3253 if(is_wp_error($post_id)){
3254 echo json_encode( array('succes'=>false) );
3255 }else{
3256
3257 $product = wc_get_product($post_id);
3258 $price = wc_format_decimal($vod_price);
3259
3260 $product = wc_get_product( $post_id );
3261 $product->set_price( $price );
3262 $product->set_regular_price( $price ); // To be sure
3263 $product->save();
3264 update_post_meta ($post_id,'event_passed',0);
3265 update_post_meta ($post_id,'_movie_url', $file_name);
3266 wp_set_object_terms( $post_id, 'video_on_demand', 'product_type' );
3267
3268
3269
3270
3271 $permalink = get_edit_post_link($post_id);
3272
3273 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
3274 $permalink= add_query_arg( 'branch', '4', $permalink );
3275
3276
3277 echo json_encode( array(
3278 'success'=> true,
3279 'link' => ($permalink) ,
3280 ' $file_name'=> $file_name,
3281 ));
3282 }
3283
3284 }
3285 die();
3286 }
3287
3288
3289 /*
3290 *
3291 * On Boarding login
3292 *
3293 */
3294 public function wpstream_on_board_login(){
3295 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3296
3297 if(current_user_can('administrator')){
3298 $username = sanitize_text_field($_POST['api_username']);
3299 $password = sanitize_text_field($_POST['api_password']);
3300 update_option('wpstream_api_username',$username);
3301 update_option('wpstream_api_password',$password);
3302
3303 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3304
3305 echo json_encode( array(
3306 'success'=> true,
3307 'token' => ($token)
3308 ));
3309
3310 }else{
3311 echo json_encode( array(
3312 'success'=> false,
3313 'token' => esc_html('You are not an administrator','wpstream')
3314 ));
3315 }
3316 die();
3317 }
3318
3319
3320 public function wpstream_register_refresh_capthca(){
3321
3322 if(current_user_can('administrator')){
3323
3324 }
3325 }
3326
3327 /*
3328 *
3329 * On Boarding login
3330 *
3331 */
3332 public function wpstream_on_board_register(){
3333
3334 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3335
3336 if(current_user_can('administrator')){
3337 $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']);
3338 $wpstream_register_password = sanitize_text_field($_POST['wpstream_register_password']);
3339 $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']);
3340 $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']);
3341
3342 $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password);
3343 if(!$validate['success']){
3344 echo json_encode($validate);
3345 die();
3346 }
3347
3348 $url='user/create';
3349 $curl_post_fields=array(
3350 'email' => $wpstream_register_email,
3351 'password' => $wpstream_register_password,
3352 'captcha' => $wpstream_register_captcha,
3353 'captcha_id' => $wpstream_register_captcha_id,
3354 );
3355
3356
3357
3358 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
3359 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
3360
3361
3362
3363 if($curl_response_decoded['success']){
3364
3365 if($curl_response_decoded['request']['registred']){
3366 // we are registerd
3367
3368 update_option('wpstream_api_username',$wpstream_register_email);
3369 update_option('wpstream_api_password',$wpstream_register_password);
3370
3371 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3372
3373 echo json_encode( array(
3374 'success' => true,
3375 'token' => $token ,
3376 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'),
3377
3378 ));
3379 die();
3380 }else{
3381
3382 echo json_encode( array(
3383 'success'=> false,
3384 'message'=> $curl_response_decoded['request']['message'],
3385 'curl'=>$curl_response_decoded,
3386
3387 ));
3388 die();
3389 }
3390
3391
3392
3393
3394 }else{
3395
3396 echo json_encode( array(
3397 'success'=> false,
3398 'message'=> esc_html__('Register action could not be completed. Please register on wpstream.net','wpstream'),
3399
3400 ));
3401 die();
3402 }
3403
3404
3405
3406
3407
3408
3409
3410
3411 }else{
3412 echo json_encode( array(
3413 'success'=> false,
3414 'message' => esc_html('You are not an administrator','wpstream')
3415 ));
3416 die();
3417 }
3418
3419 die();
3420 }
3421
3422
3423 /*
3424 *
3425 * Validate for register
3426 *
3427 */
3428
3429
3430 public function wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password){
3431
3432 $return= array(
3433 'success'=>true
3434 );
3435
3436 if ($wpstream_register_email=='' ){
3437 $return= array(
3438 'success'=> false,
3439 'message' => esc_html('The email Field is Empty','wpstream')
3440 );
3441 return $return;die();
3442 }
3443
3444 if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) {
3445 $return= array(
3446 'success'=> false,
3447 'message' => esc_html('The email doesn\'t look right !','wpstream')
3448 );
3449 return $return;die();
3450 }
3451
3452
3453 $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1);
3454 if( $domain!='' && !checkdnsrr ($domain) ){
3455 $return= array(
3456 'success'=> false,
3457 'message' => esc_html('The email doesn\'t look right !','wpstream')
3458 );
3459 return $return;die();
3460 }
3461
3462
3463
3464 if(strlen($wpstream_register_password)<5){
3465 $return= array(
3466 'success'=> false,
3467 'message' => esc_html('The password is too short. Please use at least 5 characters.','wpstream')
3468 );
3469 return $return;die();
3470 }
3471
3472 return $return;die();
3473 }
3474 }