*/
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 function __construct( $plugin_name, $version,$plugin_main ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
$this->main = $plugin_main;
}
/**
* 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( 'wpestate-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' );
}
/**
* 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',array(), WPSTREAM_PLUGIN_VERSION, true);
wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js',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 bandwidth.','wpsteam'),
'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
));
}
/**
* Add Plugin Administation menu
*
* @since 3.0.1
*/
public function wpstream_manage_admin_menu() {
add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
add_submenu_page( 'wpstream_plugin_options', __('WpStream Options','wpestream'), __('WpStream Options','wpestream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
add_submenu_page( 'wpstream_plugin_options', __('WpStream Channels','wpestream'), __('WpStream Channels','wpestream'), 'administrator', 'wpstream_new_general_set', array( $this,'wpstream_new_general_set'));
add_submenu_page( 'wpstream_plugin_options', __('WpStream Media Management','wpestream'), __('WpStream Media Management','wpestream'), 'administrator', 'wpstream_media_management', array($this,'wpstream_media_management'));
}
/**
* 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 '
'.
sprintf(esc_html__('Use %s on your Windows or Mac computer, or the Larix Broadcaster app on your %s or %s smartphone/tablet. Various other software and devices are supported, see our %s for details.','wpstream'),'OBS Studio',' iOS','Android','guides').'
';
print ' ';
print'
';
print'
';
print '
';
print '
'.__('Channel is inactive.','wpestream').'
';
print '
Record ? Yes
';
print '
Encrypt ? Yes
';
print '';
print '';
print '
'.esc_html__('* You can run multiple live events on a single channel. **Once deleted, you can no longer broadcast to it.','wpstream').'
';
print '
';
print '
';
print '
';
print '
';
print '
';
print '
';
print '
';
print '
';
print 'Some Facebook Settings for event '.$the_id;
print '
'.esc_html__('You can choose a video from your computer or use the url from external source or use the url of a YouTube Video or use the url from a Vimeo video.','wpstream').'
';
}
/**
* 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;
?>
';
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 '
';
}
/**
* 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'
);
$allowed_html=array();
foreach($_POST as $key=>$value){
update_post_meta( $post_id, 'event_passed', 0 );
if( in_array($key, $permited_values) ){
if( !empty( $_POST[$key] ) ){
update_post_meta( $post_id, wp_kses ($key,$allowed_html), wp_kses ( $_POST[$key],$allowed_html) );
}
}
}
}
/**
* 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;
if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
print '
'.__( 'WpStream Pay Per View / Subscription mode works only with WooCommerce - If you want to charge money for your live events or videos you need to activate WooCommerce plugin', 'wpestate' ).'
'.__( 'The php CURL library is not enabled on your server. WpStream plugin needs this library in order to work. Please address this issue with your hosting provider.', 'wpestate' ).'
'.esc_html__( 'New! We just released WpStream WordPress Theme - a turn key solution for video delivery & live streaming. This theme is built around WpStream plugin and is the perfect solution for video streaming or rentals platform. ','wpstream').''.esc_html__('Download Theme','wpstream').'