PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.11.1
WpStream – Live Streaming, Video on Demand, Pay Per View v4.11.1
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 +1720 -500 4.4.44.11.1 View file →
@@ -31,33 +31,33 @@
31 31 */
32 32 public $main;
33 33
34 34
35 - /**
36 - * The ID of this plugin.
37 - *
38 - * @since 3.0.1
39 - * @access private
40 - * @var string $plugin_name The ID of this plugin.
41 - */
42 - private $plugin_name;
35 + /**
36 + * The ID of this plugin.
37 + *
38 + * @since 3.0.1
39 + * @access private
40 + * @var string $plugin_name The ID of this plugin.
41 + */
42 + private $plugin_name;
43 43
44 - /**
45 - * The version of this plugin.
46 - *
47 - * @since 3.0.1
48 - * @access private
49 - * @var string $version The current version of this plugin.
50 - */
51 - private $version;
44 + /**
45 + * The version of this plugin.
46 + *
47 + * @since 3.0.1
48 + * @access private
49 + * @var string $version The current version of this plugin.
50 + */
51 + private $version;
52 52
53 - /**
54 - * Initialize the class and set its properties.
55 - *
56 - * @since 3.0.1
57 - * @param string $plugin_name The name of this plugin.
58 - * @param string $version The version of this plugin.
59 - */
53 + /**
54 + * Initialize the class and set its properties.
55 + *
56 + * @since 3.0.1
57 + * @param string $plugin_name The name of this plugin.
58 + * @param string $version The version of this plugin.
59 + */
60 60
61 61 public $global_event_options ;
62 62
63 63
@@ -63,128 +63,171 @@
63 63
64 64
65 65
66 66
67 - public function __construct( $plugin_name, $version,$plugin_main ) {
67 + public function __construct( $plugin_name, $version,$plugin_main ) {
68 68
69 - $this->plugin_name = $plugin_name;
70 - $this->version = $version;
71 - $this->main = $plugin_main;
72 -
73 - $this->global_event_options = array(
74 -
75 - 'record' =>array(
76 - 'name' => esc_html__('Record Live Stream','wpstream'),
77 - 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'),
78 - 'defaults' => 'no',
79 -
80 - ),
81 - 'view_count' =>array(
82 - 'name' => esc_html__('Display Viewer Count','wpstream'),
83 - 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'),
84 - 'defaults' => 'yes',
85 - ),
86 - 'domain_lock'=>array(
87 - 'name' => esc_html__('Lock To Website','wpstream'),
88 - 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
89 - 'defaults' => 'no',
90 - ),
91 - 'autoplay' =>array(
92 - 'name' => esc_html__('Autoplay','wpstream'),
93 - 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
94 - 'defaults' => 'yes',
95 - ),
96 - 'mute' =>array(
97 - 'name' => esc_html__('Start Muted','wpstream'),
98 - 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'),
99 - 'defaults' => 'no',
69 + $this->plugin_name = $plugin_name;
70 + $this->version = $version;
71 + $this->main = $plugin_main;
100 72
101 - ),
102 -
103 - 'encrypt' =>array(
104 - 'name' => esc_html__('Encrypt Live Stream','wpstream'),
105 - 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'),
106 - 'defaults' => 'no',
107 - ),
108 - 'ses_encrypt'=>array(
109 - 'name' => esc_html__('Use Sessions with Encryption','wpstream'),
110 - 'details' => esc_html__('If enabled, encryption key distribution will be checked against valid user sessions. Setting may malfunction or lead to reduced website performance under certain configurations. ','wpstream'),
111 - 'defaults' => 'no',
112 - ),
113 - 'autostart' =>array(
114 - 'name' => esc_html__('Auto TURN ON','wpstream'),
115 - 'details' => esc_html__('If enabled, channel will TURN ON automatically when broadcasting with an External Streaming App (RTMP Encoder/Broadcaster)','wpstream'),
116 - 'defaults' => 'no',
117 - ),
73 + add_action('init', array($this, 'load_global_event_options'));
74 + }
118 75
119 - 'vod_domain_lock' =>array(
120 - 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'),
121 - 'details' => sprintf ( esc_html__('If enabled, VODS will only display on %1$s, otherwise they can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
122 - 'defaults' => 'no',
123 - ),
124 - 'vod_encrypt' =>array(
125 - 'name' => esc_html__('Encrypt Video on Demand','wpstream'),
126 - 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'),
127 - 'defaults' => 'no',
128 - ),
129 - );
76 + public function load_global_event_options() {
77 + $this->global_event_options = array(
78 + 'record' => array(
79 + 'name' => esc_html__('Record Live Stream','wpstream'),
80 + 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'),
81 + 'defaults' => 'no',
82 + ),
83 + 'view_count' => array(
84 + 'name' => esc_html__('Display Viewer Count','wpstream'),
85 + 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'),
86 + 'defaults' => 'yes',
87 + ),
88 + 'domain_lock' => array(
89 + 'name' => esc_html__('Lock To Website','wpstream'),
90 + 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
91 + 'defaults' => 'no',
92 + ),
93 + 'autoplay' => array(
94 + 'name' => esc_html__('Autoplay','wpstream'),
95 + 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
96 + 'defaults' => 'yes',
97 + ),
98 + 'mute' => array(
99 + 'name' => esc_html__('Start Muted','wpstream'),
100 + 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'),
101 + 'defaults' => 'no',
102 + ),
103 + 'low_latency' => array(
104 + 'name' => esc_html__('Low Latency (beta)','wpstream'),
105 + 'details' => esc_html__('Shortens the live delay between streamer and viewers. Useful for interactive applications like gaming, auctions, trading etc. Low latency may worsen the viewer experience on some devices.','wpstream'),
106 + 'defaults' => 'no',
107 + ),
108 + 'adaptive_bitrate' => array(
109 + 'name' => esc_html__('Adaptive Bitrate (beta)','wpstream'),
110 + 'details' => esc_html__('Ensures a smooth and uninterrupted viewing experience by adjusting video quality for viewers with reduced network speed or device capabilities.','wpstream'),
111 + 'defaults' => 'no',
112 + ),
113 + 'encrypt' =>array(
114 + 'name' => esc_html__('Encrypt Live Stream','wpstream'),
115 + 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'),
116 + 'defaults' => 'no',
117 + ),
118 + 'ses_encrypt'=>array(
119 + 'name' => esc_html__('Use Sessions with Encryption','wpstream'),
120 + 'details' => esc_html__('If enabled, encryption key distribution will be checked against valid user sessions. Setting may malfunction or lead to reduced website performance under certain configurations. ','wpstream'),
121 + 'defaults' => 'no',
122 + ),
123 + 'autostart' =>array(
124 + 'name' => esc_html__('Auto TURN ON','wpstream'),
125 + 'details' => esc_html__('If enabled, channel will TURN ON automatically when broadcasting with an External Streaming App (RTMP Encoder/Broadcaster)','wpstream'),
126 + 'defaults' => 'no',
127 + ),
128 + );
129 + }
130 130
131 - }
131 + /**
132 + * Register the stylesheets for the admin area.
133 + *
134 + * @since 3.0.1
135 + */
136 + public function enqueue_styles() {
132 137
133 - /**
134 - * Register the stylesheets for the admin area.
135 - *
136 - * @since 3.0.1
137 - */
138 - public function enqueue_styles() {
139 -
140 - /**
141 - * This function is provided for demonstration purposes only.
142 - *
143 - * An instance of this class should be passed to the run() function
144 - * defined in Wpstream_Loader as all of the hooks are defined
145 - * in that particular class.
146 - *
147 - * The Wpstream_Loader will then create the relationship
148 - * between the defined hooks and the functions defined in this
149 - * class.
150 - */
138 + /**
139 + * This function is provided for demonstration purposes only.
140 + *
141 + * An instance of this class should be passed to the run() function
142 + * defined in Wpstream_Loader as all of the hooks are defined
143 + * in that particular class.
144 + *
145 + * The Wpstream_Loader will then create the relationship
146 + * between the defined hooks and the functions defined in this
147 + * class.
148 + */
151 149 wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
152 - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
150 + wp_enqueue_style(
151 + $this->plugin_name,
152 + plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css',
153 + array(),
154 + filemtime(plugin_dir_path(__FILE__) . 'css/wpstream-admin.css' ),
155 + 'all'
156 + );
153 157
154 - wp_enqueue_style( 'wpstream-on-boarding-css', plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css', array(), rand(1,999999999999), 'all' );
158 + wp_enqueue_style(
159 + 'wpstream-on-boarding-css',
160 + plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css',
161 + array(),
162 + filemtime(plugin_dir_path(__FILE__) . 'css/wpstream-admin-onboarding.css'),
163 + );
155 164
156 -
157 - }
165 + if (!did_action('wp_enqueue_media')) {
166 + wp_enqueue_media();
167 + }
168 + }
158 169
159 - /**
160 - * Register the JavaScript for the admin area.
161 - *
162 - * @since 3.0.1
163 - */
164 - public function enqueue_scripts() {
170 + /**
171 + * Register the JavaScript for the admin area.
172 + *
173 + * @since 3.0.1
174 + */
175 + public function enqueue_scripts() {
165 176
166 177 wp_enqueue_script("jquery-ui-slider");
167 178 wp_enqueue_script("jquery-ui-datepicker");
168 - wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
169 - wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
179 + wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
180 +
181 + wp_enqueue_script( 'wpstream-admin-utils', plugin_dir_url( __FILE__ ) .'js/utils/admin_utils.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
182 + wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
170 183 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
171 184 array(
172 - 'admin_url' => get_admin_url(),
173 - 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
174 - 'download_mess' => esc_html__('Click to download!','wpstream'),
175 - 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
176 - 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
177 - 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
178 - 'upload_complete' => esc_html('Upload Complete!','wpstream'),
179 - 'no_band' => esc_html('Not enough streaming data.','wpsteam'),
180 - 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam')
181 -
185 + 'admin_url' => get_admin_url(),
186 + 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
187 + 'download_mess' => esc_html__('Click to download!','wpstream'),
188 + 'uploading' => esc_html__('We are uploading your file. Do not close this window!','wpstream'),
189 + 'upload_complete2' => esc_html__('Upload Complete! You can upload another file!','wpstream'),
190 + 'not_accepted' => esc_html__('The file is not an accepted video format','wpstream'),
191 + 'upload_complete' => esc_html__('Upload Complete!','wpstream'),
192 + 'no_band' => esc_html__('Not enough streaming data.','wpsteam'),
193 + 'no_band_no_store' => esc_html__('Not enough streaming data or storage.','wpsteam'),
194 + 'exceeding_limit' => esc_html__('File size exceeds 5GB. Initiating multipart upload...','wpsteam'),
195 + 'upload_failed' => esc_html__('Upload Failed!','wpstream'),
196 + 'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'),
197 + 'choose_a_file' => esc_html__('Choose a file…','wpstream'),
198 + 'preparing_multipart' => esc_html__('Preparing multipart upload...','wpstream'),
199 + 'uploading_part' => esc_html__('Uploading part {part} of {total}...','wpstream'),
200 + 'upload_failed_part' => esc_html__('Failed to upload part {part}. Please try again.','wpstream'),
201 + 'completing_upload' => esc_html__('Completing upload. Please wait...','wpstream'),
202 + 'upload_failed_part_retry' => esc_html__('Failed to upload part {part}. Retrying...','wpstream'),
203 + 'choose_recording' => esc_html__( 'Choose Recording', 'wpstream' ),
204 + 'select_recording' => esc_html__( 'Please select a recording from the list', 'wpstream' ),
205 + 'invalid_response' => esc_html__('Invalid response from server. Missing required upload data.', 'wpstream'),
206 + 'video_processing' => esc_html__( 'The video is still processing', 'wpstream' ),
207 + 'file_name_text' => esc_html__('File Name:','wpstream'),
208 + 'channel_create_error' => esc_html__('Something did not work. Please try again.', 'wpstream'),
209 + 'select_caption_file' => esc_html__('Select .vtt Captions File', 'wpstream'),
210 + 'select_button' => esc_html__('Select', 'wpstream'),
211 + 'remove_button' => esc_html__('Remove', 'wpstream'),
182 212 ));
183 213
184 -
185 -
186 - wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
214 + wp_enqueue_script('wpstream-recordings-videos-list', plugin_dir_url( __FILE__ ) .'js/recordings_videos_list.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
215 + wp_localize_script( 'wpstream-recordings-videos-list', 'wpstream_recordings_videos_list_vars',
216 + array(
217 + 'delete_file' => esc_html__('Delete file', 'wpstream'),
218 + 'download' => esc_html__( 'Download', 'wpstream'),
219 + 'download_available' => esc_html__( 'Click to download! The url will work for the next 20 minutes!', 'wpstream'),
220 + 'add_free_video_url' => esc_url( admin_url( 'post-new.php?post_type=wpstream_product_vod') . '&new_video_name=' ),
221 + 'create_ftv_vod' => esc_html__( 'Create new Free-To-View VOD from this recording' , 'wpstream' ),
222 + 'woocommerce_exists' => class_exists( 'WooCommerce' ),
223 + 'add_paid_video_url' => esc_url( admin_url( 'post-new.php?post_type=product').'&new_video_name=' ),
224 + 'create_ptv_vod' => esc_html__( 'Create new Pay-Per-View VOD from this recording' , 'wpstream' ),
225 + )
226 + );
227 +
228 + $modified_start_streaming_file_time = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'public/js/start_streaming.js' ) );
229 + wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'public/js/start_streaming.js', array(), $modified_start_streaming_file_time, true);
187 230 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
188 231 array(
189 232 'admin_url' => get_admin_url(),
190 233 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
@@ -199,8 +242,9 @@
199 242 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'),
200 243 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'),
201 244 'start_streaming' => esc_html__('TURN ON','wpstream'),
202 245 'stop_streaming' => esc_html__('TURN OFF','wpstream'),
246 + 'failed_fetching' => esc_html__('Failed to get channel info. Please try again.','wpstream'),
203 247 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'),
204 248 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'),
205 249 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'),
206 250 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'),
@@ -209,29 +253,91 @@
209 253 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'),
210 254 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'),
211 255 'channel_on' => esc_html__('Channel is ON','wpstream'),
212 256 'channel_off' => esc_html__('Channel is OFF','wpstream'),
213 - 'turn_off_confirm' => esc_html__('ARE YOU SURE you\'d like to TURN OFF the channel now? '.PHP_EOL.PHP_EOL.'Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).'.PHP_EOL.PHP_EOL.'Manual TURN OFF is only useful if you require to change the channel settings immediately.'.PHP_EOL.PHP_EOL.'Statistics may be unavailable or incomplete for up to an hour.'.PHP_EOL.PHP_EOL.'If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.','wpstream')
257 + 'turn_off_confirm' => esc_html__(
258 + 'ARE YOU SURE you\'d like to TURN OFF the channel now? ' . PHP_EOL . PHP_EOL .
259 + '- Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).' . PHP_EOL .
260 + '- Manual TURN OFF is only useful if you require to change the channel settings immediately.' . PHP_EOL .
261 + '- If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.',
262 + 'wpstream'
263 + ),
264 + 'basic_streaming_warning' => esc_html__(
265 + 'Your account is now in BASIC STREAMING mode.' . PHP_EOL . PHP_EOL .
266 + '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 .
267 + 'Certain features, such as recording, viewer count, browser broadcasting, and content protection are unavailable.' . PHP_EOL . PHP_EOL .
268 + '- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL .
269 + '- Otherwise, choose OK to start your channel with these limitations.' . PHP_EOL . PHP_EOL .
270 + 'ARE YOU SURE you want to continue with Basic Streaming?',
271 + 'wpstream'
272 + ),
273 + 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
274 + 'is_onboarding' => isset($_GET['onboard']) && $_GET['onboard'] === 'yes' ? 'yes' : 'no',
214 275 ));
215 276
277 + wp_enqueue_script('wpstream-settings', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream_settings.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
278 + wp_localize_script('wpstream-settings', 'wpstream_settings_vars', array(
279 + 'error_message' => esc_html__( 'Failed to save settings. Please try again.', 'wpstream'),
280 + 'choose_image_text' => esc_html__( 'Choose Logo Image', 'wpstream'),
281 + 'select_image_text' => esc_html__( 'Select Image', 'wpstream'),
282 + 'update_successful' => esc_html__( 'Update Successful.', 'wpstream'),
283 + 'update_failed' => esc_html__( 'Something went wrong. Try again.', 'wpstream'),
284 + 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
285 + ));
216 286
217 - wp_enqueue_script('wpstream-on-boarding-js', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
287 +
288 + $branch = isset($_GET['branch']) ? sanitize_text_field( wp_unslash( $_GET['branch'] ) ) : '';
289 + wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',array(), WPSTREAM_PLUGIN_VERSION, true);
218 290 wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars',
219 291 array(
220 - 'admin_url' => get_admin_url(),
221 - 'plugin_url' => get_dashboard_url().'/plugins.php',
222 - 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings'
223 -
224 - ));
292 + 'admin_url' => get_admin_url(),
293 + 'plugin_url' => get_dashboard_url().'/plugins.php',
294 + 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings',
295 + 'branch' => $branch
296 + ));
297 +
298 + $current_screen=get_current_screen();
299 + // enqueue the file only on the on-boarding page and wpstream_product post type
300 + $is_wpstream_onboarding_page = $current_screen->base ==='wpstream_page_wpstream_onboard';
301 + $is_wpstream_onboarding_post_type_page = isset($_GET['onboard']) && $_GET['onboard'] === 'yes';
302 + $onboarding_visible = $is_wpstream_onboarding_page || $is_wpstream_onboarding_post_type_page;
303 + if( $onboarding_visible) {
304 + wp_enqueue_script('wpstream-on-boarding-page-js', plugin_dir_url( __DIR__ ) .'admin/js/wpstream-onboarding-page.js',array(), WPSTREAM_PLUGIN_VERSION, true);
305 + wp_localize_script( 'wpstream-on-boarding-page-js', 'wpstream_onboarding_page_vars',
306 + array(
307 + 'admin_url' => get_admin_url(),
308 + 'request_url' => WPSTREAM_CLICK,
309 + 'wps_user' => get_option('wpstream_api_username_from_token'),
310 + 'current_page' => $is_wpstream_onboarding_post_type_page ? 'post_edit' : 'onboarding',
311 + 'plugin_version' => WPSTREAM_PLUGIN_VERSION,
312 + 'branch' => $branch,
313 + )
314 + );
315 + }
316 +
317 + if ( in_array( $current_screen->base, ['toplevel_page_wpstream_credentials', 'wpstream_page_wpstream_live_channels', 'wpstream_page_wpstream_recordings', 'wpstream_page_wpstream_onboard'] ) ) {
318 + wp_enqueue_script( 'wpstream-user-quota-update', plugin_dir_url( __DIR__ ) . 'admin/js/wpstream-user-quota.js', array(), WPSTREAM_PLUGIN_VERSION, true );
319 + wp_localize_script( 'wpstream-user-quota-update', 'wpstream_user_quota_vars', array(
320 + 'admin_url' => get_admin_url()
321 + ));
322 + }
323 +
324 + // Add localized variables for broadcaster
325 + wp_localize_script('wpstream-broadcaster', 'wpstream_broadcaster_vars', array(
326 + 'ajax_url' => admin_url('admin-ajax.php'),
327 + 'nonce' => wp_create_nonce('wpstream_broadcaster_nonce'),
328 + 'plugin_url' => plugin_dir_url(__FILE__),
329 +
330 + ));
225 331
226 332 }
227 333
228 334
229 335 /**
230 - * Add Plugin Administation menu
231 - *
232 - * @since 3.0.1
233 - */
336 + * Add Plugin Administation menu
337 + *
338 + * @since 3.0.1
339 + */
234 340
235 341 public function wpstream_manage_admin_menu() {
236 342
237 343 add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials'), WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png',20 );
@@ -290,10 +396,10 @@
290 396
291 397
292 398 $event_list = new WP_Query($args);
293 399 global $live_event_for_user;
294 - $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
295 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
400 + $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
401 + $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
296 402
297 403 $this->main->show_user_data($pack_details);
298 404 if( $event_list->have_posts()){
299 405
@@ -331,8 +437,15 @@
331 437
332 438
333 439 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
334 440 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
441 +
442 + $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
443 + if( isset($pack_details['available_data_mb'])){
444 + if ($pack_details['available_data_mb'] <= 0){
445 + print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
446 + }
447 + }
335 448 $current_user = wp_get_current_user();
336 449 $allowded_html = array();
337 450 $userID = $current_user->ID;
338 451 $user_live_streams = get_user_meta($userID,'live_shows');
@@ -513,13 +626,17 @@
513 626
514 627 if( $live_event_for_user=='' && $is_front=='front' ){
515 628 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
516 629 }
517 - $channel_status = esc_html__('Channel is OFF','wpstream');
630 + $channel_status = '<div class="spinner" style="visibility: visible"></div>';
631 + $button_status = '<div class="spinner" style="visibility: visible"></div>';
518 632 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
519 633 $pending_streaming_class = 'pending_trigger';
520 634 $live_data_url = get_post_meta($the_id,'qos_url',true);
521 635 // $channel_status = esc_html__('Channel is on','wpstream');
636 + } else {
637 + $channel_status = esc_html__('Channel is OFF','wpstream');
638 + $button_status = esc_html__('TURN ON','wpstream');
522 639 }
523 640
524 641 $server_id = get_post_meta($the_id,'server_id',true);
525 642 $obs_uri = get_post_meta($the_id,'obs_uri',true);
@@ -541,13 +658,14 @@
541 658 /* print '***</br>'.get_post_meta($the_id,'obs_uri',true) .'***</br>'.
542 659 get_post_meta($the_id,'obs_stream',true).'***</br>'.
543 660 get_post_meta($the_id,'broadcast_url',true);
544 661 */
545 - print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
662 + print '<div class="wpstream_channel_item_id">'.esc_html( '#ID' ).' '.$the_id.'</div>';
546 663 print '</div>';
547 664
548 665
549 - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream');
666 + $start_event_nonce = wp_create_nonce( 'wpstream_start_event_nonce' );
667 + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" data-nonce="' . esc_attr( $start_event_nonce ) . '" > ' . $button_status;
550 668 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
551 669 print '</div>';
552 670
553 671 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
@@ -594,8 +712,186 @@
594 712 print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
595 713 if($is_front==''){
596 714 print '<div class="wpstream_show_settings wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_settings_modal" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">';
597 715
716 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('
717 + Turn OFF the channel to change its settings.','wpestream').'</div>';
718 + print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
719 +
720 + print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
721 + <path d="M49.22 21.8648C48.82 21.6099 45.665 19.7247 44.415 19.15L42.8651 15.4C43.3251 14.1601 44.2099 10.6849 44.3652 10.0798H44.3649C44.4911 9.52035 44.3213 8.93514 43.9149 8.52987L41.47 6.09995C41.0658 5.69189 40.4795 5.52168 39.9201 5.65003C39.4601 5.75501 35.92 6.64994 34.5999 7.15012L30.8499 5.60021C30.3048 4.40012 28.4699 1.32529 28.1351 0.795199V0.79485C27.8337 0.301688 27.298 0.00069643 26.7201 0H23.2798C22.7057 0.000348769 22.1718 0.294715 21.8648 0.779859C21.6098 1.1799 19.7247 4.33487 19.15 5.58487L15.4 7.13478C14.1601 6.67476 10.6849 5.78996 10.0798 5.63469V5.63504C9.52035 5.50878 8.93513 5.67864 8.52987 6.08496L6.09995 8.52988C5.69189 8.9341 5.52168 9.52042 5.65003 10.0798C5.75501 10.5398 6.64994 14.0799 7.15012 15.4L5.60021 19.15C4.40012 19.6951 1.32529 21.53 0.795198 21.8648H0.79485C0.301688 22.1662 0.00069643 22.7019 0 23.2798V26.7149C0.000348751 27.2893 0.294715 27.8233 0.779858 28.1299C1.1799 28.3849 4.33486 30.27 5.58487 30.8448L7.13478 34.5948C6.67475 35.8347 5.78996 39.3099 5.63469 39.915H5.63504C5.50878 40.4747 5.67863 41.06 6.08496 41.4649L8.51487 43.8948V43.8951C8.9191 44.3032 9.50541 44.4731 10.0648 44.3451C10.5248 44.2401 14.0649 43.3451 15.385 42.845L19.135 44.3949C19.6801 45.595 21.515 48.6698 21.8498 49.1999C22.1525 49.6997 22.6956 50.0035 23.2798 50H26.7149C27.2893 49.9996 27.8233 49.7053 28.1299 49.2201C28.3849 48.8201 30.27 45.6651 30.8447 44.4151L34.5947 42.8652C35.8347 43.3252 39.3098 44.21 39.9149 44.3653V44.3649C40.4747 44.4912 41.0599 44.3213 41.4649 43.915L43.8948 41.4851H43.8951C44.3032 41.0809 44.473 40.4945 44.345 39.9352C44.2401 39.4751 43.3451 35.9351 42.8449 34.615L44.3949 30.865C45.5949 30.3198 48.6698 28.485 49.1999 28.1501C49.6997 27.8474 50.0034 27.3044 49.9999 26.7201V23.2799C50.0045 22.7047 49.7087 22.1683 49.2201 21.8649L49.22 21.8648ZM24.9995 35.8845C22.1099 35.882 19.3399 34.7314 17.2985 32.6866C15.2572 30.6414 14.1118 27.8694 14.1146 24.9798C14.1171 22.0903 15.2676 19.3199 17.3125 17.2785C19.3577 15.2372 22.1297 14.0921 25.0193 14.0946C27.9088 14.0974 30.6792 15.2477 32.7205 17.2928C34.7619 19.338 35.907 22.1101 35.9045 24.9996C35.8978 27.8879 34.7462 30.6557 32.7021 32.6964C30.6576 34.7367 27.8876 35.8834 24.9994 35.8845H24.9995Z" fill="black"/>
722 + </svg>
723 + </div>';
724 +
725 +
726 + print '<a href="'.get_edit_post_link($the_id).'" class="wpstream_edit_channel wpstream-button-icon wpstream_tooltip_wrapper" target="_blank" data-show-id="'.$the_id.'"">';
727 + print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
728 + print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
729 + <path d="M44.8203 1.79549C42.4263 -0.598498 38.5591 -0.598498 36.1651 1.79549L4.67494 33.2246C4.55203 33.3475 4.49079 33.4088 4.42954 33.5317C4.42954 33.5317 4.42954 33.5929 4.36829 33.5929C4.30705 33.7159 4.24539 33.7771 4.24539 33.9V33.9613L0.0711091 47.5886C-0.113044 48.264 0.0711092 48.9389 0.500659 49.4301C0.868966 49.7984 1.29852 49.9826 1.78973 49.9826C1.97388 49.9826 2.15804 49.9826 2.34219 49.9213L15.9085 45.747H15.9697C16.0926 45.6858 16.2151 45.6858 16.2768 45.6241C16.2768 45.6241 16.338 45.6241 16.338 45.5629C16.4609 45.5016 16.5834 45.44 16.6451 45.3175L48.0742 13.8884C50.4682 11.4944 50.4682 7.62715 48.0742 5.23316L44.8203 1.79549Z" fill="black"/>
730 + </svg>';
731 + print '</a>';
732 + }
733 +
734 + print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
735 + print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
736 + print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
737 + <path d="M18.6201 15.2828H21.8752C21.8752 14.069 22.8681 13.0207 24.1373 13.0207V9.76562C21.1032 9.76562 18.6201 12.2487 18.6201 15.2828Z" fill="black"/>
738 + <path d="M24.855 0C12.9378 0 3.28272 10.9792 0.579292 14.3447C-0.193097 15.2826 -0.193097 16.662 0.579292 17.6553C3.28282 21.0208 12.9378 32 24.855 32C36.7722 32 46.4273 21.0208 49.1307 17.6553C49.9031 16.7174 49.9031 15.338 49.1307 14.3447C46.4275 10.9792 36.7722 0 24.855 0V0ZM24.855 25.8205C19.4482 25.8205 15.0344 21.4067 15.0344 15.9999C15.0344 10.5931 19.4482 6.17927 24.855 6.17927C30.2618 6.17927 34.6756 10.5931 34.6756 15.9999C34.6756 21.4067 30.2618 25.8205 24.855 25.8205Z" fill="black"/>
739 + </svg>';
740 + print '</a>';
741 +
742 +
743 + print '<div class="wpstream_share_channel wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_share_modal" data-show-id="'.$the_id.'"">';
744 + print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
745 + print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
746 + <path d="M20.0777 20.5087L24.3481 17.9427C26.6432 16.5645 29.4554 16.2443 31.96 17.198C33.443 17.7642 35.1166 17.9363 36.852 17.6105C40.3163 16.9521 43.1162 14.1831 43.8115 10.7248C45.0606 4.51597 39.7751 -0.910703 33.5907 0.12835C30.2924 0.682061 27.5604 3.16211 26.5942 6.36168C26.4405 6.86646 26.3418 7.35835 26.2804 7.84466C25.9482 10.5028 24.2498 12.8044 21.9547 14.1827L19.3458 15.7456C17.1061 17.0869 14.3986 17.1792 11.9494 16.2748C10.9956 15.9241 9.96159 15.7271 8.88507 15.7271C3.39004 15.7271 -0.960663 20.7607 0.184097 26.4527C0.879447 29.911 3.67936 32.68 7.14364 33.3384C8.87902 33.6706 10.5525 33.492 12.0356 32.9259C14.5402 31.9721 17.3461 32.2919 19.6475 33.6706L23.906 36.2241C25.346 37.0855 26.2195 38.6424 26.2195 40.3159V40.3403C26.2195 45.8229 31.2287 50.1611 36.9018 49.0472C40.3602 48.3703 43.1415 45.583 43.8244 42.1246C44.9383 36.451 40.6 31.4423 35.1175 31.4423C34.0406 31.4423 33.007 31.6394 32.0532 31.9901C29.604 32.8944 26.9029 32.8022 24.6627 31.4608L20.0721 28.7038C18.6445 27.8484 17.7706 26.304 17.7706 24.6364V24.5875C17.7642 22.9208 18.6441 21.37 20.0777 20.5085L20.0777 20.5087Z" fill="black"/>
747 + </svg>';
748 + print '</div>';
749 + print '</div>';
750 +
751 + $this->wpstream_display_modal_seetings($the_id);
752 + $this->wpstream_display_modal_share($the_id);
753 + $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
754 +
755 + print '</div>';
756 +
757 + }
758 +
759 +
760 +
761 +
762 + /**
763 + * Shows event unit card in admin - theme version
764 + *
765 + * @since 3.0.1
766 + */
767 + public function wpstream_live_stream_unit_for_theme($the_id,$is_front=''){
768 + global $live_event_for_user;
769 + global $wpstream_plugin;
770 + $current_user = wp_get_current_user();
771 +
772 + if( !current_user_can('administrator')){
773 + if($is_front=='' ){
774 + print '<div class="event_list_unit">';
775 + esc_html_e('You are not allowed to broadcast.','wpstream');
776 + print '</div>';
777 + return;
778 + }
779 +
780 + }
781 +
782 + if( !$this->main->wpstream_check_user_can_stream() ){
783 + print '<div class="event_list_unit">';
784 + esc_html_e('You are not allowed to broadcast','wpstream');
785 + print '</div>';
786 + return;
787 + }
788 +
789 +
790 + $live_class='';
791 + if(isset($live_event_for_user[$the_id])) {
792 + $live_class=" wpstream_show_started";
793 + }
794 +
795 +
796 + if(has_post_thumbnail($the_id)){
797 + $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
798 + }else{
799 + $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
800 + }
801 +
802 + $pending_streaming_class = 'hide_stream_data';
803 + $external_software_streaming_class = '';
804 + $obs_uri = '';
805 + $obs_stream = '';
806 + $live_data_url = '';
807 +
808 + if( $live_event_for_user=='' && $is_front=='front' ){
809 + $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
810 + }
811 +
812 + $spinner_url = admin_url('images/spinner-2x.gif');
813 + $button_status = '<div class="spinner" style="background-image: url(' . $spinner_url . ')"></div>';
814 + $channel_status = '';
815 + if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
816 + $pending_streaming_class = 'pending_trigger';
817 + $live_data_url = get_post_meta($the_id,'qos_url',true);
818 + // $channel_status = esc_html__('Channel is on','wpstream');
819 + } else {
820 + $channel_status = esc_html__('Channel is OFF','wpstream');
821 + $button_status = esc_html__('TURN ON', 'wpstream');
822 + }
823 +
824 + $server_id = get_post_meta($the_id,'server_id',true);
825 + $obs_uri = get_post_meta($the_id,'obs_uri',true);
826 + $obs_stream = get_post_meta($the_id,'obs_stream',true);
827 + $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
828 + $rtmp_ip_uri = '';
829 +
830 + print '<div class="wpstream_theme_event_list_unit 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.'"">';
831 +
832 + print '<div class="wpstream_channel_status" style="' . ($channel_status ? '' : 'display: none') . '">'.$channel_status.'</div>';
833 +
834 + print '<div class="server_notification"></div>';
835 +
836 + print '<div class="wpstream_theme_event_thumb_wrapper">';
837 + print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
838 + print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10);
839 + print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
840 + print '</div>';
841 + print '</div>';
842 +
843 + print '<div class="wpstream_theme_control_bar_wrapper">';
844 +
845 +
846 + print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
847 +
848 + print '<div class="wpstream_inactive_icon start_webcaster wpstream_stream_browser wpstream-button-icon wpstream_tooltip_wrapper" data-webcaster-url="'.$webcaster_url.'" data-show-id="'.$the_id.'"">';
849 +
850 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
851 + print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
852 +
853 + print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
854 + <path d="M40.7646 44.2989C39.8782 41.4216 38.3361 38.7814 36.181 36.4522C35.7274 35.9619 35.1629 35.3518 34.4858 34.8356C34.0448 34.4996 33.4262 34.5281 33.0182 34.9035C29.358 38.2714 25.2628 39.9088 20.4979 39.9088H20.4853C15.7103 39.9059 11.6117 38.264 7.95648 34.889C7.52404 34.4896 6.85874 34.484 6.41953 34.8764C3.30565 37.6569 1.20501 40.9206 0.175434 44.5778C-0.276291 46.1833 0.15652 47.8497 1.33328 49.0353C2.22709 49.9362 3.39869 50.4173 4.61958 50.4173C5.0357 50.4173 5.45813 50.3613 5.87645 50.247C10.147 49.081 14.0772 48.4108 17.8916 48.1983C21.1954 48.014 24.4465 48.1323 27.5541 48.5495C29.9559 48.8718 32.4237 49.3888 35.0996 50.1299C36.823 50.6076 38.459 50.1562 39.7059 48.86C40.9268 47.5901 41.2933 46.0132 40.7651 44.2994L40.7646 44.2989ZM38.0572 47.274C37.3825 47.9754 36.6367 48.1823 35.7092 47.9257C32.9321 47.1565 30.3638 46.6187 27.8578 46.2827C24.6079 45.8465 21.2117 45.723 17.7643 45.9151C13.7874 46.1365 9.70183 46.8319 5.27439 48.041C4.43435 48.2706 3.5673 48.0403 2.9568 47.425C2.35932 46.8227 2.14793 46.0108 2.37712 45.1975C3.21567 42.2171 4.7982 39.6162 7.2018 37.2734C11.0641 40.5378 15.5276 42.193 20.4845 42.196H20.4978C25.4557 42.196 29.9251 40.5386 33.7967 37.2667C34.024 37.4904 34.254 37.7359 34.5032 38.0059C36.4236 40.0816 37.7951 42.4256 38.5799 44.9728C38.8603 45.8811 38.6941 46.6125 38.0581 47.274L38.0572 47.274ZM20.4954 30.7538C13.8088 30.7523 8.54664 25.4128 8.54379 18.6256C8.5412 12.2624 13.9961 6.83353 20.3776 6.84872C27.1094 6.86467 32.4526 12.1652 32.4488 18.8231C32.4447 25.4243 27.1038 30.7547 20.4954 30.7538V30.7538ZM29.4401 18.8383C29.5559 13.9512 25.4358 9.8445 20.5347 9.83671C15.5301 9.82892 11.6488 13.9279 11.5328 18.5667C11.4086 23.5202 15.344 27.7103 20.3381 27.7926C25.5542 27.8783 29.554 23.5758 29.4401 18.8383V18.8383ZM20.4917 25.1342C17.2131 25.2436 14.1541 22.4349 14.1567 18.8924C14.1593 15.2627 16.9642 12.4191 20.5858 12.4662C24.0109 12.5111 26.8269 15.2466 26.8362 18.8471C26.8451 22.4293 23.782 25.2436 20.4917 25.1342V25.1342ZM18.5119 13.9982C17.3006 13.9908 15.6202 15.656 15.6295 16.8543C15.6328 17.3209 15.961 17.661 16.3983 17.6513C17.5973 17.6246 19.2281 16.0169 19.2696 14.8205C19.2881 14.2742 19.0371 14.0016 18.5119 13.9982L18.5119 13.9982ZM20.4964 0.568359C10.4428 0.568359 2.26333 8.74761 2.26333 18.8014C2.26333 28.8551 10.4426 37.0345 20.4964 37.0345C30.5502 37.0345 38.7295 28.8553 38.7295 18.8014C38.7291 8.7478 30.5502 0.568359 20.4964 0.568359V0.568359ZM20.4964 33.3886C12.4528 33.3886 5.90919 26.8449 5.90919 18.8014C5.90919 11.3105 11.585 5.12093 18.8624 4.30631C18.8561 4.36009 18.8528 4.41423 18.8528 4.46912C18.8468 5.37368 19.6112 6.16064 20.4927 6.15846C21.3636 6.15586 22.1283 5.39706 22.142 4.52143C22.1431 4.44874 22.1372 4.3768 22.1279 4.30596C29.4067 5.11929 35.0849 11.3092 35.0849 18.802C35.0842 26.8456 28.5404 33.3892 20.4968 33.3892L20.4964 33.3886Z" fill="black"/>
855 + </svg>';
856 + esc_html_e('Webcam','wpstream');
857 + print '</div>';
858 +
859 +
860 + print '<div class="wpstream_inactive_icon wpstream_stream_pro wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_broadcast_modal" data-show-id="'.$the_id.'"">';
861 +
862 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
863 + print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
864 +
865 + print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
866 + <path d="M48.1266 13.9634L41.891 17.5343V13.6438C41.891 10.8723 39.6525 8.63384 36.8811 8.63384H33.1504L30.1124 3.62393C28.7268 1.3324 26.2751 0 23.6103 0H10.2863C8.84722 0 7.67471 1.17251 7.67471 2.6116C7.67471 4.05068 8.84722 5.22319 10.2863 5.22319H23.6103C24.4631 5.22319 25.2093 5.64961 25.6888 6.3957L27.0744 8.63413L5.00991 8.63376C2.23843 8.63376 0 10.8722 0 13.6437V32.9901C0 35.7616 2.23843 38 5.00991 38H36.9342C39.7057 38 41.9441 35.7616 41.9441 32.9901V29.0461L48.1797 32.6169C49.2991 33.2564 50.6846 32.4571 50.6846 31.1778L50.6842 15.4022C50.6311 14.123 49.2455 13.3237 48.1261 13.9632L48.1266 13.9634ZM38.1603 32.9368C38.1603 33.6297 37.574 34.1625 36.9345 34.1625L5.01029 34.1629C4.31733 34.1629 3.78458 33.5766 3.78458 32.9372V13.5907C3.78458 12.8978 4.37086 12.365 5.01029 12.365H36.9345C37.6275 12.365 38.1603 12.9513 38.1603 13.5907V32.9368Z" fill="black"/>
867 + <path d="M22.4917 21.585H9.70066C8.84784 21.585 8.15527 22.2779 8.15527 23.1304V28.247C8.15527 29.0998 8.84823 29.7923 9.70066 29.7923H22.4917C23.3445 29.7923 24.0371 29.0994 24.0371 28.247V23.1304C24.0371 22.2775 23.3445 21.585 22.4917 21.585Z" fill="black"/>
868 + </svg>';
869 + esc_html_e('External App','wpstream');
870 + print '</div>';
871 +
872 +
873 +
874 +
875 + print '<a href="'.esc_url($live_data_url).'" target="_blank" class="wpstream_inactive_icon wpstream_live_data wpstream_statistics_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" >';
876 +
877 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
878 + print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
879 +
880 + print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
881 + <path fill-rule="evenodd" clip-rule="evenodd" d="M48.9001 9.02344H40.3342C39.7288 9.02344 39.2344 9.51791 39.2344 10.1233V40.4275C39.2344 41.033 39.7288 41.5274 40.3342 41.5274H48.9001C49.5055 41.5274 50 41.0329 50 40.4275V10.1233C50 9.51791 49.5055 9.02344 48.9001 9.02344V9.02344Z" fill="black"/>
882 + <path fill-rule="evenodd" clip-rule="evenodd" d="M35.821 22.4067H27.2551C26.6497 22.4067 26.1553 22.9012 26.1553 23.5066V40.4277C26.1553 41.0332 26.6497 41.5276 27.2551 41.5276H35.821C36.4264 41.5276 36.9209 41.0332 36.9209 40.4277V23.5066C36.9209 22.9012 36.4264 22.4067 35.821 22.4067V22.4067Z" fill="black"/>
883 + <path fill-rule="evenodd" clip-rule="evenodd" d="M22.7439 0H14.178C13.5726 0 13.0781 0.494478 13.0781 1.09989V40.4275C13.0781 41.0329 13.5726 41.5274 14.178 41.5274H22.7439C23.3493 41.5274 23.8438 41.0329 23.8438 40.4275V1.09989C23.8438 0.49447 23.3493 0 22.7439 0V0Z" fill="black"/>
884 + <path fill-rule="evenodd" clip-rule="evenodd" d="M9.66573 15.2559H1.09987C0.49445 15.2559 -2.24584e-05 15.7512 -2.24584e-05 16.3558V40.4285C-2.24584e-05 41.0331 0.495325 41.5284 1.09987 41.5284H9.66573C10.2703 41.5284 10.7656 41.034 10.7656 40.4285V16.3558C10.7656 15.7503 10.2711 15.2559 9.66573 15.2559V15.2559Z" fill="black"/>
885 + </svg>';
886 + esc_html_e('Statistics','wpstream');
887 + print '</a>';
888 + print '</div>';
889 +
890 + print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
891 + if($is_front==''){
892 + print '<div class="wpstream_show_settings wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_settings_modal" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">';
893 +
598 894 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
599 895 print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
600 896
601 897 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -617,8 +913,9 @@
617 913 print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
618 914 <path d="M18.6201 15.2828H21.8752C21.8752 14.069 22.8681 13.0207 24.1373 13.0207V9.76562C21.1032 9.76562 18.6201 12.2487 18.6201 15.2828Z" fill="black"/>
619 915 <path d="M24.855 0C12.9378 0 3.28272 10.9792 0.579292 14.3447C-0.193097 15.2826 -0.193097 16.662 0.579292 17.6553C3.28282 21.0208 12.9378 32 24.855 32C36.7722 32 46.4273 21.0208 49.1307 17.6553C49.9031 16.7174 49.9031 15.338 49.1307 14.3447C46.4275 10.9792 36.7722 0 24.855 0V0ZM24.855 25.8205C19.4482 25.8205 15.0344 21.4067 15.0344 15.9999C15.0344 10.5931 19.4482 6.17927 24.855 6.17927C30.2618 6.17927 34.6756 10.5931 34.6756 15.9999C34.6756 21.4067 30.2618 25.8205 24.855 25.8205Z" fill="black"/>
620 916 </svg>';
917 + esc_html_e('View','wpstream');
621 918 print '</a>';
622 919
623 920
624 921 print '<div class="wpstream_share_channel wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_share_modal" data-show-id="'.$the_id.'"">';
@@ -625,12 +922,18 @@
625 922 print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
626 923 print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
627 924 <path d="M20.0777 20.5087L24.3481 17.9427C26.6432 16.5645 29.4554 16.2443 31.96 17.198C33.443 17.7642 35.1166 17.9363 36.852 17.6105C40.3163 16.9521 43.1162 14.1831 43.8115 10.7248C45.0606 4.51597 39.7751 -0.910703 33.5907 0.12835C30.2924 0.682061 27.5604 3.16211 26.5942 6.36168C26.4405 6.86646 26.3418 7.35835 26.2804 7.84466C25.9482 10.5028 24.2498 12.8044 21.9547 14.1827L19.3458 15.7456C17.1061 17.0869 14.3986 17.1792 11.9494 16.2748C10.9956 15.9241 9.96159 15.7271 8.88507 15.7271C3.39004 15.7271 -0.960663 20.7607 0.184097 26.4527C0.879447 29.911 3.67936 32.68 7.14364 33.3384C8.87902 33.6706 10.5525 33.492 12.0356 32.9259C14.5402 31.9721 17.3461 32.2919 19.6475 33.6706L23.906 36.2241C25.346 37.0855 26.2195 38.6424 26.2195 40.3159V40.3403C26.2195 45.8229 31.2287 50.1611 36.9018 49.0472C40.3602 48.3703 43.1415 45.583 43.8244 42.1246C44.9383 36.451 40.6 31.4423 35.1175 31.4423C34.0406 31.4423 33.007 31.6394 32.0532 31.9901C29.604 32.8944 26.9029 32.8022 24.6627 31.4608L20.0721 28.7038C18.6445 27.8484 17.7706 26.304 17.7706 24.6364V24.5875C17.7642 22.9208 18.6441 21.37 20.0777 20.5085L20.0777 20.5087Z" fill="black"/>
628 925 </svg>';
926 + esc_html_e('Share','wpstream');
629 927 print '</div>';
630 928 print '</div>';
631 929
632 -
930 +
931 + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '. $button_status;
932 + print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
933 + print '</div>';
934 +
935 + print '</div>';
633 936
634 937
635 938
636 939
@@ -642,9 +945,8 @@
642 945
643 946 }
644 947
645 948
646 -
647 949 /*
648 950 *
649 951 * Close modal button
650 952 *
@@ -653,30 +955,78 @@
653 955 public function wpstream_close_modal_button(){
654 956 print '<div class="wpstream_close_modal"></div>';
655 957 }
656 958
959 + public function wpstream_local_event_options_toggle( $is_basic_stream_mode = false ) {
960 + $use_global_event_options = get_post_meta(get_the_ID(), 'use_global_event_options', true );
961 + $local_event_options = get_post_meta( get_the_ID(), 'local_event_options', true );
962 + $use_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
963 + ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
964 +
965 + if ( $is_basic_stream_mode ) {
966 + $this->wpstream_basic_stream_mode_message();
967 + }
968 +
969 + print '<div class="wpstream_local_event_options_toggle_wrapper">';
970 + print '<div class="wpstream_local_event_options_toggle_info">';
971 + print '<label for="local_event_options_enabled" class="wpstream_local_event_options_label">'.esc_html__('Edit settings for this channel','wpstream').'</label>';
972 + 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>';
973 + print '</div>';
974 + print '<label class="wpstream_switch">';
975 + 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' : '' ) . '>';
976 + print '<span class="wpstream_slider round"></span>';
977 + print '</label>';
978 + print '</div>';
979 + }
980 +
981 + public function wpstream_basic_stream_mode_message() {
982 + print '<div class="basic-mode-notice">';
983 + print sprintf(
984 + wp_kses(
985 + __(
986 + '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.',
987 + 'wpstream'
988 + ),
989 + array( 'a' => array( 'href' => array() ) )
990 + ),
991 + esc_url( 'https://wpstream.net/pricing/' )
992 + );
993 + print '</div>';
994 + }
995 +
657 996 /*
658 997 *
659 998 * Display modal settings
660 999 *
661 1000 */
662 -
1001 +
663 1002 public function wpstream_display_modal_seetings($the_id){
664 - print '<div class="wpstream_modal_form wpestate_settings_modal">';
665 - $this->wpstream_close_modal_button();
666 - print '<h3>';
1003 + $is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
1004 +
1005 + print '<div class="wpstream_modal_form wpestate_settings_modal">';
1006 + $this->wpstream_close_modal_button();
1007 + print '<h3>';
667 1008 printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id);
668 - print '</h3>';
669 - $local_event_options = get_post_meta($the_id,'local_event_options',true);
670 - if(!is_array($local_event_options)){
671 - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
672 - }
1009 + print '</h3>';
673 1010
1011 + $this->wpstream_local_event_options_toggle( $is_basic_stream_mode );
1012 +
1013 + $local_event_options = get_post_meta($the_id,'local_event_options',true);
1014 + $use_global_event_options = get_post_meta($the_id, 'use_global_event_options',true);
1015 + $is_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
1016 + ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
1017 +
674 1018 $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt');
675 -
1019 +
676 1020 print '<div class="wpstream_event_streaming_local">';
677 - $this->user_streaming_global_channel_options('',$local_event_options, $local_array_exclude);
678 - print '</div>';
1021 + $this->user_streaming_global_channel_options(
1022 + '',
1023 + $local_event_options,
1024 + $local_array_exclude,
1025 + !$is_local_event_options_enabled,
1026 + $is_basic_stream_mode
1027 + );
1028 + print '</div>';
679 1029 print '</div>';
680 1030 }
681 1031
682 1032
@@ -700,9 +1050,9 @@
700 1050 *
701 1051 */
702 1052
703 1053 public function wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream){
704 - print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
1054 + print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
705 1055 $this->wpstream_close_modal_button();
706 1056 print '<h3>'.esc_html__('Go Live with External Streaming App','wpstream').'</h3>';
707 1057
708 1058 print '<div class="wpstream_modal_explanations">'.esc_html__('Please choose your RTMP encoder/broadcaster','wpstream').'</div>';
@@ -758,9 +1108,9 @@
758 1108 <li>1. Click Settings in the OBS Window and then Select Stream.</li>
759 1109 <li>2. Choose Custom Streaming Server in the Stream Type dropdown menu.</li>
760 1110 <li>3. In the URL box, type/paste your Server.</li>
761 1111 <li>4. In the Stream key, type/paste your Stream key.</li>
762 - <li>5. Save changes.Close the Settings window and click on the “Start Streaming” button in the main window of OBS.</li></ul>';
1112 + <li>5. Save changes.Close the Settings window and click on the "Start Streaming" button in the main window of OBS.</li></ul>';
763 1113
764 1114 print '</div>';
765 1115
766 1116
@@ -866,9 +1216,9 @@
866 1216 <li>1. Click Broadcast in the XSplit Window and then click "Set up a new output".</li>
867 1217 <li>2. Choose Custom RTMP in the Set up a new output dropdown menu.</li>
868 1218 <li>3. In the URL box, type/paste your RTMP Url.</li>
869 1219 <li>4. In the Stream key, type/paste your Stream key.</li>
870 - <li>5. Save changes and click on the “Stream” button in the main window.</li></ul>';
1220 + <li>5. Save changes and click on the "Stream" button in the main window.</li></ul>';
871 1221 print '</div>';
872 1222
873 1223 print '</div>';
874 1224 }
@@ -992,27 +1342,36 @@
992 1342
993 1343
994 1344
995 1345 /*
996 - * Set Settings
997 - *
998 - *
999 - */
1346 + * Set Settings
1347 + *
1348 + *
1349 + */
1000 1350
1001 1351 public function wpstream_settings(){
1352 +
1353 + if( !current_user_can('administrator') ){
1354 + die('Only for administrators');
1355 + }
1356 +
1002 1357
1003 - if($_SERVER['REQUEST_METHOD'] === 'POST'){
1358 + if($_SERVER['REQUEST_METHOD'] === 'POST'){
1359 + if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){
1360 + die('Security check');
1361 + }
1362 +
1004 1363 $allowed_html = array();
1005 1364 $exclude_array = array();
1006 1365 $allowed_html = array();
1007 1366
1008 -
1009 -
1367 +
1368 +
1010 1369 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
1011 1370 update_option( sanitize_key('wpstream_stream_role'), '' );
1012 1371 }
1013 -
1014 - foreach($_POST as $variable=>$value){
1372 +
1373 + foreach($_POST as $variable=>$value){
1015 1374 if ($variable!='submit'){
1016 1375 if (!in_array($variable, $exclude_array) ){
1017 1376 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
1018 1377 }
@@ -1020,9 +1379,9 @@
1020 1379 if($variable=='stream_role'){
1021 1380 update_option( sanitize_key('wpstream_stream_role'), $value );
1022 1381 }
1023 1382
1024 - }
1383 + }
1025 1384 }
1026 1385
1027 1386
1028 1387 if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){
@@ -1037,15 +1396,15 @@
1037 1396 }
1038 1397 update_option('wpstream_user_streaming_global_channel_options',$event_settings);
1039 1398 }
1040 1399
1041 -
1042 -
1043 -
1400 +
1401 +
1402 +
1044 1403 // reset permalinkgs
1045 - global $wp_rewrite;
1046 -
1047 - update_option( "rewrite_rules", FALSE );
1404 + global $wp_rewrite;
1405 +
1406 + update_option( "rewrite_rules", FALSE );
1048 1407 $wp_rewrite->flush_rules( true );
1049 1408
1050 1409 }
1051 1410
@@ -1056,8 +1415,16 @@
1056 1415 'name' => 'free_media_slug',
1057 1416 'type' => 'text',
1058 1417 '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'),
1059 1418 ),
1419 +
1420 + 'free_vod_slug' => array(
1421 + 'tab' => 'general_options',
1422 + 'label' => esc_html__('Slug for free VOD pages ','wpstream'),
1423 + 'name' => 'free_media_slug_vod',
1424 + 'type' => 'text',
1425 + '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'),
1426 + ),
1060 1427
1061 1428 2 => array(
1062 1429 'tab' => 'general_options',
1063 1430 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'),
@@ -1137,14 +1504,72 @@
1137 1504 ),
1138 1505
1139 1506 12 => array(
1140 1507 'tab' => 'messages_options',
1141 - 'label' => esc_html__('Thank you message','wpstream'),
1508 + 'label' => esc_html__('Subscription Active message','wpstream'),
1142 1509 'name' => 'subscription_active',
1143 1510 'type' => 'text',
1144 1511 'details' => esc_html__('This message will be displayed on subscription product page.','wpstream'),
1145 1512 'default' => esc_html__('Your Subscription is Active','wpstream'),
1146 1513 ),
1514 + 13 => array(
1515 + 'tab' => 'messages_options',
1516 + 'label' => esc_html__('You are not live message','wpstream'),
1517 + 'name' => 'you_are_not_live',
1518 + 'type' => 'text',
1519 + 'details' => esc_html__('This message will be displayed in player.','wpstream'),
1520 + 'default' => esc_html__('We are not live at this moment','wpstream'),
1521 + ),
1522 +
1523 + 14 => array(
1524 + 'tab' => 'general_options',
1525 + 'label' => esc_html__('Video player theme','wpstream'),
1526 + 'name' => 'video_player_theme',
1527 + 'type' => 'select',
1528 + 'select_values'=>array(
1529 + 'default' => esc_html__('Default','wpstream'),
1530 + 'city' => esc_html__('City','wpstream'),
1531 + 'forest' => esc_html__('Forest','wpstream'),
1532 + 'fantasy' => esc_html__('Fantasy','wpstream'),
1533 + 'sea' => esc_html__('Sea','wpstream'),
1534 + ),
1535 + 'details' => esc_html__('Choose the video player theme to have a different look for the player.','wpstream'),
1536 + ),
1537 + 'wpstream_player_logo' => array(
1538 + 'tab' => 'general_options',
1539 + 'name' => 'player_logo',
1540 + 'label' => esc_html__('Logo for the video player','wpstream'),
1541 + 'type' => 'image',
1542 + 'details' => esc_html__('This logo will be displayed on the the video player.','wpstream'),
1543 + 'default' => '',
1544 + 'image_size' => 'thumbnail',
1545 + ),
1546 + // hide the video player logo opacity for now
1547 +// 'wpstream_player_logo_opacity' => array(
1548 +// 'tab' => 'general_options',
1549 +// 'name' => 'player_logo_opacity',
1550 +// 'label' => esc_html__('Opacity of the video player logo','wpstream'),
1551 +// 'type' => 'range',
1552 +// 'details' => esc_html__('Set the opacity of the logo','wpstream'),
1553 +// 'default' => '',
1554 +// 'image_size' => 'thumbnail',
1555 +// ),
1556 + 'wpsteram_player_logo_position' => array(
1557 + 'tab' => 'general_options',
1558 + 'name' => 'player_logo_position',
1559 + 'label' => esc_html__('Position of the video player logo','wpstream'),
1560 + 'type' => 'select',
1561 + 'select_values'=>array(
1562 + 'top-left' => esc_html__('Top Left','wpstream'),
1563 + 'top-right' => esc_html__('Top Right','wpstream'),
1564 + 'bottom-left' => esc_html__('Bottom Left','wpstream'),
1565 + 'bottom-right' => esc_html__('Bottom Right','wpstream'),
1566 + ),
1567 + 'details' => esc_html__('Choose the position of the logo on the video player.','wpstream'),
1568 + 'default' => '',
1569 + ),
1570 +
1571 +
1147 1572
1148 1573 99 => array(
1149 1574 'tab' => 'default_options',
1150 1575 'label' => esc_html__('Events Options ','wpstream'),
@@ -1151,8 +1576,61 @@
1151 1576 'name' => 'user_streaming_global_channel_options',
1152 1577 'type' => 'user_streaming_global_channel_options',
1153 1578 'details' => esc_html__('Global Options for live events.','wpstream'),
1154 1579 ),
1580 +
1581 + 100 => array(
1582 + 'tab' => 'default_options_vod',
1583 + 'label' => esc_html__('Autoplay','wpstream'),
1584 + 'name' => 'vod_autoplay',
1585 + 'type' => 'slidertoogle',
1586 + 'details' => esc_html__('If enabled, video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
1587 + ),
1588 +
1589 +
1590 + 101 => array(
1591 + 'tab' => 'default_options_vod',
1592 + 'label' => esc_html__('Start Muted','wpstream'),
1593 + 'name' => 'vod_start_muted',
1594 + 'type' => 'slidertoogle',
1595 + 'details' => esc_html__('If enabled, video will start muted. This may increase the rate of autoplay in some browsers.','wpstream'),
1596 + ),
1597 +
1598 + 102 => array(
1599 + 'tab' => 'default_options_vod',
1600 + 'label' => esc_html__('Lock To Website','wpstream'),
1601 + 'name' => 'vod_domain_lock',
1602 + 'type' => 'slidertoogle',
1603 + 'details' =>sprintf ( esc_html__('If enabled, video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
1604 + ),
1605 +
1606 + 103 => array(
1607 + 'tab' => 'default_options_vod',
1608 + 'label' => esc_html__('Encrypt Video','wpstream'),
1609 + 'name' => 'vod_encrypt',
1610 + 'type' => 'slidertoogle',
1611 + 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'),
1612 + ),
1613 +
1614 + /* 'vod_domain_lock' =>array(
1615 + 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'),
1616 + 'details' => sprintf ( esc_html__('If enabled, VODS will only display on %1$s, otherwise they can show up on any website.','wpstream'),get_bloginfo('wpurl') ),
1617 + 'defaults' => 'no',
1618 + ),
1619 + 'vod_encrypt' =>array(
1620 + 'name' => esc_html__('Encrypt Video on Demand','wpstream'),
1621 + 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'),
1622 + 'defaults' => 'no',
1623 + ),*/
1624 +
1625 + 104 => array(
1626 + 'tab' => 'support_tab',
1627 + 'label' => esc_html__('Logs','wpstream'),
1628 + 'name' => 'logs',
1629 + 'type' => 'logs_table',
1630 + 'details' => esc_html__('This is the error log of the plugin.','wpstream'),
1631 + )
1632 +
1155 1633 );
1156 1634
1157 1635 $active_tab = 'general_options';
1158 1636 if( isset( $_GET[ 'tab' ] ) ) {
@@ -1164,39 +1642,73 @@
1164 1642 <h1>'.__('WpStream Settings','wpstream').'</h1>
1165 1643 <form method="post" action="" >';
1166 1644
1167 1645 print '<h2 class="nav-tab-wrapper">
1168 - <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">General Options</a>
1169 - <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">Default Channel Settings</a>
1170 - <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : ''; echo '">Subscription Options</a>
1171 - <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">Customize Messages</a>
1172 -
1646 + <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('General Options','wpstream').'</a>
1647 + <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Default Channel Settings','wpstream').'</a>
1648 + <a href="?page=wpstream_settings&tab=default_options_vod" class="nav-tab '; echo $active_tab == 'default_options_vod' ? 'nav-tab-active' : ''; echo '">'.esc_html__('VOD Settings','wpstream').'</a>
1649 + <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : '';echo '">'.esc_html__('Subscription Options','wpstream').'</a>
1650 + <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>
1651 + <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>
1173 1652 </h2>';
1174 -
1653 + $help_link='';
1654 +
1655 + $is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
1175 1656 print '<div class="wpstream_option_wrapper">';
1176 - foreach ($wpstream_settings_array as $key=>$option){
1657 +
1658 + switch ($active_tab) {
1659 + case 'general_options':
1660 + $help_link='https://docs.wpstream.net/docs/general-settings/';
1661 + break;
1662 + case 'default_options':
1663 + $help_link='https://docs.wpstream.net/docs/default-channel-settings/';
1664 + break;
1665 + case 'default_options_vod':
1666 + $help_link='https://docs.wpstream.net/docs/vod-settings/';
1667 + break;
1668 + case 'subscription_options':
1669 + $help_link='https://docs.wpstream.net/docs/subscription-options/';
1670 + break;
1671 + case 'messages_options':
1672 + $help_link='https://docs.wpstream.net/docs/customize-messages/';
1673 + break;
1674 + }
1675 +
1676 + print '<div class="options_wrapper">';
1677 + foreach ($wpstream_settings_array as $key=>$option){
1177 1678 if($option['tab']!=$active_tab){
1178 1679 continue;
1179 1680 }
1180 -
1681 +
1682 + if ( $option['type']=='user_streaming_global_channel_options' ) {
1683 + print '<div class="default-channel-settings-info">';
1684 + print esc_html__( 'These settings will apply to newly created channels; existing channels will not change settings if you change them here', 'wpstream');
1685 + if ( $is_basic_stream_mode ) {
1686 + $this->wpstream_basic_stream_mode_message();
1687 + }
1688 + print '</div>';
1689 +
1690 + }
1181 1691 print '<div class="wpstream_option">';
1182 1692 $options_value = get_option('wpstream_'.$option['name']) ;
1183 1693
1184 1694
1185 - if($option['type']=='user_roles'){
1186 -
1695 + switch( $option['type'] ) {
1696 + case 'user_roles':
1187 1697 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1188 1698 print $this->wpstream_select_user_roles($option['name'],$options_value);
1189 1699 print '<div class="settings_details">'.$option['details'].'</div>';
1190 -
1191 - }else if($option['type']=='user_streaming_global_channel_options'){
1192 -
1700 + break;
1701 + case 'user_streaming_global_channel_options':
1193 1702 $exclude_array=array();
1194 - $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array);
1195 -
1196 -
1197 - }else if($option['type']=='text'){
1198 -
1703 + $this->user_streaming_global_channel_options(
1704 + $option['name'],
1705 + $options_value,
1706 + $exclude_array,
1707 + $is_basic_stream_mode
1708 + );
1709 + break;
1710 + case 'text':
1199 1711 if($options_value==''){
1200 1712 $options_value='';
1201 1713 if(isset($option['default'])){
1202 1714 $options_value=$option['default'];
@@ -1201,15 +1713,14 @@
1201 1713 if(isset($option['default'])){
1202 1714 $options_value=$option['default'];
1203 1715 }
1204 1716 }
1205 -
1717 +
1206 1718 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1207 - print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1719 + print '<input class="wpstream-text-input-setting" id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1208 1720 print '<div class="settings_details">'.$option['details'].'</div>';
1209 -
1210 - } else if($option['type']=='select'){
1211 -
1721 + break;
1722 + case 'select':
1212 1723 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1213 1724 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
1214 1725 foreach($option['select_values'] as $key=>$value){
1215 1726 print '<option value="'.$key.'" ';
@@ -1220,40 +1731,380 @@
1220 1731 }
1221 1732 print '</select>';
1222 1733 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
1223 1734 print '<div class="settings_details">'.$option['details'].'</div>';
1224 -
1225 - } else if($option['type']=='slidertoogle'){
1735 + break;
1736 + case 'slidertoogle':
1226 1737 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1738 + print '<div style="display: flex; gap: 25px; justify-content: space-between;">';
1739 + print '<div class="settings_details">'.$option['details'].'</div>';
1227 1740 print '<label class="wpstream_switch">
1228 1741 <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" >
1229 1742 <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" ';
1230 -
1231 - if( intval($options_value) !==0 ){
1232 - print ' checked ';
1233 - }
1234 -
1743 + if( intval($options_value) !==0 ){
1744 + print ' checked ';
1745 + }
1746 + print '> <span class="wpstream_slider round"></span>';
1747 + print '</label>';
1748 + print '</div>';
1749 + break;
1750 + case 'image':
1751 + $image_url = $options_value ? esc_url($options_value) : '';
1752 + $has_image = !empty($image_url);
1235 1753
1754 + print '<label for="' . $option['name'] . '">' . $option['label'] . '</label>';
1755 + print '<div class="wpstream-image-upload-wrapper">';
1756 + print '<input type="hidden" id="' . $option['name'] . '" name="' . $option['name'] . '" value="' . $image_url . '" />';
1236 1757
1237 - print '> <span class="slider round"></span>';
1238 - print '</label>';
1239 - print '<div class="settings_details">'.$option['details'].'</div>';
1240 - }
1758 + // Preview area
1759 + print '<div class="wpstream-image-preview" style="' . (!$has_image ? 'display:none;' : '') . '">';
1760 + print '<img src="' . $image_url . '" alt="Preview" />';
1761 + print '</div>';
1762 +
1763 + // Upload/remove buttons
1764 + print '<div class="wpstream-image-upload-buttons">';
1765 + print '<button type="button" class="wpstream-upload-image button">' . esc_html__('Upload Image', 'wpstream') . '</button>';
1766 + print '<button type="button" class="wpstream-remove-image button" style="' . (!$has_image ? 'display:none;' : '') . '">' . esc_html__('Remove Image', 'wpstream') . '</button>';
1767 + print '</div>';
1768 +
1769 + print '</div>';
1770 + print '<div class="settings_details">' . $option['details'] . '</div>';
1771 + break;
1772 + case 'range':
1773 + print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1774 + print '<input class="wpstream-range-input" type="range" id="'.$option['name'].'" name="'.$option['name'].'" min="0" max="100" step="10" value="'.esc_attr($options_value).'" />';
1775 + print '<div class="settings_details">'.$option['details'].'</div>';
1776 + break;
1777 + case 'logs_table':
1778 + $this->wpstream_support_tab();
1779 + break;
1780 + }
1241 1781 print '</div>';
1242 1782 }
1783 + print '</div>'; // options wrapper
1784 + if($help_link!==''){
1785 + print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >'.esc_html__('Video Help','wpstream').'</a></div>';
1786 + }
1243 1787 print '</div>';
1244 1788
1245 1789
1790 + if ( $active_tab != 'support_tab') {
1791 + print '<div class="wpstream-save-settings">';
1246 1792 print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1793 + print '<div class="spinner"></div>';
1794 + print '</div>';
1795 + }
1247 1796
1248 -
1797 + print '<input id="wpstream-settings-nonce" name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> ';
1249 1798 print '</form>';
1250 1799 print '</div>';
1251 1800
1252 1801 }
1253 -
1254 -
1255 -
1802 +
1803 + /**
1804 + * Get system information for support tab
1805 + *
1806 + * @return array System information
1807 + */
1808 + private function get_system_info() {
1809 + global $wp_version;
1810 +
1811 + $php_version = phpversion();
1812 + $wp_version_info = $wp_version;
1813 + $site_debug_mode = (defined('WP_DEBUG') && WP_DEBUG);
1814 + $wp_memory_limit = WP_MEMORY_LIMIT;
1815 +
1816 + $wpstream_version = WPSTREAM_PLUGIN_VERSION;
1817 + $wpstream_plugin_outdated = false;
1818 +
1819 + // Check if plugin is outdated
1820 + $update_plugins = get_site_transient('update_plugins');
1821 + if (isset($update_plugins->response['plugin/wpstream.php'])) {
1822 + $wpstream_plugin_outdated = true;
1823 + }
1824 +
1825 + // Check API status
1826 + $api_status = false;
1827 + if (method_exists($this->main->wpstream_live_connection, 'wpstream_get_token')) {
1828 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
1829 + $api_status = !empty($token);
1830 + }
1831 +
1832 + return array(
1833 + 'php_version' => $php_version,
1834 + 'wp_version' => $wp_version_info,
1835 + 'site_debug_mode' => $site_debug_mode,
1836 + 'wp_memory_limit' => $wp_memory_limit,
1837 + 'wpstream_version' => $wpstream_version,
1838 + 'wpstream_plugin_outdated' => $wpstream_plugin_outdated,
1839 + 'api_status' => $api_status
1840 + );
1841 + }
1842 +
1843 + /**
1844 + * Render system information HTML
1845 + */
1846 + private function render_system_info() {
1847 + $system_info = $this->get_system_info();
1848 + ?>
1849 +
1850 + <div class="wpstream-system-info">
1851 + <h3><?php esc_html_e('System Information', 'wpstream'); ?></h3>
1852 + <table class="widefat">
1853 + <tbody>
1854 + <tr>
1855 + <td><strong><?php esc_html_e('PHP Version', 'wpstream'); ?></strong></td>
1856 + <td><?php echo esc_html($system_info['php_version']); ?></td>
1857 + <td>
1858 + <?php if (version_compare($system_info['php_version'], '7.4', '<')): ?>
1859 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1860 + <?php esc_html_e('We recommend PHP 7.4 or higher', 'wpstream'); ?>
1861 + <?php else: ?>
1862 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1863 + <?php endif; ?>
1864 + </td>
1865 + </tr>
1866 + <tr>
1867 + <td><strong><?php esc_html_e('WordPress Version', 'wpstream'); ?></strong></td>
1868 + <td><?php echo esc_html($system_info['wp_version']); ?></td>
1869 + <td>
1870 + <?php if (version_compare($system_info['wp_version'], '5.6', '<')): ?>
1871 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1872 + <?php esc_html_e('We recommend WordPress 5.6 or higher', 'wpstream'); ?>
1873 + <?php else: ?>
1874 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1875 + <?php endif; ?>
1876 + </td>
1877 + </tr>
1878 + <tr>
1879 + <td><strong><?php esc_html_e('WP Debug Mode', 'wpstream'); ?></strong></td>
1880 + <td><?php echo $system_info['site_debug_mode'] ? esc_html__('Enabled', 'wpstream') : esc_html__('Disabled', 'wpstream'); ?></td>
1881 + <td>
1882 + <?php if ($system_info['site_debug_mode']): ?>
1883 + <span class="dashicons dashicons-info" style="color: #00a0d2;"></span>
1884 + <?php esc_html_e('Debug mode should be disabled on production sites', 'wpstream'); ?>
1885 + <?php else: ?>
1886 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1887 + <?php endif; ?>
1888 + </td>
1889 + </tr>
1890 + <tr>
1891 + <td><strong><?php esc_html_e('WP Memory Limit', 'wpstream'); ?></strong></td>
1892 + <td><?php echo esc_html($system_info['wp_memory_limit']); ?></td>
1893 + <td>
1894 + <?php
1895 + $memory_limit = wp_convert_hr_to_bytes($system_info['wp_memory_limit']);
1896 + if ($memory_limit < 64 * 1024 * 1024): // 64MB
1897 + ?>
1898 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1899 + <?php esc_html_e('We recommend at least 64MB', 'wpstream'); ?>
1900 + <?php else: ?>
1901 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1902 + <?php endif; ?>
1903 + </td>
1904 + </tr>
1905 + <tr>
1906 + <td><strong><?php esc_html_e('WpStream Version', 'wpstream'); ?></strong></td>
1907 + <td><?php echo esc_html($system_info['wpstream_version']); ?></td>
1908 + <td style="display: flex; align-items: center; gap: 5px;">
1909 + <?php if ($system_info['wpstream_plugin_outdated']): ?>
1910 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1911 + <?php esc_html_e('Update available', 'wpstream'); ?>
1912 + <div class="update-button-wrapper">
1913 + <button class="wpstream-update-plugin-button button button-primary" data-plugin="wpstream/wpstream.php">
1914 + <?php esc_html_e('Update Now', 'wpstream'); ?>
1915 + </button>
1916 + </div>
1917 + <?php else: ?>
1918 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1919 + <?php endif; ?>
1920 + </td>
1921 + </tr>
1922 + <tr>
1923 + <td><strong><?php esc_html_e('API Connection', 'wpstream'); ?></strong></td>
1924 + <td><?php echo $system_info['api_status'] ? esc_html__('Connected', 'wpstream') : esc_html__('Disconnected', 'wpstream'); ?></td>
1925 + <td>
1926 + <?php if (!$system_info['api_status']): ?>
1927 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1928 + <?php esc_html_e('API connection issue', 'wpstream'); ?>
1929 + <?php else: ?>
1930 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1931 + <?php endif; ?>
1932 + </td>
1933 + </tr>
1934 + </tbody>
1935 + </table>
1936 + </div>
1937 + <?php
1938 + }
1939 +
1940 + /**
1941 + * Render support tab content
1942 + */
1943 + public function wpstream_support_tab() {
1944 + ?>
1945 + <div class="wrap">
1946 + <div class="wpstream-support-tab-root">
1947 + <?php $this->render_system_info(); ?>
1948 +
1949 + <div class="wpstream-plugins-table-container">
1950 + <h3><?php esc_html_e('Active Plugins', 'wpstream'); ?></h3>
1951 + <table class="widefat wpstream-plugins-table">
1952 + <thead>
1953 + <tr>
1954 + <th><?php esc_html_e('Plugin', 'wpstream'); ?></th>
1955 + <th><?php esc_html_e('Version', 'wpstream'); ?></th>
1956 + </tr>
1957 + </thead>
1958 + <tbody>
1959 + <?php
1960 + $plugins_data = $this->wpstream_get_plugins_data();
1961 + if (empty($plugins_data)) {
1962 + echo '<tr><td colspan="3">' . esc_html__('No WPStream plugins found.', 'wpstream') . '</td></tr>';
1963 + } else {
1964 + foreach ($plugins_data as $plugin) {
1965 + echo '<tr>';
1966 + echo '<td>' . esc_html($plugin['name']) . '</td>';
1967 + echo '<td>';
1968 + echo esc_html($plugin['version']);
1969 + if ( isset($plugin['new_version']) ) {
1970 + echo '<div class="wpstream-tooltip-container">';
1971 + echo '<span class="dashicons dashicons-info wpstream-tooltip" title="' . esc_attr($plugin['new_version']) . '">';
1972 + echo '</span>';
1973 + echo '<div class="wpstream-custom-tooltip">' . sprintf(
1974 + esc_html__('A new version is available: %s', 'wpstream'),
1975 + esc_html($plugin['new_version'])
1976 + ) . '</div>';
1977 + echo '</div>';
1978 + }
1979 + echo '</td>';
1980 + echo '</tr>';
1981 + }
1982 + }
1983 + ?>
1984 + </tbody>
1985 + </table>
1986 + </div>
1987 +
1988 + <div class="wpstream-logs-table-container">
1989 + <h3><?php esc_html_e('Recent Logs', 'wpstream'); ?></h3>
1990 + <table class="widefat wpstream-logs-table">
1991 + <thead>
1992 + <tr>
1993 + <th><?php esc_html_e('Time', 'wpstream'); ?></th>
1994 + <th><?php esc_html_e('Type', 'wpstream'); ?></th>
1995 + <th><?php esc_html_e('Description', 'wpstream'); ?></th>
1996 + </tr>
1997 + </thead>
1998 + <tbody>
1999 + <?php
2000 + $logs = get_option('wpstream_logs');
2001 + if ( !is_array($logs) || empty($logs) ) {
2002 + echo '<tr><td colspan="3">' . esc_html__('No logs found.', 'wpstream') . '</td></tr>';
2003 + } else {
2004 + foreach ($logs as $log) {
2005 + echo '<tr>';
2006 + echo '<td>' . esc_html(date('Y-m-d H:i:s', $log['timestamp'] ) ) . '</td>';
2007 + echo '<td>' . esc_html($log['type']) . '</td>';
2008 + echo '<td>' . esc_html($log['description']) . '</td>';
2009 + echo '</tr>';
2010 + }
2011 + }
2012 + ?>
2013 + </tbody>
2014 + </table>
2015 + </div>
2016 + </div>
2017 + </div>
2018 + <?php
2019 + }
2020 +
2021 + /**
2022 + * Get plugins data.
2023 + *
2024 + * @return array
2025 + */
2026 + public function wpstream_get_plugins_data() {
2027 + if (!function_exists('get_plugins')) {
2028 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
2029 + }
2030 +
2031 + // Get all installed plugins
2032 + $all_plugins = get_plugins();
2033 + $update_data = get_site_transient('update_plugins');
2034 + $all_plugins_info = [];
2035 +
2036 + // We want to get data only for the WpStream plugins
2037 + $wpstream_plugins = array(
2038 + 'WpStream' => array(
2039 + 'path' => 'wpstream/wpstream.php',
2040 + ),
2041 + 'WooCommerce' => array(
2042 + 'path' => 'woocommerce/woocommerce.php',
2043 + ),
2044 + 'Meta Box' => array(
2045 + 'path' => 'meta-box/meta-box.php',
2046 + ),
2047 + 'One Click Demo Import' => array(
2048 + 'path' => 'one-click-demo-import/one-click-demo-import.php',
2049 + ),
2050 + 'Better Messages' => array(
2051 + 'path' => 'bp-better-messages/bp-better-messages.php',
2052 + ),
2053 +
2054 + );
2055 +
2056 + foreach ($all_plugins as $plugin_path => $plugin_data) {
2057 + $is_active = is_plugin_active( $plugin_path );
2058 + $has_update = isset( $update_data->response[$plugin_path] );
2059 +
2060 + $plugin_info = [
2061 + 'name' => $plugin_data['Name'],
2062 + 'version' => $plugin_data['Version'],
2063 + 'path' => $plugin_path,
2064 + 'active' => $is_active ? 'Yes' : 'No',
2065 + 'needs_update' => $has_update ? 'Yes' : 'No'
2066 + ];
2067 +
2068 + if ($has_update) {
2069 + $plugin_info['new_version'] = $update_data->response[$plugin_path]->new_version;
2070 + }
2071 +
2072 + $all_plugins_info[] = $plugin_info;
2073 + }
2074 +
2075 + // Filter out the elements from $all_plugins_info that are not in $wpstream_plugins
2076 + foreach ( $all_plugins_info as $key => $plugin_info ) {
2077 + // compare $plugin_info['path'] against the path property on each $wpstream_plugins element item
2078 + // if the path is not in $wpstream_plugins, unset the element
2079 + if ( !in_array( $plugin_info['path'], array_column( $wpstream_plugins, 'path' ) ) ) {
2080 + unset( $all_plugins_info[$key] );
2081 + }
2082 + }
2083 +
2084 + return $all_plugins_info;
2085 + }
2086 +
2087 + public function wpstream_render_outdated_plugin_notice() {
2088 + $has_update = get_site_transient('update_plugins');
2089 + if (isset($has_update->response['plugin/wpstream.php'])) {
2090 + ?>
2091 + <div class="notice notice-warning is-dismissible">
2092 + <p>
2093 + <?php
2094 + printf(
2095 + /* translators: 1: Link to update page */
2096 + 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'),
2097 + '<a href="' . esc_url(admin_url('update-core.php')) . '">' . esc_html__('updates page', 'wpstream') . '</a>'
2098 + );
2099 + ?>
2100 + </p>
2101 + </div>
2102 + <?php
2103 + }
2104 + }
2105 +
2106 +
1256 2107 /**
1257 2108 * Set user roles
1258 2109 *
1259 2110 * @since 3.0.1
@@ -1258,17 +2109,25 @@
1258 2109 *
1259 2110 * @since 3.0.1
1260 2111 */
1261 2112
1262 - public function user_streaming_global_channel_options($name,$value,$local_array=''){
1263 -
2113 + public function user_streaming_global_channel_options(
2114 + $name,
2115 + $value,
2116 + $local_array='',
2117 + $disabled = false,
2118 + $is_basic_stream_mode = false
2119 + ) {
2120 +
1264 2121 foreach($this->global_event_options as $key=>$option){
1265 2122
1266 2123 if( is_array($local_array) && !in_array($key,$local_array)){
1267 - print '<div class="wpstream_setting_event_unit_wrapper">';
2124 + print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">';
1268 2125
1269 2126 print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
1270 2127
2128 + print '<div style="display: flex; gap: 25px; justify-content: space-between;">';
2129 + print '<div class="settings_details">'.$option['details'].'</div>';
1271 2130 print '
1272 2131 <label class="wpstream_switch">
1273 2132 <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
1274 2133 if( isset($value[$key]) ){
@@ -1279,13 +2138,16 @@
1279 2138 if($option['defaults']=='yes') {
1280 2139 print ' checked ';
1281 2140 }
1282 2141 }
2142 + if ( $disabled || $is_basic_stream_mode ) {
2143 + print ' disabled ';
2144 + }
1283 2145
1284 2146
1285 - print '> <span class="slider round"></span>';
2147 + print '> <span class="wpstream_slider round"></span>';
1286 2148 print '</label>';
1287 - print '<div class="settings_details">'.$option['details'].'</div>';
2149 + print '</div>';
1288 2150
1289 2151
1290 2152 print '</div>';
1291 2153 }
@@ -1337,19 +2199,26 @@
1337 2199 * @since 3.0.1
1338 2200 */
1339 2201 public function wpstream_set_wpstream_credentials(){
1340 2202
1341 - if($_SERVER['REQUEST_METHOD'] === 'POST'){
2203 + if($_SERVER['REQUEST_METHOD'] === 'POST'){
1342 2204 $allowed_html = array();
1343 2205 $exclude_array = array();
1344 2206 $allowed_html = array();
1345 2207
1346 - foreach($_POST as $variable=>$value){
2208 + foreach($_POST as $variable=>$value){
1347 2209 if ($variable!='submit'){
1348 2210 if (!in_array($variable, $exclude_array) ){
1349 - update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
1350 - }
1351 - }
2211 + switch ( $variable ) {
2212 + case 'api_username':
2213 + update_option( sanitize_key('wpstream_api_username'), sanitize_text_field($value) );
2214 + break;
2215 + case 'api_password':
2216 + update_option( sanitize_key('wpstream_api_password'), $value );
2217 + break;
2218 + }
2219 + }
2220 + }
1352 2221 }
1353 2222
1354 2223
1355 2224
@@ -1380,11 +2249,11 @@
1380 2249
1381 2250 );
1382 2251
1383 2252
1384 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
1385 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
1386 -
2253 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
2254 + $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_set_wpstream_credentials' );
2255 +
1387 2256 $this->main->show_user_data($pack_details);
1388 2257
1389 2258 print '<form method="post" action="" >';
1390 2259 print '<div class="theme_options_tab_wpstream" style="display:block;" >
@@ -1390,9 +2259,9 @@
1390 2259 print '<div class="theme_options_tab_wpstream" style="display:block;" >
1391 2260 <h1>'.__('WpStream Credentials','wpstream').'</h1>';
1392 2261
1393 2262
1394 - if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== ' '){
2263 + if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== '' ){
1395 2264 echo '<div class="api_not_conected wpstream_orange">';
1396 2265 $admin_url_onboard=get_admin_url().'admin.php?page=wpstream_onboard';
1397 2266 printf ( __('To connect your plugin, enter your WpStream credentials below or go <a href="%s" target="_blank">here</a> to create an account.','wpstream'),$admin_url_onboard);
1398 2267 echo '</div>';
@@ -1397,9 +2266,12 @@
1397 2266 printf ( __('To connect your plugin, enter your WpStream credentials below or go <a href="%s" target="_blank">here</a> to create an account.','wpstream'),$admin_url_onboard);
1398 2267 echo '</div>';
1399 2268
1400 2269 }else if($token==''){
1401 - echo '<div class="api_not_conected">'.__(' Incorrect username or password. Please check your credentials or go <a href="https://wpstream.net/my-account/edit-account/" target="_blank">here</a> to reset your password.','wpstream').'</div>';
2270 + $text = get_option('wpstream_curl_failed') === "0" ?
2271 + ' Incorrect username or password. Please check your credentials or go <a href="https://wpstream.net/my-account/edit-account/" target="_blank">here</a> to reset your password.' :
2272 + 'Not connected to WpStream. Please note the errors above and contact support.';
2273 + echo '<div class="api_not_conected">'.__($text,'wpstream').'</div>';
1402 2274 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
1403 2275 echo '<div class="api_conected">'.__('Connected to WpStream.net!','wpstream').'</div>';
1404 2276 }else{
1405 2277 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
@@ -1453,9 +2325,9 @@
1453 2325 * @since 3.0.1
1454 2326 */
1455 2327
1456 2328 public function wpstream_media_management(){
1457 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2329 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_media_management');
1458 2330
1459 2331 $this->main->show_user_data($pack_details);
1460 2332
1461 2333
@@ -1527,18 +2399,23 @@
1527 2399 */
1528 2400 public function wpstream_present_media_upload(){
1529 2401 $to_return='';
1530 2402 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
1531 -
1532 -
1533 -
1534 2403
1535 - if($formInputs['success'] === 'notenough'){
1536 - $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough streaming data or storage to upload a video!','wpstream').'</div>';
2404 + if( !$formInputs['success'] ){
2405 + if ($formInputs['error'] == 'not_connected'){
2406 + $to_return.='<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
2407 + }
2408 + else {
2409 + $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You don\'t have enough cloud storage and data to upload a new item. Please delete some videos or upgrade your plan.','wpstream').'</div>';
2410 + }
1537 2411 return $to_return;
1538 2412 }
1539 2413
1540 - if($formInputs['success'] ===true):
2414 + if($formInputs['success'] ===true){
2415 +
2416 +
2417 +
1541 2418 $to_return.='<div class="wpstream_upload_container">';
1542 2419 $to_return.='<div id="wpstream_uploaded_mes">'.esc_html__('Please select or drop a video file. Do not close this window during the upload!','wpstream').'</div>';
1543 2420 $to_return.='<form action="https://wpstream-video.s3.amazonaws.com/"
1544 2421 method="POST"
@@ -1548,18 +2425,19 @@
1548 2425 data-limitConcurrentUploads="1"
1549 2426 class="direct-upload">';
1550 2427
1551 2428 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
1552 - $to_return.='<label for="wpstream_upload"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span id="wpstream_label_action">Choose a file&hellip;</span></label>';
2429 + $to_return.='<label for="wpstream_upload"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span id="wpstream_label_action">' . esc_html__('Choose a file&hellip;','wpstream') . '</span></label>';
1553 2430
1554 2431
1555 2432 $to_return.='<div class="wpstream_file_drop_color">';
1556 2433 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
1557 - $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:
2434 + $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:<br>
1558 2435
1559 - Container: <strong>MP4</strong>,
1560 - Video codec: <strong>H264</strong>,
1561 - Audio codec: <strong>AAC</strong>. Media will fail to play if it does not follow the above settings.
2436 + Container: <strong>MP4</strong>,<br>
2437 + Video codec: <strong>H264</strong>,<br>
2438 + Audio codec: <strong>AAC</strong>.<br>
2439 + Media will fail to play if it does not follow the above settings.
1562 2440 You may use a tool like MediaInfo to verify your file. Also you may convert it with specialized software like HandBrake.','wpstream').'<strong> '.esc_html__('Accepted file extensions: .mp4, .mov','wpstream').'</strong></div>';
1563 2441 if(is_array($formInputs)){
1564 2442 foreach ($formInputs['ref'] as $name => $value) {
1565 2443 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
@@ -1570,9 +2448,9 @@
1570 2448 <div class="progress-bar-area"></div></div>
1571 2449 </form>';
1572 2450
1573 2451 $to_return.='</div>';
1574 - endif;
2452 + }
1575 2453
1576 2454 return $to_return;
1577 2455
1578 2456 }
@@ -1588,22 +2466,42 @@
1588 2466 */
1589 2467 public function wpstream_present_file_management(){
1590 2468 $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api();
1591 2469
1592 - $video_list_raw_array=array();
1593 - if(isset($video_list_raw['items'])){
1594 - $video_list_raw_array=$video_list_raw['items'];
2470 + if ( $video_list_raw === false ) {
2471 + return '<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
1595 2472 }
1596 -
1597 - $keys = array_column($video_list_raw_array, 'time');
2473 +
2474 + $video_list_raw_array = [];
2475 + if( isset( $video_list_raw['items'] ) ){
2476 + $video_list_raw_array = $video_list_raw['items'];
2477 + }
2478 +
2479 + $keys = array_column( $video_list_raw_array, 'time' );
1598 2480 array_multisort($keys, SORT_DESC , $video_list_raw_array);
1599 2481
1600 2482 $to_return='';
1601 -
1602 - if(is_array($video_list_raw['items'])){
2483 +
2484 + // show pending items
2485 + if ( key_exists( 'pending', $video_list_raw ) && is_array( $video_list_raw['pending'] ) ) {
2486 + foreach ( $video_list_raw['pending'] as $key => $video ) {
2487 + $video_size = intval($video['size']/1048576);
2488 + $video_name = esc_html($video['name']);
2489 + if($video_name!=''):
2490 + $to_return.='<div class="wpstream_video_wrapper">';
2491 + $to_return.='<div class="wpstream_video_title">';
2492 + $to_return.='<div class="wpstream_video_notice"></div></div>';
2493 + $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>';
2494 + $to_return.='<div class="wpstream_video_pending">' . esc_html__( 'The video is still processing', 'wpstream') . '</div>';
2495 + $to_return.='</div>';
2496 + endif;
2497 +
2498 + }
2499 + }
2500 +
2501 + // show uploaded items
2502 + if( is_array($video_list_raw['items'] ) ) {
1603 2503 foreach ($video_list_raw_array as $key =>$video){
1604 -
1605 -
1606 2504 $video_size = intval($video['size']/1048576);
1607 2505 $video_name = esc_html($video['name']);
1608 2506 if($video_name!=''):
1609 2507 $to_return.='<div class="wpstream_video_wrapper">';
@@ -1609,9 +2507,9 @@
1609 2507 $to_return.='<div class="wpstream_video_wrapper">';
1610 2508
1611 2509 $to_return.='<div class="wpstream_video_title">';
1612 2510 $to_return.='<div class="wpstream_video_notice"></div></div>';
1613 - $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>';
2511 + $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name:','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>';
1614 2512 $to_return.=' <div class="wpstream_delete_media" ';
1615 2513 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video_name.'?\')" data-filename="'.$video_name.'">'.esc_html__('delete file','wpstream').'</div>';
1616 2514 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video_name.'">'.esc_html__('download','wpstream').'</div>';
1617 2515 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
@@ -1621,19 +2519,22 @@
1621 2519
1622 2520
1623 2521
1624 2522 $to_return .='<a class="create_new_free_video" href="'.esc_url($add_free_video_url).'">'.esc_html__('Create new Free-To-View VOD from this recording').'</a>';
1625 - $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create new Pay-Per-View VOD from this recording').'</a>';
1626 -
2523 + if (class_exists('WooCommerce')) {
2524 + $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create new Pay-Per-View VOD from this recording').'</a>';
2525 + }
2526 +
1627 2527 $to_return.='</div>';
1628 2528 endif;
1629 2529
1630 2530 }
1631 2531 $current_page= get_current_screen();
1632 -
1633 -
1634 - } else {
1635 - $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
2532 + }
2533 +
2534 + // no items to show
2535 + if ( !is_array( $video_list_raw['items'] ) || ( key_exists( 'pending', $video_list_raw ) && !is_array( $video_list_raw['pending'] ) ) ) {
2536 + $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
1636 2537 }
1637 2538 return $to_return;
1638 2539 }
1639 2540
@@ -1693,9 +2594,10 @@
1693 2594
1694 2595 $allowed_keys=array(
1695 2596 'wpstream_product_type',
1696 2597 'wpstream_free_video',
1697 - 'wpstream_free_video_external'
2598 + 'wpstream_free_video_external',
2599 + 'wpstream_closed_captions_file'
1698 2600 );
1699 2601
1700 2602
1701 2603 foreach ($_POST as $key => $value) {
@@ -1716,10 +2618,36 @@
1716 2618 * save meta options
1717 2619 *
1718 2620 * @since 3.0.1
1719 2621 */
1720 - public function add_wpstream_product_metaboxes() {
1721 - add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default');
2622 + public function add_wpstream_product_metaboxes() {
2623 + global $post;
2624 + $post_id = $post->ID;
2625 +
2626 +
2627 +
2628 +
2629 + 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');
2630 + add_meta_box( 'custom_metabox_video_collection', esc_html__( 'Video Collection', 'wpstream' ), 'wpstream_bundle_custom_metabox_callback', 'wpstream_bundles', 'normal', 'high' );
2631 + add_meta_box( 'woocommerce-product-data', esc_html__( 'Product Data', 'wpstream' ), 'woocommerce_product_data_box', 'product', 'normal', 'default' );
2632 +
2633 + if(function_exists('wc_get_product')):
2634 + $product = wc_get_product( $post_id );
2635 + if ( $product ) {
2636 +
2637 + if ( $product->get_type() === 'wpstream_bundle' ) {
2638 + add_meta_box(
2639 + 'wpstream_woo_custom_metabox',
2640 + esc_html__( 'Video Collection Options', 'wpstream' ),
2641 + 'wpstream_bundle_custom_metabox_callback',
2642 + 'product',
2643 + 'normal',
2644 + 'default'
2645 + );
2646 + }
2647 + }
2648 + endif;
2649 +
1722 2650 }
1723 2651
1724 2652
1725 2653 /**
@@ -1733,9 +2661,12 @@
1733 2661 global $post;
1734 2662 if(isset($post->ID)){
1735 2663 if ( $post->post_type !== 'product' ) return;
1736 2664 $term_list = wp_get_post_terms($post->ID, 'product_type');
1737 - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
2665 + if( !empty($term_list) &&
2666 + isset($term_list[0]->name) &&
2667 + in_array($term_list[0]->name, ['live_stream', 'video_on_demand', 'wpstream_bundle'])
2668 + ){
1738 2669 update_post_meta( $post->ID, '_virtual', 'yes' );
1739 2670 }
1740 2671 }
1741 2672 }
@@ -1787,30 +2718,42 @@
1787 2718
1788 2719 $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
1789 2720
1790 2721
1791 - print '
1792 - <p class="meta-options video_free">
1793 - <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
2722 + print '<div class="meta-options video_free">';
2723 + print '<p class="meta-option wpstream_free_video">';
2724 + print '<label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
1794 2725 <select id="wpstream_free_video" name="wpstream_free_video">';
1795 -
1796 - if(is_array($video_list)){
1797 - foreach ($video_list as $key=>$value){
1798 - print '<option value="'.$key.'"';
1799 - if($wpstream_free_video === $key){
1800 - print ' selected ';
1801 - }
1802 - print '>'.$value.'</option>';
1803 - }
2726 +
2727 + if( is_array( $video_list ) ) {
2728 + foreach ($video_list as $key=>$value){
2729 + print '<option value="'.$key.'"';
2730 + if($wpstream_free_video === $key){
2731 + print ' selected ';
1804 2732 }
1805 -
1806 - print'
1807 - </select>
1808 - </p>
1809 - ';
2733 + print '>'.$value.'</option>';
2734 + }
2735 + }
2736 + print'</select>';
2737 + print '</p> ';
1810 2738
2739 + $wpstream_closed_captions_file = get_post_meta($post->ID, 'wpstream_closed_captions_file', true);
2740 +
2741 + $button_style = $wpstream_closed_captions_file ? 'style="display:none;"' : '';
2742 +
2743 + print '<p class="meta-option wpstream_vod_captions_url">';
2744 + print '<label for="wpstream_vod_captions_url_button">'.__('Captions file (optional):','wpstream').' </label><br />
2745 + <input type="hidden" id="wpstream_closed_captions_file" name="wpstream_closed_captions_file" value="'.esc_attr($wpstream_closed_captions_file).'" />
2746 + <input id="wpstream_vod_captions_url_button" type="button" class="upload_button button" value="'.esc_html__('Select .vtt Captions File','wpstream').'" '.$button_style.' />
2747 + <span class="wpstream_caption_file_display">'.( $wpstream_closed_captions_file ? esc_html( basename( $wpstream_closed_captions_file ) ) : '' ).'</span>';
2748 + if ( $wpstream_closed_captions_file ) {
2749 + print '<input type="button" class="button wpstream_remove_caption" value="'.esc_html__('Remove','wpstream').'" style="margin-left: 5px;" />';
2750 + }
2751 + print '</p> ';
2752 + print '</div>';
2753 +
1811 2754 $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
1812 - print '<p class="meta-options1 video_free_external">
2755 + print '<div class="meta-options1 video_free_external">
1813 2756 <label for="wpstream_free_video_external">'.__('Video:','wpstream').' </label><br />
1814 2757
1815 2758 <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
1816 2759 <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />';
@@ -1821,11 +2764,11 @@
1821 2764 $show_recording='style="display:none"';
1822 2765 $show_external='';
1823 2766 }
1824 2767 print '<p '.$show_recording.' class="wpstream_option_vod_source wpstream_show_recording">'.esc_html__('Choose one of your existing recordings.','wpstream').'</p>';
1825 - 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/Vimeo/external video.','wpstream').'</p>';
2768 + 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>';
1826 2769
1827 - print '</p> ';
2770 + print '</div> ';
1828 2771 }
1829 2772
1830 2773
1831 2774
@@ -1843,11 +2786,26 @@
1843 2786 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
1844 2787
1845 2788 return $types;
1846 2789 }
1847 -
1848 -
1849 -
2790 +
2791 + public function wpstream_add_products_class( $classname, $product_type ) {
2792 + if ( 'live_stream' === $product_type ) {
2793 + $classname = 'WC_Product_Live_Stream';
2794 + }
2795 + if ( 'video_on_demand' === $product_type ) {
2796 + $classname = 'WC_Product_Video_On_Demand';
2797 + }
2798 + return $classname;
2799 + }
2800 +
2801 + public function wpstream_add_custom_wc_products() {
2802 + if( class_exists( 'WooCommerce' ) ){
2803 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php';
2804 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php';
2805 + }
2806 + }
2807 +
1850 2808 /**
1851 2809 * Js action to do when user pick live stream or video on demand
1852 2810 *
1853 2811 * @since 3.0.1
@@ -1862,10 +2820,14 @@
1862 2820 <script type='text/javascript'>
1863 2821 jQuery( document ).ready( function() {
1864 2822 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
1865 2823 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
2824 + jQuery('.options_group.pricing' ).addClass ( 'show_if_wpstream_bundle' ).show();
2825 +
1866 2826 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
1867 2827 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
2828 + jQuery('._sold_individually_field').parent().addClass('show_if_wpstream_bundle').show();
2829 +
1868 2830 jQuery('._sold_individually_field').show();
1869 2831
1870 2832 var selected = jQuery('#product-type').val();
1871 2833 });
@@ -1881,13 +2843,12 @@
1881 2843 * @since 3.0.1
1882 2844 */
1883 2845
1884 2846 public function wpstream_hide_attributes_data_panel( $tabs) {
1885 -
1886 - $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand';
1887 - $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1888 - // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1889 -
2847 +
2848 + $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand hide_if_wpstream_bundle';
2849 + $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand show_if_wpstream_bundle';
2850 +
1890 2851 return $tabs;
1891 2852 }
1892 2853
1893 2854
@@ -1903,12 +2864,12 @@
1903 2864 $product_id=$product->get_id();
1904 2865
1905 2866 $term_list = wp_get_post_terms($product_id, 'product_type');
1906 2867
1907 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
2868 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1908 2869
1909 2870 if($subscription_model==1){ // if we have Neflix mode
1910 - if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' ){
2871 + if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='wpstream_bundle' ){
1911 2872 return false;
1912 2873 }
1913 2874 }
1914 2875
@@ -1926,8 +2887,9 @@
1926 2887 * @since 3.0.1
1927 2888 */
1928 2889
1929 2890 public function wpstream_add_custom_general_fields() {
2891 +
1930 2892
1931 2893 global $woocommerce, $post;
1932 2894 if(function_exists('wcs_user_has_subscription')){
1933 2895 echo '<div class="options_group show_if_subscription">';
@@ -1942,8 +2904,10 @@
1942 2904 }
1943 2905
1944 2906 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
1945 2907 echo '<div class="options_group show_if_video_on_demand">';
2908 +
2909 +
1946 2910 $selected='';
1947 2911 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
1948 2912 $selected=esc_html($_GET['new_video_name']);
1949 2913 }
@@ -1949,18 +2913,21 @@
1949 2913 }
1950 2914 if($selected==''){
1951 2915 $selected= get_post_meta($post->ID,'_movie_url',true);
1952 2916 }
1953 -
1954 - woocommerce_wp_select(
1955 - array(
1956 - 'id' => '_movie_url',
1957 - 'label' => __( 'Library video file', 'woocommerce' ),
1958 - 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
1959 - 'selected'=> true,
1960 - 'value' => $selected
1961 - )
1962 - );
2917 + if( !current_user_can('administrator') ){
2918 + print '<div style="margin:10px;">'.esc_html('You need to be an administrator in order to assign videos','wpstream').'</div>';
2919 + }else{
2920 + woocommerce_wp_select(
2921 + array(
2922 + 'id' => '_movie_url',
2923 + 'label' => __( 'Choose video', 'woocommerce' ),
2924 + 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
2925 + 'selected'=> true,
2926 + 'value' => $selected
2927 + )
2928 + );
2929 + }
1963 2930
1964 2931
1965 2932
1966 2933 echo '</div>';
@@ -2127,9 +3094,93 @@
2127 3094 $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
2128 3095 print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
2129 3096
2130 3097 }
2131 -
3098 +
3099 + /**
3100 + * Get plugin latest update release date from WordPress.org
3101 + * @param $plugin_slug
3102 + * @param $version
3103 + *
3104 + * @return bool
3105 + */
3106 + public function get_plugin_release_date( $plugin_slug, $version = null ) {
3107 + $api_url = 'https://api.wordpress.org/plugins/info/1.0/' . $plugin_slug . '.json';
3108 + $response = wp_remote_get( $api_url );
3109 +
3110 + if ( is_wp_error( $response ) ) {
3111 + return false;
3112 + }
3113 +
3114 + $body = wp_remote_retrieve_body( $response );
3115 + $data = json_decode( $body, true );
3116 +
3117 + if ( !$data || !isset( $data['versions'] ) ) {
3118 + return false;
3119 + }
3120 +
3121 + // no version provided, get the latest version
3122 + if ( !$version ) {
3123 + $version = $data['version'];
3124 + }
3125 +
3126 + // check if the version exists in the versions array
3127 + if ( !isset( $data['versions'][ $version ] ) ) {
3128 + return false;
3129 + }
3130 +
3131 + if ( isset( $data['last_updated'] ) ) {
3132 + return date('Y-m-d', strtotime( $data['last_updated'] ) );
3133 + }
3134 +
3135 + return false;
3136 + }
3137 +
3138 + /**
3139 + * Adds notice for the WpStream update availability
3140 + * when the update is not older than 30 days
3141 + */
3142 + public function wpstream_plugin_update_available_notice() {
3143 + if (!current_user_can('update_plugins')) {
3144 + return;
3145 + }
3146 +
3147 + $plugin_slug = 'wpstream/wpstream.php';
3148 + $update_data = get_site_transient('update_plugins');
3149 +
3150 + if ( property_exists( $update_data, 'response' ) &&
3151 + is_array($update_data->response) &&
3152 + key_exists($plugin_slug, $update_data->response)
3153 + ) {
3154 + $new_version = $update_data->response[$plugin_slug]->new_version;
3155 +
3156 + $release_date = $this->get_plugin_release_date( 'wpstream', $new_version );
3157 +
3158 + if ( $release_date ) {
3159 + $days_since_release = ( time() - strtotime( $release_date ) ) / DAY_IN_SECONDS;
3160 +
3161 + // if there's an update newer than 7 days, do not show the notice
3162 + if ( $days_since_release < 7 ) {
3163 + return;
3164 + }
3165 + }
3166 + $update_url = wp_nonce_url(
3167 + self_admin_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin_slug)),
3168 + 'upgrade-plugin_' . $plugin_slug
3169 + );
3170 +
3171 + echo '<div class="notice notice-warning is-dismissible">';
3172 + echo '<p><strong>' . __('WpStream Plugin Update Available', 'wpstream') . '</strong></p>';
3173 + echo '<p>' . sprintf(
3174 + __('Version %s is available. Please update to the latest version for new features and security improvements.', 'wpstream'),
3175 + '<strong>' . esc_html($new_version) . '</strong>'
3176 + ) . '</p>';
3177 + echo '<p><a href="' . esc_url($update_url) . '" class="button button-primary">' .
3178 + __('Update Now', 'wpstream') . '</a></p>';
3179 + echo '</div>';
3180 + }
3181 + }
3182 +
2132 3183 /**
2133 3184 * Admin notices
2134 3185 *
2135 3186 * @since 3.0.1
@@ -2162,9 +3213,16 @@
2162 3213 public function wpstream_startstreaming_sidebar_meta() {
2163 3214 global $post;
2164 3215 $term_list = wp_get_post_terms($post->ID, 'product_type');
2165 3216
2166 - add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
3217 + add_meta_box(
3218 + 'wpstream-sidebar-meta',
3219 + esc_html__('Live Streaming', 'wpstream'),
3220 + array($this,'wpstream_start_stream_meta'),
3221 + 'wpstream_product',
3222 + 'side',
3223 + 'high'
3224 + );
2167 3225
2168 3226 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
2169 3227 if(!is_wp_error( $term_list )){
2170 3228 if( isset($term_list[0]->name) ){
@@ -2191,11 +3249,17 @@
2191 3249 $local_event_options = get_post_meta ($post->ID,'local_event_options','');
2192 3250
2193 3251
2194 3252
2195 - if( get_post_status($post->ID)!='auto-draft' ){
3253 + if( get_post_status( $post->ID ) === 'publish' ) {
2196 3254 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
2197 3255 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
3256 + $pack_details = $this->main->quota_manager->get_live_quota_data('wpstream_start_stream_meta');
3257 + if( isset($pack_details['available_data_mb'])){
3258 + if ($pack_details['available_data_mb'] <= 0){
3259 + print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
3260 + }
3261 + }
2198 3262
2199 3263 $this->wpstream_live_stream_unit($post->ID);
2200 3264 print '<div class="wpstream_modal_background"></div>';
2201 3265 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
@@ -2200,18 +3264,26 @@
2200 3264 print '<div class="wpstream_modal_background"></div>';
2201 3265 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
2202 3266 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
2203 3267 </div>';
2204 - }else{
3268 + } else {
2205 3269 esc_html_e('To Go Live, please publish your channel first !','wpstream');
2206 3270 }
2207 3271 }
2208 3272
2209 3273
3274 + public function wpstream_is_basic_streaming_mode(){
3275 + $pack_details = $this->main->quota_manager->get_live_quota_data('wpstream_is_basic_streaming_mode');
3276 + if( isset($pack_details['available_data_mb'] ) ) {
3277 + if ( $pack_details['available_data_mb'] <= 0 ){
3278 + return true;
3279 + }
3280 + }
3281 + return false;
3282 + }
2210 3283
2211 3284
2212 3285
2213 -
2214 3286 /**
2215 3287 *
2216 3288 *
2217 3289 *
@@ -2252,9 +3324,11 @@
2252 3324
2253 3325
2254 3326
2255 3327 public function wpstream_admin_footer_onboarding(){
2256 - $this->wpstream_onboard_display();
3328 + if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
3329 + $this->wpstream_onboard_display();
3330 + }
2257 3331 }
2258 3332
2259 3333
2260 3334 /*
@@ -2262,25 +3336,20 @@
2262 3336 *
2263 3337 */
2264 3338
2265 3339 public function wpstream_pre_onboard_display(){
2266 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2267 -
3340 + $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_pre_onboard_display' );
2268 3341 $this->main->show_user_data($pack_details);
2269 3342
2270 -
2271 - $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3343 + $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
2272 3344 ?>
2273 -
3345 + <div id="wpstream-onboarding-root"></div>
2274 3346 <div class="wpstream_quick_start_wrapper">
2275 3347 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
2276 3348
2277 3349 <h1><?php print esc_html__('WpStream','wpstream').' <span class="header_special">'.esc_html__('Quick Start','wpstream').'</span>';?></h1>
2278 3350
2279 - <?php
2280 - if( !wp_is_mobile()){
2281 - ?>
2282 -
3351 +
2283 3352 <p>
2284 3353 <?php esc_html_e('The quick start guide will help you set up Live Streaming, Video On Demand, and Monetization in a fun and interactive way. Give it a shot! ','wpstream');?>
2285 3354 </p>
2286 3355
@@ -2285,18 +3354,14 @@
2285 3354 </p>
2286 3355
2287 3356 <div id="wpstream_trigger_quick_start" class="wpstream_button wpstream_button_action"><?php esc_html_e('Start the Guide','wpstream');?></div>
2288 3357
2289 - <?php }else{
2290 - print'<p>'.esc_html__('The quick start guide is not working on mobile devices','wpstream').'</p>';
2291 - } ?>
3358 +
2292 3359
2293 3360 </div>
2294 3361
2295 3362
2296 - <?php
2297 - if( !wp_is_mobile()){
2298 - ?>
3363 +
2299 3364 <script type="text/javascript">
2300 3365 //<![CDATA[
2301 3366 jQuery(document).ready(function(){
2302 3367 jQuery(".wpstream_on_boarding_wrapper").show();
@@ -2306,10 +3371,9 @@
2306 3371 //]]>
2307 3372 </script>
2308 3373
2309 3374 <?php
2310 - }//end is mobile
2311 -
3375 +
2312 3376 }
2313 3377
2314 3378
2315 3379
@@ -2373,9 +3437,9 @@
2373 3437 </div>
2374 3438
2375 3439
2376 3440 <div class="wpstream_check_account_status">
2377 - Checking if you are already logged.....
3441 + <?php esc_html_e( 'Checking if you are already logged.....', 'wpstream' ); ?>
2378 3442 </div>
2379 3443
2380 3444 <div class="wpstream_onboarding_notification"></div>
2381 3445
@@ -2407,32 +3471,38 @@
2407 3471
2408 3472 </div>
2409 3473
2410 3474 <div class="wpstream_option">
2411 - <label for="wpstream_register_password"><?php esc_html_e('Your Password','wpstream');?></label>
2412 - <input id="wpstream_register_password" type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
3475 +<!-- <label for="wpstream_register_password">--><?php //esc_html_e('Your Password','wpstream');?><!--</label>-->
3476 + <input id="wpstream_register_password" hidden type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
3477 + <span class="" ><?php esc_html_e('We\'ll send the password to the email you attached. ', 'wpstream') ?></span>
2413 3478 </div>
2414 3479
3480 +
3481 + <!-- Altcha Widget -->
3482 + <script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist/altcha.min.js" type="module"></script>
3483 + <div class="wpstream_option" style="display:none;">
3484 + <altcha-widget
3485 + challengeurl="<?php echo esc_url( WPSTREAM_API . '/v2/user/getcaptcha' ); ?>"
3486 + name="altcha"
3487 + auto="onload"
3488 + hidefooter
3489 + hidelogo
3490 + 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'); ?>"}'
3491 + ></altcha-widget>
3492 + </div>
2415 3493
2416 - <?php
2417 -
2418 - $url = 'user/getcapthca';
2419 - $curl_post_fields = array();
2420 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
2421 - $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
2422 -
2423 -
2424 - ?>
2425 - <div class="wpstream_option">
2426 - <?php print '<div id="wpstream_capthca">'.$curl_response_decoded['capthca'].'</div>';?>
2427 - <label for="wpstream_register_captcha"><?php esc_html_e('Type the characters above','wpstream');?></label>
2428 -
2429 - <input id="wpstream_register_captcha" type="text" size="36" name="wpstream_register_captcha" />
2430 - <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']); ?>" />
3494 + <div class="wpstream_option wpstream_terms_agreement">
3495 + <!-- Add "by registering you agree to the privacy terms" checkbox-->
3496 + <input id="wpstream_register_privacy" type="checkbox" name="wpstream_register_privacy" />
3497 + <label for="wpstream_register_privacy">
3498 + <?php printf(
3499 + esc_html__('By registering you agree to the %sPrivacy Policy%s','wpstream'),
3500 + '<a href="https://wpstream.net/privacy-policy/" target="_blank">',
3501 + '</a>'
3502 + );?>
3503 + </label>
2431 3504 </div>
2432 -
2433 -
2434 -
2435 3505 <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_register" value="<?php esc_html_e('register','wpstream');?>" />
2436 3506 </div>
2437 3507
2438 3508
@@ -2452,10 +3522,10 @@
2452 3522
2453 3523 <div id="wpstream_on_board" class="wpstream_action_next_step" data-nextthing="wpstream_step_2" style="display:none;" >Move to step 2</div>
2454 3524 </div>
2455 3525 <?php
2456 -
2457 - if(trim($token)!==''){
3526 +
3527 + if( !is_null( $token ) && trim( $token ) !== '' ) {
2458 3528 print '<div id="wpstream_have_token"></div>';
2459 3529 }
2460 3530 }
2461 3531
@@ -2477,10 +3547,10 @@
2477 3547 public function randomPassword() {
2478 3548 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
2479 3549 $pass = array(); //remember to declare $pass as an array
2480 3550 $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
2481 - for ($i = 0; $i < 8; $i++) {
2482 - $n = rand(0, $alphaLength);
3551 + for ($i = 0; $i < 16; $i++) {
3552 + $n = random_int(0, $alphaLength);
2483 3553 $pass[] = $alphabet[$n];
2484 3554 }
2485 3555 return implode($pass); //turn the array into a string
2486 3556 }
@@ -2497,11 +3567,11 @@
2497 3567
2498 3568 <div class="wpstream_step_wrapper wpstream_step_2" id="wpstream_step_2">
2499 3569 <h1>Welcome to <span class="header_special">WpStream</span>! How would you like to start?</h1>
2500 3570
2501 - <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
3571 + <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3a" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
2502 3572 <div class="wpstram_or">or</div>
2503 - <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>
3573 + <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>
2504 3574
2505 3575 </div>
2506 3576
2507 3577
@@ -2519,9 +3589,9 @@
2519 3589
2520 3590 <div class="wpstream_step_wrapper wpstream_step_3 wpstream_onboarding_live" id="wpstream_step_3">
2521 3591 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream'); ?></h1>
2522 3592
2523 - <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3a"><?php esc_html_e('No - Free-To-View (FTV)','wpstream');?></div>
3593 + <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_3a" data-nextthing="wpstream_step_3a"><?php esc_html_e('No - Free-To-View (FTV)','wpstream');?></div>
2524 3594 <div class="wpstram_or">or</div>
2525 3595 <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream');?></div>
2526 3596
2527 3597 <div class="wpstream_initial_onboarding_controls_wrapper">
@@ -2545,9 +3615,9 @@
2545 3615
2546 3616 <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3a">
2547 3617 <h1><?php esc_html_e('Let’s create your first FTV live channel','wpstream');?></h1>
2548 3618
2549 -
3619 + <div id="wpstream_onboard_live_notice" class="wpstream_onboarding_notification"></div>
2550 3620 <div id="wpstream_onboard_live" class="wpstream_accordion_container">
2551 3621 <label>Name your first Free-To-View channel</label>
2552 3622 <input type="text" name="channel_name" id="wpstream_onboarding_channel_name" class="wpstream_onboarding_channel_name" value="<?php esc_html_e('My first FTV channel','wpstream');?>" >
2553 3623 <input type="submit" name="submit" id="wpstream_on_board_create_channel" class="wpstream_button wpstream_button_action wpstream_onboard_live_action" value="<?php esc_html_e('Create Channel','wpstream');?>" />
@@ -2554,9 +3624,9 @@
2554 3624
2555 3625 </div>
2556 3626
2557 3627 <div class="wpstream_initial_onboarding_controls_wrapper">
2558 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
3628 + <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2559 3629 </div>
2560 3630
2561 3631 </div>
2562 3632
@@ -2573,14 +3643,14 @@
2573 3643
2574 3644 public function wpstream_onboarding_step_3_B_live_streaming_pay_per_view(){
2575 3645 ?>
2576 3646
2577 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3b">
3647 + <div class="wpstream_step_wrapper wpstream_step_3b wpstream_onboarding_live" id="wpstream_step_3b">
2578 3648 <h1><?php esc_html_e('Make your live stream Pay Per View','wpstream');?></h1>
2579 3649 <?php
2580 3650 if ( class_exists( 'WooCommerce' ) ) {
2581 3651 ?>
2582 -
3652 + <div id="wpstream_onboard_live_ppv_notice" class="wpstream_onboarding_notification"></div>
2583 3653 <div id="wpstream_onboard_live_ppv" class="wpstream_accordion_container">
2584 3654 <label><?php esc_html_e('Choose a name for your channel','wpstream');?></label>
2585 3655 <input type="text" name="channel_name" id="wpstream_onboarding_channel_name_ppv" class="wpstream_onboarding_channel_name" value="<?php esc_html_e('My First PPV Channel','wpstream');?>">
2586 3656 <label><?php esc_html_e('Pay-Per-View Price ($)','wpstream');?></label>
@@ -2588,15 +3658,15 @@
2588 3658 <input type="submit" name="submit" id="wpstream_onboard_live_ppv_action" class="wpstream_button wpstream_button_action wpstream_onboard_live_ppv_action" value="<?php esc_html_e('Create Channel','wpstream');?>" />
2589 3659
2590 3660 </div>
2591 3661 <?php
2592 - } else {?>
3662 + } else {
2593 3663 $this->wpstream_onboarding_woo_warning();
2594 - <?php } ?>
3664 + } ?>
2595 3665
2596 3666
2597 3667 <div class="wpstream_initial_onboarding_controls_wrapper">
2598 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_3"><?php esc_html_e('Prev','wpstream');?></span>
3668 + <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2599 3669 </div>
2600 3670 </div>
2601 3671 <?php
2602 3672 }
@@ -2633,13 +3703,12 @@
2633 3703 ?>
2634 3704 <div class="wpstream_step_wrapper wpstream_step_4 wpstream_onboarding_vod" id="wpstream_step_4">
2635 3705 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream');?></h1>
2636 3706
2637 - <div class="wpstream_accordion_header wpstream_action_next_step" data-control="wpstream_onboard_vod_free" data-nextthing="wpstream_step_4a" ><?php esc_html_e('No - Free-To-View (FTV)','wpstream'); ?></div>
3707 + <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_4a" data-control="wpstream_onboard_vod_free" data-nextthing="wpstream_step_4a" ><?php esc_html_e('No - Free-To-View (FTV)','wpstream'); ?></div>
2638 3708 <div class="wpstram_or">or</div>
2639 - <div class="wpstream_accordion_header wpstream_action_next_step" data-control="wpstream_onboard_vod_ppv" data-nextthing="wpstream_step_4b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream'); ?></div>
2640 -
2641 -
3709 + <input type="hidden" id="wpstream_onboarding_video_list_nonce" value="<?php echo wp_create_nonce( "wpstream_onboarding_video_list_nonce" ); ?>">
3710 + <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_4b" data-control="wpstream_onboard_vod_ppv" data-nextthing="wpstream_step_4b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream'); ?></div>
2642 3711 <div class="wpstream_initial_onboarding_controls_wrapper">
2643 3712 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2644 3713 </div>
2645 3714
@@ -2653,37 +3722,29 @@
2653 3722 *
2654 3723 *
2655 3724 */
2656 3725 public function wpstream_onboarding_step_4_free_vod(){
2657 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
2658 - $video_list = array();
2659 - if($token!=''){
2660 - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
3726 +
3727 + $current_screen=get_current_screen();
3728 + if($current_screen->base !=='wpstream_page_wpstream_onboard'){
3729 + return;
2661 3730 }
2662 -
2663 3731 ?>
2664 -
2665 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4a">
3732 +
3733 + <div class="wpstream_step_wrapper wpstream_step_4a wpstream_onboarding_live" id="wpstream_step_4a">
2666 3734 <h1><?php esc_html_e('Let’s create your first Free-To-View VOD','wpstream');?></h1>
2667 -
2668 -
2669 -
2670 - <?php
2671 - if( count($video_list) !== 0 ) {
2672 - ?>
2673 - <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
3735 + <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div>
3736 + <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
3737 + <div class="spinner"></div>
3738 + <div class="wpstream-step-container" style="display: none">
2674 3739 <label><?php esc_html_e('Name your FTV Video-On-Demand','wpstream')?></label>
2675 3740 <input type="text" name="channel_name" class="wpstream_onboarding_vod_name" id="wpstream_onboarding_vod_name" value="<?php esc_html_e('My First FTV VOD','wpstream');?>" >
2676 - <?php $this->wpstream_show_vod_dropdown_onboarding($video_list); ?>
2677 - <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_free_action" id="wpstream_onboard_vod_free_action" value="<?php esc_html_e('Create Free VOD','wpstream');?>" />
3741 + <div id="wpstream_free_vod_dropdown_videos_list"></div>
3742 + <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_free_action" id="wpstream_onboard_vod_free_action" value="Create FTV VOD">
2678 3743 </div>
3744 + </div>
3745 + <?php $this->wpstream_obboarding_file_warning(); ?>
2679 3746
2680 - <?php }else{
2681 - $this->wpstream_obboarding_file_warning();
2682 - } ?>
2683 -
2684 -
2685 -
2686 3747 <div class="wpstream_initial_onboarding_controls_wrapper">
2687 3748 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
2688 3749 </div>
2689 3750
@@ -2697,34 +3758,10 @@
2697 3758 *
2698 3759 *
2699 3760 *
2700 3761 */
2701 -
2702 - public function wpstream_show_vod_dropdown_onboarding($video_list,$appendix=''){
2703 -
2704 - print '<label>'.esc_html__('Choose Recording','wpstream').'</label>
2705 - <select name="wpstream_free_vod_file_name" id="wpstream_free_vod_file_name'.$appendix.'">
2706 - <option>'.esc_html__('Please select a recording from the list','wpstream').'</option>';
2707 -
2708 - if(is_array($video_list)){
2709 - foreach ($video_list as $key=>$value){
2710 - print '<option value="'.$key.'"';
2711 - print '>'.$value.'</option>';
2712 - }
2713 - }
2714 - print'</select>';
2715 -
2716 - }
2717 -
2718 -
2719 -
2720 - /*
2721 - *
2722 - *
2723 - *
2724 - */
2725 3762 public function wpstream_obboarding_file_warning(){
2726 - print '<div class="wpstream_warning_onboarding">
3763 + print '<div class="wpstream_warning_onboarding" style="display: none">
2727 3764 '.esc_html__('A recording is needed to create a VOD from. There are no recordings under your account. You can create new recordings by recording a live channel or uploading video files directly.','wpstream').'
2728 3765 </br>
2729 3766 <div class="wpstream_upload_video">'.esc_html__('Upload Video','wpstream').'</div>
2730 3767
@@ -2731,11 +3768,8 @@
2731 3768 <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
2732 3769 </div>';
2733 3770 }
2734 3771
2735 -
2736 -
2737 -
2738 3772 /*
2739 3773 *
2740 3774 *
2741 3775 *
@@ -2740,54 +3774,40 @@
2740 3774 *
2741 3775 *
2742 3776 */
2743 3777 public function wpstream_onboarding_step_4_ppv_vod(){
2744 -
2745 -
2746 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
2747 - $video_list = array();
2748 - if($token!=''){
2749 - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
3778 + $current_screen=get_current_screen();
3779 +
3780 + if($current_screen->base !=='wpstream_page_wpstream_onboard'){
3781 + return;
2750 3782 }
2751 3783 ?>
2752 -
2753 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4b">
3784 +
3785 + <div class="wpstream_step_wrapper wpstream_step_4b wpstream_onboarding_live" id="wpstream_step_4b">
2754 3786 <h1><?php esc_html_e('Let\'s create your first Pay-Per-View VOD','wpstream');?></h1>
2755 3787
2756 -
2757 - <?php
2758 - if( count($video_list) !== 0 ) {
2759 - if ( class_exists( 'WooCommerce' ) ) {
2760 - ?>
2761 - <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
2762 - <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
2763 - <input type="text" name="channel_name" class="wpstream_onboarding_ppv_vod_name" id="wpstream_onboarding_ppv_vod_name" value="<?php esc_html_e('My First PPV VOD','wpstream');?>">
2764 -
2765 - <?php $this->wpstream_show_vod_dropdown_onboarding($video_list,'_for_ppv'); ?>
2766 -
2767 - <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
2768 - <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
2769 - <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_ppv_action" id="wpstream_onboard_vod_ppv_action" value="<?php esc_html_e('Create PPV VOD','wpstream');?>" />
2770 -
2771 - </div>
2772 - <?php }else{
2773 - $this->wpstream_onboarding_woo_warning();
2774 - }
2775 -
2776 -
2777 - }else{
2778 - $this->wpstream_obboarding_file_warning();
2779 - }
2780 - ?>
2781 -
2782 -
3788 + <div id="wpstream_onboard_vod_ppv_notice" class="wpstream_onboarding_notification"></div>
3789 + <?php
3790 + if ( class_exists( 'WooCommerce' ) ) { ?>
3791 + <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
3792 + <div class="spinner"></div>
3793 + <div class="wpstream-step-container" style="display: none">
3794 + <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
3795 + <input type="text" name="channel_name" class="wpstream_onboarding_ppv_vod_name" id="wpstream_onboarding_ppv_vod_name" value="<?php esc_html_e('My First PPV VOD','wpstream');?>">
3796 + <div id="wpstream_ppv_vod_dropdown_videos_list"></div>
3797 + <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
3798 + <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
3799 + <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_ppv_action" id="wpstream_onboard_vod_ppv_action" value="<?php esc_html_e('Create PPV VOD','wpstream');?>" />
3800 + </div>
3801 + </div>
3802 + <?php $this->wpstream_obboarding_file_warning(); ?>
3803 + <?php } else {
3804 + $this->wpstream_onboarding_woo_warning();
3805 + } ?>
2783 3806 <div class="wpstream_initial_onboarding_controls_wrapper">
2784 3807 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
2785 3808 </div>
2786 -
2787 3809 </div>
2788 -
2789 -
2790 3810 <?php
2791 3811 }
2792 3812
2793 3813
@@ -2820,9 +3840,8 @@
2820 3840 *
2821 3841 */
2822 3842 public function onboarding_wizard_footer() {
2823 3843 ?>
2824 - <div class="wpstream_modal_back"></div>
2825 3844 </div>
2826 3845 <div class="wpstream_modal_background_onboard"></div>
2827 3846 <?php
2828 3847 }
@@ -2849,14 +3868,20 @@
2849 3868 'post_status' => 'publish',
2850 3869 'post_type' => 'product',
2851 3870 'post_author' => $current_user->ID
2852 3871 );
2853 -
3872 +
2854 3873 // Insert the post into the database
2855 3874 $post_id = wp_insert_post( $my_post );
2856 3875
2857 3876 if(is_wp_error($post_id)){
2858 - echo json_encode( array('succes'=>false) );
3877 + $logger = new WPStream_Logger();
3878 + $log_entry = new WpStream_Log_Entry([
3879 + 'type' => 'error',
3880 + 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(),
3881 + ]);
3882 + $logger->add( $log_entry );
3883 + echo json_encode( array('succes'=>false) );
2859 3884 }else{
2860 3885
2861 3886 $product = wc_get_product($post_id);
2862 3887 $price = wc_format_decimal($channel_price);
@@ -2910,36 +3935,36 @@
2910 3935
2911 3936 // Insert the post into the database
2912 3937 $post_id = wp_insert_post( $my_post );
2913 3938
2914 - if(is_wp_error($post_id)){
2915 - echo json_encode( array('succes'=>false) );
2916 - }else{
3939 + if( is_wp_error( $post_id ) ) {
3940 + $logger = new WPStream_Logger();
3941 + $log_entry = new WpStream_Log_Entry([
3942 + 'type' => 'error',
3943 + 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(),
3944 + ]);
3945 + $logger->add( $log_entry );
3946 + echo json_encode( array('succes'=>false) );
3947 + } else {
2917 3948 $permalink = get_edit_post_link($post_id);
2918 3949
2919 3950 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
2920 3951 $permalink= add_query_arg( 'branch', '1', $permalink );
2921 -
2922 -
3952 +
2923 3953 echo json_encode( array(
2924 - 'success'=> true,
2925 - 'link' => ($permalink)
3954 + 'success'=> true,
3955 + 'link' => ($permalink)
2926 3956 ));
2927 3957 }
2928 -
2929 3958 }
2930 3959 die();
2931 3960 }
2932 3961
2933 -
2934 -
2935 3962 /*
2936 3963 *
2937 3964 * On Boarding create free vod
2938 3965 *
2939 3966 */
2940 -
2941 -
2942 3967 public function wpstream_on_board_create_free_vod(){
2943 3968 $current_user = wp_get_current_user();
2944 3969 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
2945 3970 if(current_user_can('administrator')){
@@ -2951,14 +3976,20 @@
2951 3976 'post_status' => 'publish',
2952 3977 'post_type' => 'wpstream_product_vod',
2953 3978 'post_author' => $current_user->ID
2954 3979 );
2955 -
2956 - // Insert the post into the database
3980 +
3981 + // Insert the post into the database
2957 3982 $post_id = wp_insert_post( $my_post );
2958 3983
2959 3984 if(is_wp_error($post_id)){
2960 - echo json_encode( array('succes'=>false) );
3985 + $logger = new WPStream_Logger();
3986 + $log_entry = new WpStream_Log_Entry([
3987 + 'type' => 'error',
3988 + 'description' => 'Couldn\'t create free VOD during onboarding because of error: ' . $post_id->get_error_message(),
3989 + ]);
3990 + $logger->add( $log_entry );
3991 + echo json_encode( array('succes'=>false) );
2961 3992 }else{
2962 3993 update_post_meta($post_id, 'wpstream_product_type', 2);
2963 3994 update_post_meta($post_id, 'wpstream_free_video', $file_name);
2964 3995
@@ -3002,15 +4033,21 @@
3002 4033 'post_status' => 'publish',
3003 4034 'post_type' => 'product',
3004 4035 'post_author' => $current_user->ID
3005 4036 );
3006 -
4037 +
3007 4038 // Insert the post into the database
3008 4039 $post_id = wp_insert_post( $my_post );
3009 4040
3010 - if(is_wp_error($post_id)){
3011 - echo json_encode( array('succes'=>false) );
3012 - }else{
4041 + if( is_wp_error( $post_id ) ) {
4042 + $logger = new WPStream_Logger();
4043 + $log_entry = new WpStream_Log_Entry([
4044 + 'type' => 'error',
4045 + 'description' => 'Couldn\'t create PPV VOD during onboarding because of error: ' . $post_id->get_error_message(),
4046 + ]);
4047 + $logger->add( $log_entry );
4048 + echo json_encode( array('succes'=>false) );
4049 + } else {
3013 4050
3014 4051 $product = wc_get_product($post_id);
3015 4052 $price = wc_format_decimal($vod_price);
3016 4053
@@ -3052,18 +4089,31 @@
3052 4089 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3053 4090
3054 4091 if(current_user_can('administrator')){
3055 4092 $username = sanitize_text_field($_POST['api_username']);
3056 - $password = sanitize_text_field($_POST['api_password']);
4093 + $password = $_POST['api_password'];
3057 4094 update_option('wpstream_api_username',$username);
3058 4095 update_option('wpstream_api_password',$password);
3059 4096
3060 4097 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3061 -
3062 - echo json_encode( array(
3063 - 'success'=> true,
3064 - 'token' => ($token)
3065 - ));
4098 + $videos_list = $this->main->wpstream_live_connection->wpstream_get_videos();
4099 + // cleanup any previous echo before sending json
4100 + ob_end_clean();
4101 + // !DO NOT SEND TOKEN TO THE CLIENT!
4102 + if ($token){
4103 + echo json_encode( array(
4104 + 'success'=> true
4105 + ));
4106 + }
4107 + else {
4108 + $text = get_option('wpstream_curl_failed') ?
4109 + 'Login failed with critical error: ' . get_option('wpstream_curl_failed') :
4110 + 'Wrong username or password!';
4111 + echo json_encode( array(
4112 + 'success'=> false,
4113 + 'error' => $text,
4114 + ));
4115 + }
3066 4116
3067 4117 }else{
3068 4118 echo json_encode( array(
3069 4119 'success'=> false,
@@ -3079,8 +4129,28 @@
3079 4129 if(current_user_can('administrator')){
3080 4130
3081 4131 }
3082 4132 }
4133 +
4134 + /**
4135 + * @param $challenge
4136 + * @param $difficulty
4137 + *
4138 + * @return int|null
4139 + */
4140 + private function solve_pow( $challenge, $difficulty ) {
4141 + $nonce = 0;
4142 + $target = str_repeat( "0", $difficulty );
4143 +
4144 + while ( $nonce < 5000000 ) {
4145 + $hash = hash( 'sha256', $challenge . $nonce );
4146 + if ( strpos( $hash, $target ) === 0 ) {
4147 + return $nonce;
4148 + }
4149 + $nonce++;
4150 + }
4151 + return null; // Return null if no solution is found within the max attempts
4152 + }
3083 4153
3084 4154 /*
3085 4155 *
3086 4156 * On Boarding login
@@ -3086,38 +4156,42 @@
3086 4156 * On Boarding login
3087 4157 *
3088 4158 */
3089 4159 public function wpstream_on_board_register(){
3090 -
3091 4160 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3092 -
3093 4161 if(current_user_can('administrator')){
3094 4162 $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']);
3095 - $wpstream_register_password = sanitize_text_field($_POST['wpstream_register_password']);
3096 - $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']);
3097 - $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']);
3098 -
4163 + $wpstream_register_password = $_POST['wpstream_register_password'];
4164 +
3099 4165 $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password);
3100 4166 if(!$validate['success']){
4167 + // cleanup any previous echo before sending json
4168 + ob_end_clean();
3101 4169 echo json_encode($validate);
3102 4170 die();
3103 4171 }
3104 4172
3105 - $url='user/create';
4173 + $wpstream_altcha = isset($_POST['wpstream_altcha']) ? $_POST['wpstream_altcha'] : '';
4174 +
4175 + if ( empty($wpstream_altcha) ) {
4176 + echo json_encode(array(
4177 + 'success' => false,
4178 + 'message' => esc_html__('Captcha verification failed. Please try again.', 'wpstream')
4179 + ));
4180 + die();
4181 + }
4182 +
4183 + $url='v2/user/create';
3106 4184 $curl_post_fields=array(
3107 4185 'email' => $wpstream_register_email,
3108 4186 'password' => $wpstream_register_password,
3109 - 'captcha' => $wpstream_register_captcha,
3110 - 'captcha_id' => $wpstream_register_captcha_id,
4187 + 'solution' => $wpstream_altcha,
4188 + 'captcha_id' => '',
3111 4189 );
3112 4190
3113 -
3114 -
3115 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
4191 + $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true);
3116 4192 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
3117 4193
3118 -
3119 -
3120 4194 if($curl_response_decoded['success']){
3121 4195
3122 4196 if($curl_response_decoded['request']['registred']){
3123 4197 // we are registerd
@@ -3126,8 +4200,10 @@
3126 4200 update_option('wpstream_api_password',$wpstream_register_password);
3127 4201
3128 4202 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3129 4203
4204 + // cleanup any previous echo before sending json
4205 + ob_end_clean();
3130 4206 echo json_encode( array(
3131 4207 'success' => true,
3132 4208 'token' => $token ,
3133 4209 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'),
@@ -3135,8 +4211,10 @@
3135 4211 ));
3136 4212 die();
3137 4213 }else{
3138 4214
4215 + // cleanup any previous echo before sending json
4216 + ob_end_clean();
3139 4217 echo json_encode( array(
3140 4218 'success'=> false,
3141 4219 'message'=> $curl_response_decoded['request']['message'],
3142 4220 'curl'=>$curl_response_decoded,
@@ -3148,12 +4226,13 @@
3148 4226
3149 4227
3150 4228
3151 4229 }else{
3152 -
4230 + // cleanup any previous echo before sending json
4231 + ob_end_clean();
3153 4232 echo json_encode( array(
3154 4233 'success'=> false,
3155 - 'message'=> esc_html__('Register action could not be completed. Please register on wpstream.net','wpstream'),
4234 + 'message'=> esc_html__('Registration could not be completed. Please try again or register on wpstream.net','wpstream'),
3156 4235
3157 4236 ));
3158 4237 die();
3159 4238 }
@@ -3165,8 +4244,10 @@
3165 4244
3166 4245
3167 4246
3168 4247 }else{
4248 + // cleanup any previous echo before sending json
4249 + ob_end_clean();
3169 4250 echo json_encode( array(
3170 4251 'success'=> false,
3171 4252 'message' => esc_html('You are not an administrator','wpstream')
3172 4253 ));
@@ -3200,9 +4281,9 @@
3200 4281
3201 4282 if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) {
3202 4283 $return= array(
3203 4284 'success'=> false,
3204 - 'message' => esc_html('The email doesn\'t look right !','wpstream')
4285 + 'message' => esc_html__('The email doesn\'t look right !','wpstream')
3205 4286 );
3206 4287 return $return;die();
3207 4288 }
3208 4289
@@ -3210,9 +4291,9 @@
3210 4291 $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1);
3211 4292 if( $domain!='' && !checkdnsrr ($domain) ){
3212 4293 $return= array(
3213 4294 'success'=> false,
3214 - 'message' => esc_html('The email doesn\'t look right !','wpstream')
4295 + 'message' => esc_html__('The email doesn\'t look right !','wpstream')
3215 4296 );
3216 4297 return $return;die();
3217 4298 }
3218 4299
@@ -3227,5 +4308,144 @@
3227 4308 }
3228 4309
3229 4310 return $return;die();
3230 4311 }
3231 -}
4312 +
4313 + /**
4314 + * Handle the AJAX request to initiate a multipart upload
4315 + *
4316 + * @since 3.0.1
4317 + */
4318 + public function handle_initiate_multipart_upload() {
4319 + // Security check - only admins can do this
4320 + if (!current_user_can('administrator')) {
4321 + wp_send_json_error('Unauthorized access');
4322 + return;
4323 + }
4324 +
4325 + // Get file details from request
4326 + $file_name = sanitize_text_field($_POST['file_name']);
4327 + $file_size = intval($_POST['file_size']);
4328 + $content_type = sanitize_text_field($_POST['content_type']);
4329 + $num_parts = intval($_POST['parts']);
4330 +
4331 + if (empty($file_name) || $file_size <= 0 || $num_parts <= 0) {
4332 + wp_send_json_error('Invalid file information');
4333 + return;
4334 + }
4335 +
4336 + // Prepare a clean filename (similar to the standard upload process)
4337 + $file_name_array = explode(".", $file_name);
4338 + $file_extension = $file_name_array[count($file_name_array) - 1];
4339 + $temp_file_name = $file_name_array[0];
4340 + $temp_file_name = str_replace(' ', '_', $temp_file_name);
4341 + $temp_file_name = preg_replace('/\W/', '', $temp_file_name);
4342 + $clean_file_name = $temp_file_name . '.' . $file_extension;
4343 +
4344 + // Make API call to initiate multipart upload
4345 + $url = 'video/upload';
4346 + $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
4347 +
4348 + if (!$access_token) {
4349 + wp_send_json_error('Not connected to WPStream service');
4350 + return;
4351 + }
4352 +
4353 + $api_params = array(
4354 + 'access_token' => $access_token,
4355 + 'size' => $file_size,
4356 + 'name' => $clean_file_name,
4357 + 'content_type' => $content_type,
4358 + 'parts' => $num_parts
4359 + );
4360 +
4361 + $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true);
4362 + $response_data = json_decode($response, true);
4363 +
4364 + if (!isset($response_data['success']) || $response_data['success'] !== true) {
4365 + $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to initiate multipart upload';
4366 + wp_send_json_error($error_message);
4367 + return;
4368 + }
4369 +
4370 + // Return the upload ID and pre-signed URLs for each part
4371 + wp_send_json_success($response_data);
4372 + }
4373 +
4374 + /**
4375 + * Handle the AJAX request to complete a multipart upload
4376 + *
4377 + * @since 3.0.1
4378 + */
4379 + public function handle_complete_multipart_upload() {
4380 + // Security check - only admins can do this
4381 + if (!current_user_can('administrator')) {
4382 + wp_send_json_error('Unauthorized access');
4383 + return;
4384 + }
4385 +
4386 + // Get completion details
4387 + $parts = json_decode(stripslashes($_POST['parts']), true);
4388 + $file_name = sanitize_text_field($_POST['file_name']);
4389 + $handle = sanitize_text_field($_POST['handle']);
4390 +
4391 + if (empty($parts) || !is_numeric($parts) || empty($file_name)) {
4392 + wp_send_json_error('Invalid completion information');
4393 + return;
4394 + }
4395 +
4396 + // Make API call to complete the multipart upload
4397 + $url = 'video/upload';
4398 + $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
4399 +
4400 + if (!$access_token) {
4401 + wp_send_json_error('Not connected to WPStream service');
4402 + return;
4403 + }
4404 +
4405 + $api_params = array(
4406 + 'access_token' => $access_token,
4407 + 'parts' => $parts,
4408 + 'name' => $file_name,
4409 + 'handle' => $handle,
4410 + 'action' => 'complete'
4411 + );
4412 +
4413 + $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true);
4414 + $response_data = json_decode($response, true);
4415 +
4416 + if (!isset($response_data['success']) || $response_data['success'] !== true) {
4417 + $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to complete multipart upload';
4418 + wp_send_json_error($error_message);
4419 + return;
4420 + }
4421 +
4422 + // Return success
4423 + wp_send_json_success();
4424 + }
4425 +
4426 + public function wpstream_settings_tab_update_plugin() {
4427 + if ( !current_user_can( 'update_plugins' ) ) {
4428 + wp_send_json_error( __( 'Not enough permissions to make this change', 'wpstream' ) );
4429 + }
4430 +
4431 + include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
4432 + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
4433 + include_once ABSPATH . 'wp-admin/includes/file.php';
4434 +
4435 + $credentials = request_filesystem_credentials('');
4436 + if ( !WP_Filesystem( $credentials ) ) {
4437 + wp_send_json_error( __( 'Failed to connect to the filesystem', 'wpstream' ) );
4438 + }
4439 +
4440 + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
4441 + $plugin_path = plugin_basename( WPSTREAM_PLUGIN_PATH . 'wpstream.php' );
4442 + $result = $upgrader->upgrade( $plugin_path );
4443 + activate_plugin( $plugin_path );
4444 +
4445 + if ( is_wp_error( $result ) ) {
4446 + wp_send_json_error( __( 'Update failed due to', 'wpstream' ) . $result->get_error_message() );
4447 + }
4448 +
4449 + wp_send_json_success();
4450 + }
4451 +}