*/ class Wpstream_Public { /** * Store plugin main class to allow public access. * * @since 20180622 * @var object The main class. */ public $main; /** * The ID of this plugin. * * @since 3.0.1 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 3.0.1 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 3.0.1 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ,$plugin_main) { $this->main = $plugin_main; $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the public-facing side of the site. * * @since 3.0.1 */ public function enqueue_styles() { wp_enqueue_style('wpstream-style', plugin_dir_url( __FILE__ ) .'/css/wpstream_style.css',array(), WPSTREAM_PLUGIN_VERSION, 'all' ); wp_enqueue_style('video-js.min', plugin_dir_url( __FILE__ ).'/css/video-js.min.css', array(), WPSTREAM_PLUGIN_VERSION, 'all'); wp_enqueue_style('videojs-wpstream-player', plugin_dir_url( __FILE__ ).'/css/videojs-wpstream.css', array(), WPSTREAM_PLUGIN_VERSION, 'all'); } /** * Register the JavaScript for the public-facing side of the site. * * @since 3.0.1 */ public function enqueue_scripts() { wp_enqueue_script('jquery'); wp_enqueue_script('video.min', 'https://vjs.zencdn.net/7.17.0/video.min.js', WPSTREAM_PLUGIN_VERSION, false); wp_enqueue_script('youtube.min', plugin_dir_url( __FILE__ ).'js/youtube.min.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, false); wp_enqueue_script('videojs-vimeo.min', plugin_dir_url( __FILE__ ).'js/videojs-vimeo.min.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, false); wp_enqueue_script('wpstream-player', plugin_dir_url( __FILE__ ).'js/wpstream-player.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, false); wp_enqueue_script('sldp-v2.12.1.min', plugin_dir_url( __FILE__ ).'js/sldp-v2.12.1.min.js',array(), WPSTREAM_PLUGIN_VERSION, false); wp_localize_script('wpstream-player', 'wpstream_player_vars', array( 'admin_url' => get_admin_url(), 'chat_not_connected' => esc_html__('Inactive Channel - Chat is disabled.','wpstream'), 'server_up' => esc_html__('The live stream is paused and may resume shortly.','wpstream') ) ); wp_enqueue_script( 'jquery-ui-autocomplete' ); wp_enqueue_script( "jquery-effects-core"); wp_register_script( 'sockjs-0.3.min', plugin_dir_url( __FILE__ ) . '/chat_lib/sockjs-0.3.min.js', array('jquery'), true ); wp_register_script( 'emojione.min.js',plugin_dir_url( __FILE__ ). '/chat_lib/emojione.min.js', array('jquery'), true ); wp_register_script( 'jquery.linkify.min.js', plugin_dir_url( __FILE__ ). '/chat_lib/jquery.linkify.min.js', array('jquery'), true ); wp_register_script( 'ripples.min.js',plugin_dir_url( __FILE__ ). '/chat_lib/ripples.min.js', array('jquery'), true ); wp_register_script( 'material.min.js"', plugin_dir_url( __FILE__ ). '/chat_lib/material.min.js', array('jquery'), true ); wp_register_script( 'chat.js', plugin_dir_url( __FILE__ ). '/chat_lib/chat.js', array('jquery'), true ); wp_localize_script('chat.js', 'chat-js-vars', array( 'we_are_not_live' => esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment. Please check back later.')), )); wp_register_style( 'chat.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/chat.css', array(), '1.0', 'all'); wp_register_style( 'ripples.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/ripples.css', array(), '1.0', 'all'); wp_register_style( 'emojione.min.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/emojione.min.css', array(), '1.0', 'all'); wp_enqueue_script('wpstream-start-streaming', plugin_dir_url( __FILE__ ) .'js/start_streaming.js',array(), WPSTREAM_PLUGIN_VERSION, true); wp_localize_script('wpstream-start-streaming', 'wpstream_start_streaming_vars', array( 'admin_url' => get_admin_url(), 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif', 'download_mess' => esc_html__('Click to download!','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'), 'upload_failed' => esc_html__('Upload Failed!','wpstream'), 'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'), 'no_band' => esc_html__('Not enough streaming data.','wpsteam'), 'no_band_no_store' => esc_html__('Not enough streaming data or storage.','wpsteam'), 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'), 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'), 'start_streaming' => esc_html__('TURN ON','wpstream'), 'stop_streaming' => esc_html__('TURN OFF','wpstream'), 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'), 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'), 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'), 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'), 'error1' => esc_html__('You don\'t have enough data to start a new event!','wpstream'), 'failed_event_creation' => esc_html__('Failed to start the channel. Please try again in a few minutes.','wpstream'), 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'), 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'), 'channel_on' => esc_html__('Channel is ON','wpstream'), 'channel_off' => esc_html__('Channel is OFF','wpstream'), 'turn_off_confirm' => esc_html__('Are you sure? '.PHP_EOL.' Channels turn OFF automatically after 1 hour of inactivity (no active broadcast). Manual TURN OFF is only useful if you require to change the channel settings.','wpstream'), 'turn_off_confirm' => esc_html__('ARE YOU SURE you\'d like to TURN OFF the channel now? '.PHP_EOL.PHP_EOL.'Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).'.PHP_EOL.PHP_EOL.'Manual TURN OFF is only useful if you require to change the channel settings immediately.'.PHP_EOL.PHP_EOL.'Statistics may be unavailable or incomplete for up to an hour.'.PHP_EOL.PHP_EOL.'If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.','wpstream') )); wp_enqueue_style( 'wpstream_front_style', plugin_dir_url( __DIR__ ) . 'admin/css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' ); } /** * add custom end points for woocomerce * * @since 3.0.1 * @return nothing */ public function wpstream_my_custom_endpoints() { add_rewrite_endpoint( 'video-list', EP_ROOT | EP_PAGES ); add_rewrite_endpoint( 'event-list', EP_ROOT | EP_PAGES ); } /** * add custom query vars * * @since 3.0.1 * @return nothing */ public function wpstream_my_custom_query_vars( $vars ) { $vars[] = 'video-list'; $vars[] = 'event-list'; return $vars; } /** * Hust flush rewrite rules * * @since 3.0.1 * */ public function wpstream_custom_flush_rewrite_rules() { flush_rewrite_rules(); } /** * Add new sections in woocomerce account * * @since 3.0.1 */ public 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; } /** * Add new endpoint * * @since 3.0.1 */ public function wpstream_custom_endpoint_content_event_list() { include plugin_dir_path( __DIR__ ).'woocommerce/myaccount/event_list.php'; } /** * Add new endpoint * * @since 3.0.1 */ public function wpstream_custom_endpoint_video_list() { include plugin_dir_path( __DIR__ ).'woocommerce/myaccount/video_list.php'; } /** * register shortcodes * * @since 3.0.1 * */ public function wpstream_shortcodes(){ add_shortcode('wpstream_player', array($this,'wpstream_insert_player_inpage_local') ); // add_shortcode('wpstream_list_products', array($this,'wpstream_list_products_function') ); add_shortcode('wpstream_chat', array($this,'wpstream_chat_function') ); add_shortcode('wpstream_player_low_latency', array($this,'wpstream_insert_player_inpage_low_latency') ); add_shortcode('wpstream_go_live', array($this,'wpstream_start_streaming_shortocde') ); add_shortcode('wpstream_list_media_channels', array($this,'wpstream_media_list_bakery_bypass') ); add_shortcode('wpstream_list_media_vod', array($this,'wpstream_media_list_bakery_vod_bypass') ); } /** * register shortcodes * * @since 3.0.1 * */ public function wpstream_bakery_shortcodes(){ // register shortcodes for visual composer if( function_exists('vc_map') ): vc_map( array( "name" => esc_html__( "WpStream Start Streaming Button","wpestate"), "base" => "wpstream_go_live", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( 'Insert WpStream Start Streaming Button','wpstream'), "params" => array( array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Product/Free Product Id","wpestate"), "param_name" => "id", "value" => "", "description" => esc_html__( "If you leave this option blank we will stream on the first free/paid channel for this user","wpestate") ), ) ) ); vc_map( array( "name" => esc_html__( "WpStream Chat - Beta Version","wpestate"), "base" => "wpstream_chat", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( 'Insert WpStream Chat','wpstream'), "params" => array( array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Live Stream Id","wpestate"), "param_name" => "id", "value" => "0", "description" => esc_html__( "Add here the live stream id","wpestate") ), ) ) ); vc_map( array( "name" => esc_html__( "WpStream Player","wpestate"), "base" => "wpstream_player", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( 'Insert WpStream Player','wpstream'), "params" => array( array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Product/Free Product Id","wpestate"), "param_name" => "id", "value" => "0", "description" => esc_html__( "Add here the live stream id or the video id","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "User Id","wpestate"), "param_name" => "user_id", "value" => "", "description" => esc_html__( "We will use the first channel of this user id(product id will be ignored.).","wpestate") ), ) ) ); vc_map( array( "name" => esc_html__( "WpStream Player - Low Latency - Private Beta / Requires Approval","wpestate"), "base" => "wpstream_player_low_latency", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( 'Insert WpStream Player','wpstream'), "params" => array( array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Product/Free Product Id","wpestate"), "param_name" => "id", "value" => "0", "description" => esc_html__( "Add here the live stream id or the video id","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "User Id","wpestate"), "param_name" => "user_id", "value" => "", "description" => esc_html__( "We will use the first channel of this user id(product id will be ignored.).","wpestate") ), ) ) ); $product_type=array( '0' => __('Both','wpstream'), '1' => __('Live Event','wpstream'), '2' => __('Video on demand','wpstream') ); vc_map( array( "name" => esc_html__( "WpStream Products List","wpestate"), "base" => "wpstream_list_products", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( ' List wpstream products','wpstream'), "params" => array( array( "type" => "dropdown", "holder" => "div", "class" => "", "heading" => esc_html__( "Media type","wpestate"), "param_name" => "product_type", "value" => $product_type, "description" => esc_html__( "What type of media(free/paid) ","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Media number","wpestate"), "param_name" => "media_number", "value" => "", "description" => esc_html__( "No of media ","wpestate") ), ) ) ); $free_paid_type=array( 0 => esc_html__('Free','wpstream'), 1 => esc_html__('Paid','wpstream') ); $live_settings=array( 'no'=>esc_html__('no','wpstream'), 'yes'=>esc_html__('yes','wpstream'), ); $order_by_id=array( 0=>esc_html('By date - ASC','wpstream'), 1=>esc_html('By date - DESC','wpstream'), 2=>esc_html('By title - ASC','wpstream'), 3=>esc_html('By title - DESC','wpstream'), ); vc_map( array( "name" => esc_html__( "WpStream Channel List","wpestate"), "base" => "wpstream_list_media_channels", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( ' List wpstream channels','wpstream'), "params" => array( array( "type" => "dropdown", "holder" => "div", "class" => "", "heading" => esc_html__( "Show Free or Paid Media ?","wpestate"), "param_name" => "product_type_free_paid", "value" => $free_paid_type, "description" => esc_html__( "What type of media(free/paid) ","wpestate") ), array( "type" => "dropdown", "holder" => "div", "class" => "", "heading" => esc_html__( "Only show active channels","wpestate"), "param_name" => "product_show_live", "value" => $live_settings, "description" => esc_html__( "Only show channels that are live streaming right now.","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Number of Items per Page","wpestate"), "param_name" => "media_number", "value" => "3", "description" => esc_html__( "How many items will be displayed per page","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Link Label for free items","wpestate"), "param_name" => "free_label", "value" => esc_html__('Watch now!','wpstream'), "description" => esc_html__( "Link Label for free items'","wpestate") ), array( "type" => "dropdown", "holder" => "div", "class" => "", "heading" => esc_html__( "Order by","wpestate"), "param_name" => "order_by", "value" => $order_by_id, "description" => esc_html__( "Order type","wpestate") ), ) ) ); vc_map( array( "name" => esc_html__( "WpStream VOD List","wpestate"), "base" => "wpstream_list_media_vod", "class" => "", "category" => esc_html__( 'WpStream','wpstream'), 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'), 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'), 'weight'=>100, 'icon' =>'', 'description'=>esc_html__( ' List wpstream video on demand','wpstream'), "params" => array( array( "type" => "dropdown", "holder" => "div", "class" => "", "heading" => esc_html__( "Show Free or Paid Media ?","wpestate"), "param_name" => "product_type_free_paid", "value" => $free_paid_type, "description" => esc_html__( "What type of media(free/paid) ","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Number of Items per Page","wpestate"), "param_name" => "media_number", "value" => "3", "description" => esc_html__( "How many items will be displayed per page","wpestate") ), array( "type" => "textfield", "holder" => "div", "class" => "", "heading" => esc_html__( "Link Label for free items","wpestate"), "param_name" => "free_label", "value" => esc_html__('Watch now!','wpstream'), "description" => esc_html__( "Link Label for free items'","wpestate") ), array( "type" => "dropdown", "holder" => "div", "class" => "", "heading" => esc_html__( "Order by","wpestate"), "param_name" => "order_by", "value" => $order_by_id, "description" => esc_html__( "Order type","wpestate") ), ) ) ); endif; // add shorcotes to editor interface if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) { return; } if (get_user_option('rich_editing') == 'true') { add_filter('mce_external_plugins', array( $this,'wpstream_add_plugin') ); add_filter('mce_buttons_2', array($this,'wpstream_register_button') ); } } /** * list channels - shortcode function * * @since 3.0.1 * */ public function wpstream_media_list_bakery_bypass($attributes){ $attributes = shortcode_atts( array( 'media_number' => 3, 'product_type_free_paid' => '0', 'product_show_live' => 'no', 'free_label' => '', 'order_by' => '0' ), $attributes) ; $attributes['product_type']=1; if( $attributes['product_type_free_paid']=='Paid'){ $attributes['product_type_free_paid']=1; } if( $attributes['product_type_free_paid']=='Free'){ $attributes['product_type_free_paid']=0; } if($attributes['order_by']==0){ $order_by_id=array( 0=>esc_html('By date - ASC','wpstream'), 1=>esc_html('By date - DESC','wpstream'), 2=>esc_html('By title - ASC','wpstream'), 3=>esc_html('By title - DESC','wpstream'), ); $attributes['order_by']= array_search($attributes['order_by'], $order_by_id); } global $wpstream_plugin; return $wpstream_plugin->wpstream_media_list_elementor_function( $attributes ); } /** * list vod - shortcode function * * @since 3.0.1 * */ public function wpstream_media_list_bakery_vod_bypass($attributes){ $attributes = shortcode_atts( array( 'media_number' => 3, 'product_type_free_paid' => '0', 'product_show_live' => 'no', 'free_label' => '', 'order_by' => '0' ), $attributes) ; $attributes['product_type']=2; if( $attributes['product_type_free_paid']=='Paid'){ $attributes['product_type_free_paid']=1; } if( $attributes['product_type_free_paid']=='Free'){ $attributes['product_type_free_paid']=0; } if($attributes['order_by']==0){ $order_by_id=array( 0=>esc_html('By date - ASC','wpstream'), 1=>esc_html('By date - DESC','wpstream'), 2=>esc_html('By title - ASC','wpstream'), 3=>esc_html('By title - DESC','wpstream'), ); $attributes['order_by']= array_search($attributes['order_by'], $order_by_id); } global $wpstream_plugin; return $wpstream_plugin->wpstream_media_list_elementor_function( $attributes ); } /** * shortocode player * * @since 3.0.1 * */ public function wpstream_chat_function($attributes, $content = null){ $product_id = ''; $return_string = ''; $attributes = shortcode_atts( array( 'id' => 0, ), $attributes) ; if ( isset($attributes['id']) ){ $product_id=$attributes['id']; } $return_string.= '