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

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