*/ class Wpstream_Admin { /** * 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 this plugin. * @param string $version The version of this plugin. */ public $global_event_options ; public function __construct( $plugin_name, $version,$plugin_main ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->main = $plugin_main; $this->global_event_options = array( 'record' =>array( 'name' => esc_html__('Record Live Stream','wpstream'), 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'), 'defaults' => 'no', ), 'view_count' =>array( 'name' => esc_html__('Display Viewer Count','wpstream'), 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'), 'defaults' => 'yes', ), 'domain_lock'=>array( 'name' => esc_html__('Lock To Website','wpstream'), 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ), 'defaults' => 'no', ), 'autoplay' =>array( 'name' => esc_html__('Autoplay','wpstream'), 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'), 'defaults' => 'yes', ), 'mute' =>array( 'name' => esc_html__('Start Muted','wpstream'), 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'), 'defaults' => 'no', ), 'low_latency' =>array( 'name' => esc_html__('Low Latency (beta)','wpstream'), 'details' => esc_html__('Shortens the live delay between streamer and viewers. Useful for interactive applications like gaming, auctions, trading etc. Low latency may worsen the viewer experience on some devices.','wpstream'), 'defaults' => 'no', ), 'adaptive_bitrate' =>array( 'name' => esc_html__('Adaptive Bitrate (beta)','wpstream'), 'details' => esc_html__('Ensures a smooth and uninterrupted viewing experience by adjusting video quality for viewers with reduced network speed or device capabilities.','wpstream'), 'defaults' => 'no', ), 'encrypt' =>array( 'name' => esc_html__('Encrypt Live Stream','wpstream'), 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'), 'defaults' => 'no', ), 'ses_encrypt'=>array( 'name' => esc_html__('Use Sessions with Encryption','wpstream'), 'details' => esc_html__('If enabled, encryption key distribution will be checked against valid user sessions. Setting may malfunction or lead to reduced website performance under certain configurations. ','wpstream'), 'defaults' => 'no', ), 'autostart' =>array( 'name' => esc_html__('Auto TURN ON','wpstream'), 'details' => esc_html__('If enabled, channel will TURN ON automatically when broadcasting with an External Streaming App (RTMP Encoder/Broadcaster)','wpstream'), 'defaults' => 'no', ), 'vod_domain_lock' =>array( 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'), 'details' => sprintf ( esc_html__('If enabled, VODS will only display on %1$s, otherwise they can show up on any website.','wpstream'),get_bloginfo('wpurl') ), 'defaults' => 'no', ), 'vod_encrypt' =>array( 'name' => esc_html__('Encrypt Video on Demand','wpstream'), 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'), 'defaults' => 'no', ), ); } /** * Register the stylesheets for the admin area. * * @since 3.0.1 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Wpstream_Loader as all of the hooks are defined * in that particular class. * * The Wpstream_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" ); wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' ); wp_enqueue_style( 'wpstream-on-boarding-css', plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css', array(), rand(1,999999999999), 'all' ); } /** * Register the JavaScript for the admin area. * * @since 3.0.1 */ public function enqueue_scripts() { wp_enqueue_script("jquery-ui-slider"); wp_enqueue_script("jquery-ui-datepicker"); wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, 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!','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 streaming data.','wpsteam'), 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam') )); wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); wp_localize_script('wpstream-start-streaming_admin', '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'), '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 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_script('wpstream-on-boarding-js', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars', array( 'admin_url' => get_admin_url(), 'plugin_url' => get_dashboard_url().'/plugins.php', 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings' )); } /** * Add Plugin Administation menu * * @since 3.0.1 */ public function wpstream_manage_admin_menu() { add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials'), WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png',20 ); add_submenu_page( 'wpstream_credentials', __('WpStream Credentials','wpestream'), __('Credentials','wpestream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials') ); add_submenu_page( 'wpstream_credentials', __('WpStream Live Channels','wpestream'), __('All Channels','wpestream'), 'administrator', 'wpstream_live_channels', array( $this,'wpstream_new_general_set')); add_submenu_page( 'wpstream_credentials', __('WpStream Recordings','wpestream'), __('Recordings','wpestream'), 'administrator', 'wpstream_recordings', array($this,'wpstream_media_management')); add_submenu_page( 'wpstream_credentials', __('WpStream Settings','wpestream'), __('Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings')); add_submenu_page( 'wpstream_credentials', __('WpStream Quick Start','wpestream'), __('WpStream Quick Start','wpestream'), 'administrator', 'wpstream_onboard', array($this,'wpstream_pre_onboard_display')); } /** * Shows events wpstream * * @since 3.0.1 */ public function wpstream_new_general_set() { $no_channel=1; if(class_exists ('WC_Subscription')){ } //event_passed $args = array( 'posts_per_page' => -1, 'post_type' => 'product', 'post_status' => 'publish', 'meta_query' => array( array( 'key' => 'event_passed', 'value' => 1, 'compare' => '!=', ) ), 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array('live_stream','subscription') ) ), ); $event_list = new WP_Query($args); global $live_event_for_user; $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user(); $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); $this->main->show_user_data($pack_details); if( $event_list->have_posts()){ print '

'.__('Your Pay-Per-View Channel List','wpstream').'

'; $link_new = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new'); print ''.esc_html__('Create new Pay-Per-View channel.','wpstream').''; print '
'; print '
'; while ($event_list->have_posts()): $event_list->the_post(); $the_id = get_the_ID(); $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true)); $term_list = wp_get_post_terms($the_id, 'product_type'); if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){ continue; } $this->wpstream_live_stream_unit($the_id); endwhile; print'
'; $no_channel=1; }else{ $no_channel=0; } $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" ); print ''; $current_user = wp_get_current_user(); $allowded_html = array(); $userID = $current_user->ID; $user_live_streams = get_user_meta($userID,'live_shows'); wp_reset_postdata(); // free $args_free = array( 'posts_per_page' => -1, 'post_type' => 'wpstream_product', 'post_status' => 'publish', ); $event_list_free = new WP_Query($args_free); if( $event_list_free->have_posts()){ print '

'.__('Free-To-View Channels','wpstream').'

'; $link_new = admin_url('post-new.php?post_type=wpstream_product'); print ''.esc_html__('Create new Free-To-View channel.','wpstream').''; print '
'; print '
'; while ($event_list_free->have_posts()): $event_list_free->the_post(); $the_id = get_the_ID(); if( get_post_meta ($the_id,'event_passed',true)!=1){ $this->wpstream_live_stream_unit($the_id); } endwhile; print'
'; print '
er2
'.esc_html__('Close','wpstream').'
'; $no_channel=1; }else{ $no_channel=0; } $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new'); $link_new_free = admin_url('post-new.php?post_type=wpstream_product'); print '
'; if($event_list->found_posts==0){ print '
'.__('* You do not have any Pay-Per-View channels!','wpstream').'
'; } if($event_list_free->found_posts==0){ print '
'. __('* You do not have any free channels!','wpstream').'
'; } print ''.esc_html__('Add new Free-To-View channel ','wpstream').''; print ''.esc_html__('Add new Pay-Per-View channel ','wpstream').''; print '
'; } // end wpstream_new_general_set /** * Social share * * @since 3.0.1 */ public function wpstream_social_share($the_id){ $protocol = is_ssl() ? 'https' : 'http'; $pinterest = wp_get_attachment_image_src(get_post_thumbnail_id($the_id), 'full'); $link = esc_url ( get_permalink($the_id) ); $title = get_the_title($the_id); $twiter_status = urlencode( $title.' '.$link); $email_link = 'subject='.urlencode ( $title ) .'&body='. urlencode( esc_url($link)); $facebook_link = esc_html($protocol).'://www.facebook.com/sharer.php?u='. esc_url($link) .'&t='. urlencode(get_the_title()); ?>
'; } /** * Shows event unit card in admin * * @since 3.0.1 */ public function wpstream_live_stream_unit($the_id,$is_front=''){ global $live_event_for_user; global $wpstream_plugin; $current_user = wp_get_current_user(); if( !current_user_can('administrator')){ if($is_front=='' ){ print '
'; esc_html_e('You are not allowed to broadcast.','wpstream'); print '
'; return; } } if( !$this->main->wpstream_check_user_can_stream() ){ print '
'; esc_html_e('You are not allowed to broadcast','wpstream'); print '
'; return; } $live_class=''; if(isset($live_event_for_user[$the_id])) { $live_class=" wpstream_show_started"; } if(has_post_thumbnail($the_id)){ $thumb = get_the_post_thumbnail_url($the_id,'thumbnail'); }else{ $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png'; } $pending_streaming_class = 'hide_stream_data'; $external_software_streaming_class = ''; $obs_uri = ''; $obs_stream = ''; $live_data_url = ''; if( $live_event_for_user=='' && $is_front=='front' ){ $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user(); } $channel_status = esc_html__('Channel is OFF','wpstream'); if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) { $pending_streaming_class = 'pending_trigger'; $live_data_url = get_post_meta($the_id,'qos_url',true); // $channel_status = esc_html__('Channel is on','wpstream'); } $server_id = get_post_meta($the_id,'server_id',true); $obs_uri = get_post_meta($the_id,'obs_uri',true); $obs_stream = get_post_meta($the_id,'obs_stream',true); $webcaster_url = get_post_meta($the_id,'webcaster_url',true); $rtmp_ip_uri = ''; print '
'; print '
'.$channel_status.'
'; print '
'; print '
'; print '
'.wp_trim_words(get_the_title($the_id),10); /* print '***
'.get_post_meta($the_id,'obs_uri',true) .'***
'. get_post_meta($the_id,'obs_stream',true).'***
'. get_post_meta($the_id,'broadcast_url',true); */ print '
'.esc_html('#ID','wpstream').' '.$the_id.'
'; print '
'; print '
'.esc_html__('TURN ON','wpstream'); print '
'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'
'; print '
'; print '
'; print '
'; print '
'.esc_html__('Turn ON the channel to go live.','wpestream').'
'; print '
'.esc_html__('Go live with your webcam','wpestream').'
'; print ' '; print '
'; print '
'; print '
'.esc_html__('Turn ON the channel to go live.','wpestream').'
'; print '
'.esc_html__('Go Live with external streaming app','wpestream').'
'; print ' '; print '
'; print ''; print '
'.esc_html__('Turn ON the channel to see live stats.','wpestream').'
'; print '
'.esc_html__('Live Statistics','wpestream').'
'; print' '; print '
'; print '
'; print '
'; if($is_front==''){ print '
'; print '
'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'
'; print '
'.esc_html__('Channel Settings','wpestream').'
'; print '
'; print ''; print '
'.esc_html__('Edit Channel','wpestream').'
'; print ' '; print '
'; } print ''; print '
'.esc_html__('View Channel','wpestream').'
'; print ' '; print '
'; print '
'; print '
'.esc_html__('Share Channel','wpestream').'
'; print ' '; print '
'; print '
'; $this->wpstream_display_modal_seetings($the_id); $this->wpstream_display_modal_share($the_id); $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream); print '
'; } /* * * Close modal button * */ public function wpstream_close_modal_button(){ print '
'; } /* * * Display modal settings * */ public function wpstream_display_modal_seetings($the_id){ print '
'; $this->wpstream_close_modal_button(); print '

'; printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id); print '

'; $local_event_options = get_post_meta($the_id,'local_event_options',true); if(!is_array($local_event_options)){ $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ; } $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt'); print '
'; $this->user_streaming_global_channel_options('',$local_event_options, $local_array_exclude); print '
'; print '
'; } /* * * Display share settings * */ public function wpstream_display_modal_share($the_id){ print '
'; $this->wpstream_close_modal_button(); print '

'.esc_html__('Share your Channel','wpstream').'

'; $this->wpstream_social_share($the_id); print '
'; } /* * * Display broadcast modal * */ public function wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream){ print '
'; $this->wpstream_close_modal_button(); print '

'.esc_html__('Go Live with External Streaming App','wpstream').'

'; print '
'.esc_html__('Please choose your RTMP encoder/broadcaster','wpstream').'
'; print ''; $this->wpstream_obs_settings($obs_uri,$obs_stream); $this->wpstream_streamyard_settings($obs_uri,$obs_stream); $this->wpstream_restream_settings($obs_uri,$obs_stream); $this->wpstream_wmix_settings($obs_uri,$obs_stream); $this->wpstream_wirecast_settings($obs_uri,$obs_stream); $this->wpstream_xplit_settings($obs_uri,$obs_stream); $this->wpstream_larix_settings($obs_uri,$obs_stream); print '
'; } /* * * Display OBS settings * */ public function wpstream_obs_settings($obs_uri,$obs_stream){ print '
'; print '
'; print '
'.esc_html__('Server:').' '; print '
' . $obs_uri.'
'.__('copy','wpstream').'
'; print '
'.__('Stream Key:').'
'. $obs_stream.'
'.__('copy','wpstream').'
'; print '
'; print'
'; print '
'; print '
  • 1. Click Settings in the OBS Window and then Select Stream.
  • 2. Choose Custom Streaming Server in the Stream Type dropdown menu.
  • 3. In the URL box, type/paste your Server.
  • 4. In the Stream key, type/paste your Stream key.
  • 5. Save changes.Close the Settings window and click on the “Start Streaming” button in the main window of OBS.
'; print '
'; print'
'; } /* * * Display StreamYard settings * */ public function wpstream_streamyard_settings($obs_uri,$obs_stream){ print '
'; print '
'; print '
'.esc_html__('RTMP server URL:').' '; print '
' . $obs_uri.'
'.__('copy','wpstream').'
'; print '
'.__('Stream key:').'
'. $obs_stream.'
'.__('copy','wpstream').'
'; print '
'; print'
'; print '
'; print '
  • 1. Set up your destination by going to your StreamYard account.
  • 2. Choose "Custom RTMP" and add the RTMP server URL and Stream key from WpStream.
  • 3. Go to "Broadcasts" then "create a broadcast".
  • 4. Enter Live Studio.
  • 5. Adjust all your preferred settings and Click on "Go Live".
'; print '
'; print'
'; } /* * * Display StreamYard settings * */ public function wpstream_restream_settings($obs_uri,$obs_stream){ print '
'; print '
'; print '
'.esc_html__('RTMP URL:').' '; print '
' . $obs_uri.'
'.__('copy','wpstream').'
'; print '
'.__('Stream key:').'
'. $obs_stream.'
'.__('copy','wpstream').'
'; print '
'; print'
'; print '
'; print '
  • 1. Go to your Restream account and set up a destination or channel.
  • 2. Choose "Custom RTMP" and add the RTMP URL and Stream Key from WpStream.
  • 3. Click on "Add Channel".
  • 4. Enter Live Studio.
  • 5. Adjust your preferred settings and Go Live.
'; print '
'; print'
'; } /* * * Display Xplit settings * */ public function wpstream_xplit_settings($obs_uri,$obs_stream){ print ''; } /* * * Display WireCast settings * */ public function wpstream_wirecast_settings($obs_uri,$obs_stream){ print ''; } /* * * Display Larix settings * */ public function wpstream_larix_settings($obs_uri,$obs_stream){ print ''; } /* * * Display Wmix settings * */ public function wpstream_wmix_settings($obs_uri,$obs_stream){ print ''; } /* * Set Settings * * */ public function wpstream_settings(){ if( !current_user_can('administrator') ){ die('Only for administrators'); } if($_SERVER['REQUEST_METHOD'] === 'POST'){ if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){ die('Security check'); } $allowed_html = array(); $exclude_array = array(); $allowed_html = array(); if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){ update_option( sanitize_key('wpstream_stream_role'), '' ); } foreach($_POST as $variable=>$value){ if ($variable!='submit'){ if (!in_array($variable, $exclude_array) ){ update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) ); } if($variable=='stream_role'){ update_option( sanitize_key('wpstream_stream_role'), $value ); } } } if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){ $event_settings=array(); foreach($this->global_event_options as $key=>$option){ $event_settings[$key]=''; if(isset($_POST['wpstream_event_set_'.$key]) && $_POST['wpstream_event_set_'.$key]=='on'){ $event_settings[$key]=1; }else{ $event_settings[$key]=0; } } update_option('wpstream_user_streaming_global_channel_options',$event_settings); } // reset permalinkgs global $wp_rewrite; update_option( "rewrite_rules", FALSE ); $wp_rewrite->flush_rules( true ); } $wpstream_settings_array =array( 1 => array( 'tab' => 'general_options', 'label' => esc_html__('Slug for free video/channel pages ','wpstream'), 'name' => 'free_media_slug', 'type' => 'text', 'details' => esc_html__('This will replace the default "wpstream" of all your free video/channel urls. Special characters like "&" are not permitted. To have your new slug show up you need to re-save the "Permalinks Settings" under Settings -> Permalinks, even if not making any changes.','wpstream'), ), 2 => array( 'tab' => 'general_options', 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'), 'name' => 'stream_role', 'type' => 'user_roles', 'details' => esc_html__('These types of users can stream via frontend shortcodes / blocks. Single individual channels are automaticlally created for streaming by non-admins.','wpstream'), ), 3 => array( 'tab' => 'general_options', 'label' => esc_html__('Non Admin Streamers Channel Type.','wpstream'), 'name' => 'user_streaming_channel_type', 'type' => 'select', 'select_values'=>array( 'free' => esc_html__('Free Live Channel','wpstream'), 'paid' => esc_html__('Pay-Per-View','wpstream') ), 'details' => esc_html__('Choose whether the channels assigned to non-admins are free-for-all or pay-per-view (WooCommerce product).','wpstream'), ), 4 => array( 'tab' => 'general_options', 'label' => esc_html__('Default Pay-Per-View Price','wpstream'), 'name' => 'user_streaming_default_price', 'type' => 'text', 'details' => esc_html__('Default price of pay-per-view channels assigned to non-admins.','wpstream'), ), 6 => array( 'tab' => 'subscription_options', 'label' => esc_html__('Use Global Subscription Mode','wpstream'), 'name' => 'global_sub', 'type' => 'slidertoogle', 'details' => esc_html__('If enabled, a client can access all the media products (live and VOD) by purchasing a single subscription. The "WooCommerce Subscriptions" plugin is required.','wpstream'), ), 7 => array( 'tab' => 'subscription_options', 'label' => esc_html__('Subscription ID for Global Subscription Mode','wpstream'), 'name' => 'global_sub_id', 'type' => 'text', 'details' => esc_html__('ID of the subscription product to be purchased for global access to media. All non-subscription video products that are not already attached to a subscription will be accessible to users that have purchased it.','wpstream'), ), 8 => array( 'tab' => 'messages_options', 'label' => esc_html__('PPV not logged in message','wpstream'), 'name' => 'product_not_login', 'type' => 'text', 'details' => esc_html__('This message will be displayed on top of the media player for pay-per-view items when user is not logged in.','wpstream'), 'default' => esc_html__('You must be logged in to watch this video.','wpstream'), ), 9 => array( 'tab' => 'messages_options', 'label' => esc_html__('PPV not purchased message','wpstream'), 'name' => 'product_not_bought', 'type' => 'text', 'details' => esc_html__('This message will be displayed on top of the media player for common pay-per-view items that have not been purchased.','wpstream'), 'default' => esc_html__('You did not yet purchase this item.','wpstream'), ), 10 => array( 'tab' => 'messages_options', 'label' => esc_html__('Subscription not purchased message','wpstream'), 'name' => 'product_not_subscribe', 'type' => 'text', 'details' => esc_html__('This message will be displayed on top of the media player for subscription-type pay-per-view items that have not been purchased.','wpstream'), 'default' => esc_html__(' You did not yet subscribe to this item.','wpstream'), ), 11 => array( 'tab' => 'messages_options', 'label' => esc_html__('Thank you message','wpstream'), 'name' => 'product_thankyou', 'type' => 'text', 'details' => esc_html__('This message will be displayed on the thank you page (after purchase) and the confirmation email.','wpstream'), 'default' => esc_html__('Thanks for your purchase. You can access your item at any time by visiting the following page: {item_link}','wpstream'), ), 12 => array( 'tab' => 'messages_options', 'label' => esc_html__('Subscription Active message','wpstream'), 'name' => 'subscription_active', 'type' => 'text', 'details' => esc_html__('This message will be displayed on subscription product page.','wpstream'), 'default' => esc_html__('Your Subscription is Active','wpstream'), ), 13 => array( 'tab' => 'messages_options', 'label' => esc_html__('You are not live message','wpstream'), 'name' => 'you_are_not_live', 'type' => 'text', 'details' => esc_html__('This message will be displayed in player.','wpstream'), 'default' => esc_html__('We are not live at this moment. Please check back later.','wpstream'), ), 99 => array( 'tab' => 'default_options', 'label' => esc_html__('Events Options ','wpstream'), 'name' => 'user_streaming_global_channel_options', 'type' => 'user_streaming_global_channel_options', 'details' => esc_html__('Global Options for live events.','wpstream'), ), ); $active_tab = 'general_options'; if( isset( $_GET[ 'tab' ] ) ) { $active_tab = $_GET[ 'tab' ]; } print '

'.__('WpStream Settings','wpstream').'

'; print ''; print '
'; switch ($active_tab) { case 'general_options': $help_link='https://docs.wpstream.net/docs/general-settings/'; break; case 'default_options': $help_link='https://docs.wpstream.net/docs/default-settings/'; break; case 'subscription_options': $help_link='https://docs.wpstream.net/docs/subscription-options/'; break; case 'messages_options': $help_link='https://docs.wpstream.net/docs/customize-messages/'; break; } print ''; foreach ($wpstream_settings_array as $key=>$option){ if($option['tab']!=$active_tab){ continue; } print '
'; $options_value = get_option('wpstream_'.$option['name']) ; if($option['type']=='user_roles'){ print ''; print $this->wpstream_select_user_roles($option['name'],$options_value); print '
'.$option['details'].'
'; }else if($option['type']=='user_streaming_global_channel_options'){ $exclude_array=array(); $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array); }else if($option['type']=='text'){ if($options_value==''){ $options_value=''; if(isset($option['default'])){ $options_value=$option['default']; } } print ''; print ''; print '
'.$option['details'].'
'; } else if($option['type']=='select'){ print ''; print ''; print ''; print '
'.$option['details'].'
'; } else if($option['type']=='slidertoogle'){ print ''; print ''; print '
'.$option['details'].'
'; } print '
'; } print '
'; print ''; print ' '; print '
'; print '
'; } /** * Set user roles * * @since 3.0.1 */ public function user_streaming_global_channel_options($name,$value,$local_array=''){ foreach($this->global_event_options as $key=>$option){ if( is_array($local_array) && !in_array($key,$local_array)){ print '
'; print ''; print ' '; print '
'.$option['details'].'
'; print '
'; } } } /* * Set user roles * * @since 3.0.1 */ public function wpstream_select_user_roles($name,$value){ if($value==''){ $value=array(); } $roles = get_editable_roles(); $return = ''; return $return; } /* * Set credential admin function * * @since 3.0.1 */ public function wpstream_set_wpstream_credentials(){ if($_SERVER['REQUEST_METHOD'] === 'POST'){ $allowed_html = array(); $exclude_array = array(); $allowed_html = array(); foreach($_POST as $variable=>$value){ if ($variable!='submit'){ if (!in_array($variable, $exclude_array) ){ update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) ); } } } update_option('wp_estate_token_expire',0); update_option('wp_estate_curent_token',' '); delete_transient( 'wpstream_token_api'); delete_transient('wpstream_token_request_30'); delete_transient('wpstream_request_pack_data_per_user_transient'); } $allowed_html = array(); $wpstream_options_array =array( 2 => array( 'label' => 'WpStream.net Username or Email', 'name' => 'api_username', 'type' => 'text', ), 3 => array( 'label' => 'WpStream.net Password', 'name' => 'api_password', 'type' => 'password', ), ); $token = $this->main->wpstream_live_connection->wpstream_get_token(); $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); $this->main->show_user_data($pack_details); print '
'; print '

'.__('WpStream Credentials','wpstream').'

'; if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== '' ){ echo '
'; $admin_url_onboard=get_admin_url().'admin.php?page=wpstream_onboard'; printf ( __('To connect your plugin, enter your WpStream credentials below or go here to create an account.','wpstream'),$admin_url_onboard); echo '
'; }else if($token==''){ echo '
'.__(' Incorrect username or password. Please check your credentials or go here to reset your password.','wpstream').'
'; }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){ echo '
'.__('Connected to WpStream.net!','wpstream').'
'; }else{ echo '
'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'
'; } print '
'; foreach ($wpstream_options_array as $key=>$option){ print '
'; $options_value = esc_html( get_option('wpstream_'.$option['name'],'') ); print ''; print ''; print '
'; } print '
'; print ''; print '

Video Tutorials

'; print 'How to Live Stream to WordPress with OBS'; print 'How to Live Stream to WordPress in less than 3 Minutes'; print 'How to Live-Stream to WordPress using your iPhone'; print 'More Tutorials On Our YouTube Channel'; print '
'; print '
'; print '
'; $link_new = admin_url('admin.php?page=wpstream_live_channels'); $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new'); $link_new_free = admin_url('post-new.php?post_type=wpstream_product'); print ''.esc_html__('Create new Free-To-View channel','wpstream').''; print ''.esc_html__('Create Pay-Per-View channel','wpstream').''; print ''.esc_html('My Channels','wpstream').''; print '
'; } /** * Media Management * * @since 3.0.1 */ public function wpstream_media_management(){ $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); $this->main->show_user_data($pack_details); print '

'.__('Upload New Recording','wpstream').'

'.$this->wpstream_present_media_upload().'
'; print '

'.__('Your Recordings','wpstream').'

'.$this->wpstream_present_file_management().'
'; } /** * * * WpStream Pagination * * @since 3.0.1 * * */ public function wpstream_pagination($pages , $range = 2) { $return=''; $showitems = ($range * 2) + 1; $paged = ( isset( $_GET['paged'] ) ) ? intval($_GET['paged']) : 1; if (1 != $pages && $pages != 0) { $return.= '"; } return $return; } /** * Media upload * * @since 3.0.1 */ public function wpstream_present_media_upload(){ $to_return=''; $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data(); if( !$formInputs['success'] ){ $to_return.='
'.esc_html__('There isn\'t enough storage space under your account to upload a new item. Please delete some videos or upgrade your subscription.','wpstream').'
'; return $to_return; } if($formInputs['success'] ===true){ $to_return.='
'; $to_return.='
'.esc_html__('Please select or drop a video file. Do not close this window during the upload!','wpstream').'
'; $to_return.='
'; $to_return.=''; $to_return.=''; $to_return.='
'; $to_return.='
'.esc_html__('Drop a video file here!','wpstream').'
'; $to_return.='
'.__('The Video File must be encoded with the following settings: Container: MP4, Video codec: H264, Audio codec: AAC. Media will fail to play if it does not follow the above settings. You may use a tool like MediaInfo to verify your file. Also you may convert it with specialized software like HandBrake.','wpstream').' '.esc_html__('Accepted file extensions: .mp4, .mov','wpstream').'
'; if(is_array($formInputs)){ foreach ($formInputs['ref'] as $name => $value) { $to_return.=''; } } $to_return.='
'; $to_return.='
'; } return $to_return; } /** * Display movie list * * @since 3.0.1 */ public function wpstream_present_file_management(){ $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api(); $video_list_raw_array=array(); if(isset($video_list_raw['items'])){ $video_list_raw_array=$video_list_raw['items']; } $keys = array_column($video_list_raw_array, 'time'); array_multisort($keys, SORT_DESC , $video_list_raw_array); $to_return=''; if(is_array($video_list_raw['items'])){ foreach ($video_list_raw_array as $key =>$video){ $video_size = intval($video['size']/1048576); $video_name = esc_html($video['name']); if($video_name!=''): $to_return.='
'; $to_return.='
'; $to_return.='
'; $to_return.='
'.esc_html__('File Name :','wpstream').''.''.$video_name.''.$video_size.' MB
'; $to_return.='
'.esc_html__('delete file','wpstream').'
'; $to_return.=''; $to_return.='
'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').''; $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product_vod').'&new_video_name='. rawurlencode($video_name); $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video_name); $to_return .=''.esc_html__('Create new Free-To-View VOD from this recording').''; $to_return .=''.esc_html__('Create new Pay-Per-View VOD from this recording').''; $to_return.='
'; endif; } $current_page= get_current_screen(); } else { $to_return.= '
'.esc_html__('You don\'t have any videos.','wpstream').'
'; } return $to_return; } /** * Set defualt channels values * * @since 3.0.1 */ public function wpstream_publish_wpstream_product($post_id,$post){ if( $post->post_type == 'wpstream_product' ){ update_post_meta ($post_id,'local_event_options_test','working_on_'.$post_id); $to_save_option=array(); $global_options= get_option('wpstream_user_streaming_global_channel_options'); $local_events = get_post_meta ($post_id ,'local_event_options',true) ; if( $local_events =='' ){ if( is_array($global_options) ){ foreach($global_options as $key=>$value){ $to_save_option[sanitize_key($key)]=sanitize_text_field($value); } update_post_meta ($post_id,'local_event_options',$to_save_option); } } } } /** * save meta options * * @since 3.0.1 */ public function wpstream_free_product_update_post($post_id,$post){ if(!is_object($post) || !isset($post->post_type)) { return; } if( $post->post_type == 'wpstream_product' || $post->post_type == 'wpstream_product_vod' ): $allowed_keys=array( 'wpstream_product_type', 'wpstream_free_video', 'wpstream_free_video_external' ); foreach ($_POST as $key => $value) { if( !is_array ($value) ){ if (in_array ($key, $allowed_keys)) { $postmeta = sanitize_text_field ( $value ); update_post_meta($post_id, sanitize_key($key), $postmeta ); } } } endif; } /** * save meta options * * @since 3.0.1 */ public function add_wpstream_product_metaboxes() { add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default'); } /** * make woocomerce virtual products * * @since 3.0.1 */ public function wpstream_make_product_virtual($post_id,$post){ global $post; if(isset($post->ID)){ if ( $post->post_type !== 'product' ) return; $term_list = wp_get_post_terms($post->ID, 'product_type'); if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){ update_post_meta( $post->ID, '_virtual', 'yes' ); } } } /** * render meta options * * @since 3.0.1 */ public function display_meta_options( $post ) { wp_nonce_field( plugin_basename( __FILE__ ), 'estate_agent_noncename' ); global $post; $is_live = ''; $is_video = ''; $is_video_external = ''; if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){ $is_video = ' selected '; $wpstream_free_video = esc_html( $_GET['new_video_name']); }else{ $wpstream_product_type = esc_html(get_post_meta($post->ID, 'wpstream_product_type', true)); $wpstream_free_video = esc_html(get_post_meta($post->ID, 'wpstream_free_video', true)); if($wpstream_product_type==1){ $is_live = ' selected '; } if($wpstream_product_type==2){ $is_video = ' selected '; } if($wpstream_product_type==3){ $is_video_external = ' selected '; } } print'


'; $video_list = $this->main->wpstream_live_connection->wpstream_get_videos(); print '


'; $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true)); print '


'; if($wpstream_product_type==2){ $show_recording=''; $show_external='style="display:none"'; }else{ $show_recording='style="display:none"'; $show_external=''; } print '

'.esc_html__('Choose one of your existing recordings.','wpstream').'

'; print '

'.esc_html__('Upload a video from your computer or paste the URL of a YouTube/Vimeo/external video.','wpstream').'

'; print '

'; } /** * Add new product types to Woocommerce select product type * * @since 3.0.1 */ public function wpstream_add_products( $types ){ $types[ 'live_stream' ] = __( 'Live Channel','wpestream' ); $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' ); return $types; } /** * Js action to do when user pick live stream or video on demand * * @since 3.0.1 */ public function wpstream_products_custom_js() { if ( 'product' != get_post_type() ) : return; endif; ?> get_id(); $term_list = wp_get_post_terms($product_id, 'product_type'); $subscription_model = esc_html( get_option('wpstream_global_sub','')) ; if($subscription_model==1){ // if we have Neflix mode if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' ){ return false; } } return $purchaseable_product_wpblog; } /** * Add custom fields to custom product types * * @since 3.0.1 */ public function wpstream_add_custom_general_fields() { global $woocommerce, $post; if(function_exists('wcs_user_has_subscription')){ echo '
'; woocommerce_wp_select( array( 'id' => '_subscript_live_event', 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ), 'options' => array("yes"=>"yes","no"=>"no") ) ); echo '
'; } echo '
'; echo '
'; $selected=''; if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){ $selected=esc_html($_GET['new_video_name']); } if($selected==''){ $selected= get_post_meta($post->ID,'_movie_url',true); } woocommerce_wp_select( array( 'id' => '_movie_url', 'label' => __( 'Choose video', 'woocommerce' ), 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(), 'selected'=> true, 'value' => $selected ) ); echo '
'; if(function_exists('wcs_user_has_subscription')){ $selected_sub=''; echo '
'; if( isset( $_GET['wpstream_parent_sub']) && $_GET['wpstream_parent_sub']!='' ){ $selected_sub=esc_html($_GET['wpstream_parent_sub']); } if($selected_sub==''){ $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true); } woocommerce_wp_select( array( 'id' => '_wpstream_parent_sub', 'name' => '_wpstream_parent_sub[]', 'label' => __( 'Attach to subscription', 'woocommerce' ), 'options' => $this->wpstream_return_subscriptions_created(), 'selected'=> true, 'value' => $selected_sub, 'custom_attributes' => array('multiple' => 'multiple') ) ); echo '
'; } } public function wpstream_return_subscriptions_created(){ $return=array('0'=>'none'); $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array( 'subscription'), ) ) ); $subscriptions = new WP_Query($args); if($subscriptions->have_posts()): while ($subscriptions->have_posts()): $subscriptions->the_post(); $return[ get_the_ID() ] = get_the_title(); endwhile; endif; wp_reset_postdata(); return $return; } /** * Save custom fields * * @since 3.0.1 */ public function wpstream_add_custom_general_fields_save( $post_id ){ $permited_values = array( '_movie_url', '_subscript_live_event', '_wpstream_parent_sub', ); foreach($_POST as $key=>$value){ update_post_meta( $post_id, 'event_passed', 0 ); if( in_array($key, $permited_values) ){ if( !empty( $_POST[$key] ) ){ $key = sanitize_key($key); $value = sanitize_text_field($_POST[$key]); if($key=='_wpstream_parent_sub'){ $value= $_POST[$key]; $value = array_map("sanitize_text_field", $value); } update_post_meta( $post_id, $key, $value ); } } } //die(); } /** * Add to cart redirect * * @since 3.0.1 */ public function wpstream_add_to_cart() { wc_get_template( 'single-product/add-to-cart/simple.php' ); } /** * Replace add to cart button * * @since 3.0.1 */ public function replacing_add_to_cart_button( $button, $product ) { global $product; $product_type = $product->get_type(); if($product_type==='live_stream' || $product_type=='video_on_demand'){ return $button = '' . __( 'Add to Cart', 'woocommerce' ) . ''; }else{ return $button; } } /** * Admin notices * * @since 3.0.1 */ public function wpstream_admin_notice() { global $pagenow; global $typenow; $wpstream_notices = get_option('wpstream_notices'); /* if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { if( !is_array($wpstream_notices) || !isset($wpstream_notices['wpstream_woo_notice']) || ( isset($wpestate_notices['wpstream_woo_notice']) && $wpestate_notices['wpstream_woo_notice']!='yes') ){ print '

'.__( 'WpStream Pay-Per-View Live Streaming and VOD only works with WooCommerce - Please enable and activate the WooCommerce plugin if you want to monetize your Live Events or Recorded Videos', 'wpstream' ).'

'; } } */ 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.', 'wpstream' ).'

'; } $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" ); print ''; } /** * Admin notices * * @since 3.0.1 */ public function wpstream_update_cache_notice(){ //check_ajax_referer( 'wpstream_notice_nonce', 'security' ); $notice_type = esc_html($_POST['notice_type']); $notices = get_option('wp_stream_notices'); if(! is_array($notices) ){ $notices=array(); } $notices[$notice_type]='yes'; update_option('wpstream_notices',$notices); die(); } /** * Activate metaboxes for Streaming controls on sidebar * * @since 3.0.1 */ public function wpstream_startstreaming_sidebar_meta() { global $post; $term_list = wp_get_post_terms($post->ID, 'product_type'); add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high'); $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true)); 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'), array($this,'wpstream_start_stream_meta'), 'product', 'side', 'high'); } } } } /** * edited 4.0 * * Show Streaming controls on sidebar * * @since 3.0.1 */ public function wpstream_start_stream_meta(){ global $live_event_for_user; $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user(); global $post; $local_event_options = get_post_meta ($post->ID,'local_event_options',''); if( get_post_status($post->ID)!='auto-draft' ){ $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" ); print ''; $this->wpstream_live_stream_unit($post->ID); print '
'; print '
er1
'.esc_html__('Close','wpstream').'
'; }else{ esc_html_e('To Go Live, please publish your channel first !','wpstream'); } } /** * * * */ public function add_dashboard_page() { add_dashboard_page( '', '', 'administrator', 'wpstream-onboarding', '' ); } public function wpstream_load_onboarding_wizard() { // Check for wizard-specific parameter // Allow plugins to disable the onboarding wizard // Check if current user is allowed to save settings. // Don't load the interface if doing an ajax call. if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return; } set_current_screen(); // Remove an action in the Gutenberg plugin ( not core Gutenberg ) which throws an error. remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' ); $this->actual_load_onboarding_wizard(); } /* * Add on boarding to footer */ public function wpstream_admin_footer_onboarding(){ if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') { $this->wpstream_onboard_display(); } } /* * On Board Display * */ public function wpstream_pre_onboard_display(){ $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); $this->main->show_user_data($pack_details); $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg'; ?>

'.esc_html__('Quick Start','wpstream').'';?>

onboarding_wizard_header(); $this->wpstream_onboarding_step1(); $this->wpstream_onboarding_step2(); $this->wpstream_onboarding_step3_live_streaming(); $this->wpstream_onboarding_step_3_A_live_streaming_free_view(); $this->wpstream_onboarding_step_3_B_live_streaming_pay_per_view(); $this->wpstream_onboarding_step4_vod(); $this->wpstream_onboarding_step_4_free_vod(); $this->wpstream_onboarding_step_4_ppv_vod(); $this->onboarding_wizard_footer(); } /* * * On Boarding Step 1 - the login/register * */ public function wpstream_onboarding_step1(){ $wpstream_options_array =array( 2 => array( 'label' => 'WpStream.net Username or Email', 'name' => 'api_username', 'type' => 'text', ), 3 => array( 'label' => 'WpStream.net Password', 'name' => 'api_password', 'type' => 'password', ), ); $token = $this->main->wpstream_live_connection->wpstream_get_token(); ?>

main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields); $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY); } ?>
'.$curl_response_decoded['capthca'].'
';?>
'; ?>
'; } } /* * * Generate random pass * */ public function randomPassword() { $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache for ($i = 0; $i < 8; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); //turn the array into a string } /* * * * */ public function wpstream_onboarding_step2(){ ?>

Welcome to WpStream! How would you like to start?

or

or

wpstream_onboarding_woo_warning(); } ?>
'.esc_html__('Pay-Per-View streaming requires WooCommerce. Please install the WooCommerce plugin and try again.','wpstream').'
'. esc_html__('Install WooCommerce','wpstream').'
'.esc_html__('Try Again','wpstream').'
'; } /* * * * */ public function wpstream_onboarding_step4_vod(){ ?>

or
base !=='wpstream_page_wpstream_onboard'){ return; } $token = $this->main->wpstream_live_connection->wpstream_get_token(); $video_list = array(); if($token!=''){ $video_list = $this->main->wpstream_live_connection->wpstream_get_videos(); } ?>

wpstream_show_vod_dropdown_onboarding($video_list); ?>
wpstream_obboarding_file_warning(); } ?>
'.esc_html__('Choose Recording','wpstream').' '; } /* * * * */ public function wpstream_obboarding_file_warning(){ print '
'.esc_html__('A recording is needed to create a VOD from. There are no recordings under your account. You can create new recordings by recording a live channel or uploading video files directly.','wpstream').'
'.esc_html__('Upload Video','wpstream').'
'.esc_html__('Try Again','wpstream').'
'; } /* * * * */ public function wpstream_onboarding_step_4_ppv_vod(){ $current_screen=get_current_screen(); if($current_screen->base !=='wpstream_page_wpstream_onboard'){ return; } $token = $this->main->wpstream_live_connection->wpstream_get_token(); $video_list = array(); if($token!=''){ $video_list = $this->main->wpstream_live_connection->wpstream_get_videos(); } ?>

wpstream_show_vod_dropdown_onboarding($video_list,'_for_ppv'); ?>
wpstream_onboarding_woo_warning(); } }else{ $this->wpstream_obboarding_file_warning(); } ?>
$channel_name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'product', 'post_author' => $current_user->ID ); // Insert the post into the database $post_id = wp_insert_post( $my_post ); if(is_wp_error($post_id)){ echo json_encode( array('succes'=>false) ); }else{ $product = wc_get_product($post_id); $price = wc_format_decimal($channel_price); $product = wc_get_product( $post_id ); $product->set_price( $price ); $product->set_regular_price( $price ); // To be sure $product->save(); update_post_meta ($post_id,'event_passed',0); wp_set_object_terms( $post_id, 'live_stream', 'product_type' ); $permalink = get_edit_post_link($post_id); $permalink= add_query_arg( 'onboard', 'yes', $permalink ); $permalink= add_query_arg( 'branch', '2', $permalink ); echo json_encode( array( 'success'=> true, 'link' => ($permalink) )); } } die(); } /* * * On Boarding create channel * */ public function wpstream_on_board_create_channel(){ check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); $current_user = wp_get_current_user(); if(current_user_can('administrator')){ $channel_name=sanitize_text_field($_POST['channel_name']); $my_post = array( 'post_title' => $channel_name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'wpstream_product', 'post_author' => $current_user->ID ); // Insert the post into the database $post_id = wp_insert_post( $my_post ); if(is_wp_error($post_id)){ echo json_encode( array('succes'=>false) ); }else{ $permalink = get_edit_post_link($post_id); $permalink= add_query_arg( 'onboard', 'yes', $permalink ); $permalink= add_query_arg( 'branch', '1', $permalink ); echo json_encode( array( 'success'=> true, 'link' => ($permalink) )); } } die(); } /* * * On Boarding create free vod * */ public function wpstream_on_board_create_free_vod(){ $current_user = wp_get_current_user(); check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); if(current_user_can('administrator')){ $channel_name =sanitize_text_field($_POST['channel_name']); $file_name =sanitize_text_field($_POST['file_name']); $my_post = array( 'post_title' => $channel_name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'wpstream_product_vod', 'post_author' => $current_user->ID ); // Insert the post into the database $post_id = wp_insert_post( $my_post ); if(is_wp_error($post_id)){ echo json_encode( array('succes'=>false) ); }else{ update_post_meta($post_id, 'wpstream_product_type', 2); update_post_meta($post_id, 'wpstream_free_video', $file_name); $permalink = get_edit_post_link($post_id); $permalink= add_query_arg( 'onboard', 'yes', $permalink ); $permalink= add_query_arg( 'branch', '3', $permalink ); echo json_encode( array( 'success'=> true, 'link' => ($permalink) )); } } die(); } /* * * On Boarding create ppv vod * */ public function wpstream_on_board_create_ppv_vod(){ $current_user = wp_get_current_user(); check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); if(current_user_can('administrator')){ $channel_name = sanitize_text_field($_POST['channel_name']); $vod_price = floatval($_POST['vod_price']); $file_name = sanitize_text_field($_POST['file_name']); $my_post = array( 'post_title' => $channel_name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'product', 'post_author' => $current_user->ID ); // Insert the post into the database $post_id = wp_insert_post( $my_post ); if(is_wp_error($post_id)){ echo json_encode( array('succes'=>false) ); }else{ $product = wc_get_product($post_id); $price = wc_format_decimal($vod_price); $product = wc_get_product( $post_id ); $product->set_price( $price ); $product->set_regular_price( $price ); // To be sure $product->save(); update_post_meta ($post_id,'event_passed',0); update_post_meta ($post_id,'_movie_url', $file_name); wp_set_object_terms( $post_id, 'video_on_demand', 'product_type' ); $permalink = get_edit_post_link($post_id); $permalink= add_query_arg( 'onboard', 'yes', $permalink ); $permalink= add_query_arg( 'branch', '4', $permalink ); echo json_encode( array( 'success'=> true, 'link' => ($permalink) , ' $file_name'=> $file_name, )); } } die(); } /* * * On Boarding login * */ public function wpstream_on_board_login(){ check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); if(current_user_can('administrator')){ $username = sanitize_text_field($_POST['api_username']); $password = sanitize_text_field($_POST['api_password']); update_option('wpstream_api_username',$username); update_option('wpstream_api_password',$password); $token = $this->main->wpstream_live_connection->wpstream_get_token(); echo json_encode( array( 'success'=> true, 'token' => ($token) )); }else{ echo json_encode( array( 'success'=> false, 'token' => esc_html('You are not an administrator','wpstream') )); } die(); } public function wpstream_register_refresh_capthca(){ if(current_user_can('administrator')){ } } /* * * On Boarding login * */ public function wpstream_on_board_register(){ check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); if(current_user_can('administrator')){ $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']); $wpstream_register_password = sanitize_text_field($_POST['wpstream_register_password']); $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']); $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']); $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password); if(!$validate['success']){ echo json_encode($validate); die(); } $url='user/create'; $curl_post_fields=array( 'email' => $wpstream_register_email, 'password' => $wpstream_register_password, 'captcha' => $wpstream_register_captcha, 'captcha_id' => $wpstream_register_captcha_id, ); $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields); $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY); if($curl_response_decoded['success']){ if($curl_response_decoded['request']['registred']){ // we are registerd update_option('wpstream_api_username',$wpstream_register_email); update_option('wpstream_api_password',$wpstream_register_password); $token = $this->main->wpstream_live_connection->wpstream_get_token(); echo json_encode( array( 'success' => true, 'token' => $token , 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'), )); die(); }else{ echo json_encode( array( 'success'=> false, 'message'=> $curl_response_decoded['request']['message'], 'curl'=>$curl_response_decoded, )); die(); } }else{ echo json_encode( array( 'success'=> false, 'message'=> esc_html__('Register action could not be completed. Please register on wpstream.net','wpstream'), )); die(); } }else{ echo json_encode( array( 'success'=> false, 'message' => esc_html('You are not an administrator','wpstream') )); die(); } die(); } /* * * Validate for register * */ public function wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password){ $return= array( 'success'=>true ); if ($wpstream_register_email=='' ){ $return= array( 'success'=> false, 'message' => esc_html('The email Field is Empty','wpstream') ); return $return;die(); } if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) { $return= array( 'success'=> false, 'message' => esc_html('The email doesn\'t look right !','wpstream') ); return $return;die(); } $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1); if( $domain!='' && !checkdnsrr ($domain) ){ $return= array( 'success'=> false, 'message' => esc_html('The email doesn\'t look right !','wpstream') ); return $return;die(); } if(strlen($wpstream_register_password)<5){ $return= array( 'success'=> false, 'message' => esc_html('The password is too short. Please use at least 5 characters.','wpstream') ); return $return;die(); } return $return;die(); } }