PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8.2
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8.2
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
← All changes | admin/class-wpstream-admin.php +140 -461 4.12.44.8.2 View file →
@@ -182,9 +182,8 @@
182 182 wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
183 183 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
184 184 array(
185 185 'admin_url' => get_admin_url(),
186 - 'multipart_upload_nonce' => wp_create_nonce( 'wpstream_multipart_upload_nonce' ),
187 186 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
188 187 'download_mess' => esc_html__('Click to download!','wpstream'),
189 188 'uploading' => esc_html__('We are uploading your file. Do not close this window!','wpstream'),
190 189 'upload_complete2' => esc_html__('Upload Complete! You can upload another file!','wpstream'),
@@ -191,9 +190,8 @@
191 190 'not_accepted' => esc_html__('The file is not an accepted video format','wpstream'),
192 191 'upload_complete' => esc_html__('Upload Complete!','wpstream'),
193 192 'no_band' => esc_html__('Not enough streaming data.','wpsteam'),
194 193 'no_band_no_store' => esc_html__('Not enough streaming data or storage.','wpsteam'),
195 - 'no_streaming_hours' => esc_html__('Not enough streaming hours.','wpstream'),
196 194 'exceeding_limit' => esc_html__('File size exceeds 5GB. Initiating multipart upload...','wpsteam'),
197 195 'upload_failed' => esc_html__('Upload Failed!','wpstream'),
198 196 'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'),
199 197 'choose_a_file' => esc_html__('Choose a file…','wpstream'),
@@ -207,12 +205,8 @@
207 205 'invalid_response' => esc_html__('Invalid response from server. Missing required upload data.', 'wpstream'),
208 206 'video_processing' => esc_html__( 'The video is still processing', 'wpstream' ),
209 207 'file_name_text' => esc_html__('File Name:','wpstream'),
210 208 'channel_create_error' => esc_html__('Something did not work. Please try again.', 'wpstream'),
211 - 'select_caption_file' => esc_html__('Select .vtt Captions File', 'wpstream'),
212 - 'select_button' => esc_html__('Select', 'wpstream'),
213 - 'remove_button' => esc_html__('Remove', 'wpstream'),
214 - 'use_streaming_hours' => $this->wpstream_is_use_streaming_hours(),
215 209 ));
216 210
217 211 wp_enqueue_script('wpstream-recordings-videos-list', plugin_dir_url( __FILE__ ) .'js/recordings_videos_list.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
218 212 wp_localize_script( 'wpstream-recordings-videos-list', 'wpstream_recordings_videos_list_vars',
@@ -263,27 +257,18 @@
263 257 '- Manual TURN OFF is only useful if you require to change the channel settings immediately.' . PHP_EOL .
264 258 '- If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.',
265 259 'wpstream'
266 260 ),
267 - 'is_basic_streaming' => $this->wpstream_is_basic_streaming_mode(),
268 - 'use_streaming_hours' => $this->wpstream_is_use_streaming_hours(),
269 261 'basic_streaming_warning' => esc_html__(
270 - 'You’ve used all available broadcast or viewer hours.' . PHP_EOL . PHP_EOL .
271 - 'Some live channel features will be limited, including recording, viewer count, browser broadcasting, and content protection.' . PHP_EOL . PHP_EOL .
272 - 'Top up your resources or upgrade your plan to use all features, or choose OK to start anyway.',
273 - 'wpstream'
274 - ),
275 - 'basic_streaming_warning_traffic' => esc_html__(
276 262 'Your account is now in BASIC STREAMING mode.' . PHP_EOL . PHP_EOL .
277 - '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 .
263 + '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 .
278 264 'Certain features, such as recording, viewer count, browser broadcasting, and content protection are unavailable.' . PHP_EOL . PHP_EOL .
279 - '- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL .
265 + '- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL .
280 266 '- Otherwise, choose OK to start your channel with these limitations.' . PHP_EOL . PHP_EOL .
281 267 'ARE YOU SURE you want to continue with Basic Streaming?',
282 268 'wpstream'
283 269 ),
284 270 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
285 - 'is_onboarding' => isset($_GET['onboard']) && $_GET['onboard'] === 'yes' ? 'yes' : 'no',
286 271 ));
287 272
288 273 wp_enqueue_script('wpstream-settings', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream_settings.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
289 274 wp_localize_script('wpstream-settings', 'wpstream_settings_vars', array(
@@ -295,44 +280,32 @@
295 280 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
296 281 ));
297 282
298 283
299 - $branch = isset($_GET['branch']) ? sanitize_text_field( wp_unslash( $_GET['branch'] ) ) : '';
300 - wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',array(), WPSTREAM_PLUGIN_VERSION, true);
284 + wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',array(), WPSTREAM_PLUGIN_VERSION, true);
301 285 wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars',
302 286 array(
303 - 'admin_url' => get_admin_url(),
304 - 'plugin_url' => get_dashboard_url().'/plugins.php',
305 - 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings',
306 - 'branch' => $branch
287 + 'admin_url' => get_admin_url(),
288 + 'plugin_url' => get_dashboard_url().'/plugins.php',
289 + 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings'
290 +
307 291 ));
308 292
309 - $current_screen=get_current_screen();
310 - // enqueue the file only on the on-boarding page and wpstream_product post type
311 - $is_wpstream_onboarding_page = $current_screen->base ==='wpstream_page_wpstream_onboard';
312 - $is_wpstream_onboarding_post_type_page = isset($_GET['onboard']) && $_GET['onboard'] === 'yes';
313 - $onboarding_visible = $is_wpstream_onboarding_page || $is_wpstream_onboarding_post_type_page;
314 - if( $onboarding_visible) {
315 - wp_enqueue_script('wpstream-on-boarding-page-js', plugin_dir_url( __DIR__ ) .'admin/js/wpstream-onboarding-page.js',array(), WPSTREAM_PLUGIN_VERSION, true);
316 - wp_localize_script( 'wpstream-on-boarding-page-js', 'wpstream_onboarding_page_vars',
317 - array(
318 - 'admin_url' => get_admin_url(),
319 - 'request_url' => WPSTREAM_CLICK,
320 - 'wps_user' => get_option('wpstream_api_username_from_token'),
321 - 'current_page' => $is_wpstream_onboarding_post_type_page ? 'post_edit' : 'onboarding',
322 - 'plugin_version' => WPSTREAM_PLUGIN_VERSION,
323 - 'branch' => $branch,
324 - )
325 - );
326 - }
293 +// wp_enqueue_style(
294 +// 'wpstream-broadcaster-css',
295 +// plugin_dir_url(__FILE__) . 'public/css/broadcaster.css',
296 +// array(),
297 +// filemtime(plugin_dir_path(__FILE__) . 'public/css/broadcaster.css' ),
298 +// );
299 +//
300 +// wp_enqueue_script(
301 +// 'wpstream-broadcaster',
302 +// plugin_dir_url(__FILE__) . 'public/js/broadcaster.js',
303 +// array('jquery'),
304 +// WPSTREAM_PLUGIN_VERSION,
305 +// true
306 +// );
327 307
328 - if ( in_array( $current_screen->base, ['toplevel_page_wpstream_credentials', 'wpstream_page_wpstream_live_channels', 'wpstream_page_wpstream_recordings', 'wpstream_page_wpstream_onboard'] ) ) {
329 - wp_enqueue_script( 'wpstream-user-quota-update', plugin_dir_url( __DIR__ ) . 'admin/js/wpstream-user-quota.js', array(), WPSTREAM_PLUGIN_VERSION, true );
330 - wp_localize_script( 'wpstream-user-quota-update', 'wpstream_user_quota_vars', array(
331 - 'admin_url' => get_admin_url()
332 - ));
333 - }
334 -
335 308 // Add localized variables for broadcaster
336 309 wp_localize_script('wpstream-broadcaster', 'wpstream_broadcaster_vars', array(
337 310 'ajax_url' => admin_url('admin-ajax.php'),
338 311 'nonce' => wp_create_nonce('wpstream_broadcaster_nonce'),
@@ -407,10 +380,10 @@
407 380
408 381
409 382 $event_list = new WP_Query($args);
410 383 global $live_event_for_user;
411 - $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
412 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
384 + $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
385 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_new_general_set');
413 386
414 387 $this->main->show_user_data($pack_details);
415 388 if( $event_list->have_posts()){
416 389
@@ -448,9 +421,14 @@
448 421
449 422
450 423 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
451 424 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
452 -
425 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_new_general_set');
426 + if( isset($pack_details['available_data_mb'])){
427 + if ($pack_details['available_data_mb'] <= 0){
428 + print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
429 + }
430 + }
453 431 $current_user = wp_get_current_user();
454 432 $allowded_html = array();
455 433 $userID = $current_user->ID;
456 434 $user_live_streams = get_user_meta($userID,'live_shows');
@@ -638,9 +616,9 @@
638 616 $pending_streaming_class = 'pending_trigger';
639 617 $live_data_url = get_post_meta($the_id,'qos_url',true);
640 618 // $channel_status = esc_html__('Channel is on','wpstream');
641 619 } else {
642 - $channel_status = esc_html__('Channel is OFF','wpstream');
620 + $channel_status = esc_html__('Channel is OFF','wpstream');
643 621 $button_status = esc_html__('TURN ON','wpstream');
644 622 }
645 623
646 624 $server_id = get_post_meta($the_id,'server_id',true);
@@ -648,10 +626,8 @@
648 626 $obs_stream = get_post_meta($the_id,'obs_stream',true);
649 627 $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
650 628 $rtmp_ip_uri = '';
651 629
652 - $ajax_nonce = wp_create_nonce( 'wpstream_start_event_nonce' );
653 - print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
654 630 print '<div class="event_list_unit '.$live_class.' '.$pending_streaming_class.' event_unit_style_'.esc_attr($is_front).'" data-show-id="'.intval($the_id).'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'"">';
655 631
656 632 print '<div class="wpstream_channel_status">'.$channel_status.'</div>';
657 633
@@ -669,9 +645,9 @@
669 645 print '<div class="wpstream_channel_item_id">'.esc_html( '#ID' ).' '.$the_id.'</div>';
670 646 print '</div>';
671 647
672 648
673 - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" data-nonce="' . esc_attr( $ajax_nonce ) . '" > ' . $button_status;
649 + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > ' . $button_status;
674 650 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
675 651 print '</div>';
676 652
677 653 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
@@ -961,18 +937,14 @@
961 937 public function wpstream_close_modal_button(){
962 938 print '<div class="wpstream_close_modal"></div>';
963 939 }
964 940
965 - public function wpstream_local_event_options_toggle( $is_basic_stream_mode = false ) {
941 + public function wpstream_local_event_options_toggle() {
966 942 $use_global_event_options = get_post_meta(get_the_ID(), 'use_global_event_options', true );
967 943 $local_event_options = get_post_meta( get_the_ID(), 'local_event_options', true );
968 944 $use_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
969 945 ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
970 946
971 - if ( $is_basic_stream_mode ) {
972 - $this->wpstream_basic_stream_mode_message();
973 - }
974 -
975 947 print '<div class="wpstream_local_event_options_toggle_wrapper">';
976 948 print '<div class="wpstream_local_event_options_toggle_info">';
977 949 print '<label for="local_event_options_enabled" class="wpstream_local_event_options_label">'.esc_html__('Edit settings for this channel','wpstream').'</label>';
978 950 print '<span>'.sprintf(esc_html__('When is OFF, the settings from %s will be applied','wpstream'), '<a href="' . admin_url('admin.php?page=wpstream_settings&tab=default_options') . '" target="_blank">'.esc_html__('Default Channel Settings','wpstream').'</a>').'</span>';
@@ -977,51 +949,14 @@
977 949 print '<label for="local_event_options_enabled" class="wpstream_local_event_options_label">'.esc_html__('Edit settings for this channel','wpstream').'</label>';
978 950 print '<span>'.sprintf(esc_html__('When is OFF, the settings from %s will be applied','wpstream'), '<a href="' . admin_url('admin.php?page=wpstream_settings&tab=default_options') . '" target="_blank">'.esc_html__('Default Channel Settings','wpstream').'</a>').'</span>';
979 951 print '</div>';
980 952 print '<label class="wpstream_switch">';
981 - print '<input id="local_event_options_enabled" type="checkbox" class="wpstream_local_event_options_toggle" ' . ($use_local_event_options_enabled === true ? 'checked' : '') . ' ' . ( $is_basic_stream_mode ? 'disabled' : '' ) . '>';
953 + print '<input id="local_event_options_enabled" type="checkbox" class="wpstream_local_event_options_toggle" ' . ($use_local_event_options_enabled === true ? 'checked' : '') . '>';
982 954 print '<span class="wpstream_slider round"></span>';
983 955 print '</label>';
984 956 print '</div>';
985 957 }
986 958
987 - public function wpstream_basic_stream_mode_message() {
988 - print '<div class="basic-mode-notice">';
989 - if ( $this->wpstream_is_use_streaming_hours() ) {
990 - print sprintf(
991 - wp_kses(
992 - __(
993 - 'You’ve used all available broadcast or viewer hours. Default channel settings will be used for now. To edit channel settings, <a href="%s" target="_blank">top up</a> your resources or <a href="%s" target="_blank">upgrade</a> your plan.',
994 - 'wpstream'
995 - ),
996 - array( 'a' => array(
997 - 'href' => array(),
998 - 'target' => array()
999 - )
1000 - )
1001 - ),
1002 - esc_url( 'https://wpstream.net/pricing/' ),
1003 - esc_url( 'https://wpstream.net/pricing/' )
1004 - );
1005 - } else {
1006 - print sprintf(
1007 - wp_kses(
1008 - __(
1009 - 'You are currently in Basic Streaming Mode. The default channel settings will be used instead. Please <a href="%s" target="_blank">upgrade</a> your plan to edit the channel settings.',
1010 - 'wpstream'
1011 - ),
1012 - array(
1013 - 'a' => array(
1014 - 'href' => array()
1015 - )
1016 - )
1017 - ),
1018 - esc_url( 'https://wpstream.net/pricing/' )
1019 - );
1020 - }
1021 - print '</div>';
1022 - }
1023 -
1024 959 /*
1025 960 *
1026 961 * Display modal settings
1027 962 *
@@ -1027,10 +962,8 @@
1027 962 *
1028 963 */
1029 964
1030 965 public function wpstream_display_modal_seetings($the_id){
1031 - $is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
1032 -
1033 966 print '<div class="wpstream_modal_form wpestate_settings_modal">';
1034 967 $this->wpstream_close_modal_button();
1035 968 print '<h3>';
1036 969 printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id);
@@ -1035,9 +968,9 @@
1035 968 print '<h3>';
1036 969 printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id);
1037 970 print '</h3>';
1038 971
1039 - $this->wpstream_local_event_options_toggle( $is_basic_stream_mode );
972 + $this->wpstream_local_event_options_toggle();
1040 973
1041 974 $local_event_options = get_post_meta($the_id,'local_event_options',true);
1042 975 $use_global_event_options = get_post_meta($the_id, 'use_global_event_options',true);
1043 976 $is_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
@@ -1042,8 +975,12 @@
1042 975 $use_global_event_options = get_post_meta($the_id, 'use_global_event_options',true);
1043 976 $is_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
1044 977 ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
1045 978
979 + if( !$is_local_event_options_enabled ) {
980 + $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
981 + }
982 +
1046 983 $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt');
1047 984
1048 985 print '<div class="wpstream_event_streaming_local">';
1049 986 $this->user_streaming_global_channel_options(
@@ -1050,9 +987,8 @@
1050 987 '',
1051 988 $local_event_options,
1052 989 $local_array_exclude,
1053 990 !$is_local_event_options_enabled,
1054 - $is_basic_stream_mode
1055 991 );
1056 992 print '</div>';
1057 993 print '</div>';
1058 994 }
@@ -1078,9 +1014,9 @@
1078 1014 *
1079 1015 */
1080 1016
1081 1017 public function wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream){
1082 - print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
1018 + print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
1083 1019 $this->wpstream_close_modal_button();
1084 1020 print '<h3>'.esc_html__('Go Live with External Streaming App','wpstream').'</h3>';
1085 1021
1086 1022 print '<div class="wpstream_modal_explanations">'.esc_html__('Please choose your RTMP encoder/broadcaster','wpstream').'</div>';
@@ -1443,16 +1379,8 @@
1443 1379 'name' => 'free_media_slug',
1444 1380 'type' => 'text',
1445 1381 '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'),
1446 1382 ),
1447 -
1448 - 'free_vod_slug' => array(
1449 - 'tab' => 'general_options',
1450 - 'label' => esc_html__('Slug for free VOD pages ','wpstream'),
1451 - 'name' => 'free_media_slug_vod',
1452 - 'type' => 'text',
1453 - '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'),
1454 - ),
1455 1383
1456 1384 2 => array(
1457 1385 'tab' => 'general_options',
1458 1386 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'),
@@ -1678,10 +1606,8 @@
1678 1606 <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Customize Messages','wpstream').'</a>
1679 1607 <a href="?page=wpstream_settings&tab=support_tab" class="nav-tab '; echo $active_tab == 'support_tab' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Support','wpstream').'</a>
1680 1608 </h2>';
1681 1609 $help_link='';
1682 -
1683 - $is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
1684 1610 print '<div class="wpstream_option_wrapper">';
1685 1611
1686 1612 switch ($active_tab) {
1687 1613 case 'general_options':
@@ -1709,11 +1635,8 @@
1709 1635
1710 1636 if ( $option['type']=='user_streaming_global_channel_options' ) {
1711 1637 print '<div class="default-channel-settings-info">';
1712 1638 print esc_html__( 'These settings will apply to newly created channels; existing channels will not change settings if you change them here', 'wpstream');
1713 - if ( $is_basic_stream_mode ) {
1714 - $this->wpstream_basic_stream_mode_message();
1715 - }
1716 1639 print '</div>';
1717 1640
1718 1641 }
1719 1642 print '<div class="wpstream_option">';
@@ -1727,14 +1650,9 @@
1727 1650 print '<div class="settings_details">'.$option['details'].'</div>';
1728 1651 break;
1729 1652 case 'user_streaming_global_channel_options':
1730 1653 $exclude_array=array();
1731 - $this->user_streaming_global_channel_options(
1732 - $option['name'],
1733 - $options_value,
1734 - $exclude_array,
1735 - $is_basic_stream_mode
1736 - );
1654 + $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array);
1737 1655 break;
1738 1656 case 'text':
1739 1657 if($options_value==''){
1740 1658 $options_value='';
@@ -2110,29 +2028,10 @@
2110 2028 }
2111 2029
2112 2030 return $all_plugins_info;
2113 2031 }
2114 -
2115 - public function wpstream_render_outdated_plugin_notice() {
2116 - $has_update = get_site_transient('update_plugins');
2117 - if (isset($has_update->response['plugin/wpstream.php'])) {
2118 - ?>
2119 - <div class="notice notice-warning is-dismissible">
2120 - <p>
2121 - <?php
2122 - printf(
2123 - /* translators: 1: Link to update page */
2124 - esc_html__('A new version of WpStream is available. Please update to the latest version for the best experience. Go to the %1$s to update now.', 'wpstream'),
2125 - '<a href="' . esc_url(admin_url('update-core.php')) . '">' . esc_html__('updates page', 'wpstream') . '</a>'
2126 - );
2127 - ?>
2128 - </p>
2129 - </div>
2130 - <?php
2131 - }
2132 - }
2133 -
2134 -
2032 +
2033 +
2135 2034 /**
2136 2035 * Set user roles
2137 2036 *
2138 2037 * @since 3.0.1
@@ -2137,16 +2036,10 @@
2137 2036 *
2138 2037 * @since 3.0.1
2139 2038 */
2140 2039
2141 - public function user_streaming_global_channel_options(
2142 - $name,
2143 - $value,
2144 - $local_array='',
2145 - $disabled = false,
2146 - $is_basic_stream_mode = false
2147 - ) {
2148 -
2040 + public function user_streaming_global_channel_options( $name, $value, $local_array='', $disabled = false ){
2041 +
2149 2042 foreach($this->global_event_options as $key=>$option){
2150 2043
2151 2044 if( is_array($local_array) && !in_array($key,$local_array)){
2152 2045 print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">';
@@ -2166,9 +2059,9 @@
2166 2059 if($option['defaults']=='yes') {
2167 2060 print ' checked ';
2168 2061 }
2169 2062 }
2170 - if ( $disabled || $is_basic_stream_mode ) {
2063 + if ($disabled) {
2171 2064 print ' disabled ';
2172 2065 }
2173 2066
2174 2067
@@ -2277,11 +2170,11 @@
2277 2170
2278 2171 );
2279 2172
2280 2173
2281 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
2282 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_set_wpstream_credentials' );
2283 -
2174 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
2175 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_set_wpstream_credentials');
2176 +
2284 2177 $this->main->show_user_data($pack_details);
2285 2178
2286 2179 print '<form method="post" action="" >';
2287 2180 print '<div class="theme_options_tab_wpstream" style="display:block;" >
@@ -2353,9 +2246,9 @@
2353 2246 * @since 3.0.1
2354 2247 */
2355 2248
2356 2249 public function wpstream_media_management(){
2357 - $pack_details = $this->main->user_quota_service->request_pack_data_per_user( 'wpstream_media_management' );
2250 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_media_management');
2358 2251
2359 2252 $this->main->show_user_data($pack_details);
2360 2253
2361 2254
@@ -2426,15 +2319,10 @@
2426 2319 * @since 3.0.1
2427 2320 */
2428 2321 public function wpstream_present_media_upload(){
2429 2322 $to_return='';
2430 -
2431 - if ( ! $this->main->quota_manager->has_storage_quota( null, 'recordings_screen' ) ) {
2432 - return '<div class="wpstream_upload_alert">'.esc_html__('You don\'t have enough cloud storage or data to upload a new item. Please delete some videos or upgrade your plan.','wpstream').'</div>';
2433 - }
2434 -
2435 2323 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
2436 -
2324 +
2437 2325 if( !$formInputs['success'] ){
2438 2326 if ($formInputs['error'] == 'not_connected'){
2439 2327 $to_return.='<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
2440 2328 }
@@ -2583,9 +2471,8 @@
2583 2471
2584 2472 public function wpstream_publish_wpstream_product($post_id,$post){
2585 2473 if( $post->post_type == 'wpstream_product' ){
2586 2474 update_post_meta ($post_id,'local_event_options_test','working_on_'.$post_id);
2587 - update_post_meta ($post_id, 'use_global_event_options', true);
2588 2475 $to_save_option=array();
2589 2476
2590 2477 $global_options= get_option('wpstream_user_streaming_global_channel_options');
2591 2478
@@ -2628,10 +2515,9 @@
2628 2515
2629 2516 $allowed_keys=array(
2630 2517 'wpstream_product_type',
2631 2518 'wpstream_free_video',
2632 - 'wpstream_free_video_external',
2633 - 'wpstream_closed_captions_file'
2519 + 'wpstream_free_video_external'
2634 2520 );
2635 2521
2636 2522
2637 2523 foreach ($_POST as $key => $value) {
@@ -2661,9 +2547,10 @@
2661 2547
2662 2548
2663 2549 add_meta_box( 'add_wpstream_product_metaboxes-sectionid', esc_html__( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default');
2664 2550 add_meta_box( 'custom_metabox_video_collection', esc_html__( 'Video Collection', 'wpstream' ), 'wpstream_bundle_custom_metabox_callback', 'wpstream_bundles', 'normal', 'high' );
2665 -
2551 + add_meta_box( 'woocommerce-product-data', esc_html__( 'Product Data', 'wpstream' ), 'woocommerce_product_data_box', 'product', 'normal', 'default' );
2552 +
2666 2553 if(function_exists('wc_get_product')):
2667 2554 $product = wc_get_product( $post_id );
2668 2555 if ( $product ) {
2669 2556
@@ -2694,13 +2581,12 @@
2694 2581 global $post;
2695 2582 if(isset($post->ID)){
2696 2583 if ( $post->post_type !== 'product' ) return;
2697 2584 $term_list = wp_get_post_terms($post->ID, 'product_type');
2698 - if( !empty($term_list) &&
2699 - isset($term_list[0]->name) &&
2700 - in_array($term_list[0]->name, ['live_stream', 'video_on_demand', 'wpstream_bundle'])
2701 - ){
2702 - update_post_meta( $post->ID, '_virtual', 'yes' );
2585 + if( $term_list[0]->name=='video_on_demand' ||
2586 + $term_list[0]->name=='live_stream' ||
2587 + $term_list[0]->name=='wpstream_bundle'){
2588 + update_post_meta( $post->ID, '_virtual', 'yes' );
2703 2589 }
2704 2590 }
2705 2591 }
2706 2592
@@ -2751,42 +2637,30 @@
2751 2637
2752 2638 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2753 2639
2754 2640
2755 - print '<div class="meta-options video_free">';
2756 - print '<p class="meta-option wpstream_free_video">';
2757 - print '<label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
2641 + print '
2642 + <p class="meta-options video_free">
2643 + <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
2758 2644 <select id="wpstream_free_video" name="wpstream_free_video">';
2759 -
2760 - if( is_array( $video_list ) ) {
2761 - foreach ($video_list as $key=>$value){
2762 - print '<option value="'.$key.'"';
2763 - if($wpstream_free_video === $key){
2764 - print ' selected ';
2645 +
2646 + if(is_array($video_list)){
2647 + foreach ($video_list as $key=>$value){
2648 + print '<option value="'.$key.'"';
2649 + if($wpstream_free_video === $key){
2650 + print ' selected ';
2651 + }
2652 + print '>'.$value.'</option>';
2653 + }
2765 2654 }
2766 - print '>'.$value.'</option>';
2767 - }
2768 - }
2769 - print'</select>';
2770 - print '</p> ';
2655 +
2656 + print'
2657 + </select>
2658 + </p>
2659 + ';
2771 2660
2772 - $wpstream_closed_captions_file = get_post_meta($post->ID, 'wpstream_closed_captions_file', true);
2773 -
2774 - $button_style = $wpstream_closed_captions_file ? 'style="display:none;"' : '';
2775 -
2776 - print '<p class="meta-option wpstream_vod_captions_url">';
2777 - print '<label for="wpstream_vod_captions_url_button">'.__('Captions file (optional):','wpstream').' </label><br />
2778 - <input type="hidden" id="wpstream_closed_captions_file" name="wpstream_closed_captions_file" value="'.esc_attr($wpstream_closed_captions_file).'" />
2779 - <input id="wpstream_vod_captions_url_button" type="button" class="upload_button button" value="'.esc_html__('Select .vtt Captions File','wpstream').'" '.$button_style.' />
2780 - <span class="wpstream_caption_file_display">'.( $wpstream_closed_captions_file ? esc_html( basename( $wpstream_closed_captions_file ) ) : '' ).'</span>';
2781 - if ( $wpstream_closed_captions_file ) {
2782 - print '<input type="button" class="button wpstream_remove_caption" value="'.esc_html__('Remove','wpstream').'" style="margin-left: 5px;" />';
2783 - }
2784 - print '</p> ';
2785 - print '</div>';
2786 -
2787 2661 $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
2788 - print '<div class="meta-options1 video_free_external">
2662 + print '<p class="meta-options1 video_free_external">
2789 2663 <label for="wpstream_free_video_external">'.__('Video:','wpstream').' </label><br />
2790 2664
2791 2665 <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
2792 2666 <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />';
@@ -2799,9 +2673,9 @@
2799 2673 }
2800 2674 print '<p '.$show_recording.' class="wpstream_option_vod_source wpstream_show_recording">'.esc_html__('Choose one of your existing recordings.','wpstream').'</p>';
2801 2675 print '<p '. $show_external.' class="wpstream_option_vod_source wpstream_show_external">'.esc_html__('Upload a video from your computer or paste the URL of a YouTube/external video.','wpstream').'</p>';
2802 2676
2803 - print '</div> ';
2677 + print '</p> ';
2804 2678 }
2805 2679
2806 2680
2807 2681
@@ -2841,59 +2715,15 @@
2841 2715 /**
2842 2716 * Js action to do when user pick live stream or video on demand
2843 2717 *
2844 2718 * @since 3.0.1
2845 - */
2846 -
2847 - /**
2848 - * Whether WpStream WooCommerce product UI should load for this product.
2849 - *
2850 - * Skips simple, course, and other non-WpStream types so LearnDash and
2851 - * other integrations can use the General product data tab without conflict.
2852 - *
2853 - * @param int $post_id Product post ID. Uses global $post when 0.
2854 - * @return bool
2855 - */
2856 - public function wpstream_is_wpstream_wc_product_context( $post_id = 0 ) {
2857 - if ( isset( $_GET['new_stream'] ) || isset( $_GET['new_video_name'] ) ) {
2858 - return true;
2859 - }
2860 -
2861 - if ( ! $post_id ) {
2862 - global $post;
2863 - $post_id = ( $post && isset( $post->ID ) ) ? (int) $post->ID : 0;
2864 - }
2865 -
2866 - if ( ! $post_id || ! function_exists( 'wc_get_product' ) ) {
2867 - return false;
2868 - }
2869 -
2870 - $product = wc_get_product( $post_id );
2871 - if ( ! $product ) {
2872 - return false;
2873 - }
2874 -
2875 - return in_array(
2876 - $product->get_type(),
2877 - array( 'live_stream', 'video_on_demand', 'wpstream_bundle', 'subscription' ),
2878 - true
2879 - );
2880 - }
2881 -
2882 - /**
2883 - * Js action to do when user pick live stream or video on demand
2884 - *
2885 - * @since 3.0.1
2886 - */
2719 + */
2720 +
2887 2721 public function wpstream_products_custom_js() {
2888 2722 if ( 'product' != get_post_type() ) :
2889 2723 return;
2890 2724 endif;
2891 2725
2892 - if ( ! $this->wpstream_is_wpstream_wc_product_context() ) {
2893 - return;
2894 - }
2895 -
2896 2726 ?>
2897 2727 <script type='text/javascript'>
2898 2728 jQuery( document ).ready( function() {
2899 2729 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
@@ -2964,20 +2794,18 @@
2964 2794 * @since 3.0.1
2965 2795 */
2966 2796
2967 2797 public function wpstream_add_custom_general_fields() {
2798 +
2799 +
2968 2800 global $woocommerce, $post;
2969 -
2970 - if ( ! $this->wpstream_is_wpstream_wc_product_context( isset( $post->ID ) ? (int) $post->ID : 0 ) ) {
2971 - return;
2972 - }
2973 2801 if(function_exists('wcs_user_has_subscription')){
2974 - echo '<div class="options_group show_if_subscription">';
2802 + echo '<div class="options_group show_if_subscription">';
2975 2803 woocommerce_wp_select(
2976 2804 array(
2977 2805 'id' => '_subscript_live_event',
2978 2806 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ),
2979 - 'options' => array("yes"=>"yes","no"=>"no", "none" => "none")
2807 + 'options' => array("yes"=>"yes","no"=>"no")
2980 2808 )
2981 2809 );
2982 2810 echo '</div>';
2983 2811 }
@@ -3079,11 +2907,8 @@
3079 2907 * @since 3.0.1
3080 2908 */
3081 2909
3082 2910 public function wpstream_add_custom_general_fields_save( $post_id ){
3083 - if ( ! $this->wpstream_is_wpstream_wc_product_context( (int) $post_id ) ) {
3084 - return;
3085 - }
3086 2911
3087 2912 $permited_values = array(
3088 2913 '_movie_url',
3089 2914 '_subscript_live_event',
@@ -3176,94 +3001,9 @@
3176 3001 $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
3177 3002 print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
3178 3003
3179 3004 }
3180 -
3181 - /**
3182 - * Get plugin latest update release date from WordPress.org
3183 - * @param $plugin_slug
3184 - * @param $version
3185 - *
3186 - * @return bool
3187 - */
3188 - public function get_plugin_release_date( $plugin_slug, $version = null ) {
3189 - $api_url = 'https://api.wordpress.org/plugins/info/1.0/' . $plugin_slug . '.json';
3190 - $response = wp_remote_get( $api_url );
3191 -
3192 - if ( is_wp_error( $response ) ) {
3193 - return false;
3194 - }
3195 -
3196 - $body = wp_remote_retrieve_body( $response );
3197 - $data = json_decode( $body, true );
3198 -
3199 - if ( !$data || !isset( $data['versions'] ) ) {
3200 - return false;
3201 - }
3202 -
3203 - // no version provided, get the latest version
3204 - if ( !$version ) {
3205 - $version = $data['version'];
3206 - }
3207 -
3208 - // check if the version exists in the versions array
3209 - if ( !isset( $data['versions'][ $version ] ) ) {
3210 - return false;
3211 - }
3212 -
3213 - if ( isset( $data['last_updated'] ) ) {
3214 - return date('Y-m-d', strtotime( $data['last_updated'] ) );
3215 - }
3216 -
3217 - return false;
3218 - }
3219 -
3220 - /**
3221 - * Adds notice for the WpStream update availability
3222 - * when the update is not older than 30 days
3223 - */
3224 - public function wpstream_plugin_update_available_notice() {
3225 - if (!current_user_can('update_plugins')) {
3226 - return;
3227 - }
3228 -
3229 - $plugin_slug = 'wpstream/wpstream.php';
3230 - $update_data = get_site_transient('update_plugins');
3231 -
3232 - if ( is_object( $update_data ) &&
3233 - property_exists( $update_data, 'response' ) &&
3234 - is_array($update_data->response) &&
3235 - key_exists($plugin_slug, $update_data->response)
3236 - ) {
3237 - $new_version = $update_data->response[$plugin_slug]->new_version;
3238 -
3239 - $release_date = $this->get_plugin_release_date( 'wpstream', $new_version );
3240 -
3241 - if ( $release_date ) {
3242 - $days_since_release = ( time() - strtotime( $release_date ) ) / DAY_IN_SECONDS;
3243 -
3244 - // if there's an update newer than 7 days, do not show the notice
3245 - if ( $days_since_release < 7 ) {
3246 - return;
3247 - }
3248 - }
3249 - $update_url = wp_nonce_url(
3250 - self_admin_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin_slug)),
3251 - 'upgrade-plugin_' . $plugin_slug
3252 - );
3253 -
3254 - echo '<div class="notice notice-warning is-dismissible">';
3255 - echo '<p><strong>' . __('WpStream Plugin Update Available', 'wpstream') . '</strong></p>';
3256 - echo '<p>' . sprintf(
3257 - __('Version %s is available. Please update to the latest version for new features and security improvements.', 'wpstream'),
3258 - '<strong>' . esc_html($new_version) . '</strong>'
3259 - ) . '</p>';
3260 - echo '<p><a href="' . esc_url($update_url) . '" class="button button-primary">' .
3261 - __('Update Now', 'wpstream') . '</a></p>';
3262 - echo '</div>';
3263 - }
3264 - }
3265 -
3005 +
3266 3006 /**
3267 3007 * Admin notices
3268 3008 *
3269 3009 * @since 3.0.1
@@ -3335,16 +3075,15 @@
3335 3075
3336 3076 if( get_post_status( $post->ID ) === 'publish' ) {
3337 3077 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
3338 3078 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
3339 -
3340 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
3341 - if( isset($pack_details['available_data_mb'])){
3342 - if ($pack_details['available_data_mb'] <= 0){
3343 - print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
3079 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_start_stream_meta');
3080 + if( isset($pack_details['available_data_mb'])){
3081 + if ($pack_details['available_data_mb'] <= 0){
3082 + print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
3083 + }
3344 3084 }
3345 - }
3346 -
3085 +
3347 3086 $this->wpstream_live_stream_unit($post->ID);
3348 3087 print '<div class="wpstream_modal_background"></div>';
3349 3088 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
3350 3089 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
@@ -3354,16 +3093,9 @@
3354 3093 }
3355 3094 }
3356 3095
3357 3096
3358 - public function wpstream_is_basic_streaming_mode(){
3359 - return $this->main->quota_manager->is_basic_streaming_mode( null, 'wpstream_is_basic_streaming_mode' );
3360 - }
3361 3097
3362 - public function wpstream_is_use_streaming_hours() {
3363 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_start_channel' );
3364 - return $this->main->quota_manager->uses_streaming_hours( $pack_details );
3365 - }
3366 3098
3367 3099
3368 3100
3369 3101 /**
@@ -3419,14 +3151,16 @@
3419 3151 *
3420 3152 */
3421 3153
3422 3154 public function wpstream_pre_onboard_display(){
3423 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_pre_onboard_display' );
3155 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_pre_onboard_display');
3156 +
3424 3157 $this->main->show_user_data($pack_details);
3425 3158
3426 - $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3159 +
3160 + $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3427 3161 ?>
3428 - <div id="wpstream-onboarding-root"></div>
3162 +
3429 3163 <div class="wpstream_quick_start_wrapper">
3430 3164 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
3431 3165
3432 3166 <h1><?php print esc_html__('WpStream','wpstream').' <span class="header_special">'.esc_html__('Quick Start','wpstream').'</span>';?></h1>
@@ -3554,40 +3288,38 @@
3554 3288
3555 3289 </div>
3556 3290
3557 3291 <div class="wpstream_option">
3558 -<!-- <label for="wpstream_register_password">--><?php //esc_html_e('Your Password','wpstream');?><!--</label>-->
3559 - <input id="wpstream_register_password" hidden type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
3560 - <span class="" ><?php esc_html_e('We\'ll send the password to the email you attached. ', 'wpstream') ?></span>
3292 + <label for="wpstream_register_password"><?php esc_html_e('Your Password','wpstream');?></label>
3293 + <input id="wpstream_register_password" type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
3561 3294 </div>
3562 3295
3563 3296
3564 - <!-- Altcha Widget (requires HTTPS/secure context) -->
3565 - <?php if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ) : ?>
3566 - <script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist/altcha.min.js" type="module"></script>
3567 - <div class="wpstream_option" style="display:none;">
3568 - <altcha-widget
3569 - challengeurl="<?php echo esc_url( WPSTREAM_API . '/v2/user/getcaptcha' ); ?>"
3570 - name="altcha"
3571 - auto="onload"
3572 - hidefooter
3573 - hidelogo
3574 - strings='{"label": "<?php esc_html_e('I am not a robot', 'wpstream'); ?>", "error": "<?php esc_html_e('Verification failed', 'wpstream'); ?>", "wait": "<?php esc_html_e('Verifying...', 'wpstream'); ?>"}'
3575 - ></altcha-widget>
3297 + <?php
3298 +
3299 + $curl_response_decoded['capthca']='';
3300 + $curl_response_decoded['capthca_id']='';
3301 +
3302 +
3303 + if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
3304 + $url = 'user/getcapthca';
3305 + $curl_post_fields = array();
3306 + $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true);
3307 + $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
3308 +
3309 + }
3310 +
3311 + ?>
3312 + <div class="wpstream_option">
3313 + <?php print '<div id="wpstream_capthca">'.$curl_response_decoded['capthca'].'</div>';?>
3314 + <label for="wpstream_register_captcha"><?php esc_html_e('Type the characters above','wpstream');?></label>
3315 +
3316 + <input id="wpstream_register_captcha" type="text" size="36" name="wpstream_register_captcha" />
3317 + <input id="wpstream_register_captcha_id" type="hidden" size="36" name="wpstream_register_captcha_id" value="<?php echo esc_html($curl_response_decoded['capthca_id']); ?>" />
3576 3318 </div>
3577 - <?php endif; ?>
3578 3319
3579 - <div class="wpstream_option wpstream_terms_agreement">
3580 - <!-- Add "by registering you agree to the privacy terms" checkbox-->
3581 - <input id="wpstream_register_privacy" type="checkbox" name="wpstream_register_privacy" />
3582 - <label for="wpstream_register_privacy">
3583 - <?php printf(
3584 - esc_html__('By registering you agree to the %sPrivacy Policy%s','wpstream'),
3585 - '<a href="https://wpstream.net/privacy-policy/" target="_blank">',
3586 - '</a>'
3587 - );?>
3588 - </label>
3589 - </div>
3320 +
3321 +
3590 3322 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_register" value="<?php esc_html_e('register','wpstream');?>" />
3591 3323 </div>
3592 3324
3593 3325
@@ -3632,10 +3364,10 @@
3632 3364 public function randomPassword() {
3633 3365 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
3634 3366 $pass = array(); //remember to declare $pass as an array
3635 3367 $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
3636 - for ($i = 0; $i < 16; $i++) {
3637 - $n = random_int(0, $alphaLength);
3368 + for ($i = 0; $i < 8; $i++) {
3369 + $n = rand(0, $alphaLength);
3638 3370 $pass[] = $alphabet[$n];
3639 3371 }
3640 3372 return implode($pass); //turn the array into a string
3641 3373 }
@@ -3652,11 +3384,11 @@
3652 3384
3653 3385 <div class="wpstream_step_wrapper wpstream_step_2" id="wpstream_step_2">
3654 3386 <h1>Welcome to <span class="header_special">WpStream</span>! How would you like to start?</h1>
3655 3387
3656 - <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3a" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
3388 + <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
3657 3389 <div class="wpstram_or">or</div>
3658 - <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_2_create_vod" data-nextthing="wpstream_step_4a" ><?php esc_html_e('Create a Video-On-Demand (VOD)','wpstream');?></div>
3390 + <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_4" ><?php esc_html_e('Create a Video-On-Demand (VOD)','wpstream');?></div>
3659 3391
3660 3392 </div>
3661 3393
3662 3394
@@ -3709,9 +3441,9 @@
3709 3441
3710 3442 </div>
3711 3443
3712 3444 <div class="wpstream_initial_onboarding_controls_wrapper">
3713 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
3445 + <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
3714 3446 </div>
3715 3447
3716 3448 </div>
3717 3449
@@ -3749,9 +3481,9 @@
3749 3481 } ?>
3750 3482
3751 3483
3752 3484 <div class="wpstream_initial_onboarding_controls_wrapper">
3753 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
3485 + <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
3754 3486 </div>
3755 3487 </div>
3756 3488 <?php
3757 3489 }
@@ -4178,10 +3910,8 @@
4178 3910 $password = $_POST['api_password'];
4179 3911 update_option('wpstream_api_username',$username);
4180 3912 update_option('wpstream_api_password',$password);
4181 3913
4182 - delete_transient( 'wpstream_token_api' );
4183 -
4184 3914 $token = $this->main->wpstream_live_connection->wpstream_get_token();
4185 3915 $videos_list = $this->main->wpstream_live_connection->wpstream_get_videos();
4186 3916 // cleanup any previous echo before sending json
4187 3917 ob_end_clean();
@@ -4211,54 +3941,13 @@
4211 3941 }
4212 3942
4213 3943
4214 3944 public function wpstream_register_refresh_capthca(){
4215 -
3945 +
4216 3946 if(current_user_can('administrator')){
4217 -
3947 +
4218 3948 }
4219 3949 }
4220 -
4221 - /**
4222 - * AJAX proxy: fetch a captcha challenge from the baker API and return it.
4223 - * Used on HTTP sites where the Altcha widget cannot run (requires Web Crypto / HTTPS).
4224 - * The JS side solves the PoW locally and sends back the full base64 Altcha payload.
4225 - */
4226 - public function wpstream_get_captcha_challenge() {
4227 - $api_url = WPSTREAM_API . '/v2/user/getcaptcha';
4228 - $response = wp_remote_get( $api_url, array( 'timeout' => 10 ) );
4229 -
4230 - if ( is_wp_error( $response ) ) {
4231 - echo json_encode( array( 'success' => false, 'error' => 'Could not reach captcha service.' ) );
4232 - die();
4233 - }
4234 -
4235 - $body = wp_remote_retrieve_body( $response );
4236 - // Forward the challenge JSON directly to the browser
4237 - header( 'Content-Type: application/json' );
4238 - echo $body;
4239 - die();
4240 - }
4241 -
4242 - /**
4243 - * @param $challenge
4244 - * @param $difficulty
4245 - *
4246 - * @return int|null
4247 - */
4248 - private function solve_pow( $challenge, $difficulty ) {
4249 - $nonce = 0;
4250 - $target = str_repeat( "0", $difficulty );
4251 -
4252 - while ( $nonce < 5000000 ) {
4253 - $hash = hash( 'sha256', $challenge . $nonce );
4254 - if ( strpos( $hash, $target ) === 0 ) {
4255 - return $nonce;
4256 - }
4257 - $nonce++;
4258 - }
4259 - return null; // Return null if no solution is found within the max attempts
4260 - }
4261 3950
4262 3951 /*
4263 3952 *
4264 3953 * On Boarding login
@@ -4265,12 +3954,15 @@
4265 3954 *
4266 3955 */
4267 3956 public function wpstream_on_board_register(){
4268 3957 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3958 +
4269 3959 if(current_user_can('administrator')){
4270 3960 $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']);
4271 3961 $wpstream_register_password = $_POST['wpstream_register_password'];
4272 -
3962 + $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']);
3963 + $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']);
3964 +
4273 3965 $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password);
4274 3966 if(!$validate['success']){
4275 3967 // cleanup any previous echo before sending json
4276 3968 ob_end_clean();
@@ -4277,32 +3969,23 @@
4277 3969 echo json_encode($validate);
4278 3970 die();
4279 3971 }
4280 3972
4281 - $wpstream_altcha = isset($_POST['wpstream_altcha']) ? trim( $_POST['wpstream_altcha'] ) : '';
4282 - $is_https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
4283 -
4284 - if ( empty($wpstream_altcha) ) {
4285 - if ( $is_https ) {
4286 - $message = esc_html__('Captcha verification failed. Please try again.', 'wpstream');
4287 - } else {
4288 - $message = esc_html__('Security check not ready yet. Please wait a moment and try again.', 'wpstream');
4289 - }
4290 - echo json_encode( array( 'success' => false, 'message' => $message ) );
4291 - die();
4292 - }
4293 -
4294 - $url='v2/user/create';
3973 + $url='user/create';
4295 3974 $curl_post_fields=array(
4296 3975 'email' => $wpstream_register_email,
4297 3976 'password' => $wpstream_register_password,
4298 - 'solution' => $wpstream_altcha,
4299 - 'captcha_id' => '',
3977 + 'captcha' => $wpstream_register_captcha,
3978 + 'captcha_id' => $wpstream_register_captcha_id,
4300 3979 );
4301 3980
3981 +
3982 +
4302 3983 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true);
4303 3984 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
4304 3985
3986 +
3987 +
4305 3988 if($curl_response_decoded['success']){
4306 3989
4307 3990 if($curl_response_decoded['request']['registred']){
4308 3991 // we are registerd
@@ -4392,9 +4075,9 @@
4392 4075
4393 4076 if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) {
4394 4077 $return= array(
4395 4078 'success'=> false,
4396 - 'message' => esc_html__('The email doesn\'t look right !','wpstream')
4079 + 'message' => esc_html__("The email doesn't look right !",'wpstream')
4397 4080 );
4398 4081 return $return;die();
4399 4082 }
4400 4083
@@ -4402,9 +4085,9 @@
4402 4085 $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1);
4403 4086 if( $domain!='' && !checkdnsrr ($domain) ){
4404 4087 $return= array(
4405 4088 'success'=> false,
4406 - 'message' => esc_html__('The email doesn\'t look right !','wpstream')
4089 + 'message' => esc_html__("The email doesn't look right !",'wpstream')
4407 4090 );
4408 4091 return $return;die();
4409 4092 }
4410 4093
@@ -4426,10 +4109,8 @@
4426 4109 *
4427 4110 * @since 3.0.1
4428 4111 */
4429 4112 public function handle_initiate_multipart_upload() {
4430 - check_ajax_referer( 'wpstream_multipart_upload_nonce', 'security' );
4431 -
4432 4113 // Security check - only admins can do this
4433 4114 if (!current_user_can('administrator')) {
4434 4115 wp_send_json_error('Unauthorized access');
4435 4116 return;
@@ -4489,10 +4170,8 @@
4489 4170 *
4490 4171 * @since 3.0.1
4491 4172 */
4492 4173 public function handle_complete_multipart_upload() {
4493 - check_ajax_referer( 'wpstream_multipart_upload_nonce', 'security' );
4494 -
4495 4174 // Security check - only admins can do this
4496 4175 if (!current_user_can('administrator')) {
4497 4176 wp_send_json_error('Unauthorized access');
4498 4177 return;