PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.5.11.6
WpStream – Live Streaming, Video on Demand, Pay Per View v4.5.11.6
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 / public / class-wpstream-public.php

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

1,631 lines 66.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The public-facing functionality of the plugin.
5 *
6 * @link http://wpstream.net
7 * @since 3.0.1
8 *
9 * @package Wpstream
10 * @subpackage Wpstream/public
11 */
12
13 /**
14 * The public-facing functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the public-facing stylesheet and JavaScript.
18 *
19 * @package Wpstream
20 * @subpackage Wpstream/public
21 * @author wpstream <office@wpstream.net>
22 */
23 class Wpstream_Public {
24
25
26
27 /**
28 * Store plugin main class to allow public access.
29 *
30 * @since 20180622
31 * @var object The main class.
32 */
33 public $main;
34 /**
35 * The ID of this plugin.
36 *
37 * @since 3.0.1
38 * @access private
39 * @var string $plugin_name The ID of this plugin.
40 */
41 private $plugin_name;
42
43 /**
44 * The version of this plugin.
45 *
46 * @since 3.0.1
47 * @access private
48 * @var string $version The current version of this plugin.
49 */
50 private $version;
51
52 /**
53 * Initialize the class and set its properties.
54 *
55 * @since 3.0.1
56 * @param string $plugin_name The name of the plugin.
57 * @param string $version The version of this plugin.
58 */
59 public function __construct( $plugin_name, $version ,$plugin_main) {
60 $this->main = $plugin_main;
61 $this->plugin_name = $plugin_name;
62 $this->version = $version;
63
64 }
65
66 /**
67 * Register the stylesheets for the public-facing side of the site.
68 *
69 * @since 3.0.1
70 */
71 public function enqueue_styles() {
72
73 wp_enqueue_style('wpstream-style', plugin_dir_url( __FILE__ ) .'/css/wpstream_style.css',array(), WPSTREAM_PLUGIN_VERSION, 'all' );
74 wp_enqueue_style('video-js.min', plugin_dir_url( __FILE__ ).'/css/video-js.min.css', array(), WPSTREAM_PLUGIN_VERSION, 'all');
75 wp_enqueue_style('videojs-wpstream-player', plugin_dir_url( __FILE__ ).'/css/videojs-wpstream.css', array(), WPSTREAM_PLUGIN_VERSION, 'all');
76 wp_enqueue_style('wpstream-integrations', plugin_dir_url( __DIR__ ) .'integrations/css/integrations.css',array(), WPSTREAM_PLUGIN_VERSION, 'all' );
77 }
78
79 /**
80 * Register the JavaScript for the public-facing side of the site.
81 *
82 * @since 3.0.1
83 */
84 public function enqueue_scripts() {
85
86 wp_enqueue_script('jquery');
87 wp_enqueue_script('video.min', 'https://vjs.zencdn.net/8.5.2/video.min.js', WPSTREAM_PLUGIN_VERSION, true);
88 wp_enqueue_script('youtube.min', plugin_dir_url( __FILE__ ).'js/youtube.min.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, true);
89 //wp_enqueue_script('videojs-vimeo.min', plugin_dir_url( __FILE__ ).'js/videojs-vimeo.min.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, true);
90 wp_enqueue_script('wpstream-player', plugin_dir_url( __FILE__ ).'js/wpstream-player.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, true);
91 wp_enqueue_script('ovenplayer.min', 'https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js', WPSTREAM_PLUGIN_VERSION, true);
92 wp_enqueue_script('hls.min', 'https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js', WPSTREAM_PLUGIN_VERSION, true);
93
94
95 wp_localize_script('wpstream-player', 'wpstream_player_vars',
96 array(
97 'admin_url' => get_admin_url(),
98 'chat_not_connected' => esc_html__('Inactive Channel - Chat is disabled.','wpstream'),
99 'server_up' => esc_html__('The live stream is paused and may resume shortly.','wpstream'),
100 'wpstream_player_state_stopped_msg' => esc_html__(get_option('wpstream_you_are_not_live','We are not live at this moment'),'wpstream'),
101 'wpstream_player_state_init_msg' => esc_html__('The live stream has not yet started','wpstream'),
102 'wpstream_player_state_startup_msg' => esc_html__('The live stream is starting...','wpstream'),
103 'wpstream_player_state_paused_msg' => esc_html__('The live stream is paused','wpstream'),
104 'wpstream_player_state_ended_msg' => esc_html__('The live stream has ended','wpstream'),
105 )
106 );
107
108 wp_enqueue_script( 'jquery-ui-autocomplete' );
109 wp_enqueue_script( "jquery-effects-core");
110
111 wp_register_script( 'sockjs-0.3.min', plugin_dir_url( __FILE__ ) . '/chat_lib/sockjs-0.3.min.js', array('jquery'), true );
112 wp_register_script( 'emojione.min.js',plugin_dir_url( __FILE__ ). '/chat_lib/emojione.min.js', array('jquery'), true );
113
114 wp_register_script( 'jquery.linkify.min.js', plugin_dir_url( __FILE__ ). '/chat_lib/jquery.linkify.min.js', array('jquery'), true );
115 wp_register_script( 'ripples.min.js',plugin_dir_url( __FILE__ ). '/chat_lib/ripples.min.js', array('jquery'), true );
116 wp_register_script( 'material.min.js"', plugin_dir_url( __FILE__ ). '/chat_lib/material.min.js', array('jquery'), true );
117 wp_register_script( 'chat.js', plugin_dir_url( __FILE__ ). '/chat_lib/chat.js', array('jquery'), true );
118
119 wp_localize_script('chat.js', 'chat-js-vars',
120 array(
121 'we_are_not_live' => esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')),
122 ));
123
124 wp_register_style( 'chat.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/chat.css', array(), '1.0', 'all');
125 wp_register_style( 'ripples.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/ripples.css', array(), '1.0', 'all');
126 wp_register_style( 'emojione.min.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/emojione.min.css', array(), '1.0', 'all');
127
128
129
130 wp_enqueue_script('wpstream-start-streaming', plugin_dir_url( __FILE__ ) .'js/start_streaming.js',array(), WPSTREAM_PLUGIN_VERSION, true);
131 wp_localize_script('wpstream-start-streaming', 'wpstream_start_streaming_vars',
132 array(
133 'admin_url' => get_admin_url(),
134 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
135 'download_mess' => esc_html__('Click to download!','wpstream'),
136 'uploading' => esc_html__('We are uploading your file.Do not close this window!','wpstream'),
137 'upload_complete2' => esc_html__('Upload Complete! You can upload another file!','wpstream'),
138 'not_accepted' => esc_html__('The file is not an accepted video format','wpstream'),
139 'upload_complete' => esc_html__('Upload Complete!','wpstream'),
140 'upload_failed' => esc_html__('Upload Failed!','wpstream'),
141 'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'),
142 'no_band' => esc_html__('Not enough streaming data.','wpsteam'),
143 'no_band_no_store' => esc_html__('Not enough streaming data or storage.','wpsteam'),
144
145 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'),
146 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'),
147 'start_streaming' => esc_html__('TURN ON','wpstream'),
148 'stop_streaming' => esc_html__('TURN OFF','wpstream'),
149 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'),
150 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'),
151 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'),
152 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'),
153 'error1' => esc_html__('You don\'t have enough data to start a new event!','wpstream'),
154 'failed_event_creation' => esc_html__('Failed to start the channel. Please try again in a few minutes.','wpstream'),
155 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'),
156 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'),
157 'channel_on' => esc_html__('Channel is ON','wpstream'),
158 'channel_off' => esc_html__('Channel is OFF','wpstream'),
159 'turn_off_confirm' => esc_html__('Are you sure? '.PHP_EOL.' Channels turn OFF automatically after 1 hour of inactivity (no active broadcast). Manual TURN OFF is only useful if you require to change the channel settings.','wpstream'),
160 'turn_off_confirm' => esc_html__('ARE YOU SURE you\'d like to TURN OFF the channel now? '.PHP_EOL.PHP_EOL.'Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).'.PHP_EOL.PHP_EOL.'Manual TURN OFF is only useful if you require to change the channel settings immediately.'.PHP_EOL.PHP_EOL.'Statistics may be unavailable or incomplete for up to an hour.'.PHP_EOL.PHP_EOL.'If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.','wpstream')
161
162 ));
163
164
165 $integrations_array=array(
166 'admin_url' => get_admin_url(),
167 );
168 if (class_exists('BuddyPress')) {
169 $integrations_array['is_buddyboss']='yes';
170 }
171
172 wp_enqueue_script('wpstream-integrations', plugin_dir_url( __DIR__ ) .'/integrations/js/integrations.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
173 wp_localize_script('wpstream-integrations', 'wpstream_integrations_vars', $integrations_array );
174
175
176 wp_enqueue_style( 'wpstream_front_style', plugin_dir_url( __DIR__ ) . 'admin/css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
177
178 }
179
180
181
182 /**
183 * add custom end points for woocomerce
184 *
185 * @since 3.0.1
186 * @return nothing
187 */
188 public function wpstream_my_custom_endpoints() {
189 add_rewrite_endpoint( 'video-list', EP_ROOT | EP_PAGES );
190 add_rewrite_endpoint( 'event-list', EP_ROOT | EP_PAGES );
191 }
192
193 /**
194 * add custom query vars
195 *
196 * @since 3.0.1
197 * @return nothing
198 */
199 public function wpstream_my_custom_query_vars( $vars ) {
200 $vars[] = 'video-list';
201 $vars[] = 'event-list';
202 return $vars;
203 }
204
205
206 /**
207 * Hust flush rewrite rules
208 *
209 * @since 3.0.1
210 *
211 */
212 public function wpstream_custom_flush_rewrite_rules() {
213 flush_rewrite_rules();
214 }
215
216
217 /**
218 * Add new sections in woocomerce account
219 *
220 * @since 3.0.1
221 */
222 public function wpstream_custom_my_account_menu_items( $items ) {
223 if(function_exists('wpstream_is_global_subscription') && wpstream_is_global_subscription()){
224 $items = array(
225 'dashboard' => __( 'Dashboard', 'wpstream' ),
226 'orders' => __( 'Orders', 'wpstream' ),
227 'edit-address' => __( 'Addresses', 'wpstream' ),
228 'edit-account' => __( 'Edit Account', 'wpstream' ),
229 'customer-logout' => __( 'Logout', 'wpstream' ),
230 );
231 }else{
232 $items = array(
233 'dashboard' => __( 'Dashboard', 'wpstream' ),
234 'orders' => __( 'Orders', 'wpstream' ),
235 'edit-address' => __( 'Addresses', 'wpstream' ),
236 'edit-account' => __( 'Edit Account', 'wpstream' ),
237 'event-list' => __( 'My Live Streams', 'wpstream' ),
238 'video-list' => __( 'My Videos', 'wpstream' ),
239 'customer-logout' => __( 'Logout', 'wpstream' ),
240 );
241 }
242 return $items;
243 }
244
245
246
247 /**
248 * Add new endpoint
249 *
250 * @since 3.0.1
251 */
252 public function wpstream_custom_endpoint_content_event_list() {
253 include plugin_dir_path( __DIR__ ).'woocommerce/myaccount/event_list.php';
254 }
255
256
257 /**
258 * Add new endpoint
259 *
260 * @since 3.0.1
261 */
262 public function wpstream_custom_endpoint_video_list() {
263 include plugin_dir_path( __DIR__ ).'woocommerce/myaccount/video_list.php';
264 }
265
266
267
268
269
270
271 /**
272 * register shortcodes
273 *
274 * @since 3.0.1
275 *
276 */
277 public function wpstream_shortcodes(){
278 add_shortcode('wpstream_player', array($this,'wpstream_insert_player_inpage_local') );
279 // add_shortcode('wpstream_list_products', array($this,'wpstream_list_products_function') );
280 add_shortcode('wpstream_chat', array($this,'wpstream_chat_function') );
281 add_shortcode('wpstream_player_low_latency', array($this,'wpstream_insert_player_inpage_low_latency') );
282 add_shortcode('wpstream_go_live', array($this,'wpstream_start_streaming_shortocde') );
283
284
285 add_shortcode('wpstream_list_media_channels', array($this,'wpstream_media_list_bakery_bypass') );
286 add_shortcode('wpstream_list_media_vod', array($this,'wpstream_media_list_bakery_vod_bypass') );
287 }
288
289
290 /**
291 * register shortcodes
292 *
293 * @since 3.0.1
294 *
295 */
296
297 public function wpstream_bakery_shortcodes(){
298 // register shortcodes for visual composer
299 if( function_exists('vc_map') ):
300
301
302 vc_map(
303 array(
304 "name" => esc_html__( "WpStream Start Streaming Button","wpestate"),
305 "base" => "wpstream_go_live",
306 "class" => "",
307 "category" => esc_html__( 'WpStream','wpstream'),
308 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
309 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
310 'weight'=>100,
311 'icon' =>'',
312 'description'=>esc_html__( 'Insert WpStream Start Streaming Button','wpstream'),
313 "params" => array(
314 array(
315 "type" => "textfield",
316 "holder" => "div",
317 "class" => "",
318 "heading" => esc_html__( "Product/Free Product Id","wpestate"),
319 "param_name" => "id",
320 "value" => "",
321 "description" => esc_html__( "If you leave this option blank we will stream on the first free/paid channel for this user","wpestate")
322 ),
323
324
325 )
326 )
327 );
328
329
330
331 vc_map(
332 array(
333 "name" => esc_html__( "WpStream Chat - Beta Version","wpestate"),
334 "base" => "wpstream_chat",
335 "class" => "",
336 "category" => esc_html__( 'WpStream','wpstream'),
337 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
338 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
339 'weight'=>100,
340 'icon' =>'',
341 'description'=>esc_html__( 'Insert WpStream Chat','wpstream'),
342 "params" => array(
343 array(
344 "type" => "textfield",
345 "holder" => "div",
346 "class" => "",
347 "heading" => esc_html__( "Live Stream Id","wpestate"),
348 "param_name" => "id",
349 "value" => "0",
350 "description" => esc_html__( "Add here the live stream id","wpestate")
351 ),
352
353 )
354 )
355 );
356
357
358
359 vc_map(
360 array(
361 "name" => esc_html__( "WpStream Player","wpestate"),
362 "base" => "wpstream_player",
363 "class" => "",
364 "category" => esc_html__( 'WpStream','wpstream'),
365 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
366 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
367 'weight'=>100,
368 'icon' =>'',
369 'description'=>esc_html__( 'Insert WpStream Player','wpstream'),
370 "params" => array(
371 array(
372 "type" => "textfield",
373 "holder" => "div",
374 "class" => "",
375 "heading" => esc_html__( "Product/Free Product Id","wpestate"),
376 "param_name" => "id",
377 "value" => "0",
378 "description" => esc_html__( "Add here the live stream id or the video id","wpestate")
379 ),
380 array(
381 "type" => "textfield",
382 "holder" => "div",
383 "class" => "",
384 "heading" => esc_html__( "User Id","wpestate"),
385 "param_name" => "user_id",
386 "value" => "",
387 "description" => esc_html__( "We will use the first channel of this user id(product id will be ignored.).","wpestate")
388 ),
389
390 )
391 )
392 );
393
394
395 vc_map(
396 array(
397 "name" => esc_html__( "WpStream Player - Low Latency - Private Beta / Requires Approval","wpestate"),
398 "base" => "wpstream_player_low_latency",
399 "class" => "",
400 "category" => esc_html__( 'WpStream','wpstream'),
401 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
402 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
403 'weight'=>100,
404 'icon' =>'',
405 'description'=>esc_html__( 'Insert WpStream Player','wpstream'),
406 "params" => array(
407 array(
408 "type" => "textfield",
409 "holder" => "div",
410 "class" => "",
411 "heading" => esc_html__( "Product/Free Product Id","wpestate"),
412 "param_name" => "id",
413 "value" => "0",
414 "description" => esc_html__( "Add here the live stream id or the video id","wpestate")
415 ),
416 array(
417 "type" => "textfield",
418 "holder" => "div",
419 "class" => "",
420 "heading" => esc_html__( "User Id","wpestate"),
421 "param_name" => "user_id",
422 "value" => "",
423 "description" => esc_html__( "We will use the first channel of this user id(product id will be ignored.).","wpestate")
424 ),
425
426 )
427 )
428 );
429
430
431 $product_type=array(
432 '0' => __('Both','wpstream'),
433 '1' => __('Live Event','wpstream'),
434 '2' => __('Video on demand','wpstream')
435 );
436
437 vc_map(
438 array(
439 "name" => esc_html__( "WpStream Products List","wpestate"),
440 "base" => "wpstream_list_products",
441 "class" => "",
442 "category" => esc_html__( 'WpStream','wpstream'),
443 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
444 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
445 'weight'=>100,
446 'icon' =>'',
447 'description'=>esc_html__( ' List wpstream products','wpstream'),
448 "params" => array(
449
450 array(
451 "type" => "dropdown",
452 "holder" => "div",
453 "class" => "",
454 "heading" => esc_html__( "Media type","wpestate"),
455 "param_name" => "product_type",
456 "value" => $product_type,
457 "description" => esc_html__( "What type of media(free/paid) ","wpestate")
458 ),
459
460 array(
461 "type" => "textfield",
462 "holder" => "div",
463 "class" => "",
464 "heading" => esc_html__( "Media number","wpestate"),
465 "param_name" => "media_number",
466 "value" => "",
467 "description" => esc_html__( "No of media ","wpestate")
468 ),
469
470
471
472 )
473 )
474 );
475
476
477 $free_paid_type=array(
478
479 0 => esc_html__('Free','wpstream'),
480 1 => esc_html__('Paid','wpstream')
481 );
482
483 $live_settings=array(
484
485 'no'=>esc_html__('no','wpstream'),
486 'yes'=>esc_html__('yes','wpstream'),
487 );
488
489 $order_by_id=array(
490
491 0=>esc_html('By date - ASC','wpstream'),
492 1=>esc_html('By date - DESC','wpstream'),
493 2=>esc_html('By title - ASC','wpstream'),
494 3=>esc_html('By title - DESC','wpstream'),
495 );
496
497 vc_map(
498 array(
499 "name" => esc_html__( "WpStream Channel List","wpestate"),
500 "base" => "wpstream_list_media_channels",
501 "class" => "",
502 "category" => esc_html__( 'WpStream','wpstream'),
503 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
504 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
505 'weight'=>100,
506 'icon' =>'',
507 'description'=>esc_html__( ' List wpstream channels','wpstream'),
508 "params" => array(
509
510
511
512 array(
513 "type" => "dropdown",
514 "holder" => "div",
515 "class" => "",
516 "heading" => esc_html__( "Show Free or Paid Media ?","wpestate"),
517 "param_name" => "product_type_free_paid",
518 "value" => $free_paid_type,
519 "description" => esc_html__( "What type of media(free/paid) ","wpestate")
520 ),
521
522 array(
523 "type" => "dropdown",
524 "holder" => "div",
525 "class" => "",
526 "heading" => esc_html__( "Only show active channels","wpestate"),
527 "param_name" => "product_show_live",
528 "value" => $live_settings,
529 "description" => esc_html__( "Only show channels that are live streaming right now.","wpestate")
530 ),
531 array(
532 "type" => "textfield",
533 "holder" => "div",
534 "class" => "",
535 "heading" => esc_html__( "Number of Items per Page","wpestate"),
536 "param_name" => "media_number",
537 "value" => "3",
538 "description" => esc_html__( "How many items will be displayed per page","wpestate")
539 ),
540
541 array(
542 "type" => "textfield",
543 "holder" => "div",
544 "class" => "",
545 "heading" => esc_html__( "Link Label for free items","wpestate"),
546 "param_name" => "free_label",
547 "value" => esc_html__('Watch now!','wpstream'),
548 "description" => esc_html__( "Link Label for free items'","wpestate")
549 ),
550
551 array(
552 "type" => "dropdown",
553 "holder" => "div",
554 "class" => "",
555 "heading" => esc_html__( "Order by","wpestate"),
556 "param_name" => "order_by",
557 "value" => $order_by_id,
558 "description" => esc_html__( "Order type","wpestate")
559 ),
560
561
562 )
563 )
564 );
565
566
567 vc_map(
568 array(
569 "name" => esc_html__( "WpStream VOD List","wpestate"),
570 "base" => "wpstream_list_media_vod",
571 "class" => "",
572 "category" => esc_html__( 'WpStream','wpstream'),
573 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
574 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
575 'weight'=>100,
576 'icon' =>'',
577 'description'=>esc_html__( ' List wpstream video on demand','wpstream'),
578 "params" => array(
579
580
581
582 array(
583 "type" => "dropdown",
584 "holder" => "div",
585 "class" => "",
586 "heading" => esc_html__( "Show Free or Paid Media ?","wpestate"),
587 "param_name" => "product_type_free_paid",
588 "value" => $free_paid_type,
589 "description" => esc_html__( "What type of media(free/paid) ","wpestate")
590 ),
591
592
593 array(
594 "type" => "textfield",
595 "holder" => "div",
596 "class" => "",
597 "heading" => esc_html__( "Number of Items per Page","wpestate"),
598 "param_name" => "media_number",
599 "value" => "3",
600 "description" => esc_html__( "How many items will be displayed per page","wpestate")
601 ),
602
603 array(
604 "type" => "textfield",
605 "holder" => "div",
606 "class" => "",
607 "heading" => esc_html__( "Link Label for free items","wpestate"),
608 "param_name" => "free_label",
609 "value" => esc_html__('Watch now!','wpstream'),
610 "description" => esc_html__( "Link Label for free items'","wpestate")
611 ),
612
613 array(
614 "type" => "dropdown",
615 "holder" => "div",
616 "class" => "",
617 "heading" => esc_html__( "Order by","wpestate"),
618 "param_name" => "order_by",
619 "value" => $order_by_id,
620 "description" => esc_html__( "Order type","wpestate")
621 ),
622
623
624 )
625 )
626 );
627
628
629 endif;
630
631
632 // add shorcotes to editor interface
633 if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
634 return;
635 }
636
637 if (get_user_option('rich_editing') == 'true') {
638 add_filter('mce_external_plugins', array( $this,'wpstream_add_plugin') );
639 add_filter('mce_buttons_2', array($this,'wpstream_register_button') );
640 }
641 }
642
643 /**
644 * list channels - shortcode function
645 *
646 * @since 3.0.1
647 *
648 */
649
650 public function wpstream_media_list_bakery_bypass($attributes){
651
652
653
654 $attributes = shortcode_atts(
655 array(
656 'media_number' => 3,
657 'product_type_free_paid' => '0',
658 'product_show_live' => 'no',
659 'free_label' => '',
660 'order_by' => '0'
661 ), $attributes) ;
662
663 $attributes['product_type']=1;
664
665 if( $attributes['product_type_free_paid']=='Paid'){
666 $attributes['product_type_free_paid']=1;
667 }
668 if( $attributes['product_type_free_paid']=='Free'){
669 $attributes['product_type_free_paid']=0;
670 }
671
672 if($attributes['order_by']==0){
673 $order_by_id=array(
674
675 0=>esc_html('By date - ASC','wpstream'),
676 1=>esc_html('By date - DESC','wpstream'),
677 2=>esc_html('By title - ASC','wpstream'),
678 3=>esc_html('By title - DESC','wpstream'),
679 );
680
681 $attributes['order_by']= array_search($attributes['order_by'], $order_by_id);
682 }
683 global $wpstream_plugin;
684 return $wpstream_plugin->wpstream_media_list_elementor_function( $attributes );
685
686 }
687
688 /**
689 * list vod - shortcode function
690 *
691 * @since 3.0.1
692 *
693 */
694
695 public function wpstream_media_list_bakery_vod_bypass($attributes){
696
697
698
699 $attributes = shortcode_atts(
700 array(
701 'media_number' => 3,
702 'product_type_free_paid' => '0',
703 'product_show_live' => 'no',
704 'free_label' => '',
705 'order_by' => '0'
706 ), $attributes) ;
707
708 $attributes['product_type']=2;
709
710 if( $attributes['product_type_free_paid']=='Paid'){
711 $attributes['product_type_free_paid']=1;
712 }
713 if( $attributes['product_type_free_paid']=='Free'){
714 $attributes['product_type_free_paid']=0;
715 }
716
717 if($attributes['order_by']==0){
718 $order_by_id=array(
719
720 0=>esc_html('By date - ASC','wpstream'),
721 1=>esc_html('By date - DESC','wpstream'),
722 2=>esc_html('By title - ASC','wpstream'),
723 3=>esc_html('By title - DESC','wpstream'),
724 );
725
726 $attributes['order_by']= array_search($attributes['order_by'], $order_by_id);
727 }
728 global $wpstream_plugin;
729 return $wpstream_plugin->wpstream_media_list_elementor_function( $attributes );
730
731 }
732
733 /**
734 * shortocode player
735 *
736 * @since 3.0.1
737 *
738 */
739 public function wpstream_chat_function($attributes, $content = null){
740 $product_id = '';
741 $return_string = '';
742 $attributes = shortcode_atts(
743 array(
744 'id' => 0,
745 ), $attributes) ;
746
747
748 if ( isset($attributes['id']) ){
749 $product_id=$attributes['id'];
750 }
751
752
753 $return_string.= '<div class="wpstream_plugin_chat_wrapper">';
754 ob_start();
755 $this->main->wpstream_player->wpstream_chat_wrapper($product_id);
756 $return_string.= ob_get_contents();
757 ob_end_clean();
758 $return_string.='</div>';
759 $this->main->wpstream_player->wpstream_connect_to_chat($product_id);
760
761 return $return_string;
762 }
763
764
765
766
767 /**
768 * shortocode player
769 *
770 * @since 3.0.1
771 *
772 */
773
774
775 public function wpstream_insert_player_inpage_local($attributes, $content = null){
776 $product_id = '';
777 $return_string = '';
778 $attributes = shortcode_atts(
779 array(
780 'id' => 0,
781 'user_id' => 0,
782 ), $attributes) ;
783
784
785 if ( isset($attributes['id']) ){
786 $product_id = intval( $attributes['id'] );
787 }
788
789 if ( isset($attributes['user_id']) ){
790 $user_id = intval( $attributes['user_id'] );
791 }
792
793 if(intval($product_id)==0 && $user_id!=0 ){
794 $product_id= $this->main->wpstream_player_retrive_first_id($user_id);
795 }
796
797 ob_start();
798 $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
799 $return_string= ob_get_contents();
800 ob_end_clean();
801
802 return $return_string;
803 }
804
805
806 /**
807 * shortocode function for start streaming
808 *
809 * @since 3.7
810 *
811 */
812
813
814 public function wpstream_start_streaming_shortocde($attributes, $content = null){
815 $product_id = '';
816 $return_string = '';
817
818 $attributes = shortcode_atts(
819 array(
820 'id' => 0,
821 ), $attributes) ;
822
823
824 if ( isset($attributes['id']) ){
825 $product_id=intval($attributes['id']);
826 }
827
828
829 ob_start();
830 global $wpstream_plugin;
831 $wpstream_plugin->wpstream_live_stream_unit_wrapper( $product_id,'front' );
832 $return_string= ob_get_contents();
833 ob_end_clean();
834
835 return $return_string;
836 }
837
838
839
840 /**
841 * shortocode player low latency
842 *
843 * @since 3.0.1
844 *
845 */
846
847
848 public function wpstream_insert_player_inpage_low_latency($attributes, $content = null){
849 $product_id = '';
850 $return_string = '';
851 $attributes = shortcode_atts(
852 array(
853 'id' => 0,
854 'user_id' => 0,
855 ), $attributes) ;
856
857
858 if ( isset($attributes['id']) ){
859 $product_id=$attributes['id'];
860 }
861
862
863 if ( isset($attributes['user_id']) ){
864 $user_id = intval( $attributes['user_id'] );
865 }
866
867
868 if(intval($product_id)==0 && $user_id!=0){
869 $product_id= $this->main->wpstream_player_retrive_first_id($user_id);
870 }
871
872 ob_start();
873 $this->main->wpstream_player->wpstream_video_player_shortcode_low_latency($product_id);
874 $return_string= ob_get_contents();
875 ob_end_clean();
876
877 return $return_string;
878 }
879
880
881
882 /**
883 * list products - shortcode function
884 *
885 * @since 3.0.1
886 *
887 */
888
889 public function wpstream_list_products_function($atts, $content=null){
890
891 $media_number = "";
892 $product_type = "";
893 $attributes = shortcode_atts(
894 array(
895 'media_number' => '4',
896 'product_type' => __('Free Live Channel','wpstream'),
897
898 ), $atts);
899
900 if ( isset($attributes['media_number']) ){
901 $media_number=$attributes['media_number'];
902 }
903
904 if ( isset($attributes['product_type']) ){
905 $product_type=$attributes['product_type'];
906 }
907
908 if($product_type== __('Free Live Channel','wpstream') ){
909 $product_type=1;
910 }else{
911 $product_type=2;
912 }
913
914 $return_string="";
915
916
917
918 $args = array(
919 'post_type' => 'wpstream_product',
920 'post_status' => 'publish',
921 'meta_query' =>array(
922 array(
923 'key' => 'wpstream_product_type',
924 'value' => $product_type,
925 'compare' => '=',
926 ),
927 ),
928 'posts_per_page' =>$media_number,
929 'page' => 1
930 );
931
932
933 $media_list= new WP_Query($args);
934
935 if($product_type==1){
936 $see_product= __('See Free Live Chanel','wpstream');
937 }else{
938 $see_product =__('See Free Video','wpstream');
939 }
940
941
942
943 while($media_list->have_posts()):$media_list->the_post();
944 $return_string.='<div class="wpstream_product_unit">'
945 .'<div class="product_image" style="background-image:url('.wp_get_attachment_thumb_url(get_post_thumbnail_id()).')"></div>'
946 .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>'
947 .'<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>'
948 .'</div>';
949 endwhile;
950
951 wp_reset_postdata();
952 wp_reset_query();
953
954
955 return '<div class="shortcode_list_wrapper">'.$return_string.'</div>';
956
957 }
958
959
960
961 /**
962 * register shortcodes - add buttons in js
963 *
964 * @since 3.0.1
965 *
966 */
967
968 public function wpstream_add_plugin($plugin_array) {
969 $plugin_array['wpstream_player'] = plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
970 $plugin_array['wpstream_list_products'] = plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
971 $plugin_array['wpstream_list_products_channels']= plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
972 return $plugin_array;
973 }
974
975 /**
976 * register shortcodes - add buttons
977 *
978 * @since 3.0.1
979 *
980 */
981 public function wpstream_register_button($buttons) {
982 array_push($buttons, "|", "wpstream_player");
983 array_push($buttons, "|", "wpstream_list_products");
984 array_push($buttons, "|", "wpstream_list_products_channels");
985 return $buttons;
986 }
987
988
989
990 /**
991 * wpstream cors
992 *
993 * @since 3.0.1
994 *
995 */
996
997 public function wpstream_cors_check_and_response(){
998 if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
999 header('Access-Control-Allow-Methods: POST, GET');
1000 header('Access-Control-Allow-Headers: Authorization');
1001 header('Access-Control-Max-Age: 1'); //1728000
1002 header("Content-Length: 0");
1003 header("Content-Type: text/plain charset=UTF-8");
1004 exit(0);
1005 }
1006 }
1007
1008 /**
1009 * set user cookie
1010 *
1011 * @since 3.0.1
1012 *
1013 */
1014
1015 public function wpstream_set_cookies(){
1016 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
1017
1018 if(isset($local_event_options['ses_encrypt']) && intval($local_event_options['ses_encrypt'])==1 ) {
1019
1020
1021 if (session_status() == PHP_SESSION_NONE) {
1022 session_start();
1023 }
1024
1025 if( !isset( $_REQUEST[ 'wpstream_livedrm' ]) && !isset( $_REQUEST[ 'wpstream_voddrm' ]) && !isset( $_REQUEST[ 'keys2' ]) ) {
1026
1027 if( !isset($_SESSION['wpstream_id']) ){
1028
1029 $_SESSION['wpstream_id']= uniqid();
1030 }
1031 }
1032 }
1033 }
1034
1035 /**
1036 * editd 4.0
1037 *
1038 * get key for live stream
1039 *
1040 * @since 3.0.1
1041 *
1042 */
1043
1044
1045 public function wpstream_live_streaming_key(){
1046
1047 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
1048
1049 if( isset( $_REQUEST[ 'wpstream_livedrm' ]) && $_REQUEST[ 'wpstream_livedrm' ]!='' ) {
1050
1051 if(isset($local_event_options['ses_encrypt']) && intval($local_event_options['ses_encrypt'])==1 ) {
1052
1053 if( !isset( $_SESSION['wpstream_id'] ) ){
1054 session_write_close ();die('no session');
1055
1056 }
1057 }
1058
1059
1060 $streamname_received = esc_html($_REQUEST[ 'wpstream_livedrm' ]);
1061 $stream_key_array = explode('-', $streamname_received);
1062
1063 $streamname = $stream_key_array[0];
1064 $current_user = wp_get_current_user();
1065
1066 $event_list_free_posts = get_transient( 'free_event_streamName_'.$streamname ) ;
1067
1068 wp_reset_postdata();
1069 wp_reset_query();
1070
1071
1072 if ( false === $event_list_free_posts ) {
1073
1074 $args_free = array(
1075 'posts_per_page' => -1,
1076 'cache_results' => false,
1077 'update_post_meta_cache' => false,
1078 'update_post_term_cache' => false,
1079 'post_type' => 'wpstream_product',
1080 'post_status' => 'publish',
1081 'meta_query' => array(
1082 array(
1083 'key' => 'stream_name',
1084 'value' => $streamname,
1085 'compare' => '=',
1086 )
1087 ),
1088 'fields'=>'ids',
1089 );
1090
1091 $event_list_free = new WP_Query($args_free);
1092 $event_list_free_posts = $event_list_free->posts;
1093 set_transient( 'free_event_streamName_'.$streamname, $event_list_free->posts ,60);
1094 }
1095
1096 if ( !empty($event_list_free_posts ) ){
1097 ////////////////////////////////////////////////////////////
1098 // when we have a free event
1099 ////////////////////////////////////////////////////////////
1100 $the_id = $event_list_free_posts[0];
1101 $show_id = $the_id;
1102 $get_key = $this->wpstream_get_encryption_key_remonting($show_id,$streamname_received);
1103
1104 $seconds_to_cache = 301;
1105 $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
1106 header("Expires: $ts");
1107 header("Pragma: cache");
1108 header("Cache-Control: max-age=$seconds_to_cache");
1109
1110
1111 print $get_key;
1112 die();
1113
1114
1115 }else{
1116 ////////////////////////////////////////////////////////////
1117 // this is for paid products
1118 ////////////////////////////////////////////////////////////
1119
1120 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
1121
1122 $event_list_paid_posts = get_transient( 'paid_event_streamName_'.$streamname ) ;
1123
1124
1125
1126 if ( false === $event_list_paid_posts ) {
1127 $args = array(
1128 'posts_per_page' => -1,
1129 'post_type' => 'product',
1130 'post_status' => 'publish',
1131 'meta_query' => array(
1132 array(
1133 'key' => 'stream_name',
1134 'value' => $streamname,
1135 'compare' => '=',
1136 ),
1137 ),
1138 'tax_query' => array(
1139 'relation' => 'AND',
1140 array(
1141 'taxonomy' => 'product_type',
1142 'field' => 'slug',
1143 'terms' => array('live_stream','subscription')
1144 )
1145 ),
1146 'fields'=>'ids',
1147 );
1148
1149
1150 $event_list = new WP_Query($args);
1151 $event_list_paid_posts = $event_list->posts;
1152
1153 set_transient( 'paid_event_streamName_'.$streamname, $event_list->posts ,60);
1154 }
1155
1156 if ( !empty($event_list_paid_posts ) ){
1157
1158 $the_id = $event_list_paid_posts[0];
1159 $show_id = $the_id;
1160
1161
1162 $is_valid_subscription=0;
1163 if(class_exists ('WC_Subscription')){
1164 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
1165 }
1166
1167
1168 if(function_exists('wpstream_check_global_subscription_model')){
1169 if( wpstream_check_global_subscription_model() ){
1170 $is_valid_subscription=1;// this is global subscription
1171 }
1172 }
1173
1174
1175 if( $this->main->wpstream_player->wpstream_in_plugin_check_global_subscription_model($show_id) ){
1176 $is_valid_subscription=1;// this is global subscription
1177 }
1178
1179
1180 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $show_id) || $is_valid_subscription==1 ){
1181 $get_key = $this->wpstream_get_encryption_key_remonting($show_id,$streamname_received);
1182
1183 $seconds_to_cache = 302;
1184 $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
1185 header("Expires: $ts");
1186 header("Pragma: cache");
1187 header("Cache-Control: max-age=$seconds_to_cache");
1188
1189 print $get_key;
1190 die();
1191
1192 }else{
1193 exit('live - no ticket ');
1194 }
1195
1196 } else{
1197 exit('live - no event');
1198 }
1199
1200 }else{
1201 exit('live - user not log or anwser');
1202 }
1203
1204 }
1205 exit('no free or paid event');
1206
1207 }else{
1208
1209 return;
1210 }
1211
1212 }
1213
1214
1215
1216
1217 /**
1218 * get remote key for live
1219 *
1220 * @since 3.0.1
1221 *
1222 */
1223
1224 public function wpstream_get_encryption_key_remonting ($show_id,$streamname_received){
1225 $get_key = get_transient( $show_id.'_api20_streamName' );
1226
1227
1228 if ( false === $get_key ) {
1229
1230 $url = get_post_meta($show_id,'hls_key_retrieval_url',true).'/'.$streamname_received;
1231
1232 $get= wp_remote_get( $url );
1233
1234 if(is_array($get)){
1235 $get_key = $get['body'];
1236 }else{
1237 $get_key='';
1238 }
1239
1240 set_transient( $show_id.'_api20_streamName', $get_key, 30 );
1241 }
1242 return $get_key;
1243 }
1244
1245
1246
1247 /**
1248 * get key for 3rdparty
1249 *
1250 * @since 3.0.1
1251 *
1252 */
1253
1254
1255 public function wpstream_live_streaming_key_for_3rdparty(){
1256
1257 if( isset( $_REQUEST[ 'thirdkeys' ]) && $_REQUEST[ 'thirdkeys' ]!='' ) {
1258
1259 $thirdkeys = esc_html($_REQUEST[ 'thirdkeys' ]);
1260
1261 //live_event_carnat2
1262
1263 $args = array(
1264 'post_type' => array('product','wpstream_product'),
1265 'post_status' => 'publish',
1266 'meta_query' =>array(
1267 array(
1268 'key' => 'live_event_carnat2',
1269 'value' => $thirdkeys,
1270 'compare' => '=',
1271 ),
1272 ),
1273
1274
1275 );
1276
1277
1278 $media_list= new WP_Query($args);
1279 if($media_list->have_posts()){
1280 while($media_list->have_posts()):$media_list->the_post();
1281
1282 $media_id = get_the_ID();
1283 $replay_array = array(
1284 // '', // fb will be here
1285 stripslashes( get_post_meta($media_id,'wpstream_youtube_rtmp',true )),
1286 stripslashes( get_post_meta($media_id,'wpstream_twich_rtmp',true) ),
1287 );
1288
1289 $reply_final=array('rtmp_urls'=>$replay_array);
1290 header('Content-Type: application/json;charset=utf-8');
1291 print json_encode($reply_final,JSON_UNESCAPED_SLASHES);
1292 die();
1293
1294
1295 endwhile;
1296 }else{
1297 print'{}';
1298 die('');
1299 }
1300
1301 }
1302
1303 }
1304
1305
1306
1307 /**
1308 * get key for vod
1309 *
1310 * @since 3.0.1
1311 *
1312 */
1313 public function wpstream_live_streaming_key_vod(){
1314 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
1315 $current_user = wp_get_current_user();
1316
1317
1318
1319 if( isset( $_REQUEST[ 'wpstream_voddrm' ]) && $_REQUEST[ 'wpstream_voddrm' ]!='' ) {
1320
1321 if(isset($local_event_options['ses_encrypt']) && intval($local_event_options['ses_encrypt'])==1 ) {
1322
1323 if( !isset( $_SESSION['wpstream_id'] ) ){
1324 unset($_SESSION['wpstream_id']);
1325 session_write_close ();session_register_shutdown();
1326 die('no session');
1327 }
1328 }
1329
1330 $hlsDecryptionKeyIndex = esc_html($_REQUEST[ 'wpstream_voddrm' ]);
1331 $vod_list_free_posts = get_transient( 'vod_decryption_key_index_'.$hlsDecryptionKeyIndex ) ;
1332
1333 if ( false === $vod_list_free_posts ) {
1334 $args_free = array(
1335 'posts_per_page' => -1,
1336 'cache_results' => false,
1337 'update_post_meta_cache' => false,
1338 'update_post_term_cache' => false,
1339 'post_type' => 'wpstream_product_vod',
1340 'post_status' => 'publish',
1341 'meta_query' => array(
1342 array(
1343 'key' => 'hlsDecryptionKeyIndex',
1344 'value' => $hlsDecryptionKeyIndex,
1345 'compare' => '=',
1346 )
1347 ),
1348 'fields'=>'ids',
1349 );
1350
1351 $event_list_free = new WP_Query($args_free);
1352
1353 $vod_list_free_posts= $event_list_free->posts;
1354 set_transient( 'vod_decryption_key_index_'.$hlsDecryptionKeyIndex, $event_list_free->posts ,60);
1355 }// end check transient
1356
1357
1358
1359 if ( !empty($vod_list_free_posts ) ){
1360 ////////////////////////////////////////////////////////////
1361 // when we have a free event
1362 ////////////////////////////////////////////////////////////
1363 $the_id = $vod_list_free_posts[0];
1364 $get_key = get_post_meta($the_id,'hlsDecryptionKey',true);
1365
1366 $seconds_to_cache = 301;
1367 $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
1368 header("Expires: $ts");
1369 header("Pragma: cache");
1370 header("Cache-Control: max-age=$seconds_to_cache");
1371
1372
1373 print base64_decode( $get_key );
1374 die();
1375
1376
1377 }else{
1378 ////////////////////////////////////////////////////////////
1379 // this is for paid products
1380 ////////////////////////////////////////////////////////////
1381 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
1382 $hlsDecryptionKeyIndex = esc_html($_REQUEST[ 'wpstream_voddrm' ]);
1383 $event_list_paid_posts = get_transient( 'paid_vod_key_index_'.$hlsDecryptionKeyIndex ) ;
1384
1385
1386 if ( false === $event_list_paid_posts ) {
1387 print ' transient paid expired ';
1388 $args = array(
1389 'posts_per_page' => -1,
1390 'post_type' => 'product',
1391 'post_status' => 'publish',
1392 'meta_query' => array(
1393 array(
1394 'key' => 'hlsDecryptionKeyIndex',
1395 'value' => $hlsDecryptionKeyIndex,
1396 'compare' => '=',
1397 ),
1398 ),
1399 'tax_query' => array(
1400 'relation' => 'AND',
1401 array(
1402 'taxonomy' => 'product_type',
1403 'field' => 'slug',
1404 'terms' => array('video_on_demand','subscription')
1405 )
1406 ),
1407 'fields'=>'ids',
1408 );
1409
1410
1411 $event_list = new WP_Query($args);
1412 $vod_list_paid_posts = $event_list->posts;
1413
1414 set_transient( 'paid_vod_key_index_'.$hlsDecryptionKeyIndex, $event_list->posts ,60);
1415 }
1416
1417
1418 if ( !empty($vod_list_paid_posts ) ){
1419
1420 $the_id = $vod_list_paid_posts[0];
1421 $show_id = $the_id;
1422
1423
1424 $is_valid_subscription=0;
1425 if(class_exists ('WC_Subscription')){
1426 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
1427 }
1428
1429
1430 if(function_exists('wpstream_check_global_subscription_model')){
1431 if( wpstream_check_global_subscription_model() ){
1432 $is_valid_subscription=1;// this is global subscription
1433 }
1434 }
1435
1436
1437 if( $this->main->wpstream_player->wpstream_in_plugin_check_global_subscription_model($show_id) ){
1438 $is_valid_subscription=1;// this is global subscription
1439 }
1440
1441
1442 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $show_id) || $is_valid_subscription==1 ){
1443
1444 $get_key = get_post_meta($show_id,'hlsDecryptionKey',true);
1445
1446 $seconds_to_cache = 302;
1447 $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
1448 header("Expires: $ts");
1449 header("Pragma: cache");
1450 header("Cache-Control: max-age=$seconds_to_cache");
1451
1452 print base64_decode( $get_key );
1453 die();
1454
1455 }else{
1456 exit('vod - no ticket ');
1457 }
1458
1459 } else{
1460 exit('vod - no item');
1461 }
1462
1463 }else{
1464 exit('vod - user not log or no answer');
1465 }
1466
1467
1468 }
1469
1470
1471
1472 }
1473
1474
1475 }
1476
1477
1478
1479
1480
1481
1482 public function wpstream_get_vod_key($filename){
1483 return;
1484 // global $wpstream_plugin;
1485 // $vod_key = get_transient("vod_key".$filename);
1486 // if(false===$vod_key){
1487 // $token = $wpstream_plugin->wpstream_live_connection->wpstream_get_token();
1488 // $domain = parse_url ( get_site_url() );
1489 //
1490 // $values_array=array(
1491 // "filename" => $filename,
1492 // );
1493 // $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/uservodkey/get/?access_token=".$token;
1494 //
1495 //
1496 // $arguments = array(
1497 // 'method' => 'GET',
1498 // 'timeout' => 45,
1499 // 'redirection' => 5,
1500 // 'httpversion' => '1.0',
1501 // 'blocking' => true,
1502 // 'headers' => array(),
1503 // 'body' => $values_array,
1504 // 'cookies' => array()
1505 // );
1506 // $response = wp_remote_post($url,$arguments);
1507 // $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
1508 //
1509 //
1510 // if( isset($response['response']['code']) && $response['response']['code']=='200'){
1511 // set_transient("vod_key".$filename,$received_data,120);
1512 // return ($received_data);
1513 // }else{
1514 // return 'failed connection';
1515 // }
1516 // }else{
1517 // return $vod_key;
1518 // }
1519
1520 }
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530 /**
1531 * wrapper start around woo
1532 *
1533 * @since 3.0.1
1534 *
1535 */
1536
1537
1538 public function wpstream_non_image_content_wrapper_start() {
1539 if ( is_user_logged_in() ) {
1540 global $product;
1541 $current_user = wp_get_current_user();
1542 $product = wc_get_product();
1543
1544 if($product){
1545 $product_id = $product->get_id();
1546 if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){
1547 echo '<div id="wpstream_product_wrap">';
1548 }else{
1549 echo '<div id="wpstream_product_wrap_no_buy">';
1550 }
1551 }
1552 }
1553
1554 }
1555
1556 /**
1557 * wrapper end around woo
1558 *
1559 * @since 3.0.1
1560 *
1561 */
1562
1563
1564 function wpstream_non_image_content_wrapper_end() {
1565 // echo '</div>';
1566 }
1567
1568
1569 /**
1570 * wpstream thank you extra
1571 *
1572 * @since 3.12
1573 *
1574 */
1575
1576 function wpstream_thankyou_extra($var,$order){
1577 return $this->wpstream_get_ordered_items($order);
1578 }
1579
1580
1581 /**
1582 * wpstream thank you extra on order
1583 *
1584 * @since 3.12
1585 *
1586 */
1587 function wpstream_email_order_details($order, $sent_to_admin, $plain_text, $email){
1588 print $this->wpstream_get_ordered_items($order).'</br>';
1589 }
1590
1591
1592
1593 /**
1594 * wpstream compose message for complted order and thank you page
1595 *
1596 * @since 3.12
1597 *
1598 */
1599
1600 function wpstream_get_ordered_items($order){
1601
1602 $message = esc_html( get_option('wpstream_product_thankyou','Thanks for your purchase. You can access your item at any time by visiting the following page: {item_link}')) ;
1603 $list = '';
1604 $product_id = 0;
1605
1606 foreach( $order->get_items() as $line_item ) {
1607 // The WC_Product object
1608 $product = $line_item->get_product(); // Added
1609 $list .= '<a href="'.$product->get_permalink().'">'.$product->get_title().'</a>, ';// Changed
1610 $product_id = $product->get_id();
1611 }
1612 $list = trim($list,', ');
1613 $message = str_replace('{item_link}', $list, $message);
1614
1615 $term_list = wp_get_post_terms($product_id, 'product_type');
1616 $product = wc_get_product($product_id);
1617
1618 $product_type = $product->get_type();
1619
1620
1621 if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' || $product_type=='subscription' ){
1622 return $message;
1623 }else{
1624 $message = esc_html('Thank you. Your order has been received','wpstream');
1625 return $message;
1626 }
1627
1628
1629 }
1630 }
1631