PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 1.2
WpStream – Live Streaming, Video on Demand, Pay Per View v1.2
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
← All changes | wpstream.php +298 -95 4.51.2 View file →
@@ -1,21 +1,20 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: WpStream - Live Streaming, Video on Demand, Pay Per View
4 - * Plugin URI: http://wpstream.net
5 - * Description: WpStream is a platform that allows you to live stream, create Video-on-Demand, and offer Pay-Per-View videos. We provide an affordable and user-friendly way for businesses, non-profits, and public institutions to broadcast their content and monetize their work.
6 - * Version: 4.5
7 - * Author: wpstream
8 - * Author URI: http://wpstream.net
9 - * Text Domain: wpstream
10 - * Domain Path: /languages
3 + * Plugin Name: WpStream
4 + * Plugin URI: wpstream.net
5 + * Description: WpStream is a wordpress plugin to help you stream & monetize media content.
6 + * Version: 1.2
7 + * Author: wpstream.net
8 + * Author URI: https://wpstream.net
9 + * Developer: WpStream
10 + * Developer URI: https://wpstream.net
11 + * Text Domain: wpstream
12 + * Domain Path: /languages
13 + * * Copyright: © 2017 WpStream
11 14 */
12 15
13 -// If this file is called directly, abort.
14 -if ( ! defined( 'WPINC' ) ) {
15 - die;
16 -}
17 -define('WPSTREAM_PLUGIN_VERSION', '4.4.20.12');
16 +
18 17 define('WPSTREAM_CLUBLINK', 'wpstream.net');
19 18 define('WPSTREAM_CLUBLINKSSL', 'https');
20 19 define('WPSTREAM_PLUGIN_URL', plugins_url() );
21 20 define('WPSTREAM_PLUGIN_DIR_URL', plugin_dir_url(__FILE__) );
@@ -20,125 +19,329 @@
20 19 define('WPSTREAM_PLUGIN_URL', plugins_url() );
21 20 define('WPSTREAM_PLUGIN_DIR_URL', plugin_dir_url(__FILE__) );
22 21 define('WPSTREAM_PLUGIN_PATH', plugin_dir_path(__FILE__) );
23 22 define('WPSTREAM_PLUGIN_BASE', plugin_basename(__FILE__) );
24 -define('WPSTREAM_API', 'https://baker.wpstream.net');
25 23
24 +require_once ('main.php');
25 +require_once ('libs/api_functions.php');
26 +require_once ('libs/plugin-admin.php');
27 +require_once ('libs/product_types.php');
28 +require_once ('libs/wpstream_free_product_types.php');
29 +require_once ('libs/shortcodes.php');
26 30
27 31
28 32
33 +function wpstream_install(){
34 + flush_rewrite_rules();
35 +}
29 36
30 -/**
31 - * The code that runs during plugin activation.
32 - * This action is documented in includes/class-wpstream-activator.php
33 - */
34 -function activate_wpstream() {
35 - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpstream-activator.php';
36 - Wpstream_Activator::activate();
37 +register_activation_hook( __FILE__, 'wpstream_install' );
38 +
39 +
40 +
41 +
42 +function wpstream_deactivation(){
43 + delete_option('wp_estate_token_expire');
44 + delete_option('wp_estate_curent_token');
45 + delete_option('wpstream_api_key');
46 + delete_option('wpstream_api_secret_key');
47 + delete_option('wpstream_api_username');
48 + delete_option('wpstream_api_password');
49 +
50 + flush_rewrite_rules();
37 51 }
52 +register_deactivation_hook( __FILE__, 'wpstream_deactivation' );
38 53
39 -/**
40 - * The code that runs during plugin deactivation.
41 - * This action is documented in includes/class-wpstream-deactivator.php
42 - */
43 -function deactivate_wpstream() {
44 - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpstream-deactivator.php';
45 - Wpstream_Deactivator::deactivate();
54 +
55 +wpstream_main_start();
56 +
57 +
58 +
59 +function wpstream_admin_notice(){
60 + if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
61 + print '<div class="notice notice-error is-dismissible">
62 + <p>'.__( 'WpStream Pay Per View / Subscription mode works only with WooCommerce - If you want to charge money for your live events or videos you need to activate WooCommerce plugin', 'wpestate' ).'</p>
63 + </div>';
64 + }
46 65 }
66 +add_action( 'admin_notices', 'wpstream_admin_notice' );
47 67
48 -register_activation_hook( __FILE__, 'activate_wpstream' );
49 -register_deactivation_hook( __FILE__, 'deactivate_wpstream' );
50 68
51 -/**
52 - * The core plugin class that is used to define internationalization,
53 - * admin-specific hooks, and public-facing site hooks.
54 - */
55 -require plugin_dir_path( __FILE__ ) . 'includes/class-wpstream.php';
56 -require plugin_dir_path( __FILE__ ) . 'wpstream-elementor.php';
57 69
70 +function wpstream_enqueue_styles() {
71 + wp_enqueue_style('wpstream-style', WPSTREAM_PLUGIN_DIR_URL .'/wpstream_style.css' );
72 + wp_enqueue_style('video-js.min', WPSTREAM_PLUGIN_DIR_URL.'/css/video-js.min.css', array(), '1.0', 'all');
73 + wp_enqueue_script('video.min', WPSTREAM_PLUGIN_DIR_URL.'js/video.min.js',array(), '1.0', false);
74 + wp_enqueue_script('video.min', WPSTREAM_PLUGIN_DIR_URL.'js/video.min.js',array(), '1.0', false);
75 + wp_enqueue_script('videojs-contrib-hls', WPSTREAM_PLUGIN_DIR_URL.'js/videojs-contrib-hls.min.js',array(), '1.0', false);
76 +}
58 77
59 -require plugin_dir_path( __FILE__ ) . 'integrations/integrations.php';
60 78
61 -/**
62 - * Begins execution of the plugin.
63 - *
64 - * Since everything within the plugin is registered via hooks,
65 - * then kicking off the plugin from this point in the file does
66 - * not affect the page life cycle.
67 - *
68 - * @since 3.0.1
69 - */
70 79
71 -global $wpstream_plugin;
72 -$wpstream_plugin = new Wpstream();
73 -$wpstream_plugin->run();
74 80
75 -add_action( 'upgrader_process_complete', 'wpstream_my_upgrate_function',10, 2);
81 +function wpstream_enqueue_styles_admin(){
82 + wp_enqueue_script("jquery-ui-slider");
83 + wp_enqueue_script("jquery-ui-datepicker");
84 + wp_enqueue_style ('admin-css', WPSTREAM_PLUGIN_DIR_URL.'/css/admin_style.css', array(), '1.0', 'all');
85 + wp_enqueue_script('wpstream-admin-control', WPSTREAM_PLUGIN_DIR_URL.'js/admin_control.js',array(), '1.0', true);
86 + wp_localize_script('wpstream-admin-control', 'admin_control_vars',
87 + array(
88 + 'admin_url' => get_admin_url()
89 + ));
90 +}
76 91
77 -function wpstream_my_upgrate_function( $upgrader_object, $options ) {
78 92
79 -
80 - $current_plugin_path_name = plugin_basename( __FILE__ );
81 -
82 - if ($options['action'] == 'update' && $options['type'] == 'plugin' ) {
83 - if(is_array($options)):
84 - foreach($options['plugins'] as $each_plugin) {
85 - if ($each_plugin==$current_plugin_path_name) {
86 - delete_transient('wpstream_token_api');
87 - update_option('wp_estate_token_expire',0);
88 - update_option('wp_estate_curent_token',' ');
89 93
90 - }
94 +
95 +
96 +function wpstream_my_custom_endpoints() {
97 + add_rewrite_endpoint( 'video-list', EP_ROOT | EP_PAGES );
98 + add_rewrite_endpoint( 'event-list', EP_ROOT | EP_PAGES );
99 +}
100 +
101 +
102 +
103 +function wpstream_my_custom_query_vars( $vars ) {
104 + $vars[] = 'video-list';
105 + $vars[] = 'event-list';
106 + return $vars;
107 +}
108 +
109 +
110 +
111 +function wpstream_custom_flush_rewrite_rules() {
112 + flush_rewrite_rules();
113 +}
114 +
115 +
116 +
117 +function wpstream_custom_my_account_menu_items( $items ) {
118 + $items = array(
119 + 'dashboard' => __( 'Dashboard', 'woocommerce' ),
120 + 'orders' => __( 'Orders', 'woocommerce' ),
121 + 'edit-address' => __( 'Addresses', 'woocommerce' ),
122 + 'edit-account' => __( 'Edit Account', 'woocommerce' ),
123 + 'event-list' => __( 'Events', 'wpstream' ),
124 + 'video-list' => __( 'Videos', 'wpstream' ),
125 + 'customer-logout' => __( 'Logout', 'woocommerce' ),
126 + );
127 + return $items;
128 +}
129 +
130 +
131 +function wpstream_custom_endpoint_content_event_list() {
132 + include 'woocommerce/myaccount/event_list.php';
133 +}
134 +
135 +
136 +
137 +function wpstream_custom_endpoint_video_list() {
138 + include 'woocommerce/myaccount/video_list.php';
139 +}
140 +
141 +
142 +
143 +
144 +function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
145 +
146 + if ( is_user_logged_in() ) {
147 + global $product;
148 + $current_user = wp_get_current_user();
149 + $product_id = $product->get_id();
150 +
151 +
152 + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) || ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
153 +
154 +
155 + echo '<div class="wpstream_player_wrapper"><div class="wpstream_player_container">';
156 +
157 + $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
158 + $term_list = wp_get_post_terms($product_id, 'product_type');
159 +
160 + if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
161 + wpstream_live_event_player($product_id);
162 + }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
163 + wpstream_video_on_demand_player($product_id);
91 164 }
92 - endif;
165 +
166 + }else{
167 + echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
168 + echo '<div class="wpstream_notice">'.__('You did not buy this product!','wpstream').'</div>';
169 + }
170 +
171 + echo '</div></div>';
93 172 }
94 -
95 -
96 173 }
97 174
98 175
176 +function wpstream_live_event_player($product_id){
177 + $live_event_uri = get_post_meta($product_id,'live_event_uri',true);
178 + $thumb_id = get_post_thumbnail_id($product_id);
179 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
180 + $live_event_uri_final='';
181 + if(isset($live_event_uri) ){
182 + $live_event_uri_aray = explode('/wpstream/', $live_event_uri);
183 + $part1 = str_replace('rtmp', 'https',$live_event_uri_aray[0]);
184 + $part2_array = explode('?auth=', $live_event_uri_aray[1]);
185 + $live_event_uri_final = $part1.'/hls/'.$part2_array[0].'.m3u8';
186 + }
187 + echo'<video id="wpstream-video" class="video-js vjs-default-skin vjs-16-9" controls>
188 + <source
189 + src="'.$live_event_uri_final.'"
190 + type="application/x-mpegURL">
191 + </video>
99 192
100 -add_action('wp_head', 'wpstream_add_custom_meta_to_header');
193 + <script>
194 + var player = videojs(\'wpstream-video\');
195 + player.play();
196 + </script>';
101 197
102 -function wpstream_add_custom_meta_to_header(){
103 - global $post;
198 +}
104 199
105 200
106 - if ( is_singular('product') || is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
107 - $image_id = get_post_thumbnail_id();
108 - $share_img = wp_get_attachment_image_src( $image_id, 'full');
109 - $the_post = get_post($post->ID); ?>
110 201
111 - <meta property='og:title' content="<?php print esc_html(get_the_title($post->ID)); ?>"/>
112 - <?php if(isset($share_img[0])){ ?>
113 - <meta property="og:image" content="<?php print esc_url($share_img[0]); ?>"/>
114 - <meta property="og:image:secure_url" content="<?php print esc_url($share_img[0]); ?>" />
115 - <?php }?>
116 -
117 - <meta property="og:description" content=" <?php print wp_strip_all_tags( $the_post->post_content);?>" />
118 - <?php }
202 +function wpstream_video_on_demand_player($product_id){
203 + $thumb_id = get_post_thumbnail_id($product_id);
204 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
205 + $video_path = get_post_meta($product_id,'_movie_url',true);
119 206
207 + if(get_post_type($product_id)=='wpstream_product'){
208 + $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true));
209 + }
120 210
211 +
212 + $username = esc_html ( get_option('wpstream_api_username','') );
213 +
214 + if(strpos($username,'@')!=false){
215 + $username_array= explode('@', $username);
216 + $username=$username_array[0];
217 + }
218 +
219 + $video_path_final = 'https://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
220 + if(!is_ssl()){
221 + $video_path_final = 'http://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
222 + }
223 +
224 + echo'<video id="my-video" class="video-js vjs-default-skin vjs-16-9" controls preload="auto"
225 + poster="'.$thumb[0].'" data-setup="{}">
226 +
227 + <source src="'.trim($video_path_final).'" type="application/x-mpegURL">
228 + <p class="vjs-no-js">
229 + To view this video please enable JavaScript, and consider upgrading to a web browser that
230 + <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
231 + </p>
232 + </video>';
233 +
121 234 }
122 235
123 236
124 -/*
125 -*
126 -* Check integrations
127 -*
128 -*/
129 -add_action( 'plugins_loaded', 'wpstream_check_integrations' );
130 237
238 +add_filter('display_post_states', 'wpstream_custom_post_states',10,2);
131 239
132 -/*
133 -*
134 -* Redirect on plugin activation
135 -*
136 -*/
240 +function wpstream_custom_post_states( $states, $post ) {
241 + $title =strtolower( get_the_title($post->ID));
242 + if ( ( 'page' == get_post_type( $post->ID ) ) && ( $title ==='userkey' || $title ==='vodkey' || $title ==='wpstream' )) {
243 + $states[] = __('by WpStream - do not delete','wpstream');
244 + }
137 245
138 -function wpstream_activation_redirect( $plugin ) {
139 - if( $plugin == plugin_basename( __FILE__ ) ) {
140 - exit( wp_redirect( admin_url( 'admin.php?page=wpstream_onboard' ) ) );
246 + return $states;
247 +}
248 +
249 +
250 +
251 +
252 +
253 +
254 +function wpstream_custom_rewrite_tag() {
255 + add_rewrite_tag('%streamname%', '([^&]+)');
256 + add_rewrite_tag('%streamname2%', '([^&]+)');
257 + add_rewrite_tag('%variety%', '([^&]+)');
258 + add_rewrite_tag('%userkey%', '([^&]+)');
259 + add_rewrite_tag('%streamvod%', '([^&]+)');
260 +}
261 +add_action('init', 'wpstream_custom_rewrite_tag', 10, 0);
262 +
263 +
264 +
265 +function wpstream_custom_rewrite_rule() {
266 + $page = get_page_by_title( 'WpStream' );
267 + $page_user_key = get_page_by_title( 'Userkey' );
268 + $page_vod_key = get_page_by_title( 'Vodkey' );
269 +
270 +
271 + if( isset($page->ID) ){
272 + add_rewrite_rule('^keys/([^/]*/?)','index.php?page_id='.$page->ID.'&streamname=$matches[1]','top');
141 273 }
274 +
275 + if( isset($page_vod_key->ID) ){ // is wod-key=page-template
276 + add_rewrite_rule('^keys1/([^/]*)/([^/]*)/?','index.php?page_id='.$page_vod_key->ID.'&streamname=$matches[1]&streamname2=$matches[2]','top');
277 + }
278 +
279 + if( isset($page_user_key->ID) ){//us user-key-page-temaplte
280 + add_rewrite_rule('^keys2/([^/]*)/([^/]*)/?','index.php?page_id='.$page_user_key->ID.'&streamname=$matches[1]&streamname2=$matches[2]','top');
281 + }
282 +
283 + flush_rewrite_rules();
284 +
142 285 }
143 -add_action( 'activated_plugin', 'wpstream_activation_redirect' );
286 +add_action('init', 'wpstream_custom_rewrite_rule', 10, 0);
287 +
288 +
289 +
290 +
291 +
292 +function wpstream_live_page_template( $page_template ){
293 + if ( is_page( 'wpstream' ) ) {
294 + $page_template = dirname( __FILE__ ) . '/live_stream_checker.php';
295 + }
296 + return $page_template;
297 +}
298 +add_filter( 'page_template', 'wpstream_live_page_template' );
299 +
300 +
301 +
302 +
303 +function wpstream_userkey_page_template( $page_template ){
304 + if ( is_page( 'Userkey' ) ) {
305 + $page_template = dirname( __FILE__ ) . '/user-key-page-template.php';
306 + }
307 + return $page_template;
308 +}
309 +add_filter( 'page_template', 'wpstream_userkey_page_template' );
310 +
311 +
312 +
313 +
314 +
315 +function wpstream_vodkey_page_template( $page_template ){
316 + if ( is_page( 'vodkey' ) ) {
317 + $page_template = dirname( __FILE__ ) . '/vod-key-page-template.php';
318 + }
319 + return $page_template;
320 +}
321 +add_filter( 'page_template', 'wpstream_vodkey_page_template' );
322 +
323 +
324 +
325 +function wpstream_remove_gallery_and_product_images() {
326 + if ( is_product() ) {
327 + remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
328 + }
329 +}
330 +
331 +
332 +
333 +
334 +function wpstream_cors_check_and_response(){
335 + if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
336 + header('Access-Control-Allow-Methods: POST, GET');
337 + header('Access-Control-Allow-Headers: Authorization');
338 + header('Access-Control-Max-Age: 1'); //1728000
339 + header("Content-Length: 0");
340 + header("Content-Type: text/plain charset=UTF-8");
341 + exit(0);
342 + }
343 +}
344 +
345 +add_action('wo_before_api', 'wpstream_cors_check_and_response');
346 +
144 347