PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8.2
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8.2
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
← All changes | includes/class-wpstream.php +36 -107 4.134.8.2 View file →
@@ -76,10 +76,8 @@
76 76 */
77 77
78 78 public $wpstream_live_connection;
79 79 public $wpstream_player;
80 - public $quota_manager;
81 - public $user_quota_service;
82 80 public $xtest;
83 81 public $plugin_admin;
84 82
85 83 public function __construct() {
@@ -101,36 +99,22 @@
101 99 $this->wpstream_load_theme_notice();
102 100
103 101 $this->wpstream_conection();
104 102 $this->wpstream_player();
105 - $this->wpstream_init_quota_manager();
106 103
107 104 }
108 105
109 -
110 -
111 -
112 -
106 +
107 +
108 +
109 +
113 110 public function wpstream_convert_band($megabits){
114 - $gigabit = $megabits * 0.001;
115 - return floatval( sprintf( '%.1f', $gigabit ) );
111 + $gigabit = $megabits * 0.001;
112 + $gigabit = floatval(sprintf('%.1f', $gigabit));
113 + return $gigabit;
116 114 }
117 115
118 - /**
119 - * Floor a number to a given number of decimal places.
120 - *
121 - * @param float $value The number to floor.
122 - * @param int $decimals Number of decimal places.
123 - * @return float
124 - */
125 - public function wpstream_floor_decimals( $value, $decimals = 2 ) {
126 - $decimals = max( 0, (int) $decimals );
127 - $factor = pow( 10, $decimals );
128 116
129 - return floatval( sprintf( '%.' . $decimals . 'f', floor( (float) $value * $factor ) / $factor ) );
130 - }
131 -
132 -
133 117 public $wpstream_ajax;
134 118
135 119 private function define_ajax_hooks() {
136 120 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wpstream-ajax.php';
@@ -140,9 +124,8 @@
140 124
141 125 private function wpstream_conection(){
142 126 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-live-api-connection.php';
143 127 $this->wpstream_live_connection = new Wpstream_Live_Api_Connection();
144 - $this->user_quota_service = $this->wpstream_live_connection->get_user_quota_service();
145 128 }
146 129
147 130
148 131 private function wpstream_player(){
@@ -149,14 +132,9 @@
149 132 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-player.php';
150 133 $this->wpstream_player = new Wpstream_Player($this->main);
151 134 }
152 135
153 - private function wpstream_init_quota_manager() {
154 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-quota-manager.php';
155 - $this->quota_manager = new Wpstream_Quota_Manager( $this );
156 - }
157 136
158 -
159 137 private function wpstream_load_page_templates() {
160 138 require_once WPSTREAM_PLUGIN_PATH . 'includes/class-wpstream-templates.php';
161 139 new WpStream_Template_Loader();
162 140 }
@@ -264,10 +242,8 @@
264 242 // save and render metaboxed
265 243 $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wpstream_product_metaboxes' );
266 244 $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
267 245 $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 );
268 - $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_create_remote_channel_on_publish',20,2 );
269 - $this->loader->add_action( 'publish_product', $plugin_admin, 'wpstream_create_remote_channel_on_publish', 20, 2 );
270 246
271 247
272 248
273 249 // make product virtual
@@ -287,10 +263,8 @@
287 263
288 264
289 265 $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' );
290 266 $this->loader->add_action( 'wp_ajax_wpstream_on_board_register', $plugin_admin,'wpstream_on_board_register' );
291 - $this->loader->add_action( 'wp_ajax_wpstream_get_captcha_challenge', $plugin_admin, 'wpstream_get_captcha_challenge' );
292 - $this->loader->add_action( 'wp_ajax_nopriv_wpstream_get_captcha_challenge', $plugin_admin, 'wpstream_get_captcha_challenge' );
293 267
294 268 // Register AJAX actions for multipart uploads
295 269 $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
296 270 $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
@@ -295,10 +269,8 @@
295 269 $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
296 270 $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
297 271
298 272 $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
299 - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_plugin_update_available_notice' );
300 -
301 273 $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
302 274 // $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' );
303 275
304 276
@@ -341,9 +313,9 @@
341 313 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
342 314 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
343 315 $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2);
344 316
345 - $this->loader->add_action( 'woocommerce_product_options_general_product_data', $plugin_admin, 'wpstream_add_custom_general_fields', 20 );
317 + $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
346 318 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
347 319 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
348 320 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
349 321 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
@@ -365,12 +337,9 @@
365 337
366 338 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
367 339
368 340 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
369 - // Registered on `wp` (not `wp_enqueue_scripts`/`wp_head`) because block themes render
370 - // the Post Content block - and thus our `the_content` filter that enqueues/localizes
371 - // these scripts - before `wp_head` ever fires, leaving the handles unregistered.
372 - $this->loader->add_action( 'wp', $plugin_public, 'enqueue_scripts' );
341 + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
373 342
374 343 $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
375 344 $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
376 345
@@ -466,71 +435,34 @@
466 435
467 436
468 437
469 438 public function show_user_data($pack_details){
470 - if ( ! isset( $pack_details['use_streaming_hours'] ) || $pack_details['use_streaming_hours'] !== true ) {
471 - if ( isset( $pack_details['available_data_mb'] ) && isset( $pack_details['available_storage_mb'] ) ) {
472 - $wpstream_convert_band = $this->wpstream_convert_band( $pack_details['available_data_mb'] );
473 - if ( $wpstream_convert_band < 0 ) {
474 - $wpstream_convert_band = 0;
475 - }
439 + if( isset($pack_details['available_data_mb']) && isset( $pack_details['available_storage_mb']) ){
440 + $wpstream_convert_band = $this->wpstream_convert_band($pack_details['available_data_mb']);
441 + if( $wpstream_convert_band < 0 ) {
442 + $wpstream_convert_band = 0;
443 + }
476 444
477 - $wpstream_convert_storage = $this->wpstream_convert_band( $pack_details['available_storage_mb'] );
478 - if ( $wpstream_convert_storage < 0 ) {
479 - $wpstream_convert_storage = 0;
480 - }
445 + $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['available_storage_mb']);
446 + if( $wpstream_convert_storage < 0 ) {
447 + $wpstream_convert_storage = 0;
448 + }
449 +
450 + print '<div class="pack_details_wrapper">'
451 + . '<strong>' . __('Your account information: ', 'wpstream') . '</strong> '
452 + . __('You have', 'wpstream') . '<strong> ' . abs( $wpstream_convert_band ) . ' GB</strong> '
453 + . __('available cloud data and', 'wpstream') . ' '
454 + . '<strong>' . $wpstream_convert_storage . ' GB</strong> '
455 + . __('available cloud storage', 'wpstream') . '.';
481 456
482 - print '<div class="pack_details_wrapper">'
483 - . '<strong>' . __( 'Your account information: ', 'wpstream' ) . '</strong> '
484 - . __( 'You have ', 'wpstream' ) . '<strong id="wpstream_available_data">' . abs( $wpstream_convert_band ) . ' GB</strong> '
485 - . __( 'available cloud data and ', 'wpstream' )
486 - . '<strong id="wpstream_available_storage">' . abs( $wpstream_convert_storage ) . ' GB</strong> '
487 - . __( 'available cloud storage', 'wpstream' ) . '.';
457 + print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">'.esc_html__('Upgrade Plan','wpstream').'</a>';
458 + print '</div>';
459 + print'<input type="hidden" id="wpstream_band" value="'.$pack_details['available_data_mb'].'">';
460 + print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['available_storage_mb'].'">';
488 461
489 - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">' . esc_html__( 'Upgrade Plan', 'wpstream' ) . '</a>';
490 - print '</div>';
491 - print '<input type="hidden" id="wpstream_band" value="' . esc_attr( $pack_details['available_data_mb'] ) . '">';
492 - print '<input type="hidden" id="wpstream_storage" value="' . esc_attr( $pack_details['available_storage_mb'] ) . '">';
493 - }
494 - } else {
495 - if ( isset( $pack_details['available_viewer_hours'] ) && isset( $pack_details['available_broadcast_hours'] ) && isset( $pack_details['available_storage_hours'] ) ) {
496 - $available_viewer_hours = floatval( $pack_details['available_viewer_hours'] );
497 - if ( $available_viewer_hours < 0 ) {
498 - $available_viewer_hours = 0;
499 - }
462 + }
463 + }
500 464
501 - $available_broadcast_hours = floatval( $pack_details['available_broadcast_hours'] );
502 - if ( $available_broadcast_hours < 0 ) {
503 - $available_broadcast_hours = 0;
504 - }
505 -
506 - $available_storage_hours = floatval( $pack_details['available_storage_hours'] );
507 - if ( $available_storage_hours < 0 ) {
508 - $available_storage_hours = 0;
509 - }
510 -
511 - $formatted_viewer_hours = $this->wpstream_floor_decimals( $available_viewer_hours, 2 );
512 - $formatted_broadcast_hours = $this->wpstream_floor_decimals( $available_broadcast_hours, 2 );
513 - $formatted_storage_hours = $this->wpstream_floor_decimals( $available_storage_hours, 2 );
514 -
515 - print '<div class="pack_details_wrapper">'
516 - . __( 'Available streaming resources: ', 'wpstream' )
517 - . '<strong id="wpstream_available_viewer_hours">' . abs( $formatted_viewer_hours ) . ' viewer</strong> '
518 - . __( 'hours, ', 'wpstream' )
519 - . '<strong id="wpstream_available_broadcast_hours">' . abs( $formatted_broadcast_hours ) . ' broadcast</strong> '
520 - . __( 'hours, ', 'wpstream' )
521 - . '<strong id="wpstream_available_storage_hours">' . $formatted_storage_hours . ' storage</strong> '
522 - . __( 'hours', 'wpstream' ) . '.';
523 -
524 - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">' . esc_html__( 'Upgrade Plan', 'wpstream' ) . '</a>';
525 - print '</div>';
526 - print '<input type="hidden" id="wpstream_viewer_hours" value="' . esc_attr( $pack_details['available_viewer_hours'] ) . '">';
527 - print '<input type="hidden" id="wpstream_broadcast_hours" value="' . esc_attr( $pack_details['available_broadcast_hours'] ) . '">';
528 - print '<input type="hidden" id="wpstream_storage_hours" value="' . esc_attr( $pack_details['available_storage_hours'] ) . '">';
529 - }
530 - }
531 - }
532 -
533 465
534 466 /**
535 467 * help function for media list elementor widget
536 468 *
@@ -918,9 +850,9 @@
918 850 */
919 851
920 852 public function wpstream_check_user_can_stream(){
921 853 $current_user = wp_get_current_user();
922 -
854 +
923 855 if( !is_user_logged_in() ){
924 856 return false;
925 857 exit('user not logged in');
926 858 }
@@ -930,17 +862,14 @@
930 862 return true;
931 863 }
932 864
933 865 $extra_roles = get_option( 'wpstream_stream_role', true );
934 - $user_role = '';
935 - if( is_array( $current_user->roles) && count( $current_user->roles ) > 0 ){
936 - $user_role = $current_user->roles[0];
937 - }
938 -
939 - if ( is_array($extra_roles) && in_array( $user_role, $extra_roles ) ) {
866 + $user_role = $current_user->roles[0];
867 +
868 + if (is_array($extra_roles) && in_array($user_role, $extra_roles)){
940 869 return true;
941 870 }
942 -
871 +
943 872 if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){
944 873 return true;
945 874 }
946 875