| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * The file that defines the core plugin class |
| 4 | 5 | * |
| 5 | 6 | * A class definition that includes attributes and functions used across both the |
| @@ -34,9 +35,8 @@ | ||
| 34 | 35 | * @since 3.0.1 |
| 35 | 36 | * @var object The main class. |
| 36 | 37 | */ |
| 37 | 38 | public $main; |
| 38 | - public $admin; | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * The loader that's responsible for maintaining and registering all hooks that power |
| 42 | 42 | * the plugin. |
| @@ -76,54 +76,45 @@ | ||
| 76 | 76 | */ |
| 77 | 77 | |
| 78 | 78 | public $wpstream_live_connection; |
| 79 | 79 | public $wpstream_player; |
| 80 | - public $quota_manager; | |
| 81 | 80 | public $xtest; |
| 82 | 81 | public $plugin_admin; |
| 83 | 82 | |
| 84 | 83 | public function __construct() { |
| 85 | - $this->main = $this; | |
| 86 | - | |
| 87 | - if ( defined( 'WPSTREAM_PLUGIN_VERSION' ) ) { | |
| 88 | - $this->version = WPSTREAM_PLUGIN_VERSION; | |
| 84 | + $this->main = $this; | |
| 85 | + if ( defined( 'WPSTREAM_VERSION' ) ) { | |
| 86 | + $this->version = WPSTREAM_VERSION; | |
| 89 | 87 | } else { |
| 90 | - $this->version = '3.0.1'; | |
| 88 | + $this->version = '3.0.1'; | |
| 91 | 89 | } |
| 92 | - | |
| 93 | 90 | $this->plugin_name = 'wpstream'; |
| 94 | 91 | |
| 95 | 92 | $this->load_dependencies(); |
| 93 | + $this->set_locale(); | |
| 96 | 94 | $this->define_admin_hooks(); |
| 97 | 95 | $this->define_public_hooks(); |
| 98 | - $this->define_ajax_hooks(); | |
| 99 | - $this->wpstream_load_page_templates(); | |
| 100 | - $this->wpstream_load_theme_notice(); | |
| 96 | + | |
| 97 | + $this->xtest = "this is test2"; | |
| 98 | + $this->wpstream_conection(); | |
| 99 | + $this->wpstream_player(); | |
| 101 | 100 | |
| 102 | - $this->wpstream_conection(); | |
| 103 | - $this->wpstream_player(); | |
| 104 | - $this->wpstream_init_quota_manager(); | |
| 105 | - | |
| 106 | 101 | } |
| 107 | 102 | |
| 108 | - | |
| 109 | - | |
| 110 | - | |
| 111 | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 112 | 107 | public function wpstream_convert_band($megabits){ |
| 113 | - $gigabit = $megabits * 0.001; | |
| 114 | - return floatval( sprintf( '%.1f', $gigabit ) ); | |
| 108 | + $gigabit = $megabits * 0.001; | |
| 109 | + $gigabit = number_format($gigabit,2); | |
| 110 | + return $gigabit; | |
| 115 | 111 | } |
| 116 | 112 | |
| 117 | - | |
| 118 | - public $wpstream_ajax; | |
| 119 | - | |
| 120 | - private function define_ajax_hooks() { | |
| 121 | - require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wpstream-ajax.php'; | |
| 122 | - $this->wpstream_ajax = new WpStream_Ajax( $this->main ); | |
| 123 | - } | |
| 124 | 113 | |
| 125 | 114 | |
| 115 | + | |
| 116 | + | |
| 126 | 117 | private function wpstream_conection(){ |
| 127 | 118 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-live-api-connection.php'; |
| 128 | 119 | $this->wpstream_live_connection = new Wpstream_Live_Api_Connection(); |
| 129 | 120 | } |
| @@ -132,26 +123,12 @@ | ||
| 132 | 123 | private function wpstream_player(){ |
| 133 | 124 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-player.php'; |
| 134 | 125 | $this->wpstream_player = new Wpstream_Player($this->main); |
| 135 | 126 | } |
| 136 | - | |
| 137 | - private function wpstream_init_quota_manager() { | |
| 138 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-quota-manager.php'; | |
| 139 | - $this->quota_manager = new Wpstream_Quota_Manager( $this ); | |
| 140 | - } | |
| 141 | - | |
| 142 | - | |
| 143 | - private function wpstream_load_page_templates() { | |
| 144 | - require_once WPSTREAM_PLUGIN_PATH . 'includes/class-wpstream-templates.php'; | |
| 145 | - new WpStream_Template_Loader(); | |
| 146 | - } | |
| 147 | - | |
| 148 | - private function wpstream_load_theme_notice() { | |
| 149 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream-theme-notice.php'; | |
| 150 | - new WPStream_Theme_Notice(); | |
| 151 | - } | |
| 152 | 127 | |
| 153 | 128 | |
| 129 | + | |
| 130 | + | |
| 154 | 131 | /** |
| 155 | 132 | * Load the required dependencies for this plugin. |
| 156 | 133 | * |
| 157 | 134 | * Include the following files that make up the plugin: |
| @@ -190,21 +167,19 @@ | ||
| 190 | 167 | * The class responsible for defining all actions that occur in the public-facing |
| 191 | 168 | * side of the site. |
| 192 | 169 | */ |
| 193 | 170 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpstream-public.php'; |
| 194 | - /** | |
| 171 | + | |
| 172 | + /** | |
| 195 | 173 | * The class responsible for custom post type |
| 196 | 174 | |
| 197 | - */ | |
| 198 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream_product.php'; | |
| 199 | - if( class_exists( 'WooCommerce' ) ){ | |
| 200 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php'; | |
| 201 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php'; | |
| 202 | - } | |
| 175 | + */ | |
| 176 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpstream_product.php'; | |
| 177 | + if( class_exists( 'WooCommerce' ) ){ | |
| 178 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php'; | |
| 179 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php'; | |
| 180 | + } | |
| 203 | 181 | |
| 204 | - require_once plugin_dir_path(__FILE__) . 'Helpers/class-wpstream-log-entry.php'; | |
| 205 | - require_once plugin_dir_path(__FILE__) . 'Logger/class-wpstream-logger.php'; | |
| 206 | - | |
| 207 | 182 | $this->loader = new Wpstream_Loader(); |
| 208 | 183 | |
| 209 | 184 | } |
| 210 | 185 | |
| @@ -220,9 +195,9 @@ | ||
| 220 | 195 | private function set_locale() { |
| 221 | 196 | |
| 222 | 197 | $plugin_i18n = new Wpstream_i18n(); |
| 223 | 198 | |
| 224 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain', 1 ); | |
| 199 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); | |
| 225 | 200 | |
| 226 | 201 | } |
| 227 | 202 | |
| 228 | 203 | /** |
| @@ -233,95 +208,64 @@ | ||
| 233 | 208 | * @access private |
| 234 | 209 | */ |
| 235 | 210 | private function define_admin_hooks() { |
| 236 | 211 | |
| 237 | - $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main ); | |
| 212 | + $this->admin= $plugin_admin = new Wpstream_Admin( $this->get_plugin_name(), $this->get_version(), $this->main ); | |
| 238 | 213 | |
| 239 | - $this->admin = $plugin_admin; | |
| 240 | - | |
| 241 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); | |
| 242 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); | |
| 214 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); | |
| 215 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); | |
| 243 | 216 | $this->loader->add_action( 'admin_menu', $plugin_admin, 'wpstream_manage_admin_menu',999); |
| 244 | - | |
| 217 | + | |
| 245 | 218 | $plugin_post_types = new Wpstream_Product(); |
| 246 | 219 | $this->loader->add_action( 'init', $plugin_post_types, 'create_custom_post_type', 999 ); |
| 247 | - | |
| 220 | + | |
| 248 | 221 | // save and render metaboxed |
| 249 | - $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wpstream_product_metaboxes' ); | |
| 250 | - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 ); | |
| 251 | - $this->loader->add_action( 'publish_wpstream_product', $plugin_admin, 'wpstream_publish_wpstream_product',1,2 ); | |
| 252 | - | |
| 253 | - | |
| 254 | - | |
| 255 | - // make product virtual | |
| 256 | - $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_make_product_virtual', 99999, 2 ); | |
| 222 | + $this->loader->add_action( 'admin_init', $plugin_admin, 'add_wpstream_product_metaboxes' ); | |
| 223 | + $this->loader->add_action( 'save_post', $plugin_admin, 'wpstream_free_product_update_post',1,2 ); | |
| 224 | + | |
| 225 | + // show streaming controls on sidebar | |
| 226 | + $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta'); | |
| 257 | 227 | |
| 258 | 228 | |
| 229 | + $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' ); | |
| 230 | + $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' ); | |
| 259 | 231 | |
| 260 | - // show streaming controls on sidebar | |
| 261 | - $this->loader->add_action('add_meta_boxes', $plugin_admin, 'wpstream_startstreaming_sidebar_meta'); | |
| 262 | - | |
| 263 | - // on boarding actions | |
| 264 | - $this->loader->add_action('admin_footer',$plugin_admin, 'wpstream_admin_footer_onboarding'); | |
| 265 | - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel', $plugin_admin,'wpstream_on_board_create_channel' ); | |
| 266 | - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_channel_ppv', $plugin_admin,'wpstream_on_board_create_channel_ppv' ); | |
| 267 | - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_free_vod', $plugin_admin,'wpstream_on_board_create_free_vod' ); | |
| 268 | - $this->loader->add_action( 'wp_ajax_wpstream_on_board_create_ppv_vod', $plugin_admin,'wpstream_on_board_create_ppv_vod' ); | |
| 269 | - | |
| 270 | - | |
| 271 | - $this->loader->add_action( 'wp_ajax_wpstream_on_board_login', $plugin_admin,'wpstream_on_board_login' ); | |
| 272 | - $this->loader->add_action( 'wp_ajax_wpstream_on_board_register', $plugin_admin,'wpstream_on_board_register' ); | |
| 273 | - | |
| 274 | - // Register AJAX actions for multipart uploads | |
| 275 | - $this->loader->add_action( 'wp_ajax_wpstream_initiate_multipart_upload', $plugin_admin, 'handle_initiate_multipart_upload' ); | |
| 276 | - $this->loader->add_action( 'wp_ajax_wpstream_complete_multipart_upload', $plugin_admin, 'handle_complete_multipart_upload' ); | |
| 277 | - | |
| 278 | - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_admin_notice' ); | |
| 279 | - $this->loader->add_action( 'admin_notices', $plugin_admin,'wpstream_plugin_update_available_notice' ); | |
| 280 | - | |
| 281 | - $this->loader->add_action( 'wp_ajax_wpstream_update_cache_notice', $plugin_admin,'wpstream_update_cache_notice' ); | |
| 282 | -// $this->loader->add_action( 'wp_ajax_wpstream_get_videos_list', $plugin_admin,'wpstream_get_videos_list' ); | |
| 283 | - | |
| 284 | - | |
| 285 | - $this->loader->add_action( 'wp_ajax_wpstream_settings_tab_update_plugin', $plugin_admin, 'wpstream_settings_tab_update_plugin' ); | |
| 286 | - | |
| 287 | 232 | // add and save category extra fields |
| 288 | 233 | $this->loader->add_action( 'category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); |
| 289 | - $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); | |
| 234 | + $this->loader->add_action( 'category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 ); | |
| 290 | 235 | $this->loader->add_action( 'created_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 291 | 236 | $this->loader->add_action( 'edited_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 292 | 237 | |
| 293 | 238 | $this->loader->add_action( 'product_cat_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); |
| 294 | - $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); | |
| 239 | + $this->loader->add_action( 'product_cat_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 ); | |
| 295 | 240 | $this->loader->add_action( 'created_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 296 | 241 | $this->loader->add_action( 'edited_product_cat', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 297 | 242 | |
| 298 | 243 | |
| 299 | 244 | $this->loader->add_action( 'wpstream_category_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); |
| 300 | - $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); | |
| 245 | + $this->loader->add_action( 'wpstream_category_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 ); | |
| 301 | 246 | $this->loader->add_action( 'created_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 302 | 247 | $this->loader->add_action( 'edited_wpstream_category', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 303 | 248 | |
| 304 | 249 | |
| 305 | 250 | $this->loader->add_action( 'wpstream_actors_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); |
| 306 | - $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); | |
| 251 | + $this->loader->add_action( 'wpstream_actors_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 ); | |
| 307 | 252 | $this->loader->add_action( 'created_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 308 | 253 | $this->loader->add_action( 'edited_wpstream_actors', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 309 | 254 | |
| 310 | 255 | $this->loader->add_action( 'wpstream_movie_rating_edit_form_fields', $plugin_post_types, 'wpstream_category_callback_function', 10, 2); |
| 311 | - $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function' ); | |
| 256 | + $this->loader->add_action( 'wpstream_movie_rating_add_form_fields', $plugin_post_types, 'wpstream_category_callback_add_function', 10, 2 ); | |
| 312 | 257 | $this->loader->add_action( 'created_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 313 | 258 | $this->loader->add_action( 'edited_wpstream_movie_rating', $plugin_post_types, 'wpstream_category_save_extra_fields_callback', 10, 2); |
| 259 | + | |
| 260 | + | |
| 314 | 261 | |
| 315 | 262 | |
| 316 | 263 | if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
| 317 | - | |
| 318 | - $this->loader->add_action( 'init', $plugin_admin, 'wpstream_add_custom_wc_products' ); | |
| 264 | + | |
| 319 | 265 | $this->loader->add_filter( 'product_type_selector', $plugin_admin, 'wpstream_add_products' ); |
| 320 | - $this->loader->add_filter( 'woocommerce_product_class', $plugin_admin, 'wpstream_add_products_class', 10, 2 ); | |
| 321 | 266 | $this->loader->add_action( 'admin_footer', $plugin_admin, 'wpstream_products_custom_js' ); |
| 322 | 267 | $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'wpstream_hide_attributes_data_panel',10,1 ); |
| 323 | - $this->loader->add_filter( 'woocommerce_is_purchasable', $plugin_admin, 'wpstream_hide_buy_now_subscription_mode',10,2); | |
| 324 | 268 | |
| 325 | 269 | $this->loader->add_filter( 'woocommerce_product_options_general_product_data',$plugin_admin, 'wpstream_add_custom_general_fields', 10,1); |
| 326 | 270 | $this->loader->add_filter( 'woocommerce_process_product_meta',$plugin_admin, 'wpstream_add_custom_general_fields_save',10,1 ); |
| 327 | 271 | $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1); |
| @@ -327,14 +271,16 @@ | ||
| 327 | 271 | $this->loader->add_action( 'woocommerce_live_stream_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1); |
| 328 | 272 | $this->loader->add_action( 'woocommerce_video_on_demand_add_to_cart', $plugin_admin, 'wpstream_add_to_cart',10,1); |
| 329 | 273 | $this->loader->add_filter( 'woocommerce_loop_add_to_cart_link', $plugin_admin,'replacing_add_to_cart_button', 10, 2 ); |
| 330 | 274 | } |
| 331 | - } | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 332 | 279 | |
| 333 | 280 | |
| 281 | + } | |
| 334 | 282 | |
| 335 | - | |
| 336 | - | |
| 337 | 283 | /** |
| 338 | 284 | * Register all of the hooks related to the public-facing functionality |
| 339 | 285 | * of the plugin. |
| 340 | 286 | * |
| @@ -346,49 +292,44 @@ | ||
| 346 | 292 | $plugin_public = new Wpstream_Public( $this->get_plugin_name(), $this->get_version(), $this->main ); |
| 347 | 293 | |
| 348 | 294 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
| 349 | 295 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
| 296 | + | |
| 297 | + $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' ); | |
| 298 | + $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 ); | |
| 299 | + | |
| 300 | + //live stream action | |
| 301 | + $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0); | |
| 302 | + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key'); | |
| 303 | + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty'); | |
| 304 | + $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod'); | |
| 305 | + // woo action | |
| 306 | + | |
| 307 | + $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 ); | |
| 308 | + $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 ); | |
| 309 | + | |
| 310 | + $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' ); | |
| 311 | + $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' ); | |
| 312 | + $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' ); | |
| 313 | + | |
| 350 | 314 | |
| 351 | - $this->loader->add_action( 'init', $plugin_public,'wpstream_my_custom_endpoints' ); | |
| 352 | - $this->loader->add_filter( 'query_vars',$plugin_public, 'wpstream_my_custom_query_vars', 0 ); | |
| 315 | + $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' ); | |
| 316 | + $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes'); | |
| 353 | 317 | |
| 354 | - //live stream action | |
| 355 | - $this->loader->add_action('init',$plugin_public,'wpstream_set_cookies',0); | |
| 356 | - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key'); | |
| 357 | - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_for_3rdparty'); | |
| 358 | - $this->loader->add_action('init',$plugin_public,'wpstream_live_streaming_key_vod',10); | |
| 359 | - | |
| 360 | - // woo action | |
| 361 | - $this->loader->add_action( 'woocommerce_before_single_product', $plugin_public,'wpstream_non_image_content_wrapper_start', 20 ); | |
| 362 | - $this->loader->add_action( 'woocommerce_after_single_product', $plugin_public,'wpstream_non_image_content_wrapper_end', 20 ); | |
| 363 | - $this->loader->add_action( 'woocommerce_thankyou_order_received_text', $plugin_public,'wpstream_thankyou_extra', 20,2 ); | |
| 364 | - $this->loader->add_action( 'woocommerce_email_order_details', $plugin_public,'wpstream_email_order_details', 20,4 ); | |
| 365 | - | |
| 366 | - $this->loader->add_filter( 'woocommerce_account_menu_items', $plugin_public,'wpstream_custom_my_account_menu_items' ); | |
| 367 | - $this->loader->add_action( 'woocommerce_account_event-list_endpoint', $plugin_public,'wpstream_custom_endpoint_content_event_list' ); | |
| 368 | - $this->loader->add_action( 'woocommerce_account_video-list_endpoint', $plugin_public,'wpstream_custom_endpoint_video_list' ); | |
| 369 | - | |
| 370 | - $this->loader->add_action( 'after_switch_theme', $plugin_public,'wpstream_custom_flush_rewrite_rules' ); | |
| 371 | - $this->loader->add_action('init', $plugin_public,'wpstream_shortcodes'); | |
| 372 | - $this->loader->add_action('vc_before_init', $plugin_public,'wpstream_bakery_shortcodes'); | |
| 373 | - | |
| 374 | - $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1); | |
| 375 | - | |
| 376 | - $this->loader->add_filter( 'wpstream_search_template_item_post_type', $plugin_public, 'wpstream_search_template_add_item_post_type' ); | |
| 377 | - $this->loader->add_filter( 'wpstream_sidebar_id_by_post_type', $plugin_public, 'wpstream_sidebar_id_by_post_type' ); | |
| 378 | - $this->loader->add_filter( 'wpstream_header_search_values', $plugin_public, 'wpstream_header_search_values' ); | |
| 379 | - $this->loader->add_filter( 'wpstream_extend_category_archive_query_filter', $plugin_public, 'wpstream_extend_category_archive_query_filter_callback' ); | |
| 380 | - $this->loader->add_filter( 'wpstream_archives_lists_taxonomy_labels', $plugin_public, 'wpstream_archives_lists_taxonomy_labels_callback' ); | |
| 381 | - $this->loader->add_filter( 'wpstream_author_archive_list_taxonomy_labels', $plugin_public, 'wpstream_author_archive_list_taxonomy_labels_callback' ); | |
| 382 | - $this->loader->add_action( 'wpstream_vod_attached_to_channel', $plugin_public, 'wpstream_vod_attached_to_channel' ); | |
| 383 | - $this->loader->add_action( 'wpstream_additional_content_post_type', $plugin_public, 'wpstream_additional_content_post_type_callback' ); | |
| 384 | - $this->loader->add_action( 'wpstream_post_author_content_post_type_list', $plugin_public, 'wpstream_post_author_content_post_type_list_callback' ); | |
| 385 | - $this->loader->add_action( 'wpstream_author_content_simple_post_type_message', $plugin_public, 'wpstream_author_content_simple_post_type_message_callback', 10, 2 ); | |
| 386 | - $this->loader->add_action( 'wpstream_author_content_post_type_message', $plugin_public, 'wpstream_author_content_post_type_message_callback', 10, 2 ); | |
| 387 | - $this->loader->add_action( 'wpstream_show_sidebar_for_post_type', $plugin_public, 'wpstream_show_sidebar_for_post_type_callback', 10, 2 ); | |
| 388 | - $this->loader->add_action( 'wpstream_video_episodes_post_type', $plugin_public, 'wpstream_video_episodes_post_type_callback' ); | |
| 389 | - $this->loader->add_action( 'wpstream_video_past_broadcast_post_type', $plugin_public, 'wpstream_video_past_broadcast_post_type_callback' ); | |
| 390 | - $this->loader->add_action( 'wpstream_additional_content_post_type_label', $plugin_public, 'wpstream_additional_content_post_type_label_callback', 10, 2 ); | |
| 318 | +// // rewrite urls | |
| 319 | +// $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_tag', 10, 0); | |
| 320 | +// $this->loader->add_action('init', $plugin_public,'wpstream_custom_rewrite_rule', 10, 0); | |
| 321 | +// | |
| 322 | +// $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_userkey_page_template' ); | |
| 323 | +// $this->loader->add_filter( 'page_template',$plugin_public, 'wpstream_vodkey_page_template' ); | |
| 324 | + | |
| 325 | + //api | |
| 326 | + | |
| 327 | + | |
| 328 | + $this->loader->add_action('wo_before_api', 'wpstream_cors_check_and_response',10,1); | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 391 | 332 | } |
| 392 | 333 | |
| 393 | 334 | /** |
| 394 | 335 | * Run the loader to execute all of the hooks with WordPress. |
| @@ -428,310 +369,20 @@ | ||
| 428 | 369 | */ |
| 429 | 370 | public function get_version() { |
| 430 | 371 | return $this->version; |
| 431 | 372 | } |
| 432 | - | |
| 433 | - public function is_plugin_outdated(){ | |
| 434 | - $update_data = get_site_transient('update_plugins'); | |
| 435 | - $plugin_path = 'wpstream/wpstream.php'; | |
| 436 | - | |
| 437 | - if (isset($update_data->response[$plugin_path])) { | |
| 438 | - return true; | |
| 439 | - } | |
| 440 | - | |
| 441 | - return false; | |
| 442 | - } | |
| 443 | - | |
| 444 | - | |
| 445 | - | |
| 446 | - public function show_user_data($pack_details){ | |
| 447 | - if( isset($pack_details['available_data_mb']) && isset( $pack_details['available_storage_mb']) ){ | |
| 448 | - $wpstream_convert_band = $this->wpstream_convert_band($pack_details['available_data_mb']); | |
| 449 | - if( $wpstream_convert_band < 0 ) { | |
| 450 | - $wpstream_convert_band = 0; | |
| 451 | - } | |
| 452 | - | |
| 453 | - $wpstream_convert_storage = $this->wpstream_convert_band($pack_details['available_storage_mb']); | |
| 454 | - if( $wpstream_convert_storage < 0 ) { | |
| 455 | - $wpstream_convert_storage = 0; | |
| 456 | - } | |
| 457 | - | |
| 458 | - print '<div class="pack_details_wrapper">' | |
| 459 | - . '<strong>' . __('Your account information: ', 'wpstream') . '</strong> ' | |
| 460 | - . __('You have ', 'wpstream') . '<strong id="wpstream_available_data">' . abs( $wpstream_convert_band ) . ' GB</strong> ' | |
| 461 | - . __('available cloud data and ', 'wpstream') | |
| 462 | - . '<strong id="wpstream_available_storage">' . abs( $wpstream_convert_storage ) . ' GB</strong> ' | |
| 463 | - . __('available cloud storage', 'wpstream') . '.'; | |
| 464 | - | |
| 465 | - print '<a href="https://wpstream.net/pricing/" class="wpstream_upgrade_topbar" target="_blank">'.esc_html__('Upgrade Plan','wpstream').'</a>'; | |
| 466 | - print '</div>'; | |
| 467 | - print'<input type="hidden" id="wpstream_band" value="'.$pack_details['available_data_mb'].'">'; | |
| 468 | - print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['available_storage_mb'].'">'; | |
| 469 | - | |
| 470 | - } | |
| 471 | - } | |
| 472 | - | |
| 473 | 373 | |
| 474 | - /** | |
| 475 | - * help function for media list elementor widget | |
| 476 | - * | |
| 477 | - * @since 3.0.1 | |
| 478 | - * @return string | |
| 479 | - */ | |
| 480 | 374 | |
| 481 | - public function wpstream_media_list_elementor_function($attributes, $content = null){ | |
| 482 | - | |
| 483 | - | |
| 484 | - $media_number=3; | |
| 485 | - if ( isset($attributes['media_number']) ){ | |
| 486 | - $media_number=$attributes['media_number']; | |
| 487 | - } | |
| 488 | - | |
| 489 | - | |
| 490 | - $row_number=3; | |
| 491 | - if ( isset($attributes['row_number']) ){ | |
| 492 | - $row_number=$attributes['row_number']; | |
| 493 | - } | |
| 494 | - if($row_number>4){ | |
| 495 | - $row_number=4; | |
| 496 | - } | |
| 497 | - | |
| 498 | - | |
| 499 | - ob_start(); | |
| 500 | - | |
| 501 | - // check if is vod or live stream | |
| 502 | - $meta_query = array(); | |
| 503 | - $tax_query_array= array(); | |
| 504 | - $tax_query = array(); | |
| 505 | - | |
| 506 | - // check if the media is paid or free | |
| 507 | - $event_types = array(); | |
| 508 | - $product_type_free_paid = 0; | |
| 509 | - if ( isset($attributes['product_type_free_paid']) ){ | |
| 510 | - $product_type_free_paid=$attributes['product_type_free_paid']; | |
| 511 | - | |
| 512 | - if($product_type_free_paid==0){ | |
| 513 | - $event_types=array('wpstream_product'); | |
| 514 | - | |
| 515 | - if ( isset($attributes['product_type']) && intval($attributes['product_type'])==2){ | |
| 516 | - $event_types=array('wpstream_product_vod'); | |
| 517 | - } | |
| 518 | - | |
| 519 | - }else{ | |
| 520 | - $event_types=array('product'); | |
| 521 | - if ( isset($attributes['product_type']) ){ | |
| 522 | - $product_type = $attributes['product_type']; | |
| 523 | - $product_type_slug = 'video_on_demand'; | |
| 524 | - if($product_type==1){ | |
| 525 | - $product_type_slug ='live_stream'; | |
| 526 | - } | |
| 527 | - | |
| 528 | - $tax_query_array = array( | |
| 529 | - 'taxonomy' => 'product_type', | |
| 530 | - 'field' => 'slug', | |
| 531 | - 'terms' => $product_type_slug | |
| 532 | - ); | |
| 533 | - | |
| 534 | - $tax_query= array( | |
| 535 | - 'relation' => 'AND', | |
| 536 | - $tax_query_array | |
| 537 | - ); | |
| 538 | - | |
| 539 | - } | |
| 540 | - } | |
| 541 | - | |
| 542 | - } | |
| 543 | - $see_product=''; | |
| 544 | - if(isset($attributes['free_label'])){ | |
| 545 | - $see_product=$attributes['free_label']; | |
| 546 | - } | |
| 547 | - | |
| 548 | - // pagination | |
| 549 | - $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
| 550 | - if( is_front_page() ){ | |
| 551 | - $paged= (get_query_var('page')) ? get_query_var('page') : 1; | |
| 552 | - } | |
| 553 | - | |
| 554 | - | |
| 555 | - //order | |
| 556 | - $orderby='ID'; | |
| 557 | - $order ='ASC'; | |
| 558 | - if ( isset($attributes['order_by']) ){ | |
| 559 | - $order_by=intval($attributes['order_by']); | |
| 560 | - switch ($order_by) { | |
| 561 | - case 0: | |
| 562 | - $orderby='ID'; | |
| 563 | - $order ='ASC'; | |
| 564 | - break; | |
| 565 | - case 1: | |
| 566 | - $orderby='ID'; | |
| 567 | - $order ='DESC'; | |
| 568 | - break; | |
| 569 | - case 2: | |
| 570 | - $orderby='title'; | |
| 571 | - $order ='ASC'; | |
| 572 | - break; | |
| 573 | - case 3: | |
| 574 | - $orderby='title'; | |
| 575 | - $order ='DESC'; | |
| 576 | - break; | |
| 577 | - } | |
| 578 | - } | |
| 579 | - | |
| 580 | - // building wp_query arg array | |
| 581 | - $args = array( | |
| 582 | - 'post_type' => $event_types, | |
| 583 | - 'post_status' => 'publish', | |
| 584 | - 'meta_query' => $meta_query, | |
| 585 | - 'posts_per_page' => $media_number, | |
| 586 | - 'paged' => $paged, | |
| 587 | - 'orderby' => $orderby, | |
| 588 | - 'order' => $order, | |
| 589 | - 'tax_query' => $tax_query | |
| 590 | - ); | |
| 591 | - | |
| 592 | - | |
| 593 | - | |
| 594 | - // show live events | |
| 595 | - if ( isset($attributes['product_show_live']) && $attributes['product_show_live']=='yes'){ | |
| 596 | - $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user_for_shortcode('shortcode'); | |
| 597 | 375 | |
| 598 | - | |
| 599 | - if( is_array($live_event_for_user) ){ | |
| 600 | - $live_event_for_user[]=0; | |
| 601 | - | |
| 602 | - $args['post__in']=$live_event_for_user; | |
| 603 | - } | |
| 604 | - } | |
| 605 | - | |
| 606 | - | |
| 607 | - | |
| 376 | + public function show_user_data($pack_details){ | |
| 377 | + if( isset($pack_details['band']) && isset( $pack_details['storage']) ){ | |
| 378 | + print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.$this->wpstream_convert_band($pack_details['band']).' Gb</strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.$this->wpstream_convert_band($pack_details['storage']).' Gb</strong> '.__('available media storage','wpstream').'.</div>'; | |
| 379 | + print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">'; | |
| 380 | + print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">'; | |
| 608 | 381 | |
| 609 | - $media_list= new WP_Query($args); | |
| 610 | - if($media_list->have_posts()){ | |
| 611 | - print '<ul class="wpstream_media_list_wrapper products columns-'.esc_attr($row_number).'" >'; | |
| 612 | - while($media_list->have_posts()):$media_list->the_post(); | |
| 613 | - if($product_type_free_paid==0 ){ | |
| 614 | - | |
| 615 | - $thumb=wp_get_attachment_image_src(get_post_thumbnail_id(),'medium'); | |
| 616 | - | |
| 617 | - $thumb_src=''; | |
| 618 | - if( isset($thumb[0]) ){ | |
| 619 | - $thumb_src=$thumb[0]; | |
| 620 | - } | |
| 621 | - | |
| 622 | - if(($thumb_src)==''){ | |
| 623 | - $thumb_src= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_300.png'; | |
| 624 | - } | |
| 625 | - print '<li class="wpstream_product_unit">' | |
| 626 | - .'<a href="'.get_permalink().'" class="product_title" ><div class="product_image" style="background-image:url('.esc_url($thumb_src).')"></div></a>' | |
| 627 | - .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>'; | |
| 628 | - | |
| 629 | - if($see_product!=''){ | |
| 630 | - print '<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>'; | |
| 631 | - } | |
| 632 | - print '</li>'; | |
| 633 | - }else{ | |
| 634 | - wc_get_template_part( 'content', 'product' ); | |
| 635 | - } | |
| 636 | - endwhile; | |
| 637 | - print '</ul>'; | |
| 638 | - }else{ | |
| 639 | - print esc_html__('No media found! ','wpstream'); | |
| 640 | - } | |
| 641 | - | |
| 642 | - | |
| 643 | - wp_reset_query(); | |
| 644 | - wp_reset_postdata(); | |
| 645 | - | |
| 646 | - $this->wpstream_pagination($media_list->max_num_pages,$range=2); | |
| 647 | - $return_string= ob_get_contents(); | |
| 648 | - ob_end_clean(); | |
| 649 | - | |
| 650 | - return $return_string; | |
| 651 | - } | |
| 652 | - | |
| 653 | - | |
| 654 | - | |
| 655 | - | |
| 656 | - | |
| 657 | - | |
| 658 | - /* | |
| 659 | - * | |
| 660 | - * | |
| 661 | - * Pagination for media lista | |
| 662 | - * | |
| 663 | - * | |
| 664 | - * | |
| 665 | - */ | |
| 666 | - | |
| 667 | - | |
| 668 | - | |
| 669 | - | |
| 670 | - function wpstream_pagination($pages = '', $range = 2){ | |
| 671 | - | |
| 672 | - $showitems = ($range * 2)+1; | |
| 673 | - global $paged; | |
| 674 | - if(empty($paged)) $paged = 1; | |
| 675 | - | |
| 676 | - | |
| 677 | - if($pages == ''){ | |
| 678 | - global $wp_query; | |
| 679 | - $pages = $wp_query->max_num_pages; | |
| 680 | - if(!$pages) | |
| 681 | - { | |
| 682 | - $pages = 1; | |
| 683 | 382 | } |
| 684 | 383 | } |
| 685 | 384 | |
| 686 | - if(1 != $pages){ | |
| 687 | - print '<ul class="wpstream_pagination ">'; | |
| 688 | - print '<li class="roundleft"><a href="'.get_pagenum_link($paged - 1).'"> < </a></li>'; | |
| 689 | - | |
| 690 | - for ($i=1; $i <= $pages; $i++) | |
| 691 | - { | |
| 692 | - if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) | |
| 693 | - { | |
| 694 | - if ($paged == $i){ | |
| 695 | - print '<li class="active"><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>'; | |
| 696 | - }else{ | |
| 697 | - print '<li><a href="'.esc_url(get_pagenum_link($i)).'" >'.$i.'</a><li>'; | |
| 698 | - } | |
| 699 | - } | |
| 700 | - } | |
| 701 | - | |
| 702 | - $prev_page= get_pagenum_link($paged + 1); | |
| 703 | - if ( ($paged +1) > $pages){ | |
| 704 | - $prev_page= get_pagenum_link($paged ); | |
| 705 | - }else{ | |
| 706 | - $prev_page= get_pagenum_link($paged + 1); | |
| 707 | - } | |
| 708 | - | |
| 709 | - | |
| 710 | - print '<li class="roundright"><a href="'.$prev_page.'"> > </a><li>'; | |
| 711 | - print '</ul>'; | |
| 712 | - } | |
| 713 | - } | |
| 714 | - | |
| 715 | - | |
| 716 | - | |
| 717 | - | |
| 718 | - | |
| 719 | - | |
| 720 | - | |
| 721 | - | |
| 722 | - | |
| 723 | - | |
| 724 | - | |
| 725 | - | |
| 726 | - | |
| 727 | - /** | |
| 728 | - * help function for player elementr widget | |
| 729 | - * | |
| 730 | - * @since 3.0.1 | |
| 731 | - * @return string | |
| 732 | - */ | |
| 733 | - | |
| 734 | 385 | public function wpstream_insert_player_elementor($attributes, $content = null){ |
| 735 | 386 | $product_id = ''; |
| 736 | 387 | $return_string = ''; |
| 737 | 388 | $attributes = shortcode_atts( |
| @@ -736,9 +387,8 @@ | ||
| 736 | 387 | $return_string = ''; |
| 737 | 388 | $attributes = shortcode_atts( |
| 738 | 389 | array( |
| 739 | 390 | 'id' => 0, |
| 740 | - 'user_id' => 0, | |
| 741 | 391 | ), $attributes) ; |
| 742 | 392 | |
| 743 | 393 | |
| 744 | 394 | if ( isset($attributes['id']) ){ |
| @@ -743,65 +393,11 @@ | ||
| 743 | 393 | |
| 744 | 394 | if ( isset($attributes['id']) ){ |
| 745 | 395 | $product_id=$attributes['id']; |
| 746 | 396 | } |
| 747 | - if ( isset($attributes['user_id']) ){ | |
| 748 | - $user_id = intval( $attributes['user_id'] ); | |
| 749 | - } | |
| 750 | - | |
| 751 | - if(intval($product_id)==0 && $user_id!=0 ){ | |
| 752 | - $product_id= $this->wpstream_player_retrive_first_id($user_id); | |
| 753 | - } | |
| 754 | - | |
| 755 | - | |
| 756 | - | |
| 757 | - | |
| 758 | - ob_start(); | |
| 759 | - ?> | |
| 760 | - <div class="wpstream_insert_player_elementor_wrapper"> | |
| 761 | - <?php | |
| 762 | - $this->main->wpstream_player->wpstream_video_player_shortcode($product_id); | |
| 763 | - ?> | |
| 764 | - </div> | |
| 765 | - <?php | |
| 766 | - $return_string= ob_get_contents(); | |
| 767 | - ob_end_clean(); | |
| 768 | 397 | |
| 769 | - return $return_string; | |
| 770 | - } | |
| 771 | - | |
| 772 | - /** | |
| 773 | - * help function for player low latency elementor widget | |
| 774 | - * | |
| 775 | - * @since 3.0.1 | |
| 776 | - * @return string | |
| 777 | - */ | |
| 778 | - | |
| 779 | - public function wpstream_insert_player__low_latency_elementor($attributes, $content = null){ | |
| 780 | - $product_id = ''; | |
| 781 | - $return_string = ''; | |
| 782 | - $attributes = shortcode_atts( | |
| 783 | - array( | |
| 784 | - 'id' => 0, | |
| 785 | - 'user_id' => 0, | |
| 786 | - ), $attributes) ; | |
| 787 | - | |
| 788 | - | |
| 789 | - if ( isset($attributes['id']) ){ | |
| 790 | - $product_id=$attributes['id']; | |
| 791 | - } | |
| 792 | - | |
| 793 | - if ( isset($attributes['user_id']) ){ | |
| 794 | - $user_id = intval( $attributes['user_id'] ); | |
| 795 | - } | |
| 796 | - | |
| 797 | - if(intval($product_id)==0 && $user_id!=0){ | |
| 798 | - $product_id= $this->wpstream_player_retrive_first_id($user_id); | |
| 799 | - } | |
| 800 | - | |
| 801 | - | |
| 802 | 398 | ob_start(); |
| 803 | - $this->main->wpstream_player->wpstream_video_player_shortcode_low_latency($product_id); | |
| 399 | + $this->main->wpstream_player->wpstream_video_player_shortcode($product_id); | |
| 804 | 400 | $return_string= ob_get_contents(); |
| 805 | 401 | ob_end_clean(); |
| 806 | 402 | |
| 807 | 403 | return $return_string; |
| @@ -808,224 +404,6 @@ | ||
| 808 | 404 | } |
| 809 | 405 | |
| 810 | 406 | |
| 811 | 407 | |
| 812 | - public function wpstream_player_retrive_first_id($received_user_id=''){ | |
| 813 | - $channel_type = get_option ('wpstream_user_streaming_channel_type'); | |
| 814 | - $product_id = $this->wpstream_get_current_event_per_author($received_user_id,$channel_type); | |
| 815 | - return $product_id; | |
| 816 | - } | |
| 817 | - | |
| 818 | - | |
| 819 | - | |
| 820 | - /** | |
| 821 | - * help function for chat elementor widget | |
| 822 | - * | |
| 823 | - * @since 3.0.1 | |
| 824 | - * @return string | |
| 825 | - */ | |
| 826 | - | |
| 827 | - public function wpstream_insert_chat_elementor($attributes, $content = null){ | |
| 828 | - $product_id = ''; | |
| 829 | - $return_string = ''; | |
| 830 | - $attributes = shortcode_atts( | |
| 831 | - array( | |
| 832 | - 'id' => 0, | |
| 833 | - ), $attributes) ; | |
| 834 | 408 | |
| 835 | - | |
| 836 | - if ( isset($attributes['id']) ){ | |
| 837 | - $product_id=$attributes['id']; | |
| 838 | - } | |
| 839 | - | |
| 840 | - $return_string.= '<div class="wpstream_plugin_chat_wrapper">'; | |
| 841 | - ob_start(); | |
| 842 | - $this->main->wpstream_player->wpstream_chat_wrapper($product_id); | |
| 843 | - $return_string.= ob_get_contents(); | |
| 844 | - ob_end_clean(); | |
| 845 | - $return_string.='</div>'; | |
| 846 | - $this->main->wpstream_player->wpstream_connect_to_chat($product_id); | |
| 847 | - | |
| 848 | - return $return_string; | |
| 849 | - } | |
| 850 | - | |
| 851 | - | |
| 852 | - /** | |
| 853 | - * edited 4.0 | |
| 854 | - * | |
| 855 | - * Check if user is allowed to stream | |
| 856 | - * | |
| 857 | - * @since 3.7 | |
| 858 | - */ | |
| 859 | - | |
| 860 | - public function wpstream_check_user_can_stream(){ | |
| 861 | - $current_user = wp_get_current_user(); | |
| 862 | - | |
| 863 | - if( !is_user_logged_in() ){ | |
| 864 | - return false; | |
| 865 | - exit('user not logged in'); | |
| 866 | - } | |
| 867 | - | |
| 868 | - if(current_user_can('administrator')){ | |
| 869 | - // admins can always brodcast | |
| 870 | - return true; | |
| 871 | - } | |
| 872 | - | |
| 873 | - $extra_roles = get_option( 'wpstream_stream_role', true ); | |
| 874 | - $user_role = ''; | |
| 875 | - if( is_array( $current_user->roles) && count( $current_user->roles ) > 0 ){ | |
| 876 | - $user_role = $current_user->roles[0]; | |
| 877 | - } | |
| 878 | - | |
| 879 | - if ( is_array($extra_roles) && in_array( $user_role, $extra_roles ) ) { | |
| 880 | - return true; | |
| 881 | - } | |
| 882 | - | |
| 883 | - if(function_exists('wpstream_get_option') && intval(wpstream_get_option('allow_streaming_regular_users',''))==1 ){ | |
| 884 | - return true; | |
| 885 | - } | |
| 886 | - | |
| 887 | - return false; | |
| 888 | - } | |
| 889 | - | |
| 890 | - | |
| 891 | - /** | |
| 892 | - * Start Streaming wrapper | |
| 893 | - * | |
| 894 | - * @since 3.7 | |
| 895 | - */ | |
| 896 | - | |
| 897 | - public function wpstream_live_stream_unit_wrapper($item_id,$type){ | |
| 898 | - $item_id = intval($item_id); | |
| 899 | - | |
| 900 | - if($item_id == 0){ | |
| 901 | - //retrive or create channel for front end streamers | |
| 902 | - $item_id=$this->wpstream_retrive_front_end_channel(); | |
| 903 | - } | |
| 904 | - print'<div class="wpstream_modal_background"></div>'; | |
| 905 | - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div> | |
| 906 | - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div> | |
| 907 | - </div>'; | |
| 908 | - $this->admin->wpstream_live_stream_unit( $item_id,$type ); | |
| 909 | - } | |
| 910 | - | |
| 911 | - | |
| 912 | - /** | |
| 913 | - * Start Streaming wrapper for wpstream theme | |
| 914 | - * | |
| 915 | - * @since 3.7 | |
| 916 | - */ | |
| 917 | - | |
| 918 | - public function wpstream_live_stream_unit_wrapper_for_theme($item_id,$type){ | |
| 919 | - $item_id = intval($item_id); | |
| 920 | - | |
| 921 | - if($item_id == 0){ | |
| 922 | - //retrive or create channel for front end streamers | |
| 923 | - $item_id=$this->wpstream_retrive_front_end_channel(); | |
| 924 | - } | |
| 925 | - print'<div class="wpstream_modal_background"></div>'; | |
| 926 | - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div> | |
| 927 | - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div> | |
| 928 | - </div>'; | |
| 929 | - $this->admin->wpstream_live_stream_unit_for_theme( $item_id,$type ); | |
| 930 | - } | |
| 931 | - | |
| 932 | - | |
| 933 | - /** | |
| 934 | - * retrive channel for front end streaming | |
| 935 | - * | |
| 936 | - * @since 3.7 | |
| 937 | - */ | |
| 938 | - public function wpstream_retrive_front_end_channel(){ | |
| 939 | - | |
| 940 | - $current_user = wp_get_current_user(); | |
| 941 | - $channel_type = get_option ('wpstream_user_streaming_channel_type'); | |
| 942 | - $channel_price = floatval( get_option ('wpstream_user_streaming_default_price') ); | |
| 943 | - | |
| 944 | - $front_end_streamin_channel = $this->wpstream_get_current_event_per_author($current_user->ID,$channel_type); | |
| 945 | - | |
| 946 | - if(intval($front_end_streamin_channel) == 0){ | |
| 947 | - $front_end_streamin_channel= $this->wpstrea_create_front_end_event($current_user->ID,$current_user->user_login ,$channel_type,$channel_price); | |
| 948 | - } | |
| 949 | - return $front_end_streamin_channel; | |
| 950 | - | |
| 951 | - } | |
| 952 | - | |
| 953 | - /** | |
| 954 | - * create the event from front end | |
| 955 | - * | |
| 956 | - * @since 3.7 | |
| 957 | - */ | |
| 958 | - | |
| 959 | - public function wpstrea_create_front_end_event($userID,$userLogin,$channel_type,$channel_price){ | |
| 960 | - | |
| 961 | - if( !$this->wpstream_check_user_can_stream() ){ | |
| 962 | - return; | |
| 963 | - } | |
| 964 | - | |
| 965 | - $post_type='wpstream_product'; | |
| 966 | - if($channel_type=='paid'){ | |
| 967 | - $post_type='product'; | |
| 968 | - } | |
| 969 | - | |
| 970 | - $post = array( | |
| 971 | - 'post_title' => sprintf( esc_html__('%s Channel','wpstream'),$userLogin), | |
| 972 | - 'post_content' => '', | |
| 973 | - 'post_type' => $post_type , | |
| 974 | - 'post_author' => $userID, | |
| 975 | - 'post_status' => 'publish', | |
| 976 | - ); | |
| 977 | - $post_id = wp_insert_post($post ); | |
| 978 | - if($channel_type=='paid'){ | |
| 979 | - $product = wc_get_product($post_id); | |
| 980 | - $price = wc_format_decimal($channel_price); | |
| 981 | - | |
| 982 | - $product = wc_get_product( $post_id ); | |
| 983 | - // Set the product active price (regular) | |
| 984 | - $product->set_price( $price ); | |
| 985 | - $product->set_regular_price( $price ); // To be sure | |
| 986 | - $product->save(); | |
| 987 | - update_post_meta ($post_id,'event_passed',0); | |
| 988 | - wp_set_object_terms( $post_id, 'live_stream', 'product_type' ); | |
| 989 | - } | |
| 990 | - update_post_meta($post_id,'wpstream_product_type',1); | |
| 991 | - | |
| 992 | - return $post_id; | |
| 993 | - } | |
| 994 | - | |
| 995 | - | |
| 996 | - public function wpstream_get_current_event_per_author($userID,$channel_type){ | |
| 997 | - | |
| 998 | - $post_type='wpstream_product'; | |
| 999 | - if($channel_type=='paid'){ | |
| 1000 | - $post_type='product'; | |
| 1001 | - } | |
| 1002 | - | |
| 1003 | - $args = array( | |
| 1004 | - | |
| 1005 | - 'post_type' => $post_type, | |
| 1006 | - 'author' => $userID, | |
| 1007 | - 'posts_per_page' => 1, | |
| 1008 | - 'fields' => 'ids' | |
| 1009 | - ) | |
| 1010 | - ; | |
| 1011 | - $author_posts = new WP_Query( $args ); | |
| 1012 | - if( $author_posts->have_posts() ) { | |
| 1013 | - $author_posts->the_post(); | |
| 1014 | - $the_id= get_the_ID(); | |
| 1015 | - }else{ | |
| 1016 | - $the_id= 0; | |
| 1017 | - } | |
| 1018 | - | |
| 1019 | - wp_reset_query(); | |
| 1020 | - wp_reset_postdata(); | |
| 1021 | - return $the_id; | |
| 1022 | - } | |
| 1023 | - | |
| 1024 | - /** | |
| 1025 | - * Cleanup old logs | |
| 1026 | - */ | |
| 1027 | - public function cleanup_logs() { | |
| 1028 | - $logger = new WPStream_Logger(); | |
| 1029 | - $logger->clear_old_logs(); | |
| 1030 | - } | |
| 1031 | 409 | } |