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

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

1,311 lines 60.5 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 public function __construct( $plugin_name, $version,$plugin_main ) {
61
62 $this->plugin_name = $plugin_name;
63 $this->version = $version;
64 $this->main = $plugin_main;
65
66 }
67
68 /**
69 * Register the stylesheets for the admin area.
70 *
71 * @since 3.0.1
72 */
73 public function enqueue_styles() {
74
75 /**
76 * This function is provided for demonstration purposes only.
77 *
78 * An instance of this class should be passed to the run() function
79 * defined in Wpstream_Loader as all of the hooks are defined
80 * in that particular class.
81 *
82 * The Wpstream_Loader will then create the relationship
83 * between the defined hooks and the functions defined in this
84 * class.
85 */
86 wp_enqueue_style( 'wpestate-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
87 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
88
89 }
90
91 /**
92 * Register the JavaScript for the admin area.
93 *
94 * @since 3.0.1
95 */
96 public function enqueue_scripts() {
97
98 wp_enqueue_script("jquery-ui-slider");
99 wp_enqueue_script("jquery-ui-datepicker");
100 wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js',array(), WPSTREAM_PLUGIN_VERSION, true);
101 wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js',array(), WPSTREAM_PLUGIN_VERSION, true);
102 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
103 array(
104 'admin_url' => get_admin_url(),
105 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
106 'download_mess' => esc_html__('Click to download!','wpstream'),
107 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
108 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
109 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
110 'upload_complete' => esc_html('Upload Complete!','wpstream'),
111 'no_band' => esc_html('Not enough bandwidth.','wpsteam'),
112 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
113
114 ));
115
116
117
118 wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js',array(), WPSTREAM_PLUGIN_VERSION, true);
119 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
120 array(
121 'admin_url' => get_admin_url(),
122 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
123 'download_mess' => esc_html__('Click to download!','wpstream'),
124 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
125 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
126 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
127 'upload_complete' => esc_html('Upload Complete!','wpstream'),
128 'no_band' => esc_html('Not enough bandwidth.','wpsteam'),
129 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
130
131 ));
132
133 }
134
135
136 /**
137 * Add Plugin Administation menu
138 *
139 * @since 3.0.1
140 */
141
142 public function wpstream_manage_admin_menu() {
143
144 add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
145 add_submenu_page( 'wpstream_plugin_options', __('WpStream Credentials','wpestream'), __('WpStream Credentials','wpestream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
146 add_submenu_page( 'wpstream_plugin_options', __('WpStream Channels','wpestream'), __('WpStream Channels','wpestream'), 'administrator', 'wpstream_new_general_set', array( $this,'wpstream_new_general_set'));
147 add_submenu_page( 'wpstream_plugin_options', __('WpStream Media Management','wpestream'), __('WpStream Media Management','wpestream'), 'administrator', 'wpstream_media_management', array($this,'wpstream_media_management'));
148 add_submenu_page( 'wpstream_plugin_options', __('WpStream Settings','wpestream'), __('WpStream Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings'));
149
150 }
151
152
153
154 /**
155 * Shows events wpstream
156 *
157 * @since 3.0.1
158 */
159
160 public function wpstream_new_general_set() {
161
162 $no_channel=1;
163
164 if(class_exists ('WC_Subscription')){
165
166 }
167
168 //event_passed
169 $args = array(
170 'posts_per_page' => -1,
171 'post_type' => 'product',
172 'post_status' => 'publish',
173 'meta_query' => array(
174 array(
175 'key' => 'event_passed',
176 'value' => 1,
177 'compare' => '!=',
178 )
179 ),
180
181 'tax_query' => array(
182 'relation' => 'AND',
183 array(
184 'taxonomy' => 'product_type',
185 'field' => 'slug',
186 'terms' => array('live_stream','subscription')
187 )
188 ),
189 );
190
191
192
193 $event_list = new WP_Query($args);
194 global $live_event_for_user;
195 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
196 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
197
198 $this->main->show_user_data($pack_details);
199
200
201
202
203 if( $event_list->have_posts()){
204
205
206 print '<div class="pack_details_wrapper_transparent">
207 <h3>'.__('Your Pay-Per-View Channel List','wpstream').'</h3>';
208
209
210 $link_new = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
211
212 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new pay-per-view channel.','wpstream').'</a>';
213 print '</div>';
214
215 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
216
217 while ($event_list->have_posts()): $event_list->the_post();
218
219 $the_id = get_the_ID();
220 $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true));
221 $term_list = wp_get_post_terms($the_id, 'product_type');
222
223 if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){
224 continue;
225 }
226
227 $this->wpstream_live_stream_unit($the_id);
228
229 endwhile;
230
231 print'</div>';
232 $no_channel=1;
233 }else{
234 $no_channel=0;
235 }
236
237
238 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
239 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
240 $current_user = wp_get_current_user();
241 $allowded_html = array();
242 $userID = $current_user->ID;
243 $user_live_streams = get_user_meta($userID,'live_shows');
244
245
246 wp_reset_postdata();
247
248
249
250
251 // free
252
253 $args_free = array(
254 'posts_per_page' => -1,
255 'post_type' => 'wpstream_product',
256 'post_status' => 'publish',
257 'meta_query' => array(
258 'relation' => 'AND',
259 array(
260 'key' => 'wpstream_product_type',
261 'value' => 1,
262 'compare' => '==',
263 ),
264
265 ),
266
267
268 );
269 $event_list_free = new WP_Query($args_free);
270
271
272 if( $event_list_free->have_posts()){
273 print '<div class="pack_details_wrapper_transparent">
274 <h3>'.__('Your Free Channel List','wpestate').'</h3>';
275
276 $link_new = admin_url('post-new.php?post_type=wpstream_product');
277 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new free channel.','wpstream').'</a>';
278 print '</div>';
279 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
280
281 while ($event_list_free->have_posts()): $event_list_free->the_post();
282
283
284 $the_id = get_the_ID();
285
286 if( get_post_meta ($the_id,'event_passed',true)!=1){
287 $this->wpstream_live_stream_unit($the_id);
288 }
289
290 endwhile;
291
292 print'</div>';
293 $no_channel=1;
294 }else{
295 $no_channel=0;
296 }
297
298
299
300 if($no_channel==0){
301 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
302 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
303 print '<div class="no_events_warning"> '.__('* You don\'t have any live channels!','wpstream');
304
305 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new free channel ','wpstream').'</a>';
306 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new pay-per-view channel ','wpstream').'</a>';
307
308 print '</div>';
309 }
310
311
312
313
314 }
315 // end wpstream_new_general_set
316
317
318
319
320
321
322 /**
323 * Shows event unit card in admin
324 *
325 * @since 3.0.1
326 */
327 public function wpstream_live_stream_unit($the_id,$is_front=''){
328 global $live_event_for_user;
329 $current_user = wp_get_current_user();
330
331 if(!current_user_can('administrator')){
332 if($is_front=='' ){
333 print '<div class="event_list_unit">';
334 esc_html_e('You are not allowed to broadcast.','wpstream');
335 print '</div>';
336 return;
337 }
338
339 }
340
341 if( !$this->main->wpstream_check_user_can_stream() ){
342 print '<div class="event_list_unit">';
343 esc_html_e('You are not allowed to broadcast','wpstream');
344 print '</div>';
345 return;
346
347 }
348
349
350 $live_class='';
351 if(isset($live_event_for_user[$the_id])) {
352 $live_class=" wpstream_show_started";
353 }
354
355
356 print '<div class="event_list_unit '.$live_class.' event_unit_style_'.esc_attr($is_front).'">';
357 if(has_post_thumbnail($the_id)){
358 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
359 }else{
360 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_150.jpg';
361 }
362
363 global $wpstream_plugin;
364
365
366 print '<div class="event_thumb_wrapper"><img class="event_thumb" src="'.$thumb.'" alt="show_imagge"></div>';
367 print '<h3 data-prodid="'.$the_id.'">'.get_the_title($the_id).' - '.esc_html__('Id','wpstream').': '.$the_id.'<a class="view_channel" href="'.get_permalink($the_id).'" target="_blank">'.esc_html__('View Channel','wprentals').'</a></h3> ';
368
369
370
371 $live_event_stream_name = get_post_meta($the_id,'live_event_stream_name',true);
372 $live_event_array = get_post_meta($the_id,'live_event_uri',true);
373 $live_event_uri = '';
374
375
376 $pending_streaming_class = '';
377 $wpstream_ready_to_stream_class = '';
378 $external_software_streaming_class = '';
379 $wpstream_no_stream_class = '';
380 $carnat_key1 = '';
381 $carnat_key2 = '';
382 $uri = '';
383 $webcaster_url = '';
384 $rtmp_ip_uri = '';
385 $uri_ip = '';
386 $server_id = '';
387 $obs_uri = '';
388 $obs_stream = '';
389 $webCasterUrl = '';
390
391 if( $live_event_for_user=='' && $is_front=='front' ){
392 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
393 }
394
395
396
397 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
398
399 $pending_streaming_class = 'show_stream_data pending_trigger';
400 $wpstream_ready_to_stream_class = 'hide_stream_data';
401 $external_software_streaming_class = 'show_stream_data';
402 $wpstream_no_stream_class = 'hide_stream_data';
403 if(isset($live_event_for_user[$the_id]['live_uri'])){
404 $explode = explode('wpstream.net/', $live_event_for_user[$the_id]['live_uri']);
405 $uri = $explode[0].'wpstream.net/wpstream/';
406 $stream_name = get_post_meta($the_id,'live_event_stream_name',true);
407 $carnat_key1 = $live_event_for_user[$the_id]['carnat1'];
408 $carnat_key2 = $live_event_for_user[$the_id]['carnat2'];
409 $webcaster_url = 'https://'.$live_event_for_user[$the_id]['subdomain_key'].'.live.streamer.wpstream.net:8443/'.$live_event_for_user[$the_id]['carnat2'];
410
411 $rtmp_ip_uri = 'http://'.$live_event_for_user[$the_id]['ip'].':8444';
412 $uri_ip= 'rtmp://'.$live_event_for_user[$the_id]['ip'].'/wpstream/';
413
414 // starting from 2.0
415 $server_id = get_post_meta($the_id,'server_id',true);
416 $obs_uri = get_post_meta($the_id,'obs_uri',true);
417 $obs_stream = get_post_meta($the_id,'obs_stream',true);
418 $webCasterUrl= get_post_meta($the_id,'webCasterUrl',true);
419
420 // if local server id diffrens than wpstream server id it means call was made via api and we use wpstream ip
421 if( $server_id != $live_event_for_user[$the_id]['api20_event_id'] && $live_event_for_user[$the_id]['api20_event_id']!='' ){
422
423 $server_id=esc_html($live_event_for_user[$the_id]['api20_event_id']);
424 }
425
426 }
427
428 }else{
429
430 $pending_streaming_class = 'hide_stream_data';
431 $wpstream_ready_to_stream_class = 'hide_stream_data';
432 $external_software_streaming_class = 'hide_stream_data';
433 $wpstream_no_stream_class = 'show_stream_data';
434 }
435
436
437
438
439 print' <div class="pending_streaming '.$pending_streaming_class.' " data-show-id="'.$the_id.'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'">';
440 print'<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'.esc_html__('Your Event is starting. Please wait...','wprentals').' ';
441 print '<img class="server_loading_new" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/loading.gif" alt="loading" /></div>';
442 print '<div class="multiple_warning_events"> '.esc_html__('To go Live on a Channel, you need to start an Event. It will stop automatically after an hour of inactivity.','wpstream').'</div>';
443 print '</div>';
444
445
446 print '<div class="wpstream_ready_to_stream '.$wpstream_ready_to_stream_class.'">';
447 print '<div class="wpstream_channel_status"><span class="dashicons dashicons-yes"></span>'.esc_html__('Ready to Go Live !','wpstream').'</div>';
448 print '<div class="start_webcaster wpstream_button" data-webcaster-url="'.$webCasterUrl.'" >'.esc_html__('Go Live from Browser','wpstream').'</div>';
449 print '<div class="start_external wpstream_button" >'.esc_html__('Go Live with External Broadcaster','wpstream').'</div>';
450 print '<div class="stop_server wpstream_button" data-show-id="'.$the_id.'">'.esc_html__('Turn Off Channel','wpstream').'</div>';
451 $ajax_nonce_stop = wp_create_nonce( "wpstream_stop_event_nonce" );
452 print '<input type="hidden" id="wpstream_stop_event_nonce" value="'.$ajax_nonce_stop.'">';
453 print '</div>';
454
455
456
457 print '<div class="external_software_streaming '. $external_software_streaming_class.' ">';
458 print '<div class="event_list_unit_notificationx"><strong>'.__('Server:').' </strong> <div class="wpstream_live_uri_text">' . $obs_uri.'</div><div class="copy_live_uri">'.__('copy to clipboard','wpstream').'</div>';
459 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong><div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy to clipboard','wpstream').'</div></div>';
460 print '<div class="warning_stream">'.
461 sprintf(esc_html__('Use %s on your Windows or Mac computer, or the Larix Broadcaster app on your %s or %s smartphone/tablet. Various other Apps and devices are compatible. See %s for more details.','wpstream'),'<a href="https://obsproject.com/download" target="_blank">OBS Studio</a>','<a href="https://apps.apple.com/us/app/larix-broadcaster/id1042474385" target="_blank"> iOS</a>','<a href="https://play.google.com/store/apps/details?id=com.wmspanel.larix_broadcaster&hl=en" target="_blank">Android</a>','<a href="https://wpstream.net/external-broadcasters/" target="_blank">this page</a>').'</div>';
462 print ' <img class="how_to" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/how_to_obs.jpg" alt="show_imagge">';
463 print'</div>';
464 print'</div>';
465
466
467
468
469 print '<div class="wpstream_no_stream '.$wpstream_no_stream_class.' ">';
470 print '<div class="event_list_unit_notificationx"><span class="server_notification">'.__('Broadcast Offline.','wpestream').' <img class="server_loading" src="'.plugins_url().'/wpstream/img/loading.gif" alt="loading" /></span></div>';
471 print '<div class="record_wrapper">Record ? <input type="checkbox" name="record_event" class="record_event"/>Yes</div>';
472 print '<div class="encrypt_wrapper">Encrypt ? <input type="checkbox" name="encrypt_event" class="encrypt_event"/>Yes</div>';
473
474 print '<input class="start_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Start Live Event','wpstream').'">';
475
476 if($is_front==''){
477 print '<input class="close_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Delete Channel','wpstream').'">';
478 }
479
480 print '<div class="multiple_warning_events"> '.esc_html__('To go Live on a Channel, you need to start an Event. It will stop automatically after an hour of inactivity.','wpstream').'</div>';
481
482
483 print '<div class="wpstream_social_media_broadcast">';
484
485 print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_facebook" id="wpstream_on_facebook'.$the_id.'"><label for="wpstream_on_facebook'.$the_id.'">'.esc_html__('Stream on Facebook','wpstream').'</label>';
486 print '</div>';
487
488 print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_youtube" id="wpstream_on_youtube'.$the_id.'"><label for="wpstream_on_youtube'.$the_id.'">'.esc_html__('Stream on Youtube','wpstream').'</label>';
489 print '</div>';
490
491
492 print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_twich" id="wpstream_on_twich'.$the_id.'"><label for="wpstream_on_twich'.$the_id.'">'.esc_html__('Stream on Twich','wpstream').'</label>';
493 print '</div>';
494
495 print '<div class="wpstream_on_facebook_container wpstream_social_stream_container">';
496 print 'Some Facebook Settings for event '.$the_id;
497 print '</div>';
498
499 print '<div class="wpstream_on_youtube_container wpstream_social_stream_container">';
500 print '<label for="wpstream_youtube_rtmp'.$the_id.'">'.esc_html__('Youtube RTMP','wpstream').'</label>';
501 print '<input type="text" class="wpstream_youtube_rtmp" id="wpstream_youtube_rtmp'.$the_id.'" value="'.esc_html(get_post_meta($the_id,'wpstream_youtube_rtmp',true )).'">';
502 print '</div>';
503
504 print '<div class="wpstream_on_twich_container wpstream_social_stream_container">';
505 print '<label for="wpstream_twich_rtmp'.$the_id.'">'.esc_html__('Twich RTMP','wpstream').'</label>';
506 print '<input type="text" class="wpstream_twich_rtmp" id="wpstream_twich_rtmp'.$the_id.'" value="'.esc_html(get_post_meta($the_id,'wpstream_twich_rtmp',true )).'">';
507 print '</div>';
508
509
510 print '</div>';
511 print '</div>';
512
513
514 print '</div>';
515 }
516
517
518
519
520
521 /**
522 * Set Settings
523 *
524 *
525 */
526
527 public function wpstream_settings(){
528
529 if($_SERVER['REQUEST_METHOD'] === 'POST'){
530 $allowed_html = array();
531 $exclude_array = array();
532 $allowed_html = array();
533
534
535 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
536 update_option( sanitize_key('wpstream_stream_role'), '' );
537 }
538
539
540 foreach($_POST as $variable=>$value){
541 if ($variable!='submit'){
542 if (!in_array($variable, $exclude_array) ){
543 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
544 }
545
546 if($variable=='stream_role'){
547 update_option( sanitize_key('wpstream_stream_role'), $value );
548 }
549
550 }
551 }
552
553 // reset permalinkgs
554 global $wp_rewrite;
555
556 update_option( "rewrite_rules", FALSE );
557 $wp_rewrite->flush_rules( true );
558
559 }
560
561 $wpstream_settings_array =array(
562 1 => array(
563 'label' => esc_html__('Slug for wpstream free videos/channels','wpstream'),
564 'name' => 'free_media_slug',
565 'type' => 'text',
566 'details' => esc_html__('It will replace wpstream in the free videos/channels url with your new slug. You cannot use special characters like "&". After changing the url go to Settings - Permalinks and Save again the "Permalinks Settings" - option "Post name" ','wpstream'),
567 ),
568
569 2 => array(
570 'label' => esc_html__('Extra roles who can stream via wpstream shortcodes / blocks','wpstream'),
571 'name' => 'stream_role',
572 'type' => 'user_roles',
573 'details' => esc_html__('A non admin user will be able to stream only on one channel only that will be automaticaly created.','wpstream'),
574
575 ),
576 3 => array(
577 'label' => esc_html__('Type channel on wich non admin users can stream ','wpstream'),
578 'name' => 'user_streaming_channel_type',
579 'type' => 'select',
580 'select_values'=>array(
581 'free' => esc_html__('Free Live Channels','wpstream'),
582 'paid' => esc_html__('Pay per view (WooCommerce product)','wpstream')
583 ),
584 'details' => esc_html__('The product type channel is a WooCommerce product (pay per view) while Free Channels is visible to all types of visitors ','wpstream'),
585 ),
586
587 4 => array(
588 'label' => esc_html__('Default Price ','wpstream'),
589 'name' => 'user_streaming_default_price',
590 'type' => 'text',
591 'details' => esc_html__('If non admins can stream on a product channel then you can set here the default price here.','wpstream'),
592 ),
593 );
594
595
596
597 print '<form method="post" action="" >';
598 print '<div class="theme_options_tab_wpstream" style="display:block;" >
599 <h1>'.__('WpStream Settings','wpstream').'</h1>';
600
601
602
603 print '<div class="wpstream_option_wrapper">';
604 foreach ($wpstream_settings_array as $key=>$option){
605 print '<div class="wpstream_option">';
606 $options_value = get_option('wpstream_'.$option['name']) ;
607
608
609
610 if($option['type']=='user_roles'){
611
612 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
613 print $this->wpstream_select_user_roles($option['name'],$options_value);
614 print '<div class="settings_details">'.$option['details'].'</div>';
615
616
617 }else if($option['type']=='text'){
618
619 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
620 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
621 print '<div class="settings_details">'.$option['details'].'</div>';
622
623 } else if($option['type']=='select'){
624
625 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
626 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
627 foreach($option['select_values'] as $key=>$value){
628 print '<option value="'.$key.'" ';
629 if( $key == esc_html($options_value) ){
630 print ' selected ';
631 }
632 print '>'.$value.'</option>';
633 }
634 print '</select>';
635 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
636 print '<div class="settings_details">'.$option['details'].'</div>';
637
638 }
639
640 print '</div>';
641 }
642 print '</div>';
643
644
645 print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
646
647
648
649 print '</div>';
650 print '</form>';
651 }
652
653
654
655
656
657
658
659 /**
660 * Set user roles
661 *
662 * @since 3.0.1
663 */
664 public function wpstream_select_user_roles($name,$value){
665 if($value==''){
666 $value=array();
667 }
668
669 $roles = get_editable_roles();
670 $return = '<select id="wpstream_user_roles" name="'.esc_html($name).'[]" multiple>';
671 unset( $roles['administrator'] );
672
673 foreach ($roles as $key=>$role){
674 $return .= '<option value="'.$key.'" ';
675 if( in_array($key, $value) ){
676 $return .= ' selected ';
677 }
678 $return .= '>'.$role['name'].'</option>';
679 }
680 $return .= '</select>';
681
682
683 return $return;
684 }
685
686
687 /**
688 * Set credential admin function
689 *
690 * @since 3.0.1
691 */
692 public function wpstream_set_wpstream_credentials(){
693
694 if($_SERVER['REQUEST_METHOD'] === 'POST'){
695 $allowed_html = array();
696 $exclude_array = array();
697 $allowed_html = array();
698
699 foreach($_POST as $variable=>$value){
700 if ($variable!='submit'){
701 if (!in_array($variable, $exclude_array) ){
702 update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
703 }
704 }
705 }
706
707
708
709
710 update_option('wp_estate_token_expire',0);
711 update_option('wp_estate_curent_token',' ');
712 delete_transient( 'wpstream_token_request');
713
714 }
715
716
717 $allowed_html = array();
718 $api_key = esc_html( get_option('wpstream_api_key','') );
719
720
721 $wpstream_options_array =array(
722 2 => array(
723 'label' => 'WpStream.net Username or Email',
724 'name' => 'api_username',
725 'type' => 'text',
726 ),
727 3 => array(
728 'label' => 'WpStream.net Password',
729 'name' => 'api_password',
730 'type' => 'password',
731 ),
732
733 );
734
735
736 $token = $this->main->wpstream_live_connection->wpstream_get_token();
737 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
738
739 $this->main->show_user_data($pack_details);
740
741 print '<form method="post" action="" >';
742 print '<div class="theme_options_tab_wpstream" style="display:block;" >
743 <h1>'.__('WpStream Credentials','wpstream').'</h1>';
744
745
746 if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== ' '){
747 echo '<div class="api_not_conected wpstream_orange">'.__('To connect your plugin, enter your WpStream credentials below or go <a href="https://wpstream.net/my-account/" target="_blank">here</a> to create an account.','wpstream').'</div>';
748 }else if($token==''){
749 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>';
750 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
751 echo '<div class="api_conected">'.__('Conected to WpStream.net!','wpstream').'</div>';
752 }else{
753 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
754 }
755 print '<div class="wpstream_option_wrapper">';
756 foreach ($wpstream_options_array as $key=>$option){
757 print '<div class="wpstream_option">';
758
759 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
760 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
761 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
762
763 print '</div>';
764 }
765 print '</div>';
766
767
768 print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
769
770
771
772 print '</div>';
773 print '</form>';
774
775 print '<div class="theme_options_tab_wpstream" style="display:block;" >';
776 $link_new = admin_url('admin.php?page=wpstream_new_general_set');
777 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
778 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
779
780
781 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new free channel','wpstream').'</a>';
782 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create pay-per-view channel','wpstream').'</a>';
783 print '<a href="'.esc_url($link_new).'" class="wpstream_no_chanel_add_channel">'.esc_html('My Channels','wpstream').'</a>';
784 print '</div>';
785
786
787 }
788
789
790
791 /**
792 * Media Management
793 *
794 * @since 3.0.1
795 */
796 public function wpstream_media_management(){
797 $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
798
799 $this->main->show_user_data($pack_details);
800
801
802 print '<div id="wpstream_media_upload"><h3>'.__('Media Upload','wpstream').'</h3>'.$this->wpstream_present_media_upload().'</div>';
803
804 print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Video Management','wpstream').'</h3>'.$this->wpstream_present_file_management().'</div>';
805
806 }
807
808
809
810 /**
811 * Media upload
812 *
813 * @since 3.0.1
814 */
815 public function wpstream_present_media_upload(){
816 $to_return='';
817 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
818
819 if($formInputs === 'notenough'){
820 $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough bandwidth or storage to upload a video!','wpstream').'</div>';
821 return $to_return;
822 }
823
824
825 $to_return.='<div class="wpstream_upload_container">';
826 $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>';
827 $to_return.='<form action="https://wpstream-videos.s3.amazonaws.com/"
828 method="POST"
829 enctype="multipart/form-data"
830 class="direct-upload">';
831
832 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
833 $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>';
834
835
836 $to_return.='<div class="wpstream_file_drop_color">';
837 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
838 $to_return.='<div class="wpstream_form_ex_details">'.esc_html__('The Video File must be encoded with the following settings:
839
840 Container: MP4,
841 Video codec: H264,
842 Audio codec: AAC. Media will fail to play back if it does not follow the above settings.
843 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>';
844 if(is_array($formInputs)){
845 foreach ($formInputs as $name => $value) {
846 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
847 }
848 }
849
850 $to_return.='
851 <div class="progress-bar-area"></div></div>
852 </form>';
853
854 $to_return.='</div>';
855 return $to_return;
856
857 }
858
859
860
861 /**
862 * Display movie list
863 *
864 * @since 3.0.1
865 */
866 public function wpstream_present_file_management(){
867 $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_storage_raw_data();
868
869 $to_return='';
870 if(is_array($video_list_raw)){
871 foreach ($video_list_raw as $key =>$video){
872 $to_return.='<div class="wpstream_video_wrapper">';
873
874 $to_return.='<div class="wpstream_video_title">';
875 $to_return.='<div class="wpstream_video_notice"></div></div>';
876 $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video['video_name_storage'].'</span></div>';
877 $to_return.=' <div class="wpstream_delete_media" ';
878 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video['video_name_storage'].'?\')" data-filename="'.$video['video_name_storage'].'">'.esc_html__('delete file','wpstream').'</div>';
879 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video['video_name_storage'].'">'.esc_html__('get download link','wpstream').'</div>';
880 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
881
882 $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product').'&new_video_name='. rawurlencode($video['video_name_storage']);
883 $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video['video_name_storage']);
884
885
886
887 $to_return .='<a class="create_new_free_video" href="'.esc_url($add_free_video_url).'">'.esc_html__('Create new free VOD from this video').'</a>';
888 $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create pay-per-view VOD from this video').'</a>';
889
890 $to_return.='</div>';
891
892 }
893 } else {
894 $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
895 }
896 return $to_return;
897 }
898
899
900
901
902
903 /**
904 * save meta options
905 *
906 * @since 3.0.1
907 */
908 public function wpstream_free_product_update_post($post_id,$post){
909
910 if(!is_object($post) || !isset($post->post_type)) {
911 return;
912 }
913
914 if($post->post_type!='wpstream_product'){
915 return;
916 }
917
918
919 $allowed_keys=array(
920 'wpstream_product_type',
921 'wpstream_free_video',
922 'wpstream_free_video_external'
923 );
924
925 $allowed_html=array();
926
927 foreach ($_POST as $key => $value) {
928 if( !is_array ($value) ){
929 if (in_array ($key, $allowed_keys)) {
930 $postmeta = wp_kses ( $value,$allowed_html );
931 update_post_meta($post_id, sanitize_key($key), $postmeta );
932 }
933 }
934 }
935 }
936
937
938 /**
939 * save meta options
940 *
941 * @since 3.0.1
942 */
943 public function add_wpstream_product_metaboxes() {
944 add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Live Channel/Video Settings', 'wpestate' ),array($this,'display_meta_options'),'wpstream_product' ,'normal','default');
945 }
946
947
948 /**
949 * make woocomerce virtual products
950 *
951 * @since 3.0.1
952 */
953
954
955 public function wpstream_make_product_virtual($post_id,$post){
956 global $post;
957 if(isset($post->ID)){
958 if ( $post->post_type !== 'product' ) return;
959 $term_list = wp_get_post_terms($post->ID, 'product_type');
960 if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
961 update_post_meta( $post->ID, '_virtual', 'yes' );
962 }
963 }
964 }
965
966
967
968 /**
969 * render meta options
970 *
971 * @since 3.0.1
972 */
973 public function display_meta_options( $post ) {
974 wp_nonce_field( plugin_basename( __FILE__ ), 'estate_agent_noncename' );
975 global $post;
976
977 $is_live = '';
978 $is_video = '';
979 $is_video_external = '';
980 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
981 $is_video = ' selected ';
982 $wpstream_free_video = esc_html( $_GET['new_video_name']);
983 }else{
984 $wpstream_product_type = esc_html(get_post_meta($post->ID, 'wpstream_product_type', true));
985 $wpstream_free_video = esc_html(get_post_meta($post->ID, 'wpstream_free_video', true));
986
987 if($wpstream_product_type==1){
988 $is_live = ' selected ';
989 }
990
991 if($wpstream_product_type==2){
992 $is_video = ' selected ';
993 }
994
995 if($wpstream_product_type==3){
996 $is_video_external = ' selected ';
997 }
998 }
999
1000 print'
1001 <p class="meta-options">
1002 <label for="wpstream_product_type">'.__('Media Type:','wpstream').' </label><br />
1003 <select id="wpstream_product_type" name="wpstream_product_type">
1004 <option value="1" '.$is_live.'>'.__('Free Live Channel - encrypted streaming & copy protection','wpstream').'</option>
1005 <option value="2" '.$is_video.'>'.__('Free Video - encrypted streaming & copy protection','wpstream').'</option>
1006 <option value="3" '.$is_video_external.'>'.__('Free Video - unprotected','wpstream').'</option>
1007 </select>
1008 </p>
1009 ';
1010
1011
1012
1013 print '
1014 <p class="meta-options video_free">
1015 <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
1016 <select id="wpstream_free_video" name="wpstream_free_video">';
1017 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
1018
1019 if(is_array($video_list)){
1020 foreach ($video_list as $key=>$value){
1021 print '<option value="'.$key.'"';
1022 if($wpstream_free_video === $key){
1023 print ' selected ';
1024 }
1025 print '>'.$value.'</option>';
1026 }
1027 }
1028 print'
1029 </select>
1030 </p>
1031 ';
1032
1033 $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
1034 print '<p class="meta-options1 video_free_external">
1035 <label for="wpstream_free_video_external">'.__('Choose video:','wpstream').' </label><br />
1036
1037 <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
1038 <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />
1039
1040 <p>'.esc_html__('You can choose a video from your computer or use the url from external source or use the url of a YouTube Video or use the url from a Vimeo video.','wpstream').'</p>
1041
1042 </p> ';
1043 }
1044
1045
1046
1047
1048
1049
1050
1051 /**
1052 * Add new product types to Woocommerce select product type
1053 *
1054 * @since 3.0.1
1055 */
1056 public function wpstream_add_products( $types ){
1057 $types[ 'live_stream' ] = __( 'Live Channel','wpestream' );
1058 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
1059
1060 return $types;
1061 }
1062
1063
1064
1065 /**
1066 * Js action to do when user pick live stream or video on demand
1067 *
1068 * @since 3.0.1
1069 */
1070
1071 public function wpstream_products_custom_js() {
1072 if ( 'product' != get_post_type() ) :
1073 return;
1074 endif;
1075
1076 ?>
1077 <script type='text/javascript'>
1078 jQuery( document ).ready( function() {
1079 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
1080 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
1081 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
1082 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
1083 jQuery('._sold_individually_field').show();
1084
1085 var selected = jQuery('#product-type').val();
1086 });
1087 </script>
1088 <?php
1089
1090 }
1091
1092
1093 /**
1094 * Add custom classes to the product types
1095 *
1096 * @since 3.0.1
1097 */
1098
1099 public function wpstream_hide_attributes_data_panel( $tabs) {
1100
1101 $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand';
1102 $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1103 // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1104
1105 return $tabs;
1106 }
1107
1108
1109 /**
1110 * Add custom fields to custom product types
1111 *
1112 * @since 3.0.1
1113 */
1114
1115 public function wpstream_add_custom_general_fields() {
1116
1117 global $woocommerce, $post;
1118 if(function_exists('wcs_user_has_subscription')){
1119 echo '<div class="options_group show_if_subscription">';
1120 woocommerce_wp_select(
1121 array(
1122 'id' => '_subscript_live_event',
1123 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ),
1124 'options' => array("yes"=>"yes","no"=>"no")
1125 )
1126 );
1127 echo '</div>';
1128 }
1129
1130 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
1131 echo '<div class="options_group show_if_video_on_demand">';
1132 $selected='';
1133 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
1134 $selected=esc_html($_GET['new_video_name']);
1135 }
1136 if($selected==''){
1137 $selected= get_post_meta($post->ID,'_movie_url',true);
1138 }
1139
1140 woocommerce_wp_select(
1141 array(
1142 'id' => '_movie_url',
1143 'label' => __( 'Select the video file.', 'woocommerce' ),
1144 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
1145 'selected'=> true,
1146 'value' => $selected
1147 )
1148 );
1149
1150 echo '</div>';
1151 }
1152
1153 /**
1154 * Save custom fields
1155 *
1156 * @since 3.0.1
1157 */
1158
1159 public function wpstream_add_custom_general_fields_save( $post_id ){
1160
1161 $permited_values = array(
1162 '_movie_url',
1163 '_subscript_live_event'
1164 );
1165 $allowed_html=array();
1166 foreach($_POST as $key=>$value){
1167 update_post_meta( $post_id, 'event_passed', 0 );
1168 if( in_array($key, $permited_values) ){
1169 if( !empty( $_POST[$key] ) ){
1170 update_post_meta( $post_id, wp_kses ($key,$allowed_html), wp_kses ( $_POST[$key],$allowed_html) );
1171 }
1172 }
1173 }
1174
1175 }
1176
1177 /**
1178 * Add to cart redirect
1179 *
1180 * @since 3.0.1
1181 */
1182
1183 public function wpstream_add_to_cart() {
1184 wc_get_template( 'single-product/add-to-cart/simple.php' );
1185 }
1186
1187
1188 /**
1189 * Replace add to cart button
1190 *
1191 * @since 3.0.1
1192 */
1193 public function replacing_add_to_cart_button( $button, $product ) {
1194 global $product;
1195 $product_type = $product->get_type();
1196
1197 if($product_type==='live_stream' || $product_type=='video_on_demand'){
1198 return $button = '<a class="button" href="'.get_site_url().'/shop/?add-to-cart=' .$product->get_id(). '&quantity=1">' . __( 'Add to Cart', 'woocommerce' ) . '</a>';
1199 }else{
1200 return $button;
1201 }
1202 }
1203
1204
1205 /**
1206 * Admin notices
1207 *
1208 * @since 3.0.1
1209 */
1210 public function wpstream_admin_notice() {
1211 global $pagenow;
1212 global $typenow;
1213
1214
1215 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
1216 print '<div class="notice notice-error is-dismissible">
1217 <p>'.__( 'WpStream Pay Per View / Subscription mode works only with WooCommerce - If you want to charge money for your live events or videos you need to activate WooCommerce plugin', 'wpestate' ).'</p>
1218 </div>';
1219 }
1220 if( !in_array ('curl', get_loaded_extensions())) {
1221 print '<div class="notice notice-error is-dismissible">
1222 <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.', 'wpestate' ).'</p>
1223 </div>';
1224 }
1225
1226
1227 $wpestate_notices = get_option('wp_stream_notices');
1228
1229 if( !is_array($wpestate_notices) ||
1230 !isset($wpestate_notices['wpstream_update_1021']) ||
1231 ( isset($wpestate_notices['wpstream_update_1021']) && $wpestate_notices['wpstream_update_1021']!='yes') ){
1232
1233 print '<div id ="setting-error-wprentals-cache" data-notice-type="wpstream_update_1021" data-dismissible="disable-done-notice-forever" class="wpestate_notices updated settings-error notice is-dismissible">
1234 <p>'.esc_html__( 'New! We just released WpStream WordPress Theme - a turn key solution for video delivery & live streaming. This theme is built around WpStream plugin and is the perfect solution for video streaming or rentals platform. ','wpstream').'<a href="https://wpstream.net/wpstream-theme-a-live-streaming-wordpress-theme" target="_blank">'.esc_html__('Download Theme','wpstream').'</a></p>
1235 </div>';
1236 }
1237
1238
1239
1240
1241
1242 $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
1243 print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
1244
1245 }
1246
1247 /**
1248 * Admin notices
1249 *
1250 * @since 3.0.1
1251 */
1252 public function wpstream_update_cache_notice(){
1253
1254 //check_ajax_referer( 'wpstream_notice_nonce', 'security' );
1255
1256 $notice_type = esc_html($_POST['notice_type']);
1257 $notices = get_option('wp_stream_notices');
1258
1259 if(! is_array($notices) ){
1260 $notices=array();
1261 }
1262
1263 $notices[$notice_type]='yes';
1264
1265 update_option('wp_stream_notices',$notices);
1266 die();
1267 }
1268
1269
1270
1271 /**
1272 * Activate metaboxes for Streaming controls on sidebar
1273 *
1274 * @since 3.0.1
1275 */
1276 public function wpstream_startstreaming_sidebar_meta() {
1277 global $post;
1278 $term_list = wp_get_post_terms($post->ID, 'product_type');
1279 if( get_post_meta($post->ID, 'wpstream_product_type', true)==1 ){
1280 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
1281 }
1282
1283 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
1284
1285
1286 if(!is_wp_error( $term_list )){
1287 if( isset($term_list[0]->name) ){
1288 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
1289 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'product', 'side', 'high');
1290 }
1291 }
1292 }
1293
1294 }
1295
1296 /**
1297 * Show Streaming controls on sidebar
1298 *
1299 * @since 3.0.1
1300 */
1301 public function wpstream_start_stream_meta(){
1302 global $live_event_for_user;
1303 global $post;
1304
1305 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
1306 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
1307 $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user();
1308 $this->wpstream_live_stream_unit($post->ID);
1309
1310 }
1311 }