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 -105 4.12.44.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 }
@@ -285,10 +263,8 @@
285 263
286 264
287 265 $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' );
288 266 $this->loader->add_action( 'wp_ajax_wpstream_on_board_register', $plugin_admin,'wpstream_on_board_register' );
289 - $this->loader->add_action( 'wp_ajax_wpstream_get_captcha_challenge', $plugin_admin, 'wpstream_get_captcha_challenge' );
290 - $this->loader->add_action( 'wp_ajax_nopriv_wpstream_get_captcha_challenge', $plugin_admin, 'wpstream_get_captcha_challenge' );
291 267
292 268 // Register AJAX actions for multipart uploads
293 269 $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
294 270 $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
@@ -293,10 +269,8 @@
293 269 $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
294 270 $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
295 271
296 272 $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
297 - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_plugin_update_available_notice' );
298 -
299 273 $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
300 274 // $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' );
301 275
302 276
@@ -339,9 +313,9 @@
339 313 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
340 314 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
341 315 $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2);
342 316
343 - $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);
344 318 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
345 319 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
346 320 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
347 321 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
@@ -363,12 +337,9 @@
363 337
364 338 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
365 339
366 340 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
367 - // Registered on `wp` (not `wp_enqueue_scripts`/`wp_head`) because block themes render
368 - // the Post Content block - and thus our `the_content` filter that enqueues/localizes
369 - // these scripts - before `wp_head` ever fires, leaving the handles unregistered.
370 - $this->loader->add_action( 'wp', $plugin_public, 'enqueue_scripts' );
341 + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
371 342
372 343 $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
373 344 $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
374 345
@@ -464,71 +435,34 @@
464 435
465 436
466 437
467 438 public function show_user_data($pack_details){
468 - if ( ! isset( $pack_details['use_streaming_hours'] ) || $pack_details['use_streaming_hours'] !== true ) {
469 - if ( isset( $pack_details['available_data_mb'] ) && isset( $pack_details['available_storage_mb'] ) ) {
470 - $wpstream_convert_band = $this->wpstream_convert_band( $pack_details['available_data_mb'] );
471 - if ( $wpstream_convert_band < 0 ) {
472 - $wpstream_convert_band = 0;
473 - }
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 + }
474 444
475 - $wpstream_convert_storage = $this->wpstream_convert_band( $pack_details['available_storage_mb'] );
476 - if ( $wpstream_convert_storage < 0 ) {
477 - $wpstream_convert_storage = 0;
478 - }
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') . '.';
479 456
480 - print '<div class="pack_details_wrapper">'
481 - . '<strong>' . __( 'Your account information: ', 'wpstream' ) . '</strong> '
482 - . __( 'You have ', 'wpstream' ) . '<strong id="wpstream_available_data">' . abs( $wpstream_convert_band ) . ' GB</strong> '
483 - . __( 'available cloud data and ', 'wpstream' )
484 - . '<strong id="wpstream_available_storage">' . abs( $wpstream_convert_storage ) . ' GB</strong> '
485 - . __( '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'].'">';
486 461
487 - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">' . esc_html__( 'Upgrade Plan', 'wpstream' ) . '</a>';
488 - print '</div>';
489 - print '<input type="hidden" id="wpstream_band" value="' . esc_attr( $pack_details['available_data_mb'] ) . '">';
490 - print '<input type="hidden" id="wpstream_storage" value="' . esc_attr( $pack_details['available_storage_mb'] ) . '">';
491 - }
492 - } else {
493 - if ( isset( $pack_details['available_viewer_hours'] ) && isset( $pack_details['available_broadcast_hours'] ) && isset( $pack_details['available_storage_hours'] ) ) {
494 - $available_viewer_hours = floatval( $pack_details['available_viewer_hours'] );
495 - if ( $available_viewer_hours < 0 ) {
496 - $available_viewer_hours = 0;
497 - }
462 + }
463 + }
498 464
499 - $available_broadcast_hours = floatval( $pack_details['available_broadcast_hours'] );
500 - if ( $available_broadcast_hours < 0 ) {
501 - $available_broadcast_hours = 0;
502 - }
503 -
504 - $available_storage_hours = floatval( $pack_details['available_storage_hours'] );
505 - if ( $available_storage_hours < 0 ) {
506 - $available_storage_hours = 0;
507 - }
508 -
509 - $formatted_viewer_hours = $this->wpstream_floor_decimals( $available_viewer_hours, 2 );
510 - $formatted_broadcast_hours = $this->wpstream_floor_decimals( $available_broadcast_hours, 2 );
511 - $formatted_storage_hours = $this->wpstream_floor_decimals( $available_storage_hours, 2 );
512 -
513 - print '<div class="pack_details_wrapper">'
514 - . '<strong>' . __( 'Your account information: ', 'wpstream' ) . '</strong> '
515 - . __( 'You have ', 'wpstream' ) . '<strong id="wpstream_available_viewer_hours">' . abs( $formatted_viewer_hours ) . ' hours</strong> '
516 - . __( 'available viewer time, ', 'wpstream' )
517 - . '<strong id="wpstream_available_broadcast_hours">' . abs( $formatted_broadcast_hours ) . ' hours</strong> '
518 - . __( 'available broadcast time, and ', 'wpstream' )
519 - . '<strong id="wpstream_available_storage_hours">' . $formatted_storage_hours . ' hours</strong> '
520 - . __( 'available storage time', 'wpstream' ) . '.';
521 -
522 - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">' . esc_html__( 'Upgrade Plan', 'wpstream' ) . '</a>';
523 - print '</div>';
524 - print '<input type="hidden" id="wpstream_viewer_hours" value="' . esc_attr( $pack_details['available_viewer_hours'] ) . '">';
525 - print '<input type="hidden" id="wpstream_broadcast_hours" value="' . esc_attr( $pack_details['available_broadcast_hours'] ) . '">';
526 - print '<input type="hidden" id="wpstream_storage_hours" value="' . esc_attr( $pack_details['available_storage_hours'] ) . '">';
527 - }
528 - }
529 - }
530 -
531 465
532 466 /**
533 467 * help function for media list elementor widget
534 468 *
@@ -916,9 +850,9 @@
916 850 */
917 851
918 852 public function wpstream_check_user_can_stream(){
919 853 $current_user = wp_get_current_user();
920 -
854 +
921 855 if( !is_user_logged_in() ){
922 856 return false;
923 857 exit('user not logged in');
924 858 }
@@ -928,17 +862,14 @@
928 862 return true;
929 863 }
930 864
931 865 $extra_roles = get_option( 'wpstream_stream_role', true );
932 - $user_role = '';
933 - if( is_array( $current_user->roles) && count( $current_user->roles ) > 0 ){
934 - $user_role = $current_user->roles[0];
935 - }
936 -
937 - 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)){
938 869 return true;
939 870 }
940 -
871 +
941 872 if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){
942 873 return true;
943 874 }
944 875