*/
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;
add_action('init', array($this, 'load_global_event_options'));
}
public function load_global_event_options() {
$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',
// ),
);
}
/**
* 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(),
filemtime(plugin_dir_path(__FILE__) . 'css/wpstream-admin.css' ),
'all'
);
wp_enqueue_style(
'wpstream-on-boarding-css',
plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css',
array(),
filemtime(plugin_dir_path(__FILE__) . 'css/wpstream-admin-onboarding.css'),
);
if (!did_action('wp_enqueue_media')) {
wp_enqueue_media();
}
}
/**
* 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-utils', plugin_dir_url( __FILE__ ) .'js/utils/admin_utils.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(),
'multipart_upload_nonce' => wp_create_nonce( 'wpstream_multipart_upload_nonce' ),
'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'),
'no_streaming_hours' => esc_html__('Not enough streaming hours.','wpstream'),
'exceeding_limit' => esc_html__('File size exceeds 5GB. Initiating multipart upload...','wpsteam'),
'upload_failed' => esc_html__('Upload Failed!','wpstream'),
'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'),
'choose_a_file' => esc_html__('Choose a file…','wpstream'),
'preparing_multipart' => esc_html__('Preparing multipart upload...','wpstream'),
'uploading_part' => esc_html__('Uploading part {part} of {total}...','wpstream'),
'upload_failed_part' => esc_html__('Failed to upload part {part}. Please try again.','wpstream'),
'completing_upload' => esc_html__('Completing upload. Please wait...','wpstream'),
'upload_failed_part_retry' => esc_html__('Failed to upload part {part}. Retrying...','wpstream'),
'choose_recording' => esc_html__( 'Choose Recording', 'wpstream' ),
'select_recording' => esc_html__( 'Please select a recording from the list', 'wpstream' ),
'invalid_response' => esc_html__('Invalid response from server. Missing required upload data.', 'wpstream'),
'video_processing' => esc_html__( 'The video is still processing', 'wpstream' ),
'file_name_text' => esc_html__('File Name:','wpstream'),
'channel_create_error' => esc_html__('Something did not work. Please try again.', 'wpstream'),
'select_caption_file' => esc_html__('Select .vtt Captions File', 'wpstream'),
'select_button' => esc_html__('Select', 'wpstream'),
'remove_button' => esc_html__('Remove', 'wpstream'),
'use_streaming_hours' => $this->wpstream_get_start_streaming_localization_flags()['use_streaming_hours'],
));
wp_enqueue_script('wpstream-recordings-videos-list', plugin_dir_url( __FILE__ ) .'js/recordings_videos_list.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
wp_localize_script( 'wpstream-recordings-videos-list', 'wpstream_recordings_videos_list_vars',
array(
'delete_file' => esc_html__('Delete file', 'wpstream'),
'download' => esc_html__( 'Download', 'wpstream'),
'download_available' => esc_html__( 'Click to download! The url will work for the next 20 minutes!', 'wpstream'),
'add_free_video_url' => esc_url( admin_url( 'post-new.php?post_type=wpstream_product_vod') . '&new_video_name=' ),
'create_ftv_vod' => esc_html__( 'Create new Free-To-View VOD from this recording' , 'wpstream' ),
'woocommerce_exists' => class_exists( 'WooCommerce' ),
'add_paid_video_url' => esc_url( admin_url( 'post-new.php?post_type=product').'&new_video_name=' ),
'create_ptv_vod' => esc_html__( 'Create new Pay-Per-View VOD from this recording' , 'wpstream' ),
)
);
$modified_start_streaming_file_time = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'public/js/start_streaming.js' ) );
wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'public/js/start_streaming.js', array(), $modified_start_streaming_file_time, true);
$streaming_localization_flags = $this->wpstream_get_start_streaming_localization_flags();
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'),
'failed_fetching' => esc_html__('Failed to get channel info. Please try again.','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 .
'- Manual TURN OFF is only useful if you require to change the channel settings immediately.' . PHP_EOL .
'- If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.',
'wpstream'
),
'is_basic_streaming' => $streaming_localization_flags['is_basic_streaming'],
'use_streaming_hours' => $streaming_localization_flags['use_streaming_hours'],
'basic_streaming_warning' => esc_html__(
'You’ve used all available broadcast or viewer hours.' . PHP_EOL . PHP_EOL .
'Some live channel features will be limited, including recording, viewer count, browser broadcasting, and content protection.' . PHP_EOL . PHP_EOL .
'Top up your resources or upgrade your plan to use all features, or choose OK to start anyway.',
'wpstream'
),
'basic_streaming_warning_traffic' => esc_html__(
'Your account is now in BASIC STREAMING mode.' . PHP_EOL . PHP_EOL .
'Instead of offloading to the WpStream Cloud, this mode relies on WordPress and hosting resources to process and deliver video. In some WP environments, streaming may be unreliable.' . PHP_EOL .
'Certain features, such as recording, viewer count, browser broadcasting, and content protection are unavailable.' . PHP_EOL . PHP_EOL .
'- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL .
'- Otherwise, choose OK to start your channel with these limitations.' . PHP_EOL . PHP_EOL .
'ARE YOU SURE you want to continue with Basic Streaming?',
'wpstream'
),
'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
'is_onboarding' => isset($_GET['onboard']) && $_GET['onboard'] === 'yes' ? 'yes' : 'no',
));
wp_enqueue_script('wpstream-settings', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream_settings.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
wp_localize_script('wpstream-settings', 'wpstream_settings_vars', array(
'error_message' => esc_html__( 'Failed to save settings. Please try again.', 'wpstream'),
'choose_image_text' => esc_html__( 'Choose Logo Image', 'wpstream'),
'select_image_text' => esc_html__( 'Select Image', 'wpstream'),
'update_successful' => esc_html__( 'Update Successful.', 'wpstream'),
'update_failed' => esc_html__( 'Something went wrong. Try again.', 'wpstream'),
'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
));
$branch = isset($_GET['branch']) ? sanitize_text_field( wp_unslash( $_GET['branch'] ) ) : '';
wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',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',
'branch' => $branch
));
$current_screen=get_current_screen();
// enqueue the file only on the on-boarding page and wpstream_product post type
$is_wpstream_onboarding_page = $current_screen->base ==='wpstream_page_wpstream_onboard';
$is_wpstream_onboarding_post_type_page = isset($_GET['onboard']) && $_GET['onboard'] === 'yes';
$onboarding_visible = $is_wpstream_onboarding_page || $is_wpstream_onboarding_post_type_page;
if( $onboarding_visible) {
wp_enqueue_script('wpstream-on-boarding-page-js', plugin_dir_url( __DIR__ ) .'admin/js/wpstream-onboarding-page.js',array(), WPSTREAM_PLUGIN_VERSION, true);
wp_localize_script( 'wpstream-on-boarding-page-js', 'wpstream_onboarding_page_vars',
array(
'admin_url' => get_admin_url(),
'request_url' => WPSTREAM_CLICK,
'wps_user' => get_option('wpstream_api_username_from_token'),
'current_page' => $is_wpstream_onboarding_post_type_page ? 'post_edit' : 'onboarding',
'plugin_version' => WPSTREAM_PLUGIN_VERSION,
'branch' => $branch,
)
);
}
if ( in_array( $current_screen->base, ['toplevel_page_wpstream_credentials', 'wpstream_page_wpstream_live_channels', 'wpstream_page_wpstream_recordings', 'wpstream_page_wpstream_onboard'] ) ) {
wp_enqueue_script( 'wpstream-user-quota-update', plugin_dir_url( __DIR__ ) . 'admin/js/wpstream-user-quota.js', array(), WPSTREAM_PLUGIN_VERSION, true );
wp_localize_script( 'wpstream-user-quota-update', 'wpstream_user_quota_vars', array(
'admin_url' => get_admin_url()
));
}
// Add localized variables for broadcaster
wp_localize_script('wpstream-broadcaster', 'wpstream_broadcaster_vars', array(
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('wpstream_broadcaster_nonce'),
'plugin_url' => plugin_dir_url(__FILE__),
));
}
/**
* 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->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
$this->main->show_user_data($pack_details);
if( $event_list->have_posts()){
print '
';
}
/**
* Shows event unit card in admin - theme version
*
* @since 3.0.1
*/
public function wpstream_live_stream_unit_for_theme($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 '
';
}
public function wpstream_basic_stream_mode_message() {
print '
';
if ( $this->wpstream_is_use_streaming_hours() ) {
print sprintf(
wp_kses(
__(
'You’ve used all available broadcast or viewer hours. Default channel settings will be used for now. To edit channel settings, top up your resources or upgrade your plan.',
'wpstream'
),
array( 'a' => array(
'href' => array(),
'target' => array()
)
)
),
esc_url( 'https://wpstream.net/pricing/' ),
esc_url( 'https://wpstream.net/pricing/' )
);
} else {
print sprintf(
wp_kses(
__(
'You are currently in Basic Streaming Mode. The default channel settings will be used instead. Please upgrade your plan to edit the channel settings.',
'wpstream'
),
array(
'a' => array(
'href' => array()
)
)
),
esc_url( 'https://wpstream.net/pricing/' )
);
}
print '
';
}
/*
*
* Display modal settings
*
*/
public function wpstream_display_modal_seetings($the_id){
$is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
print '
';
}
/*
*
* Display Wmix settings
*
*/
public function wpstream_wmix_settings($obs_uri,$obs_stream){
print '
';
print '
';
print '
'.esc_html__('URL:').' ';
print '
' . $obs_uri.'
'.__('copy','wpstream').'
';
print '
'.__('Stream Key:').'
'. $obs_stream.'
'.__('copy','wpstream').'
';
print '
';
print'
';
print '
';
print '
1. Click on the gear icon near the stream button on the bottom.
2. Choose a custom RTMP Server in destination.
3. In the URL box, type/paste your URL.
4. In the Stream key, type/paste your Stream key.
5. Save changes. You can start streaming by clicking on the stream button at the bottom of the dashboard.
';
print '
';
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'),
),
'free_vod_slug' => array(
'tab' => 'general_options',
'label' => esc_html__('Slug for free VOD pages ','wpstream'),
'name' => 'free_media_slug_vod',
'type' => 'text',
'details' => esc_html__('This will replace the default "wpstream_vod" of all your free VOD 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','wpstream'),
),
14 => array(
'tab' => 'general_options',
'label' => esc_html__('Video player theme','wpstream'),
'name' => 'video_player_theme',
'type' => 'select',
'select_values'=>array(
'default' => esc_html__('Default','wpstream'),
'city' => esc_html__('City','wpstream'),
'forest' => esc_html__('Forest','wpstream'),
'fantasy' => esc_html__('Fantasy','wpstream'),
'sea' => esc_html__('Sea','wpstream'),
),
'details' => esc_html__('Choose the video player theme to have a different look for the player.','wpstream'),
),
'wpstream_player_logo' => array(
'tab' => 'general_options',
'name' => 'player_logo',
'label' => esc_html__('Logo for the video player','wpstream'),
'type' => 'image',
'details' => esc_html__('This logo will be displayed on the the video player.','wpstream'),
'default' => '',
'image_size' => 'thumbnail',
),
// hide the video player logo opacity for now
// 'wpstream_player_logo_opacity' => array(
// 'tab' => 'general_options',
// 'name' => 'player_logo_opacity',
// 'label' => esc_html__('Opacity of the video player logo','wpstream'),
// 'type' => 'range',
// 'details' => esc_html__('Set the opacity of the logo','wpstream'),
// 'default' => '',
// 'image_size' => 'thumbnail',
// ),
'wpsteram_player_logo_position' => array(
'tab' => 'general_options',
'name' => 'player_logo_position',
'label' => esc_html__('Position of the video player logo','wpstream'),
'type' => 'select',
'select_values'=>array(
'top-left' => esc_html__('Top Left','wpstream'),
'top-right' => esc_html__('Top Right','wpstream'),
'bottom-left' => esc_html__('Bottom Left','wpstream'),
'bottom-right' => esc_html__('Bottom Right','wpstream'),
),
'details' => esc_html__('Choose the position of the logo on the video player.','wpstream'),
'default' => '',
),
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'),
),
100 => array(
'tab' => 'default_options_vod',
'label' => esc_html__('Autoplay','wpstream'),
'name' => 'vod_autoplay',
'type' => 'slidertoogle',
'details' => esc_html__('If enabled, video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
),
101 => array(
'tab' => 'default_options_vod',
'label' => esc_html__('Start Muted','wpstream'),
'name' => 'vod_start_muted',
'type' => 'slidertoogle',
'details' => esc_html__('If enabled, video will start muted. This may increase the rate of autoplay in some browsers.','wpstream'),
),
102 => array(
'tab' => 'default_options_vod',
'label' => esc_html__('Lock To Website','wpstream'),
'name' => 'vod_domain_lock',
'type' => 'slidertoogle',
'details' =>sprintf ( esc_html__('If enabled, video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
),
103 => array(
'tab' => 'default_options_vod',
'label' => esc_html__('Encrypt Video','wpstream'),
'name' => 'vod_encrypt',
'type' => 'slidertoogle',
'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'),
),
/* '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',
),*/
104 => array(
'tab' => 'support_tab',
'label' => esc_html__('Logs','wpstream'),
'name' => 'logs',
'type' => 'logs_table',
'details' => esc_html__('This is the error log of the plugin.','wpstream'),
)
);
$active_tab = 'general_options';
if( isset( $_GET[ 'tab' ] ) ) {
$active_tab = $_GET[ 'tab' ];
}
print '
'.__('WpStream Settings','wpstream').'
';
print '
';
}
/**
* Get system information for support tab
*
* @return array System information
*/
private function get_system_info() {
global $wp_version;
$php_version = phpversion();
$wp_version_info = $wp_version;
$site_debug_mode = (defined('WP_DEBUG') && WP_DEBUG);
$wp_memory_limit = WP_MEMORY_LIMIT;
$wpstream_version = WPSTREAM_PLUGIN_VERSION;
$wpstream_plugin_outdated = false;
// Check if plugin is outdated
$update_plugins = get_site_transient('update_plugins');
if (isset($update_plugins->response['plugin/wpstream.php'])) {
$wpstream_plugin_outdated = true;
}
// Check API status
$api_status = false;
if (method_exists($this->main->wpstream_live_connection, 'wpstream_get_token')) {
$token = $this->main->wpstream_live_connection->wpstream_get_token();
$api_status = !empty($token);
}
return array(
'php_version' => $php_version,
'wp_version' => $wp_version_info,
'site_debug_mode' => $site_debug_mode,
'wp_memory_limit' => $wp_memory_limit,
'wpstream_version' => $wpstream_version,
'wpstream_plugin_outdated' => $wpstream_plugin_outdated,
'api_status' => $api_status
);
}
/**
* Render system information HTML
*/
private function render_system_info() {
$system_info = $this->get_system_info();
?>
render_system_info(); ?>
wpstream_get_plugins_data();
if (empty($plugins_data)) {
echo '
'.__( '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' ).'
'.__( '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 '';
}
/**
* Get plugin latest update release date from WordPress.org
* @param $plugin_slug
* @param $version
*
* @return bool
*/
public function get_plugin_release_date( $plugin_slug, $version = null ) {
$api_url = 'https://api.wordpress.org/plugins/info/1.0/' . $plugin_slug . '.json';
$response = wp_remote_get( $api_url );
if ( is_wp_error( $response ) ) {
return false;
}
$body = wp_remote_retrieve_body( $response );
$data = json_decode( $body, true );
if ( !$data || !isset( $data['versions'] ) ) {
return false;
}
// no version provided, get the latest version
if ( !$version ) {
$version = $data['version'];
}
// check if the version exists in the versions array
if ( !isset( $data['versions'][ $version ] ) ) {
return false;
}
if ( isset( $data['last_updated'] ) ) {
return date('Y-m-d', strtotime( $data['last_updated'] ) );
}
return false;
}
/**
* Adds notice for the WpStream update availability
* when the update is not older than 30 days
*/
public function wpstream_plugin_update_available_notice() {
if (!current_user_can('update_plugins')) {
return;
}
$plugin_slug = 'wpstream/wpstream.php';
$update_data = get_site_transient('update_plugins');
if ( is_object( $update_data ) &&
property_exists( $update_data, 'response' ) &&
is_array($update_data->response) &&
key_exists($plugin_slug, $update_data->response)
) {
$new_version = $update_data->response[$plugin_slug]->new_version;
$release_date = $this->get_plugin_release_date( 'wpstream', $new_version );
if ( $release_date ) {
$days_since_release = ( time() - strtotime( $release_date ) ) / DAY_IN_SECONDS;
// if there's an update newer than 7 days, do not show the notice
if ( $days_since_release < 7 ) {
return;
}
}
$update_url = wp_nonce_url(
self_admin_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin_slug)),
'upgrade-plugin_' . $plugin_slug
);
echo '
' . sprintf(
__('Version %s is available. Please update to the latest version for new features and security improvements.', 'wpstream'),
'' . esc_html($new_version) . ''
) . '
';
} else {
esc_html_e('To Go Live, please publish your channel first !','wpstream');
}
}
public function wpstream_is_basic_streaming_mode(){
return $this->main->quota_manager->is_basic_streaming_mode( null, 'wpstream_is_basic_streaming_mode' );
}
public function wpstream_is_use_streaming_hours() {
$pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_start_channel' );
return $this->main->quota_manager->uses_streaming_hours( $pack_details );
}
/**
* Cached-only flags for start_streaming.js localization (no API on cold cache).
*
* @return array{is_basic_streaming: bool, use_streaming_hours: bool}
*/
public function wpstream_get_start_streaming_localization_flags() {
return $this->main->quota_manager->get_streaming_ui_flags_from_cache();
}
/**
*
*
*
*/
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->quota_manager->get_live_quota_data( 'wpstream_pre_onboard_display' );
$this->main->show_user_data($pack_details);
$thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
?>
';
}
}
/*
*
* 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 < 16; $i++) {
$n = random_int(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;
}
?>
wpstream_obboarding_file_warning(); ?>
'.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;
}
?>