'.__( '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' ).'

'; } if( !in_array ('curl', get_loaded_extensions())) { print '

'.__( 'The php CURL library is not enabled on your server. WpStream plugin needs this library in order to work. Please address this issue with your hosting provider.', 'wpestate' ).'

'; } } add_action( 'admin_notices', 'wpstream_admin_notice' ); function wpstream_enqueue_styles() { wp_enqueue_style('wpstream-style', WPSTREAM_PLUGIN_DIR_URL .'/wpstream_style.css' ); wp_enqueue_style('video-js.min', WPSTREAM_PLUGIN_DIR_URL.'/css/video-js.min.css', array(), '1.0', 'all'); wp_enqueue_script('video.min', WPSTREAM_PLUGIN_DIR_URL.'js/video.min.js',array(), '1.0', false); wp_enqueue_script('videojs-contrib-hls', WPSTREAM_PLUGIN_DIR_URL.'js/videojs-contrib-hls.min.js',array('video.min'), '1.0', false); wp_enqueue_script('youtube.min', WPSTREAM_PLUGIN_DIR_URL.'js/youtube.min.js',array('video.min'), '1.0', false); wp_enqueue_script('videojs-vimeo.min', WPSTREAM_PLUGIN_DIR_URL.'js/videojs-vimeo.min.js',array('video.min'), '1.0', false); } function wpstream_enqueue_styles_admin(){ wp_enqueue_script("jquery-ui-slider"); wp_enqueue_script("jquery-ui-datepicker"); wp_enqueue_script('wpstream-jquery.fileupload', WPSTREAM_PLUGIN_DIR_URL.'js/jquery.fileupload.js',array(), '1.0', true); wp_enqueue_style ('admin-css', WPSTREAM_PLUGIN_DIR_URL.'/css/admin_style.css', array(), '1.0', 'all'); wp_enqueue_script('wpstream-admin-control', WPSTREAM_PLUGIN_DIR_URL.'js/admin_control.js',array(), '1.0', true); wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars', array( 'admin_url' => get_admin_url(), 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif', 'download_mess' => esc_html__('Click to download! The url will work for the next 20 minutes! Refresh page if you need to generate the link again!','wpstream'), 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'), 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'), 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'), 'upload_complete' => esc_html('Upload Complete!','wpstream'), 'no_band' => esc_html('Not enough bandwidth.','wpsteam'), 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam') )); } function wpstream_my_custom_endpoints() { add_rewrite_endpoint( 'video-list', EP_ROOT | EP_PAGES ); add_rewrite_endpoint( 'event-list', EP_ROOT | EP_PAGES ); } function wpstream_my_custom_query_vars( $vars ) { $vars[] = 'video-list'; $vars[] = 'event-list'; return $vars; } function wpstream_custom_flush_rewrite_rules() { flush_rewrite_rules(); } function wpstream_custom_my_account_menu_items( $items ) { if(function_exists('wpstream_is_global_subscription') && wpstream_is_global_subscription()){ $items = array( 'dashboard' => __( 'Dashboard', 'woocommerce' ), 'orders' => __( 'Orders', 'woocommerce' ), 'edit-address' => __( 'Addresses', 'woocommerce' ), 'edit-account' => __( 'Edit Account', 'woocommerce' ), 'customer-logout' => __( 'Logout', 'woocommerce' ), ); }else{ $items = array( 'dashboard' => __( 'Dashboard', 'woocommerce' ), 'orders' => __( 'Orders', 'woocommerce' ), 'edit-address' => __( 'Addresses', 'woocommerce' ), 'edit-account' => __( 'Edit Account', 'woocommerce' ), 'event-list' => __( 'Events', 'wpstream' ), 'video-list' => __( 'Videos', 'wpstream' ), 'customer-logout' => __( 'Logout', 'woocommerce' ), ); } return $items; } function wpstream_custom_endpoint_content_event_list() { include 'woocommerce/myaccount/event_list.php'; } function wpstream_custom_endpoint_video_list() { include 'woocommerce/myaccount/video_list.php'; } function wpstream_user_logged_in_product_already_bought($from_sh_id='') { if ( is_user_logged_in() ) { global $product; $current_user = wp_get_current_user(); $product_id = $product->get_id(); 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') ) ){ echo '
'; $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true)); $term_list = wp_get_post_terms($product_id, 'product_type'); if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){ wpstream_live_event_player($product_id); }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){ wpstream_video_on_demand_player($product_id); } }else{ echo '
'; echo '
'.__('You did not buy this product!','wpstream').'
'; } echo '
'; } } function wpstream_live_event_player($product_id){ $live_event_uri = get_post_meta($product_id,'live_event_uri',true); $thumb_id = get_post_thumbnail_id($product_id); $thumb = wp_get_attachment_image_src($thumb_id,'small'); $live_event_uri_final=''; if(isset($live_event_uri) ){ $live_event_uri_aray = explode('/wpstream/', $live_event_uri); $part1 = str_replace('rtmp', 'https',$live_event_uri_aray[0]); if(isset($live_event_uri_aray[1])){ $part2_array = explode('?auth=', $live_event_uri_aray[1]); $live_event_uri_final = $part1.'/hls/'.$part2_array[0].'.m3u8'; } } $now=time().rand(0,10); echo' '; } function wpstream_video_on_demand_player($product_id){ $thumb_id = get_post_thumbnail_id($product_id); $thumb = wp_get_attachment_image_src($thumb_id,'small'); $wpstream_data_setup= ' data-setup="{}" '; $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true)); if($free_video_type==2 || get_post_type($product_id)=='product' ){ $video_type = 'application/x-mpegURL'; $video_path = get_post_meta($product_id,'_movie_url',true); if(get_post_type($product_id)=='wpstream_product'){ $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true)); } $username = esc_html ( get_option('wpstream_api_username','') ); if (filter_var($username, FILTER_VALIDATE_EMAIL)) { $username = wpstream_retrive_username(); } if(strpos($username,'@')!=false){ $username_array= explode('@', $username); $username=$username_array[0]; } $video_path_final = 'https://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url(); if(!is_ssl()){ $video_path_final = 'http://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url(); } }else if($free_video_type==3){ $video_type = 'video/mp4'; $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true)); if (strpos($video_path_final, 'www.youtube') !== false) { $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "'.$video_path_final.'"}] }\' '; $video_path_final=''; } if (strpos($video_path_final, 'vimeo.com') !== false) { $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["vimeo"], "sources": [{ "type": "video/vimeo", "src": "'.$video_path_final.'"}], "vimeo": { "color": "#fbc51b"} }\' '; $video_path_final=''; } } echo ''; } add_filter('display_post_states', 'wpstream_custom_post_states',10,2); function wpstream_custom_post_states( $states, $post ) { $title =strtolower( get_the_title($post->ID)); if ( ( 'page' == get_post_type( $post->ID ) ) && ( $title ==='userkey' || $title ==='vodkey' || $title ==='wpstream' )) { $states[] = __('by WpStream - do not delete','wpstream'); } return $states; } function wpstream_custom_rewrite_tag() { add_rewrite_tag('%streamname%', '([^&]+)'); add_rewrite_tag('%streamname2%', '([^&]+)'); add_rewrite_tag('%variety%', '([^&]+)'); add_rewrite_tag('%userkey%', '([^&]+)'); add_rewrite_tag('%streamvod%', '([^&]+)'); } add_action('init', 'wpstream_custom_rewrite_tag', 10, 0); function wpstream_custom_rewrite_rule() { $page = get_page_by_title( 'WpStream' ); $page_user_key = get_page_by_title( 'Userkey' ); $page_vod_key = get_page_by_title( 'Vodkey' ); if( isset($page->ID) ){ add_rewrite_rule('^keys/([^/]*/?)','index.php?page_id='.$page->ID.'&streamname=$matches[1]','top'); } if( isset($page_vod_key->ID) ){ // is wod-key=page-template add_rewrite_rule('^keys1/([^/]*)/([^/]*)/?','index.php?page_id='.$page_vod_key->ID.'&streamname=$matches[1]&streamname2=$matches[2]','top'); } if( isset($page_user_key->ID) ){//us user-key-page-temaplte add_rewrite_rule('^keys2/([^/]*)/([^/]*)/?','index.php?page_id='.$page_user_key->ID.'&streamname=$matches[1]&streamname2=$matches[2]','top'); } flush_rewrite_rules(); } add_action('init', 'wpstream_custom_rewrite_rule', 10, 0); function wpstream_live_page_template( $page_template ){ if ( is_page( 'wpstream' ) ) { $page_template = dirname( __FILE__ ) . '/live_stream_checker.php'; } return $page_template; } add_filter( 'page_template', 'wpstream_live_page_template' ); function wpstream_userkey_page_template( $page_template ){ if ( is_page( 'Userkey' ) ) { $page_template = dirname( __FILE__ ) . '/user-key-page-template.php'; } return $page_template; } add_filter( 'page_template', 'wpstream_userkey_page_template' ); function wpstream_vodkey_page_template( $page_template ){ if ( is_page( 'vodkey' ) ) { $page_template = dirname( __FILE__ ) . '/vod-key-page-template.php'; } return $page_template; } add_filter( 'page_template', 'wpstream_vodkey_page_template' ); function wpstream_remove_gallery_and_product_images() { if ( is_product() ) { remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); } } function wpstream_cors_check_and_response(){ if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") { header('Access-Control-Allow-Methods: POST, GET'); header('Access-Control-Allow-Headers: Authorization'); header('Access-Control-Max-Age: 1'); //1728000 header("Content-Length: 0"); header("Content-Type: text/plain charset=UTF-8"); exit(0); } } add_action('wo_before_api', 'wpstream_cors_check_and_response'); add_action('add_meta_boxes', 'wpstream_startstreaming_sidebar_meta'); if( !function_exists('wpstream_startstreaming_sidebar_meta') ): function wpstream_startstreaming_sidebar_meta() { global $post; $term_list = wp_get_post_terms($post->ID, 'product_type'); if( get_post_meta($post->ID, 'wpstream_product_type', true)==1 ){ add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), 'wpstream_start_stream_meta', 'wpstream_product', 'side', 'high'); } if(!is_wp_error( $term_list )){ if( isset($term_list[0]->name) ){ if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){ add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), 'wpstream_start_stream_meta', 'product', 'side', 'high'); } } } } endif; function wpstream_start_stream_meta(){ global $live_event_for_user; global $post; $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" ); print ''; $live_event_for_user = wpstream_get_live_event_for_user(); wpstream_live_stream_unit($post->ID); }