PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.7
WpStream – Live Streaming, Video on Demand, Pay Per View v3.7
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 +104 -493 4.12.23.7 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 /**
3 4 * The file that defines the core plugin class
4 5 *
5 6 * A class definition that includes attributes and functions used across both the
@@ -34,9 +35,8 @@
34 35 * @since 3.0.1
35 36 * @var object The main class.
36 37 */
37 38 public $main;
38 - public $admin;
39 39
40 40 /**
41 41 * The loader that's responsible for maintaining and registering all hooks that power
42 42 * the plugin.
@@ -76,54 +76,45 @@
76 76 */
77 77
78 78 public $wpstream_live_connection;
79 79 public $wpstream_player;
80 - public $quota_manager;
81 80 public $xtest;
82 81 public $plugin_admin;
83 82
84 83 public function __construct() {
85 - $this->main = $this;
86 -
87 - if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) {
88 - $this->version = WPSTREAM_PLUGIN_VERSION;
84 + $this->main = $this;
85 + if ( defined( 'WPSTREAM_VERSION' ) ) {
86 + $this->version = WPSTREAM_VERSION;
89 87 } else {
90 - $this->version = '3.0.1';
88 + $this->version = '3.0.1';
91 89 }
92 -
93 90 $this->plugin_name = 'wpstream';
94 91
95 92 $this->load_dependencies();
93 + $this->set_locale();
96 94 $this->define_admin_hooks();
97 95 $this->define_public_hooks();
98 - $this->define_ajax_hooks();
99 - $this->wpstream_load_page_templates();
100 - $this->wpstream_load_theme_notice();
96 +
97 + $this->xtest = "this is test2";
98 + $this->wpstream_conection();
99 + $this->wpstream_player();
101 100
102 - $this->wpstream_conection();
103 - $this->wpstream_player();
104 - $this->wpstream_init_quota_manager();
105 -
106 101 }
107 102
108 -
109 -
110 -
111 -
103 +
104 +
105 +
106 +
112 107 public function wpstream_convert_band($megabits){
113 - $gigabit = $megabits * 0.001;
114 - return floatval( sprintf( '%.1f', $gigabit ) );
108 + $gigabit = $megabits * 0.001;
109 + $gigabit = number_format($gigabit,2);
110 + return $gigabit;
115 111 }
116 112
117 -
118 - public $wpstream_ajax;
119 -
120 - private function define_ajax_hooks() {
121 - require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wpstream-ajax.php';
122 - $this->wpstream_ajax = new WpStream_Ajax( $this->main );
123 - }
124 113
125 114
115 +
116 +
126 117 private function wpstream_conection(){
127 118 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-live-api-connection.php';
128 119 $this->wpstream_live_connection = new Wpstream_Live_Api_Connection();
129 120 }
@@ -132,26 +123,12 @@
132 123 private function wpstream_player(){
133 124 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-player.php';
134 125 $this->wpstream_player = new Wpstream_Player($this->main);
135 126 }
136 -
137 - private function wpstream_init_quota_manager() {
138 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-quota-manager.php';
139 - $this->quota_manager = new Wpstream_Quota_Manager( $this );
140 - }
141 -
142 -
143 - private function wpstream_load_page_templates() {
144 - require_once WPSTREAM_PLUGIN_PATH . 'includes/class-wpstream-templates.php';
145 - new WpStream_Template_Loader();
146 - }
147 -
148 - private function wpstream_load_theme_notice() {
149 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-theme-notice.php';
150 - new WPStream_Theme_Notice();
151 - }
152 127
153 128
129 +
130 +
154 131 /**
155 132 * Load the required dependencies for this plugin.
156 133 *
157 134 * Include the following files that make up the plugin:
@@ -190,21 +167,19 @@
190 167 * The class responsible for defining all actions that occur in the public-facing
191 168 * side of the site.
192 169 */
193 170 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpstream-public.php';
194 - /**
171 +
172 + /**
195 173 * The class responsible for custom post type
196 174
197 - */
198 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream_product.php';
199 - if( class_exists( 'WooCommerce' ) ){
200 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php';
201 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php';
202 - }
175 + */
176 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream_product.php';
177 + if( class_exists( 'WooCommerce' ) ){
178 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php';
179 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php';
180 + }
203 181
204 - require_once plugin_dir_path(__FILE__) . 'Helpers/class-wpstream-log-entry.php';
205 - require_once plugin_dir_path(__FILE__) . 'Logger/class-wpstream-logger.php';
206 -
207 182 $this->loader = new Wpstream_Loader();
208 183
209 184 }
210 185
@@ -220,9 +195,9 @@
220 195 private function set_locale() {
221 196
222 197 $plugin_i18n = new Wpstream_i18n();
223 198
224 - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain', 1 );
199 + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
225 200
226 201 }
227 202
228 203 /**
@@ -233,26 +208,23 @@
233 208 * @access private
234 209 */
235 210 private function define_admin_hooks() {
236 211
237 - $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
212 + $this->admin= $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
238 213
239 - $this->admin = $plugin_admin;
240 -
241 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
242 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
214 +
215 +
216 + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
217 + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
243 218 $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999);
244 -
219 +
245 220 $plugin_post_types = new Wpstream_Product();
246 221 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
247 -
222 +
248 223 // save and render metaboxed
249 - $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wpstream_product_metaboxes' );
250 - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
251 - $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 );
252 -
253 -
254 -
224 + $this->loader->add_action( 'admin_init', $plugin_admin, 'add_wpstream_product_metaboxes' );
225 + $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
226 +
255 227 // make product virtual
256 228 $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 );
257 229
258 230
@@ -258,72 +230,49 @@
258 230
259 231
260 232 // show streaming controls on sidebar
261 233 $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta');
262 -
263 - // on boarding actions
264 - $this->loader->add_action('admin_footer',$plugin_admin, 'wpstream_admin_footer_onboarding');
265 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel', $plugin_admin,'wpstream_on_board_create_channel' );
266 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' );
267 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' );
268 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' );
269 -
270 -
271 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' );
272 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_register', $plugin_admin,'wpstream_on_board_register' );
273 - $this->loader->add_action( 'wp_ajax_wpstream_get_captcha_challenge', $plugin_admin, 'wpstream_get_captcha_challenge' );
274 - $this->loader->add_action( 'wp_ajax_nopriv_wpstream_get_captcha_challenge', $plugin_admin, 'wpstream_get_captcha_challenge' );
275 234
276 - // Register AJAX actions for multipart uploads
277 - $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
278 - $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
279 -
280 - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
281 - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_plugin_update_available_notice' );
282 -
283 - $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
284 -// $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' );
285 -
286 -
287 - $this->loader->add_action( 'wp_ajax_wpstream_settings_tab_update_plugin', $plugin_admin, 'wpstream_settings_tab_update_plugin' );
288 -
235 +
236 + $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
237 + $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
238 +
289 239 // add and save category extra fields
290 240 $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
291 - $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
241 + $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
292 242 $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
293 243 $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
294 244
295 245 $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
296 - $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
246 + $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
297 247 $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
298 248 $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
299 249
300 250
301 251 $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
302 - $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
252 + $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
303 253 $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
304 254 $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
305 255
306 256
307 257 $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
308 - $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
258 + $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
309 259 $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
310 260 $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
311 261
312 262 $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
313 - $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
263 + $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
314 264 $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
315 265 $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
266 +
267 +
316 268
317 269
318 270 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
319 -
320 - $this->loader->add_action( 'init', $plugin_admin, 'wpstream_add_custom_wc_products' );
271 +
321 272 $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' );
322 - $this->loader->add_filter( 'woocommerce_product_class', $plugin_admin, 'wpstream_add_products_class', 10, 2 );
323 273 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
324 274 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
325 - $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2);
326 275
327 276 $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
328 277 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
329 278 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
@@ -329,14 +278,16 @@
329 278 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
330 279 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
331 280 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
332 281 }
333 - }
282 +
283 +
284 +
285 +
334 286
335 287
288 + }
336 289
337 -
338 -
339 290 /**
340 291 * Register all of the hooks related to the public-facing functionality
341 292 * of the plugin.
342 293 *
@@ -348,49 +299,34 @@
348 299 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
349 300
350 301 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
351 302 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
303 +
304 + $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
305 + $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
306 +
307 + //live stream action
308 + $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
309 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
310 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
311 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod');
312 + // woo action
313 +
314 + $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
315 + $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
316 +
317 + $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
318 + $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
319 + $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
320 +
352 321
353 - $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
354 - $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
355 -
356 - //live stream action
357 - $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
358 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
359 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
360 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10);
361 -
362 - // woo action
363 - $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
364 - $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
365 - $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 );
366 - $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 );
367 -
368 - $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
369 - $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
370 - $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
371 -
372 - $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
373 - $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
374 - $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes');
375 -
376 - $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
377 -
378 - $this->loader->add_filter( 'wpstream_search_template_item_post_type', $plugin_public, 'wpstream_search_template_add_item_post_type' );
379 - $this->loader->add_filter( 'wpstream_sidebar_id_by_post_type', $plugin_public, 'wpstream_sidebar_id_by_post_type' );
380 - $this->loader->add_filter( 'wpstream_header_search_values', $plugin_public, 'wpstream_header_search_values' );
381 - $this->loader->add_filter( 'wpstream_extend_category_archive_query_filter', $plugin_public, 'wpstream_extend_category_archive_query_filter_callback' );
382 - $this->loader->add_filter( 'wpstream_archives_lists_taxonomy_labels', $plugin_public, 'wpstream_archives_lists_taxonomy_labels_callback' );
383 - $this->loader->add_filter( 'wpstream_author_archive_list_taxonomy_labels', $plugin_public, 'wpstream_author_archive_list_taxonomy_labels_callback' );
384 - $this->loader->add_action( 'wpstream_vod_attached_to_channel', $plugin_public, 'wpstream_vod_attached_to_channel' );
385 - $this->loader->add_action( 'wpstream_additional_content_post_type', $plugin_public, 'wpstream_additional_content_post_type_callback' );
386 - $this->loader->add_action( 'wpstream_post_author_content_post_type_list', $plugin_public, 'wpstream_post_author_content_post_type_list_callback' );
387 - $this->loader->add_action( 'wpstream_author_content_simple_post_type_message', $plugin_public, 'wpstream_author_content_simple_post_type_message_callback', 10, 2 );
388 - $this->loader->add_action( 'wpstream_author_content_post_type_message', $plugin_public, 'wpstream_author_content_post_type_message_callback', 10, 2 );
389 - $this->loader->add_action( 'wpstream_show_sidebar_for_post_type', $plugin_public, 'wpstream_show_sidebar_for_post_type_callback', 10, 2 );
390 - $this->loader->add_action( 'wpstream_video_episodes_post_type', $plugin_public, 'wpstream_video_episodes_post_type_callback' );
391 - $this->loader->add_action( 'wpstream_video_past_broadcast_post_type', $plugin_public, 'wpstream_video_past_broadcast_post_type_callback' );
392 - $this->loader->add_action( 'wpstream_additional_content_post_type_label', $plugin_public, 'wpstream_additional_content_post_type_label_callback', 10, 2 );
322 + $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
323 + $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
324 +
325 + $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
326 +
327 +
328 +
393 329 }
394 330
395 331 /**
396 332 * Run the loader to execute all of the hooks with WordPress.
@@ -430,303 +366,27 @@
430 366 */
431 367 public function get_version() {
432 368 return $this->version;
433 369 }
434 -
435 - public function is_plugin_outdated(){
436 - $update_data = get_site_transient('update_plugins');
437 - $plugin_path = 'wpstream/wpstream.php';
438 -
439 - if (isset($update_data->response[$plugin_path])) {
440 - return true;
441 - }
442 -
443 - return false;
444 - }
445 -
446 -
447 -
448 - public function show_user_data($pack_details){
449 - if( isset($pack_details['available_data_mb']) && isset( $pack_details['available_storage_mb']) ){
450 - $wpstream_convert_band = $this->wpstream_convert_band($pack_details['available_data_mb']);
451 - if( $wpstream_convert_band < 0 ) {
452 - $wpstream_convert_band = 0;
453 - }
454 -
455 - $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['available_storage_mb']);
456 - if( $wpstream_convert_storage < 0 ) {
457 - $wpstream_convert_storage = 0;
458 - }
459 -
460 - print '<div class="pack_details_wrapper">'
461 - . '<strong>' . __('Your account information: ', 'wpstream') . '</strong> '
462 - . __('You have ', 'wpstream') . '<strong id="wpstream_available_data">' . abs( $wpstream_convert_band ) . ' GB</strong> '
463 - . __('available cloud data and ', 'wpstream')
464 - . '<strong id="wpstream_available_storage">' . abs( $wpstream_convert_storage ) . ' GB</strong> '
465 - . __('available cloud storage', 'wpstream') . '.';
466 -
467 - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">'.esc_html__('Upgrade Plan','wpstream').'</a>';
468 - print '</div>';
469 - print'<input type="hidden" id="wpstream_band" value="'.$pack_details['available_data_mb'].'">';
470 - print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['available_storage_mb'].'">';
471 -
472 - }
473 - }
474 -
475 370
476 - /**
477 - * help function for media list elementor widget
478 - *
479 - * @since 3.0.1
480 - * @return string
481 - */
482 371
483 - public function wpstream_media_list_elementor_function($attributes, $content = null){
484 -
485 -
486 - $media_number=3;
487 - if ( isset($attributes['media_number']) ){
488 - $media_number=$attributes['media_number'];
489 - }
490 -
491 -
492 - $row_number=3;
493 - if ( isset($attributes['row_number']) ){
494 - $row_number=$attributes['row_number'];
495 - }
496 - if($row_number>4){
497 - $row_number=4;
498 - }
499 -
500 -
501 - ob_start();
502 -
503 - // check if is vod or live stream
504 - $meta_query = array();
505 - $tax_query_array= array();
506 - $tax_query = array();
507 -
508 - // check if the media is paid or free
509 - $event_types = array();
510 - $product_type_free_paid = 0;
511 - if ( isset($attributes['product_type_free_paid']) ){
512 - $product_type_free_paid=$attributes['product_type_free_paid'];
513 -
514 - if($product_type_free_paid==0){
515 - $event_types=array('wpstream_product');
516 -
517 - if ( isset($attributes['product_type']) && intval($attributes['product_type'])==2){
518 - $event_types=array('wpstream_product_vod');
519 - }
520 -
521 - }else{
522 - $event_types=array('product');
523 - if ( isset($attributes['product_type']) ){
524 - $product_type = $attributes['product_type'];
525 - $product_type_slug = 'video_on_demand';
526 - if($product_type==1){
527 - $product_type_slug ='live_stream';
528 - }
529 -
530 - $tax_query_array = array(
531 - 'taxonomy' => 'product_type',
532 - 'field' => 'slug',
533 - 'terms' => $product_type_slug
534 - );
535 -
536 - $tax_query= array(
537 - 'relation' => 'AND',
538 - $tax_query_array
539 - );
540 -
541 - }
542 - }
543 -
544 - }
545 - $see_product='';
546 - if(isset($attributes['free_label'])){
547 - $see_product=$attributes['free_label'];
548 - }
549 -
550 - // pagination
551 - $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
552 - if( is_front_page() ){
553 - $paged= (get_query_var('page')) ? get_query_var('page') : 1;
554 - }
555 -
556 -
557 - //order
558 - $orderby='ID';
559 - $order ='ASC';
560 - if ( isset($attributes['order_by']) ){
561 - $order_by=intval($attributes['order_by']);
562 - switch ($order_by) {
563 - case 0:
564 - $orderby='ID';
565 - $order ='ASC';
566 - break;
567 - case 1:
568 - $orderby='ID';
569 - $order ='DESC';
570 - break;
571 - case 2:
572 - $orderby='title';
573 - $order ='ASC';
574 - break;
575 - case 3:
576 - $orderby='title';
577 - $order ='DESC';
578 - break;
579 - }
580 - }
581 -
582 - // building wp_query arg array
583 - $args = array(
584 - 'post_type' => $event_types,
585 - 'post_status' => 'publish',
586 - 'meta_query' => $meta_query,
587 - 'posts_per_page' => $media_number,
588 - 'paged' => $paged,
589 - 'orderby' => $orderby,
590 - 'order' => $order,
591 - 'tax_query' => $tax_query
592 - );
593 -
594 -
595 -
596 - // show live events
597 - if ( isset($attributes['product_show_live']) && $attributes['product_show_live']=='yes'){
598 - $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user_for_shortcode('shortcode');
599 372
600 -
601 - if( is_array($live_event_for_user) ){
602 - $live_event_for_user[]=0;
603 -
604 - $args['post__in']=$live_event_for_user;
605 - }
606 - }
373 + public function show_user_data($pack_details){
374 + if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
375 + $wpstream_convert_band = $this->wpstream_convert_band($pack_details['band']);
376 + if($wpstream_convert_band<0)$wpstream_convert_band=0;
607 377
608 -
378 + $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['storage']);
379 + if($wpstream_convert_storage<0)$wpstream_convert_storage=0;
609 380
381 + print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.$wpstream_convert_band.' Gb</strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.$wpstream_convert_storage.' Gb</strong> '.__('available media storage','wpstream').'.</div>';
382 + print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
383 + print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
610 384
611 - $media_list= new WP_Query($args);
612 - if($media_list->have_posts()){
613 - print '<ul class="wpstream_media_list_wrapper products columns-'.esc_attr($row_number).'" >';
614 - while($media_list->have_posts()):$media_list->the_post();
615 - if($product_type_free_paid==0 ){
616 -
617 - $thumb=wp_get_attachment_image_src(get_post_thumbnail_id(),'medium');
618 -
619 - $thumb_src='';
620 - if( isset($thumb[0]) ){
621 - $thumb_src=$thumb[0];
622 - }
623 -
624 - if(($thumb_src)==''){
625 - $thumb_src= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_300.png';
626 - }
627 - print '<li class="wpstream_product_unit">'
628 - .'<a href="'.get_permalink().'" class="product_title" ><div class="product_image" style="background-image:url('.esc_url($thumb_src).')"></div></a>'
629 - .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>';
630 -
631 - if($see_product!=''){
632 - print '<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>';
633 - }
634 - print '</li>';
635 - }else{
636 - wc_get_template_part( 'content', 'product' );
637 - }
638 - endwhile;
639 - print '</ul>';
640 - }else{
641 - print esc_html__('No media found! ','wpstream');
642 - }
643 -
644 -
645 - wp_reset_query();
646 - wp_reset_postdata();
647 -
648 - $this->wpstream_pagination($media_list->max_num_pages,$range=2);
649 - $return_string= ob_get_contents();
650 - ob_end_clean();
651 -
652 - return $return_string;
653 - }
654 -
655 -
656 -
657 -
658 -
659 -
660 - /*
661 - *
662 - *
663 - * Pagination for media lista
664 - *
665 - *
666 - *
667 - */
668 -
669 -
670 -
671 -
672 - function wpstream_pagination($pages = '', $range = 2){
673 -
674 - $showitems = ($range * 2)+1;
675 - global $paged;
676 - if(empty($paged)) $paged = 1;
677 -
678 -
679 - if($pages == ''){
680 - global $wp_query;
681 - $pages = $wp_query->max_num_pages;
682 - if(!$pages)
683 - {
684 - $pages = 1;
685 385 }
686 386 }
687 387
688 - if(1 != $pages){
689 - print '<ul class="wpstream_pagination ">';
690 - print '<li class="roundleft"><a href="'.get_pagenum_link($paged - 1).'"> < </a></li>';
691 -
692 - for ($i=1; $i <= $pages; $i++)
693 - {
694 - if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
695 - {
696 - if ($paged == $i){
697 - print '<li class="active"><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>';
698 - }else{
699 - print '<li><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>';
700 - }
701 - }
702 - }
703 -
704 - $prev_page= get_pagenum_link($paged + 1);
705 - if ( ($paged +1) > $pages){
706 - $prev_page= get_pagenum_link($paged );
707 - }else{
708 - $prev_page= get_pagenum_link($paged + 1);
709 - }
710 -
711 -
712 - print '<li class="roundright"><a href="'.$prev_page.'"> > </a><li>';
713 - print '</ul>';
714 - }
715 - }
716 -
717 388
718 -
719 -
720 -
721 -
722 -
723 -
724 -
725 -
726 -
727 -
728 -
729 389 /**
730 390 * help function for player elementr widget
731 391 *
732 392 * @since 3.0.1
@@ -757,15 +417,9 @@
757 417
758 418
759 419
760 420 ob_start();
761 - ?>
762 - <div class="wpstream_insert_player_elementor_wrapper">
763 - <?php
764 - $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
765 - ?>
766 - </div>
767 - <?php
421 + $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
768 422 $return_string= ob_get_contents();
769 423 ob_end_clean();
770 424
771 425 return $return_string;
@@ -851,10 +505,8 @@
851 505 }
852 506
853 507
854 508 /**
855 - * edited 4.0
856 - *
857 509 * Check if user is allowed to stream
858 510 *
859 511 * @since 3.7
860 512 */
@@ -860,12 +512,12 @@
860 512 */
861 513
862 514 public function wpstream_check_user_can_stream(){
863 515 $current_user = wp_get_current_user();
864 -
516 +
865 517 if( !is_user_logged_in() ){
866 518 return false;
867 - exit('user not logged in');
519 + exit('user not logged in 497');
868 520 }
869 521
870 522 if(current_user_can('administrator')){
871 523 // admins can always brodcast
@@ -872,17 +524,14 @@
872 524 return true;
873 525 }
874 526
875 527 $extra_roles = get_option( 'wpstream_stream_role', true );
876 - $user_role = '';
877 - if( is_array( $current_user->roles) && count( $current_user->roles ) > 0 ){
878 - $user_role = $current_user->roles[0];
879 - }
880 -
881 - if ( is_array($extra_roles) && in_array( $user_role, $extra_roles ) ) {
528 + $user_role = $current_user->roles[0];
529 +
530 + if (in_array($user_role, $extra_roles)){
882 531 return true;
883 532 }
884 -
533 +
885 534 if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){
886 535 return true;
887 536 }
888 537
@@ -902,35 +551,14 @@
902 551 if($item_id == 0){
903 552 //retrive or create channel for front end streamers
904 553 $item_id=$this->wpstream_retrive_front_end_channel();
905 554 }
906 - print'<div class="wpstream_modal_background"></div>';
907 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
908 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
909 - </div>';
555 +
910 556 $this->admin->wpstream_live_stream_unit( $item_id,$type );
911 557 }
912 558
913 559
914 - /**
915 - * Start Streaming wrapper for wpstream theme
916 - *
917 - * @since 3.7
918 - */
919 560
920 - public function wpstream_live_stream_unit_wrapper_for_theme($item_id,$type){
921 - $item_id = intval($item_id);
922 -
923 - if($item_id == 0){
924 - //retrive or create channel for front end streamers
925 - $item_id=$this->wpstream_retrive_front_end_channel();
926 - }
927 - print'<div class="wpstream_modal_background"></div>';
928 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
929 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
930 - </div>';
931 - $this->admin->wpstream_live_stream_unit_for_theme( $item_id,$type );
932 - }
933 561
934 562
935 563 /**
936 564 * retrive channel for front end streaming
@@ -950,20 +578,11 @@
950 578 }
951 579 return $front_end_streamin_channel;
952 580
953 581 }
954 -
955 - /**
956 - * create the event from front end
957 - *
958 - * @since 3.7
959 - */
960 582
583 +
961 584 public function wpstrea_create_front_end_event($userID,$userLogin,$channel_type,$channel_price){
962 -
963 - if( !$this->wpstream_check_user_can_stream() ){
964 - return;
965 - }
966 585
967 586 $post_type='wpstream_product';
968 587 if($channel_type=='paid'){
969 588 $post_type='product';
@@ -985,9 +604,9 @@
985 604 // Set the product active price (regular)
986 605 $product->set_price( $price );
987 606 $product->set_regular_price( $price ); // To be sure
988 607 $product->save();
989 - update_post_meta ($post_id,'event_passed',0);
608 +
990 609 wp_set_object_terms( $post_id, 'live_stream', 'product_type' );
991 610 }
992 611 update_post_meta($post_id,'wpstream_product_type',1);
993 612
@@ -1012,22 +631,14 @@
1012 631 ;
1013 632 $author_posts = new WP_Query( $args );
1014 633 if( $author_posts->have_posts() ) {
1015 634 $author_posts->the_post();
1016 - $the_id= get_the_ID();
635 + return get_the_ID();
1017 636 }else{
1018 - $the_id= 0;
637 + return 0;
1019 638 }
1020 639
1021 640 wp_reset_query();
1022 641 wp_reset_postdata();
1023 - return $the_id;
1024 642 }
1025 -
1026 - /**
1027 - * Cleanup old logs
1028 - */
1029 - public function cleanup_logs() {
1030 - $logger = new WPStream_Logger();
1031 - $logger->clear_old_logs();
1032 - }
643 +
1033 644 }