PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.4.10
WpStream – Live Streaming, Video on Demand, Pay Per View v4.4.10
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
← All changes | includes/class-wpstream.php +114 -265 4.12.44.4.10 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,73 +76,48 @@
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() {
86 - $this->main = $this;
87 -
84 + $this->main = $this;
88 85 if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) {
89 - $this->version = WPSTREAM_PLUGIN_VERSION;
86 + $this->version = WPSTREAM_PLUGIN_VERSION;
90 87 } else {
91 - $this->version = '3.0.1';
88 + $this->version = '3.0.1';
92 89 }
93 -
94 90 $this->plugin_name = 'wpstream';
95 91
96 92 $this->load_dependencies();
93 + $this->set_locale();
97 94 $this->define_admin_hooks();
98 95 $this->define_public_hooks();
99 - $this->define_ajax_hooks();
100 - $this->wpstream_load_page_templates();
101 - $this->wpstream_load_theme_notice();
96 +
97 +
98 + $this->wpstream_conection();
99 + $this->wpstream_player();
102 100
103 - $this->wpstream_conection();
104 - $this->wpstream_player();
105 - $this->wpstream_init_quota_manager();
106 -
107 101 }
108 102
109 -
110 -
111 -
112 -
103 +
104 +
105 +
106 +
113 107 public function wpstream_convert_band($megabits){
114 - $gigabit = $megabits * 0.001;
115 - return floatval( sprintf( '%.1f', $gigabit ) );
108 + $gigabit = $megabits * 0.001;
109 + $gigabit = number_format($gigabit,2);
110 + return $gigabit;
116 111 }
117 112
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 -
129 - return floatval( sprintf( '%.' . $decimals . 'f', floor( (float) $value * $factor ) / $factor ) );
130 - }
131 -
132 -
133 - public $wpstream_ajax;
134 -
135 - private function define_ajax_hooks() {
136 - require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wpstream-ajax.php';
137 - $this->wpstream_ajax = new WpStream_Ajax( $this->main );
138 - }
139 113
140 114
115 +
116 +
141 117 private function wpstream_conection(){
142 118 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-live-api-connection.php';
143 119 $this->wpstream_live_connection = new Wpstream_Live_Api_Connection();
144 - $this->user_quota_service = $this->wpstream_live_connection->get_user_quota_service();
145 120 }
146 121
147 122
148 123 private function wpstream_player(){
@@ -148,26 +123,12 @@
148 123 private function wpstream_player(){
149 124 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-player.php';
150 125 $this->wpstream_player = new Wpstream_Player($this->main);
151 126 }
152 -
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 -
158 -
159 - private function wpstream_load_page_templates() {
160 - require_once WPSTREAM_PLUGIN_PATH . 'includes/class-wpstream-templates.php';
161 - new WpStream_Template_Loader();
162 - }
163 -
164 - private function wpstream_load_theme_notice() {
165 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-theme-notice.php';
166 - new WPStream_Theme_Notice();
167 - }
168 127
169 128
129 +
130 +
170 131 /**
171 132 * Load the required dependencies for this plugin.
172 133 *
173 134 * Include the following files that make up the plugin:
@@ -206,21 +167,19 @@
206 167 * The class responsible for defining all actions that occur in the public-facing
207 168 * side of the site.
208 169 */
209 170 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpstream-public.php';
210 - /**
171 +
172 + /**
211 173 * The class responsible for custom post type
212 174
213 - */
214 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream_product.php';
215 - if( class_exists( 'WooCommerce' ) ){
216 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php';
217 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php';
218 - }
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 + }
219 181
220 - require_once plugin_dir_path(__FILE__) . 'Helpers/class-wpstream-log-entry.php';
221 - require_once plugin_dir_path(__FILE__) . 'Logger/class-wpstream-logger.php';
222 -
223 182 $this->loader = new Wpstream_Loader();
224 183
225 184 }
226 185
@@ -236,9 +195,9 @@
236 195 private function set_locale() {
237 196
238 197 $plugin_i18n = new Wpstream_i18n();
239 198
240 - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain', 1 );
199 + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
241 200
242 201 }
243 202
244 203 /**
@@ -249,26 +208,24 @@
249 208 * @access private
250 209 */
251 210 private function define_admin_hooks() {
252 211
253 - $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
254 -
255 - $this->admin = $plugin_admin;
256 -
257 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
212 + $this->admin= $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
213 +
214 + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
258 215 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
259 216 $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999);
260 -
217 +
261 218 $plugin_post_types = new Wpstream_Product();
262 219 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
263 -
220 +
264 221 // save and render metaboxed
265 - $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wpstream_product_metaboxes' );
266 - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
267 - $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 );
268 -
269 -
270 -
222 + $this->loader->add_action( 'admin_init', $plugin_admin, 'add_wpstream_product_metaboxes' );
223 + $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 );
224 + $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 );
225 +
226 +
227 +
271 228 // make product virtual
272 229 $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 );
273 230
274 231
@@ -278,75 +235,73 @@
278 235
279 236 // on boarding actions
280 237 $this->loader->add_action('admin_footer',$plugin_admin, 'wpstream_admin_footer_onboarding');
281 238 $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel', $plugin_admin,'wpstream_on_board_create_channel' );
282 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' );
283 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' );
284 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' );
239 + $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' );
240 + $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' );
241 + $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' );
242 +
285 243
286 -
287 244 $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' );
288 245 $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 246
292 - // Register AJAX actions for multipart uploads
293 - $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
294 - $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
295 247
296 248 $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 249 $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
300 -// $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' );
250 +
301 251
302 252
303 - $this->loader->add_action( 'wp_ajax_wpstream_settings_tab_update_plugin', $plugin_admin, 'wpstream_settings_tab_update_plugin' );
304 -
253 +
305 254 // add and save category extra fields
306 255 $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
307 - $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
256 + $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
308 257 $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
309 258 $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
310 259
311 260 $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
312 - $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
261 + $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
313 262 $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
314 263 $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
315 264
316 265
317 266 $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
318 - $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
267 + $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
319 268 $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
320 269 $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
321 270
322 271
323 272 $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
324 - $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
273 + $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
325 274 $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
326 275 $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
327 276
328 277 $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
329 - $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
278 + $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
330 279 $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
331 280 $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
281 +
282 +
332 283
333 284
334 285 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
335 -
336 - $this->loader->add_action( 'init', $plugin_admin, 'wpstream_add_custom_wc_products' );
286 +
337 287 $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' );
338 - $this->loader->add_filter( 'woocommerce_product_class', $plugin_admin, 'wpstream_add_products_class', 10, 2 );
339 288 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
340 289 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
341 290 $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2);
342 291
343 - $this->loader->add_action( 'woocommerce_product_options_general_product_data', $plugin_admin, 'wpstream_add_custom_general_fields', 20 );
292 + $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
344 293 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
345 294 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
346 295 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
347 296 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
348 297 }
298 +
299 +
300 +
301 +
302 +
303 +
349 304 }
350 305
351 306
352 307
@@ -363,53 +318,39 @@
363 318
364 319 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
365 320
366 321 $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' );
322 + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
323 +
324 + $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
325 + $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
326 +
327 + //live stream action
328 + $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
329 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
330 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
331 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10);
332 + // woo action
333 +
334 + $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
335 + $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
336 + $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 );
337 + $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 );
338 +
339 + $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
340 + $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
341 + $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
342 +
371 343
372 - $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
373 - $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
374 -
375 - //live stream action
376 - $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
377 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
378 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
379 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10);
380 -
381 - // woo action
382 - $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
383 - $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
384 - $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 );
385 - $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 );
386 -
387 - $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
388 - $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
389 - $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
390 -
391 - $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
392 - $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
393 - $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes');
394 -
395 - $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
396 -
397 - $this->loader->add_filter( 'wpstream_search_template_item_post_type', $plugin_public, 'wpstream_search_template_add_item_post_type' );
398 - $this->loader->add_filter( 'wpstream_sidebar_id_by_post_type', $plugin_public, 'wpstream_sidebar_id_by_post_type' );
399 - $this->loader->add_filter( 'wpstream_header_search_values', $plugin_public, 'wpstream_header_search_values' );
400 - $this->loader->add_filter( 'wpstream_extend_category_archive_query_filter', $plugin_public, 'wpstream_extend_category_archive_query_filter_callback' );
401 - $this->loader->add_filter( 'wpstream_archives_lists_taxonomy_labels', $plugin_public, 'wpstream_archives_lists_taxonomy_labels_callback' );
402 - $this->loader->add_filter( 'wpstream_author_archive_list_taxonomy_labels', $plugin_public, 'wpstream_author_archive_list_taxonomy_labels_callback' );
403 - $this->loader->add_action( 'wpstream_vod_attached_to_channel', $plugin_public, 'wpstream_vod_attached_to_channel' );
404 - $this->loader->add_action( 'wpstream_additional_content_post_type', $plugin_public, 'wpstream_additional_content_post_type_callback' );
405 - $this->loader->add_action( 'wpstream_post_author_content_post_type_list', $plugin_public, 'wpstream_post_author_content_post_type_list_callback' );
406 - $this->loader->add_action( 'wpstream_author_content_simple_post_type_message', $plugin_public, 'wpstream_author_content_simple_post_type_message_callback', 10, 2 );
407 - $this->loader->add_action( 'wpstream_author_content_post_type_message', $plugin_public, 'wpstream_author_content_post_type_message_callback', 10, 2 );
408 - $this->loader->add_action( 'wpstream_show_sidebar_for_post_type', $plugin_public, 'wpstream_show_sidebar_for_post_type_callback', 10, 2 );
409 - $this->loader->add_action( 'wpstream_video_episodes_post_type', $plugin_public, 'wpstream_video_episodes_post_type_callback' );
410 - $this->loader->add_action( 'wpstream_video_past_broadcast_post_type', $plugin_public, 'wpstream_video_past_broadcast_post_type_callback' );
411 - $this->loader->add_action( 'wpstream_additional_content_post_type_label', $plugin_public, 'wpstream_additional_content_post_type_label_callback', 10, 2 );
344 + $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
345 + $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
346 + $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes');
347 +
348 +
349 + $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
350 +
351 +
352 +
412 353 }
413 354
414 355 /**
415 356 * Run the loader to execute all of the hooks with WordPress.
@@ -449,86 +390,28 @@
449 390 */
450 391 public function get_version() {
451 392 return $this->version;
452 393 }
453 -
454 - public function is_plugin_outdated(){
455 - $update_data = get_site_transient('update_plugins');
456 - $plugin_path = 'wpstream/wpstream.php';
457 -
458 - if (isset($update_data->response[$plugin_path])) {
459 - return true;
460 - }
461 -
462 - return false;
463 - }
464 -
465 -
394 +
395 +
466 396
467 397 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 - }
398 + if( isset($pack_details['available_data_mb']) && isset( $pack_details['available_storage_mb']) ){
399 + $wpstream_convert_band = $this->wpstream_convert_band($pack_details['available_data_mb']);
400 + if($wpstream_convert_band<0)$wpstream_convert_band=0;
401 +
402 + $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['available_storage_mb']);
403 + if($wpstream_convert_storage<0)$wpstream_convert_storage=0;
404 +
405 + print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.$wpstream_convert_band.' Gb</strong> '.__('available streaming data and','wpstream').' <strong>'.$wpstream_convert_storage.' Gb</strong> '.__('available recording storage','wpstream');
406 + print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">'.esc_html__('Upgrade Subscription','wpstream').'</a>';
407 + print '</div>';
408 + print'<input type="hidden" id="wpstream_band" value="'.$pack_details['available_data_mb'].'">';
409 + print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['available_storage_mb'].'">';
474 410
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 - }
411 + }
412 + }
479 413
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' ) . '.';
486 -
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 - }
498 -
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 414
532 415 /**
533 416 * help function for media list elementor widget
534 417 *
@@ -813,15 +696,9 @@
813 696
814 697
815 698
816 699 ob_start();
817 - ?>
818 - <div class="wpstream_insert_player_elementor_wrapper">
819 - <?php
820 - $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
821 - ?>
822 - </div>
823 - <?php
700 + $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
824 701 $return_string= ob_get_contents();
825 702 ob_end_clean();
826 703
827 704 return $return_string;
@@ -916,9 +793,9 @@
916 793 */
917 794
918 795 public function wpstream_check_user_can_stream(){
919 796 $current_user = wp_get_current_user();
920 -
797 +
921 798 if( !is_user_logged_in() ){
922 799 return false;
923 800 exit('user not logged in');
924 801 }
@@ -928,17 +805,14 @@
928 805 return true;
929 806 }
930 807
931 808 $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 ) ) {
809 + $user_role = $current_user->roles[0];
810 +
811 + if (is_array($extra_roles) && in_array($user_role, $extra_roles)){
938 812 return true;
939 813 }
940 -
814 +
941 815 if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){
942 816 return true;
943 817 }
944 818
@@ -966,27 +840,9 @@
966 840 $this->admin->wpstream_live_stream_unit( $item_id,$type );
967 841 }
968 842
969 843
970 - /**
971 - * Start Streaming wrapper for wpstream theme
972 - *
973 - * @since 3.7
974 - */
975 844
976 - public function wpstream_live_stream_unit_wrapper_for_theme($item_id,$type){
977 - $item_id = intval($item_id);
978 -
979 - if($item_id == 0){
980 - //retrive or create channel for front end streamers
981 - $item_id=$this->wpstream_retrive_front_end_channel();
982 - }
983 - print'<div class="wpstream_modal_background"></div>';
984 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
985 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
986 - </div>';
987 - $this->admin->wpstream_live_stream_unit_for_theme( $item_id,$type );
988 - }
989 845
990 846
991 847 /**
992 848 * retrive channel for front end streaming
@@ -1077,13 +933,6 @@
1077 933 wp_reset_query();
1078 934 wp_reset_postdata();
1079 935 return $the_id;
1080 936 }
1081 -
1082 - /**
1083 - * Cleanup old logs
1084 - */
1085 - public function cleanup_logs() {
1086 - $logger = new WPStream_Logger();
1087 - $logger->clear_old_logs();
1088 - }
937 +
1089 938 }