PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.3
WpStream – Live Streaming, Video on Demand, Pay Per View v3.3
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 4.5.12 All 180 releases
wpstream / includes / class-wpstream.php

class-wpstream.php in WpStream – Live Streaming, Video on Demand, Pay Per View 3.3, at includes/class-wpstream.php

454 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link http://wpstream.net
10 * @since 3.0.1
11 *
12 * @package Wpstream
13 * @subpackage Wpstream/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 3.0.1
26 * @package Wpstream
27 * @subpackage Wpstream/includes
28 * @author wpstream <office@wpstream.net>
29 */
30 class Wpstream {
31
32 /**
33 * Store plugin main class to allow public access.
34 *
35 * @since 3.0.1
36 * @var object The main class.
37 */
38 public $main;
39
40 /**
41 * The loader that's responsible for maintaining and registering all hooks that power
42 * the plugin.
43 *
44 * @since 3.0.1
45 * @access protected
46 * @var Wpstream_Loader $loader Maintains and registers all hooks for the plugin.
47 */
48 protected $loader;
49
50 /**
51 * The unique identifier of this plugin.
52 *
53 * @since 3.0.1
54 * @access protected
55 * @var string $plugin_name The string used to uniquely identify this plugin.
56 */
57 protected $plugin_name;
58
59 /**
60 * The current version of the plugin.
61 *
62 * @since 3.0.1
63 * @access protected
64 * @var string $version The current version of the plugin.
65 */
66 protected $version;
67
68 /**
69 * Define the core functionality of the plugin.
70 *
71 * Set the plugin name and the plugin version that can be used throughout the plugin.
72 * Load the dependencies, define the locale, and set the hooks for the admin area and
73 * the public-facing side of the site.
74 *
75 * @since 3.0.1
76 */
77
78 public $wpstream_live_connection;
79 public $wpstream_player;
80 public $xtest;
81 public $plugin_admin;
82
83 public function __construct() {
84 $this->main = $this;
85 if ( defined( 'WPSTREAM_VERSION' ) ) {
86 $this->version = WPSTREAM_VERSION;
87 } else {
88 $this->version = '3.0.1';
89 }
90 $this->plugin_name = 'wpstream';
91
92 $this->load_dependencies();
93 $this->set_locale();
94 $this->define_admin_hooks();
95 $this->define_public_hooks();
96
97 $this->xtest = "this is test2";
98 $this->wpstream_conection();
99 $this->wpstream_player();
100
101 }
102
103
104
105
106
107 public function wpstream_convert_band($megabits){
108 $gigabit = $megabits * 0.001;
109 $gigabit = number_format($gigabit,2);
110 return $gigabit;
111 }
112
113
114
115
116
117 private function wpstream_conection(){
118 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-live-api-connection.php';
119 $this->wpstream_live_connection = new Wpstream_Live_Api_Connection();
120 }
121
122
123 private function wpstream_player(){
124 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-player.php';
125 $this->wpstream_player = new Wpstream_Player($this->main);
126 }
127
128
129
130
131 /**
132 * Load the required dependencies for this plugin.
133 *
134 * Include the following files that make up the plugin:
135 *
136 * - Wpstream_Loader. Orchestrates the hooks of the plugin.
137 * - Wpstream_i18n. Defines internationalization functionality.
138 * - Wpstream_Admin. Defines all hooks for the admin area.
139 * - Wpstream_Public. Defines all hooks for the public side of the site.
140 *
141 * Create an instance of the loader which will be used to register the hooks
142 * with WordPress.
143 *
144 * @since 3.0.1
145 * @access private
146 */
147 private function load_dependencies() {
148
149 /**
150 * The class responsible for orchestrating the actions and filters of the
151 * core plugin.
152 */
153 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-loader.php';
154
155 /**
156 * The class responsible for defining internationalization functionality
157 * of the plugin.
158 */
159 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-i18n.php';
160
161 /**
162 * The class responsible for defining all actions that occur in the admin area.
163 */
164 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpstream-admin.php';
165
166 /**
167 * The class responsible for defining all actions that occur in the public-facing
168 * side of the site.
169 */
170 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpstream-public.php';
171
172 /**
173 * The class responsible for custom post type
174
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 }
181
182 $this->loader = new Wpstream_Loader();
183
184 }
185
186 /**
187 * Define the locale for this plugin for internationalization.
188 *
189 * Uses the Wpstream_i18n class in order to set the domain and to register the hook
190 * with WordPress.
191 *
192 * @since 3.0.1
193 * @access private
194 */
195 private function set_locale() {
196
197 $plugin_i18n = new Wpstream_i18n();
198
199 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
200
201 }
202
203 /**
204 * Register all of the hooks related to the admin area functionality
205 * of the plugin.
206 *
207 * @since 3.0.1
208 * @access private
209 */
210 private function define_admin_hooks() {
211
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' );
215 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
216 $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999);
217
218 $plugin_post_types = new Wpstream_Product();
219 $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 );
220
221 // save and render metaboxed
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');
227
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' );
231
232 // add and save category extra fields
233 $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
234 $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
235 $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
236 $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
237
238 $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
239 $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
240 $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
241 $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
242
243
244 $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
245 $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
246 $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
247 $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
248
249
250 $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
251 $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
252 $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
253 $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
254
255 $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
256 $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
257 $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
258 $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
259
260
261
262
263 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
264
265 $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' );
266 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
267 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
268
269 $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
270 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
271 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
272 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
273 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
274 }
275
276
277
278
279
280
281 }
282
283 /**
284 * Register all of the hooks related to the public-facing functionality
285 * of the plugin.
286 *
287 * @since 3.0.1
288 * @access private
289 */
290 private function define_public_hooks() {
291
292 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
293
294 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
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
314
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');
317
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
332 }
333
334 /**
335 * Run the loader to execute all of the hooks with WordPress.
336 *
337 * @since 3.0.1
338 */
339 public function run() {
340 $this->loader->run();
341 }
342
343 /**
344 * The name of the plugin used to uniquely identify it within the context of
345 * WordPress and to define internationalization functionality.
346 *
347 * @since 3.0.1
348 * @return string The name of the plugin.
349 */
350 public function get_plugin_name() {
351 return $this->plugin_name;
352 }
353
354 /**
355 * The reference to the class that orchestrates the hooks with the plugin.
356 *
357 * @since 3.0.1
358 * @return Wpstream_Loader Orchestrates the hooks of the plugin.
359 */
360 public function get_loader() {
361 return $this->loader;
362 }
363
364 /**
365 * Retrieve the version number of the plugin.
366 *
367 * @since 3.0.1
368 * @return string The version number of the plugin.
369 */
370 public function get_version() {
371 return $this->version;
372 }
373
374
375
376 public function show_user_data($pack_details){
377 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
378 $wpstream_convert_band = $this->wpstream_convert_band($pack_details['band']);
379 if($wpstream_convert_band<0)$wpstream_convert_band=0;
380
381 $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['storage']);
382 if($wpstream_convert_storage<0)$wpstream_convert_storage=0;
383
384 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>';
385 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
386 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
387
388 }
389 }
390
391
392 /**
393 * help function for player elementr widget
394 *
395 * @since 3.0.1
396 * @return string
397 */
398
399 public function wpstream_insert_player_elementor($attributes, $content = null){
400 $product_id = '';
401 $return_string = '';
402 $attributes = shortcode_atts(
403 array(
404 'id' => 0,
405 ), $attributes) ;
406
407
408 if ( isset($attributes['id']) ){
409 $product_id=$attributes['id'];
410 }
411
412 ob_start();
413 $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
414 $return_string= ob_get_contents();
415 ob_end_clean();
416
417 return $return_string;
418 }
419
420
421 /**
422 * help function for chat elementor widget
423 *
424 * @since 3.0.1
425 * @return string
426 */
427
428 public function wpstream_insert_chat_elementor($attributes, $content = null){
429 $product_id = '';
430 $return_string = '';
431 $attributes = shortcode_atts(
432 array(
433 'id' => 0,
434 ), $attributes) ;
435
436
437 if ( isset($attributes['id']) ){
438 $product_id=$attributes['id'];
439 }
440
441 $return_string.= '<div class="wpstream_plugin_chat_wrapper">';
442 ob_start();
443 $this->main->wpstream_player->wpstream_chat_wrapper($product_id);
444 $return_string.= ob_get_contents();
445 ob_end_clean();
446 $return_string.='</div>';
447 $this->main->wpstream_player->wpstream_connect_to_chat($product_id);
448
449 return $return_string;
450 }
451
452
453 }
454