*/ class Wpstream { /** * Store plugin main class to allow public access. * * @since 3.0.1 * @var object The main class. */ public $main; public $admin; /** * The loader that's responsible for maintaining and registering all hooks that power * the plugin. * * @since 3.0.1 * @access protected * @var Wpstream_Loader $loader Maintains and registers all hooks for the plugin. */ protected $loader; /** * The unique identifier of this plugin. * * @since 3.0.1 * @access protected * @var string $plugin_name The string used to uniquely identify this plugin. */ protected $plugin_name; /** * The current version of the plugin. * * @since 3.0.1 * @access protected * @var string $version The current version of the plugin. */ protected $version; /** * Define the core functionality of the plugin. * * Set the plugin name and the plugin version that can be used throughout the plugin. * Load the dependencies, define the locale, and set the hooks for the admin area and * the public-facing side of the site. * * @since 3.0.1 */ public $wpstream_live_connection; public $wpstream_player; public $quota_manager; public $xtest; public $plugin_admin; public function __construct() { $this->main = $this; if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) { $this->version = WPSTREAM_PLUGIN_VERSION; } else { $this->version = '3.0.1'; } $this->plugin_name = 'wpstream'; $this->load_dependencies(); $this->define_admin_hooks(); $this->define_public_hooks(); $this->define_ajax_hooks(); $this->wpstream_load_page_templates(); $this->wpstream_load_theme_notice(); $this->wpstream_conection(); $this->wpstream_player(); $this->wpstream_init_quota_manager(); } public function wpstream_convert_band($megabits){ $gigabit = $megabits * 0.001; return floatval( sprintf( '%.1f', $gigabit ) ); } public $wpstream_ajax; private function define_ajax_hooks() { require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wpstream-ajax.php'; $this->wpstream_ajax = new WpStream_Ajax( $this->main ); } private function wpstream_conection(){ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-live-api-connection.php'; $this->wpstream_live_connection = new Wpstream_Live_Api_Connection(); } private function wpstream_player(){ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-player.php'; $this->wpstream_player = new Wpstream_Player($this->main); } private function wpstream_init_quota_manager() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-quota-manager.php'; $this->quota_manager = new Wpstream_Quota_Manager( $this ); } private function wpstream_load_page_templates() { require_once WPSTREAM_PLUGIN_PATH . 'includes/class-wpstream-templates.php'; new WpStream_Template_Loader(); } private function wpstream_load_theme_notice() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-theme-notice.php'; new WPStream_Theme_Notice(); } /** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - Wpstream_Loader. Orchestrates the hooks of the plugin. * - Wpstream_i18n. Defines internationalization functionality. * - Wpstream_Admin. Defines all hooks for the admin area. * - Wpstream_Public. Defines all hooks for the public side of the site. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * * @since 3.0.1 * @access private */ private function load_dependencies() { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-loader.php'; /** * The class responsible for defining internationalization functionality * of the plugin. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-i18n.php'; /** * The class responsible for defining all actions that occur in the admin area. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpstream-admin.php'; /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpstream-public.php'; /** * The class responsible for custom post type */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream_product.php'; if( class_exists( 'WooCommerce' ) ){ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php'; } require_once plugin_dir_path(__FILE__) . 'Helpers/class-wpstream-log-entry.php'; require_once plugin_dir_path(__FILE__) . 'Logger/class-wpstream-logger.php'; $this->loader = new Wpstream_Loader(); } /** * Define the locale for this plugin for internationalization. * * Uses the Wpstream_i18n class in order to set the domain and to register the hook * with WordPress. * * @since 3.0.1 * @access private */ private function set_locale() { $plugin_i18n = new Wpstream_i18n(); $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain', 1 ); } /** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 3.0.1 * @access private */ private function define_admin_hooks() { $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main ); $this->admin = $plugin_admin; $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999); $plugin_post_types = new Wpstream_Product(); $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 ); // save and render metaboxed $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wpstream_product_metaboxes' ); $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 ); $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 ); // make product virtual $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 ); // show streaming controls on sidebar $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta'); // on boarding actions $this->loader->add_action('admin_footer',$plugin_admin, 'wpstream_admin_footer_onboarding'); $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel', $plugin_admin,'wpstream_on_board_create_channel' ); $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' ); $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' ); $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' ); $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' ); $this->loader->add_action( 'wp_ajax_wpstream_on_board_register', $plugin_admin,'wpstream_on_board_register' ); // Register AJAX actions for multipart uploads $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' ); $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' ); $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' ); $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_plugin_update_available_notice' ); $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' ); // $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' ); $this->loader->add_action( 'wp_ajax_wpstream_settings_tab_update_plugin', $plugin_admin, 'wpstream_settings_tab_update_plugin' ); // add and save category extra fields $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { $this->loader->add_action( 'init', $plugin_admin, 'wpstream_add_custom_wc_products' ); $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' ); $this->loader->add_filter( 'woocommerce_product_class', $plugin_admin, 'wpstream_add_products_class', 10, 2 ); $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' ); $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 ); $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2); $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1); $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 ); $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1); $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1); $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 ); } } /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 3.0.1 * @access private */ private function define_public_hooks() { $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' ); $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 ); //live stream action $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0); $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key'); $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty'); $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10); // woo action $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 ); $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 ); $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 ); $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 ); $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' ); $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' ); $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' ); $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' ); $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes'); $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes'); $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1); $this->loader->add_filter( 'wpstream_search_template_item_post_type', $plugin_public, 'wpstream_search_template_add_item_post_type' ); $this->loader->add_filter( 'wpstream_sidebar_id_by_post_type', $plugin_public, 'wpstream_sidebar_id_by_post_type' ); $this->loader->add_filter( 'wpstream_header_search_values', $plugin_public, 'wpstream_header_search_values' ); $this->loader->add_filter( 'wpstream_extend_category_archive_query_filter', $plugin_public, 'wpstream_extend_category_archive_query_filter_callback' ); $this->loader->add_filter( 'wpstream_archives_lists_taxonomy_labels', $plugin_public, 'wpstream_archives_lists_taxonomy_labels_callback' ); $this->loader->add_filter( 'wpstream_author_archive_list_taxonomy_labels', $plugin_public, 'wpstream_author_archive_list_taxonomy_labels_callback' ); $this->loader->add_action( 'wpstream_vod_attached_to_channel', $plugin_public, 'wpstream_vod_attached_to_channel' ); $this->loader->add_action( 'wpstream_additional_content_post_type', $plugin_public, 'wpstream_additional_content_post_type_callback' ); $this->loader->add_action( 'wpstream_post_author_content_post_type_list', $plugin_public, 'wpstream_post_author_content_post_type_list_callback' ); $this->loader->add_action( 'wpstream_author_content_simple_post_type_message', $plugin_public, 'wpstream_author_content_simple_post_type_message_callback', 10, 2 ); $this->loader->add_action( 'wpstream_author_content_post_type_message', $plugin_public, 'wpstream_author_content_post_type_message_callback', 10, 2 ); $this->loader->add_action( 'wpstream_show_sidebar_for_post_type', $plugin_public, 'wpstream_show_sidebar_for_post_type_callback', 10, 2 ); $this->loader->add_action( 'wpstream_video_episodes_post_type', $plugin_public, 'wpstream_video_episodes_post_type_callback' ); $this->loader->add_action( 'wpstream_video_past_broadcast_post_type', $plugin_public, 'wpstream_video_past_broadcast_post_type_callback' ); $this->loader->add_action( 'wpstream_additional_content_post_type_label', $plugin_public, 'wpstream_additional_content_post_type_label_callback', 10, 2 ); } /** * Run the loader to execute all of the hooks with WordPress. * * @since 3.0.1 */ public function run() { $this->loader->run(); } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 3.0.1 * @return string The name of the plugin. */ public function get_plugin_name() { return $this->plugin_name; } /** * The reference to the class that orchestrates the hooks with the plugin. * * @since 3.0.1 * @return Wpstream_Loader Orchestrates the hooks of the plugin. */ public function get_loader() { return $this->loader; } /** * Retrieve the version number of the plugin. * * @since 3.0.1 * @return string The version number of the plugin. */ public function get_version() { return $this->version; } public function is_plugin_outdated(){ $update_data = get_site_transient('update_plugins'); $plugin_path = 'wpstream/wpstream.php'; if (isset($update_data->response[$plugin_path])) { return true; } return false; } public function show_user_data($pack_details){ if( isset($pack_details['available_data_mb']) && isset( $pack_details['available_storage_mb']) ){ $wpstream_convert_band = $this->wpstream_convert_band($pack_details['available_data_mb']); if( $wpstream_convert_band < 0 ) { $wpstream_convert_band = 0; } $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['available_storage_mb']); if( $wpstream_convert_storage < 0 ) { $wpstream_convert_storage = 0; } print '