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

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