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