PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.5.3
WpStream – Live Streaming, Video on Demand, Pay Per View v3.5.3
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
wpstream / includes / class-wpstream.php

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

459 lines 18.5 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 // make product virtual
226 $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 );
227
228
229
230 // show streaming controls on sidebar
231 $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta');
232
233
234 $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' );
235 $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' );
236
237 // add and save category extra fields
238 $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
239 $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
240 $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
241 $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
242
243 $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
244 $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
245 $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
246 $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
247
248
249 $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
250 $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
251 $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
252 $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
253
254
255 $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
256 $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
257 $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
258 $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
259
260 $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2);
261 $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 );
262 $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
263 $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2);
264
265
266
267
268 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
269
270 $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' );
271 $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' );
272 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 );
273
274 $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1);
275 $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 );
276 $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
277 $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1);
278 $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 );
279 }
280
281
282
283
284
285
286 }
287
288 /**
289 * Register all of the hooks related to the public-facing functionality
290 * of the plugin.
291 *
292 * @since 3.0.1
293 * @access private
294 */
295 private function define_public_hooks() {
296
297 $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
298
299 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
300 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
301
302 $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' );
303 $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 );
304
305 //live stream action
306 $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0);
307 $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key');
308 $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty');
309 $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod');
310 // woo action
311
312 $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 );
313 $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 );
314
315 $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' );
316 $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' );
317 $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' );
318
319
320 $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' );
321 $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes');
322
323 // // rewrite urls
324 // $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_tag', 10, 0);
325 // $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_rule', 10, 0);
326 //
327 // $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_userkey_page_template' );
328 // $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_vodkey_page_template' );
329
330 //api
331
332
333 $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1);
334
335
336
337 }
338
339 /**
340 * Run the loader to execute all of the hooks with WordPress.
341 *
342 * @since 3.0.1
343 */
344 public function run() {
345 $this->loader->run();
346 }
347
348 /**
349 * The name of the plugin used to uniquely identify it within the context of
350 * WordPress and to define internationalization functionality.
351 *
352 * @since 3.0.1
353 * @return string The name of the plugin.
354 */
355 public function get_plugin_name() {
356 return $this->plugin_name;
357 }
358
359 /**
360 * The reference to the class that orchestrates the hooks with the plugin.
361 *
362 * @since 3.0.1
363 * @return Wpstream_Loader Orchestrates the hooks of the plugin.
364 */
365 public function get_loader() {
366 return $this->loader;
367 }
368
369 /**
370 * Retrieve the version number of the plugin.
371 *
372 * @since 3.0.1
373 * @return string The version number of the plugin.
374 */
375 public function get_version() {
376 return $this->version;
377 }
378
379
380
381 public function show_user_data($pack_details){
382 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
383 $wpstream_convert_band = $this->wpstream_convert_band($pack_details['band']);
384 if($wpstream_convert_band<0)$wpstream_convert_band=0;
385
386 $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['storage']);
387 if($wpstream_convert_storage<0)$wpstream_convert_storage=0;
388
389 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>';
390 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
391 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
392
393 }
394 }
395
396
397 /**
398 * help function for player elementr widget
399 *
400 * @since 3.0.1
401 * @return string
402 */
403
404 public function wpstream_insert_player_elementor($attributes, $content = null){
405 $product_id = '';
406 $return_string = '';
407 $attributes = shortcode_atts(
408 array(
409 'id' => 0,
410 ), $attributes) ;
411
412
413 if ( isset($attributes['id']) ){
414 $product_id=$attributes['id'];
415 }
416
417 ob_start();
418 $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
419 $return_string= ob_get_contents();
420 ob_end_clean();
421
422 return $return_string;
423 }
424
425
426 /**
427 * help function for chat elementor widget
428 *
429 * @since 3.0.1
430 * @return string
431 */
432
433 public function wpstream_insert_chat_elementor($attributes, $content = null){
434 $product_id = '';
435 $return_string = '';
436 $attributes = shortcode_atts(
437 array(
438 'id' => 0,
439 ), $attributes) ;
440
441
442 if ( isset($attributes['id']) ){
443 $product_id=$attributes['id'];
444 }
445
446 $return_string.= '<div class="wpstream_plugin_chat_wrapper">';
447 ob_start();
448 $this->main->wpstream_player->wpstream_chat_wrapper($product_id);
449 $return_string.= ob_get_contents();
450 ob_end_clean();
451 $return_string.='</div>';
452 $this->main->wpstream_player->wpstream_connect_to_chat($product_id);
453
454 return $return_string;
455 }
456
457
458 }
459