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

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