PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.1.8
WpStream – Live Streaming, Video on Demand, Pay Per View v3.1.8
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 +97 -779 4.133.1.8 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 -
88 - if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) {
89 - $this->version = WPSTREAM_PLUGIN_VERSION;
84 + $this->main = $this;
85 + if ( defined( 'WPSTREAM_VERSION' ) ) {
86 + $this->version = WPSTREAM_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 + $this->xtest = "this is test2";
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,112 +208,79 @@
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 );
212 + $this->admin= $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
254 213
255 - $this->admin = $plugin_admin;
256 -
257 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
258 - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
214 + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
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 - $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 -
271 -
272 -
273 - // make product virtual
274 - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 );
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 +
225 + // show streaming controls on sidebar
226 + $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta');
275 227
276 228
229 + $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
230 + $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
277 231
278 - // show streaming controls on sidebar
279 - $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta');
280 -
281 - // on boarding actions
282 - $this->loader->add_action('admin_footer',$plugin_admin, 'wpstream_admin_footer_onboarding');
283 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel', $plugin_admin,'wpstream_on_board_create_channel' );
284 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' );
285 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' );
286 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' );
287 -
288 -
289 - $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' );
290 - $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 -
294 - // Register AJAX actions for multipart uploads
295 - $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' );
296 - $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' );
297 -
298 - $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 - $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
302 -// $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' );
303 -
304 -
305 - $this->loader->add_action( 'wp_ajax_wpstream_settings_tab_update_plugin', $plugin_admin, 'wpstream_settings_tab_update_plugin' );
306 -
307 232 // add and save category extra fields
308 233 $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
309 - $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
234 + $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
310 235 $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
311 236 $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
312 237
313 238 $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
314 - $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
239 + $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
315 240 $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
316 241 $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
317 242
318 243
319 244 $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
320 - $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
245 + $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
321 246 $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
322 247 $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
323 248
324 249
325 250 $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
326 - $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
251 + $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
327 252 $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
328 253 $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
329 254
330 255 $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
331 - $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' );
256 + $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
332 257 $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
333 258 $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
259 +
260 +
334 261
335 262
336 263 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
337 -
338 - $this->loader->add_action( 'init', $plugin_admin, 'wpstream_add_custom_wc_products' );
264 +
339 265 $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' );
340 - $this->loader->add_filter( 'woocommerce_product_class', $plugin_admin, 'wpstream_add_products_class', 10, 2 );
341 266 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
342 267 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
343 - $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2);
344 268
345 - $this->loader->add_action( 'woocommerce_product_options_general_product_data', $plugin_admin, 'wpstream_add_custom_general_fields', 20 );
269 + $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
346 270 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
347 271 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
348 272 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
349 273 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
350 274 }
351 - }
275 +
276 +
277 +
278 +
352 279
353 280
281 + }
354 282
355 -
356 -
357 283 /**
358 284 * Register all of the hooks related to the public-facing functionality
359 285 * of the plugin.
360 286 *
@@ -365,53 +291,45 @@
365 291
366 292 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
367 293
368 294 $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' );
295 + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
296 +
297 + $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
298 + $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
299 +
300 + //live stream action
301 + $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
302 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
303 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
304 + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod');
305 + // woo action
306 +
307 + $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
308 + $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
309 +
310 + $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
311 + $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
312 + $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
313 +
373 314
374 - $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
375 - $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
315 + $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
316 + $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
376 317
377 - //live stream action
378 - $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
379 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
380 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
381 - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10);
382 -
383 - // woo action
384 - $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
385 - $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
386 - $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 );
387 - $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 );
388 -
389 - $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
390 - $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
391 - $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
392 -
393 - $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
394 - $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
395 - $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes');
396 -
397 - $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
398 -
399 - $this->loader->add_filter( 'wpstream_search_template_item_post_type', $plugin_public, 'wpstream_search_template_add_item_post_type' );
400 - $this->loader->add_filter( 'wpstream_sidebar_id_by_post_type', $plugin_public, 'wpstream_sidebar_id_by_post_type' );
401 - $this->loader->add_filter( 'wpstream_header_search_values', $plugin_public, 'wpstream_header_search_values' );
402 - $this->loader->add_filter( 'wpstream_extend_category_archive_query_filter', $plugin_public, 'wpstream_extend_category_archive_query_filter_callback' );
403 - $this->loader->add_filter( 'wpstream_archives_lists_taxonomy_labels', $plugin_public, 'wpstream_archives_lists_taxonomy_labels_callback' );
404 - $this->loader->add_filter( 'wpstream_author_archive_list_taxonomy_labels', $plugin_public, 'wpstream_author_archive_list_taxonomy_labels_callback' );
405 - $this->loader->add_action( 'wpstream_vod_attached_to_channel', $plugin_public, 'wpstream_vod_attached_to_channel' );
406 - $this->loader->add_action( 'wpstream_additional_content_post_type', $plugin_public, 'wpstream_additional_content_post_type_callback' );
407 - $this->loader->add_action( 'wpstream_post_author_content_post_type_list', $plugin_public, 'wpstream_post_author_content_post_type_list_callback' );
408 - $this->loader->add_action( 'wpstream_author_content_simple_post_type_message', $plugin_public, 'wpstream_author_content_simple_post_type_message_callback', 10, 2 );
409 - $this->loader->add_action( 'wpstream_author_content_post_type_message', $plugin_public, 'wpstream_author_content_post_type_message_callback', 10, 2 );
410 - $this->loader->add_action( 'wpstream_show_sidebar_for_post_type', $plugin_public, 'wpstream_show_sidebar_for_post_type_callback', 10, 2 );
411 - $this->loader->add_action( 'wpstream_video_episodes_post_type', $plugin_public, 'wpstream_video_episodes_post_type_callback' );
412 - $this->loader->add_action( 'wpstream_video_past_broadcast_post_type', $plugin_public, 'wpstream_video_past_broadcast_post_type_callback' );
413 - $this->loader->add_action( 'wpstream_additional_content_post_type_label', $plugin_public, 'wpstream_additional_content_post_type_label_callback', 10, 2 );
318 +// // rewrite urls
319 +// $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_tag', 10, 0);
320 +// $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_rule', 10, 0);
321 +//
322 +// $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_userkey_page_template' );
323 +// $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_vodkey_page_template' );
324 +
325 + //api
326 +
327 +
328 + $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
329 +
330 +
331 +
414 332 }
415 333
416 334 /**
417 335 * Run the loader to execute all of the hooks with WordPress.
@@ -451,347 +369,20 @@
451 369 */
452 370 public function get_version() {
453 371 return $this->version;
454 372 }
455 -
456 - public function is_plugin_outdated(){
457 - $update_data = get_site_transient('update_plugins');
458 - $plugin_path = 'wpstream/wpstream.php';
459 -
460 - if (isset($update_data->response[$plugin_path])) {
461 - return true;
462 - }
463 -
464 - return false;
465 - }
466 -
467 -
468 -
469 - 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 - }
476 -
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 - }
481 -
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' ) . '.';
488 -
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 - }
500 -
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 373
534 - /**
535 - * help function for media list elementor widget
536 - *
537 - * @since 3.0.1
538 - * @return string
539 - */
540 374
541 - public function wpstream_media_list_elementor_function($attributes, $content = null){
542 -
543 -
544 - $media_number=3;
545 - if ( isset($attributes['media_number']) ){
546 - $media_number=$attributes['media_number'];
547 - }
548 -
549 -
550 - $row_number=3;
551 - if ( isset($attributes['row_number']) ){
552 - $row_number=$attributes['row_number'];
553 - }
554 - if($row_number>4){
555 - $row_number=4;
556 - }
557 -
558 -
559 - ob_start();
560 -
561 - // check if is vod or live stream
562 - $meta_query = array();
563 - $tax_query_array= array();
564 - $tax_query = array();
565 -
566 - // check if the media is paid or free
567 - $event_types = array();
568 - $product_type_free_paid = 0;
569 - if ( isset($attributes['product_type_free_paid']) ){
570 - $product_type_free_paid=$attributes['product_type_free_paid'];
571 -
572 - if($product_type_free_paid==0){
573 - $event_types=array('wpstream_product');
574 -
575 - if ( isset($attributes['product_type']) && intval($attributes['product_type'])==2){
576 - $event_types=array('wpstream_product_vod');
577 - }
578 -
579 - }else{
580 - $event_types=array('product');
581 - if ( isset($attributes['product_type']) ){
582 - $product_type = $attributes['product_type'];
583 - $product_type_slug = 'video_on_demand';
584 - if($product_type==1){
585 - $product_type_slug ='live_stream';
586 - }
587 -
588 - $tax_query_array = array(
589 - 'taxonomy' => 'product_type',
590 - 'field' => 'slug',
591 - 'terms' => $product_type_slug
592 - );
593 -
594 - $tax_query= array(
595 - 'relation' => 'AND',
596 - $tax_query_array
597 - );
598 -
599 - }
600 - }
601 -
602 - }
603 - $see_product='';
604 - if(isset($attributes['free_label'])){
605 - $see_product=$attributes['free_label'];
606 - }
607 -
608 - // pagination
609 - $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
610 - if( is_front_page() ){
611 - $paged= (get_query_var('page')) ? get_query_var('page') : 1;
612 - }
613 -
614 -
615 - //order
616 - $orderby='ID';
617 - $order ='ASC';
618 - if ( isset($attributes['order_by']) ){
619 - $order_by=intval($attributes['order_by']);
620 - switch ($order_by) {
621 - case 0:
622 - $orderby='ID';
623 - $order ='ASC';
624 - break;
625 - case 1:
626 - $orderby='ID';
627 - $order ='DESC';
628 - break;
629 - case 2:
630 - $orderby='title';
631 - $order ='ASC';
632 - break;
633 - case 3:
634 - $orderby='title';
635 - $order ='DESC';
636 - break;
637 - }
638 - }
639 -
640 - // building wp_query arg array
641 - $args = array(
642 - 'post_type' => $event_types,
643 - 'post_status' => 'publish',
644 - 'meta_query' => $meta_query,
645 - 'posts_per_page' => $media_number,
646 - 'paged' => $paged,
647 - 'orderby' => $orderby,
648 - 'order' => $order,
649 - 'tax_query' => $tax_query
650 - );
651 -
652 -
653 -
654 - // show live events
655 - if ( isset($attributes['product_show_live']) && $attributes['product_show_live']=='yes'){
656 - $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user_for_shortcode('shortcode');
657 375
658 -
659 - if( is_array($live_event_for_user) ){
660 - $live_event_for_user[]=0;
661 -
662 - $args['post__in']=$live_event_for_user;
663 - }
664 - }
665 -
666 -
667 -
376 + public function show_user_data($pack_details){
377 + if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
378 + print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.$this->wpstream_convert_band($pack_details['band']).' Gb</strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.$this->wpstream_convert_band($pack_details['storage']).' Gb</strong> '.__('available media storage','wpstream').'.</div>';
379 + print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
380 + print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
668 381
669 - $media_list= new WP_Query($args);
670 - if($media_list->have_posts()){
671 - print '<ul class="wpstream_media_list_wrapper products columns-'.esc_attr($row_number).'" >';
672 - while($media_list->have_posts()):$media_list->the_post();
673 - if($product_type_free_paid==0 ){
674 -
675 - $thumb=wp_get_attachment_image_src(get_post_thumbnail_id(),'medium');
676 -
677 - $thumb_src='';
678 - if( isset($thumb[0]) ){
679 - $thumb_src=$thumb[0];
680 - }
681 -
682 - if(($thumb_src)==''){
683 - $thumb_src= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_300.png';
684 - }
685 - print '<li class="wpstream_product_unit">'
686 - .'<a href="'.get_permalink().'" class="product_title" ><div class="product_image" style="background-image:url('.esc_url($thumb_src).')"></div></a>'
687 - .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>';
688 -
689 - if($see_product!=''){
690 - print '<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>';
691 - }
692 - print '</li>';
693 - }else{
694 - wc_get_template_part( 'content', 'product' );
695 - }
696 - endwhile;
697 - print '</ul>';
698 - }else{
699 - print esc_html__('No media found! ','wpstream');
700 - }
701 -
702 -
703 - wp_reset_query();
704 - wp_reset_postdata();
705 -
706 - $this->wpstream_pagination($media_list->max_num_pages,$range=2);
707 - $return_string= ob_get_contents();
708 - ob_end_clean();
709 -
710 - return $return_string;
711 - }
712 -
713 -
714 -
715 -
716 -
717 -
718 - /*
719 - *
720 - *
721 - * Pagination for media lista
722 - *
723 - *
724 - *
725 - */
726 -
727 -
728 -
729 -
730 - function wpstream_pagination($pages = '', $range = 2){
731 -
732 - $showitems = ($range * 2)+1;
733 - global $paged;
734 - if(empty($paged)) $paged = 1;
735 -
736 -
737 - if($pages == ''){
738 - global $wp_query;
739 - $pages = $wp_query->max_num_pages;
740 - if(!$pages)
741 - {
742 - $pages = 1;
743 382 }
744 383 }
745 384
746 - if(1 != $pages){
747 - print '<ul class="wpstream_pagination ">';
748 - print '<li class="roundleft"><a href="'.get_pagenum_link($paged - 1).'"> < </a></li>';
749 -
750 - for ($i=1; $i <= $pages; $i++)
751 - {
752 - if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
753 - {
754 - if ($paged == $i){
755 - print '<li class="active"><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>';
756 - }else{
757 - print '<li><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>';
758 - }
759 - }
760 - }
761 -
762 - $prev_page= get_pagenum_link($paged + 1);
763 - if ( ($paged +1) > $pages){
764 - $prev_page= get_pagenum_link($paged );
765 - }else{
766 - $prev_page= get_pagenum_link($paged + 1);
767 - }
768 -
769 -
770 - print '<li class="roundright"><a href="'.$prev_page.'"> > </a><li>';
771 - print '</ul>';
772 - }
773 - }
774 -
775 -
776 -
777 -
778 -
779 -
780 -
781 -
782 -
783 -
784 -
785 -
786 -
787 - /**
788 - * help function for player elementr widget
789 - *
790 - * @since 3.0.1
791 - * @return string
792 - */
793 -
794 385 public function wpstream_insert_player_elementor($attributes, $content = null){
795 386 $product_id = '';
796 387 $return_string = '';
797 388 $attributes = shortcode_atts(
@@ -796,9 +387,8 @@
796 387 $return_string = '';
797 388 $attributes = shortcode_atts(
798 389 array(
799 390 'id' => 0,
800 - 'user_id' => 0,
801 391 ), $attributes) ;
802 392
803 393
804 394 if ( isset($attributes['id']) ){
@@ -803,65 +393,11 @@
803 393
804 394 if ( isset($attributes['id']) ){
805 395 $product_id=$attributes['id'];
806 396 }
807 - if ( isset($attributes['user_id']) ){
808 - $user_id = intval( $attributes['user_id'] );
809 - }
810 -
811 - if(intval($product_id)==0 && $user_id!=0 ){
812 - $product_id= $this->wpstream_player_retrive_first_id($user_id);
813 - }
814 -
815 -
816 -
817 -
818 - ob_start();
819 - ?>
820 - <div class="wpstream_insert_player_elementor_wrapper">
821 - <?php
822 - $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
823 - ?>
824 - </div>
825 - <?php
826 - $return_string= ob_get_contents();
827 - ob_end_clean();
828 397
829 - return $return_string;
830 - }
831 -
832 - /**
833 - * help function for player low latency elementor widget
834 - *
835 - * @since 3.0.1
836 - * @return string
837 - */
838 -
839 - public function wpstream_insert_player__low_latency_elementor($attributes, $content = null){
840 - $product_id = '';
841 - $return_string = '';
842 - $attributes = shortcode_atts(
843 - array(
844 - 'id' => 0,
845 - 'user_id' => 0,
846 - ), $attributes) ;
847 -
848 -
849 - if ( isset($attributes['id']) ){
850 - $product_id=$attributes['id'];
851 - }
852 -
853 - if ( isset($attributes['user_id']) ){
854 - $user_id = intval( $attributes['user_id'] );
855 - }
856 -
857 - if(intval($product_id)==0 && $user_id!=0){
858 - $product_id= $this->wpstream_player_retrive_first_id($user_id);
859 - }
860 -
861 -
862 398 ob_start();
863 - $this->main->wpstream_player->wpstream_video_player_shortcode_low_latency($product_id);
399 + $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
864 400 $return_string= ob_get_contents();
865 401 ob_end_clean();
866 402
867 403 return $return_string;
@@ -868,224 +404,6 @@
868 404 }
869 405
870 406
871 407
872 - public function wpstream_player_retrive_first_id($received_user_id=''){
873 - $channel_type = get_option ('wpstream_user_streaming_channel_type');
874 - $product_id = $this->wpstream_get_current_event_per_author($received_user_id,$channel_type);
875 - return $product_id;
876 - }
877 -
878 -
879 -
880 - /**
881 - * help function for chat elementor widget
882 - *
883 - * @since 3.0.1
884 - * @return string
885 - */
886 -
887 - public function wpstream_insert_chat_elementor($attributes, $content = null){
888 - $product_id = '';
889 - $return_string = '';
890 - $attributes = shortcode_atts(
891 - array(
892 - 'id' => 0,
893 - ), $attributes) ;
894 408
895 -
896 - if ( isset($attributes['id']) ){
897 - $product_id=$attributes['id'];
898 - }
899 -
900 - $return_string.= '<div class="wpstream_plugin_chat_wrapper">';
901 - ob_start();
902 - $this->main->wpstream_player->wpstream_chat_wrapper($product_id);
903 - $return_string.= ob_get_contents();
904 - ob_end_clean();
905 - $return_string.='</div>';
906 - $this->main->wpstream_player->wpstream_connect_to_chat($product_id);
907 -
908 - return $return_string;
909 - }
910 -
911 -
912 - /**
913 - * edited 4.0
914 - *
915 - * Check if user is allowed to stream
916 - *
917 - * @since 3.7
918 - */
919 -
920 - public function wpstream_check_user_can_stream(){
921 - $current_user = wp_get_current_user();
922 -
923 - if( !is_user_logged_in() ){
924 - return false;
925 - exit('user not logged in');
926 - }
927 -
928 - if(current_user_can('administrator')){
929 - // admins can always brodcast
930 - return true;
931 - }
932 -
933 - $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 ) ) {
940 - return true;
941 - }
942 -
943 - if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){
944 - return true;
945 - }
946 -
947 - return false;
948 - }
949 -
950 -
951 - /**
952 - * Start Streaming wrapper
953 - *
954 - * @since 3.7
955 - */
956 -
957 - public function wpstream_live_stream_unit_wrapper($item_id,$type){
958 - $item_id = intval($item_id);
959 -
960 - if($item_id == 0){
961 - //retrive or create channel for front end streamers
962 - $item_id=$this->wpstream_retrive_front_end_channel();
963 - }
964 - print'<div class="wpstream_modal_background"></div>';
965 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
966 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
967 - </div>';
968 - $this->admin->wpstream_live_stream_unit( $item_id,$type );
969 - }
970 -
971 -
972 - /**
973 - * Start Streaming wrapper for wpstream theme
974 - *
975 - * @since 3.7
976 - */
977 -
978 - public function wpstream_live_stream_unit_wrapper_for_theme($item_id,$type){
979 - $item_id = intval($item_id);
980 -
981 - if($item_id == 0){
982 - //retrive or create channel for front end streamers
983 - $item_id=$this->wpstream_retrive_front_end_channel();
984 - }
985 - print'<div class="wpstream_modal_background"></div>';
986 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
987 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
988 - </div>';
989 - $this->admin->wpstream_live_stream_unit_for_theme( $item_id,$type );
990 - }
991 -
992 -
993 - /**
994 - * retrive channel for front end streaming
995 - *
996 - * @since 3.7
997 - */
998 - public function wpstream_retrive_front_end_channel(){
999 -
1000 - $current_user = wp_get_current_user();
1001 - $channel_type = get_option ('wpstream_user_streaming_channel_type');
1002 - $channel_price = floatval( get_option ('wpstream_user_streaming_default_price') );
1003 -
1004 - $front_end_streamin_channel = $this->wpstream_get_current_event_per_author($current_user->ID,$channel_type);
1005 -
1006 - if(intval($front_end_streamin_channel) == 0){
1007 - $front_end_streamin_channel= $this->wpstrea_create_front_end_event($current_user->ID,$current_user->user_login ,$channel_type,$channel_price);
1008 - }
1009 - return $front_end_streamin_channel;
1010 -
1011 - }
1012 -
1013 - /**
1014 - * create the event from front end
1015 - *
1016 - * @since 3.7
1017 - */
1018 -
1019 - public function wpstrea_create_front_end_event($userID,$userLogin,$channel_type,$channel_price){
1020 -
1021 - if( !$this->wpstream_check_user_can_stream() ){
1022 - return;
1023 - }
1024 -
1025 - $post_type='wpstream_product';
1026 - if($channel_type=='paid'){
1027 - $post_type='product';
1028 - }
1029 -
1030 - $post = array(
1031 - 'post_title' => sprintf( esc_html__('%s Channel','wpstream'),$userLogin),
1032 - 'post_content' => '',
1033 - 'post_type' => $post_type ,
1034 - 'post_author' => $userID,
1035 - 'post_status' => 'publish',
1036 - );
1037 - $post_id = wp_insert_post($post );
1038 - if($channel_type=='paid'){
1039 - $product = wc_get_product($post_id);
1040 - $price = wc_format_decimal($channel_price);
1041 -
1042 - $product = wc_get_product( $post_id );
1043 - // Set the product active price (regular)
1044 - $product->set_price( $price );
1045 - $product->set_regular_price( $price ); // To be sure
1046 - $product->save();
1047 - update_post_meta ($post_id,'event_passed',0);
1048 - wp_set_object_terms( $post_id, 'live_stream', 'product_type' );
1049 - }
1050 - update_post_meta($post_id,'wpstream_product_type',1);
1051 -
1052 - return $post_id;
1053 - }
1054 -
1055 -
1056 - public function wpstream_get_current_event_per_author($userID,$channel_type){
1057 -
1058 - $post_type='wpstream_product';
1059 - if($channel_type=='paid'){
1060 - $post_type='product';
1061 - }
1062 -
1063 - $args = array(
1064 -
1065 - 'post_type' => $post_type,
1066 - 'author' => $userID,
1067 - 'posts_per_page' => 1,
1068 - 'fields' => 'ids'
1069 - )
1070 - ;
1071 - $author_posts = new WP_Query( $args );
1072 - if( $author_posts->have_posts() ) {
1073 - $author_posts->the_post();
1074 - $the_id= get_the_ID();
1075 - }else{
1076 - $the_id= 0;
1077 - }
1078 -
1079 - wp_reset_query();
1080 - wp_reset_postdata();
1081 - return $the_id;
1082 - }
1083 -
1084 - /**
1085 - * Cleanup old logs
1086 - */
1087 - public function cleanup_logs() {
1088 - $logger = new WPStream_Logger();
1089 - $logger->clear_old_logs();
1090 - }
1091 409 }