PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8.2
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8.2
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
← All changes | admin/class-wpstream-admin.php +1392 -423 4.4.94.8.2 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,168 @@
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'),
182 209 ));
183 210
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);
211 + wp_enqueue_script('wpstream-recordings-videos-list', plugin_dir_url( __FILE__ ) .'js/recordings_videos_list.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
212 + wp_localize_script( 'wpstream-recordings-videos-list', 'wpstream_recordings_videos_list_vars',
213 + array(
214 + 'delete_file' => esc_html__('Delete file', 'wpstream'),
215 + 'download' => esc_html__( 'Download', 'wpstream'),
216 + 'download_available' => esc_html__( 'Click to download! The url will work for the next 20 minutes!', 'wpstream'),
217 + 'add_free_video_url' => esc_url( admin_url( 'post-new.php?post_type=wpstream_product_vod') . '&new_video_name=' ),
218 + 'create_ftv_vod' => esc_html__( 'Create new Free-To-View VOD from this recording' , 'wpstream' ),
219 + 'woocommerce_exists' => class_exists( 'WooCommerce' ),
220 + 'add_paid_video_url' => esc_url( admin_url( 'post-new.php?post_type=product').'&new_video_name=' ),
221 + 'create_ptv_vod' => esc_html__( 'Create new Pay-Per-View VOD from this recording' , 'wpstream' ),
222 + )
223 + );
224 +
225 + $modified_start_streaming_file_time = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'public/js/start_streaming.js' ) );
226 + wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'public/js/start_streaming.js', array(), $modified_start_streaming_file_time, true);
187 227 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
188 228 array(
189 229 'admin_url' => get_admin_url(),
190 230 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
@@ -199,8 +239,9 @@
199 239 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'),
200 240 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'),
201 241 'start_streaming' => esc_html__('TURN ON','wpstream'),
202 242 'stop_streaming' => esc_html__('TURN OFF','wpstream'),
243 + 'failed_fetching' => esc_html__('Failed to get channel info. Please try again.','wpstream'),
203 244 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'),
204 245 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'),
205 246 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'),
206 247 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'),
@@ -209,13 +250,39 @@
209 250 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'),
210 251 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'),
211 252 'channel_on' => esc_html__('Channel is ON','wpstream'),
212 253 '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')
254 + 'turn_off_confirm' => esc_html__(
255 + 'ARE YOU SURE you\'d like to TURN OFF the channel now? ' . PHP_EOL . PHP_EOL .
256 + '- Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).' . PHP_EOL .
257 + '- Manual TURN OFF is only useful if you require to change the channel settings immediately.' . PHP_EOL .
258 + '- If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.',
259 + 'wpstream'
260 + ),
261 + 'basic_streaming_warning' => esc_html__(
262 + 'Your account is now in BASIC STREAMING mode.' . PHP_EOL . PHP_EOL .
263 + 'Instead of offloading to the WpStream Cloud, this mode relies on WordPress and hosting resources to process and deliver video. In some WP environments, streaming may be unreliable.' . PHP_EOL .
264 + 'Certain features, such as recording, viewer count, browser broadcasting, and content protection are unavailable.' . PHP_EOL . PHP_EOL .
265 + '- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL .
266 + '- Otherwise, choose OK to start your channel with these limitations.' . PHP_EOL . PHP_EOL .
267 + 'ARE YOU SURE you want to continue with Basic Streaming?',
268 + 'wpstream'
269 + ),
270 + 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
214 271 ));
215 272
273 + wp_enqueue_script('wpstream-settings', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream_settings.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
274 + wp_localize_script('wpstream-settings', 'wpstream_settings_vars', array(
275 + 'error_message' => esc_html__( 'Failed to save settings. Please try again.', 'wpstream'),
276 + 'choose_image_text' => esc_html__( 'Choose Logo Image', 'wpstream'),
277 + 'select_image_text' => esc_html__( 'Select Image', 'wpstream'),
278 + 'update_successful' => esc_html__( 'Update Successful.', 'wpstream'),
279 + 'update_failed' => esc_html__( 'Something went wrong. Try again.', 'wpstream'),
280 + 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
281 + ));
216 282
217 - wp_enqueue_script('wpstream-on-boarding-js', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
283 +
284 + wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',array(), WPSTREAM_PLUGIN_VERSION, true);
218 285 wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars',
219 286 array(
220 287 'admin_url' => get_admin_url(),
221 288 'plugin_url' => get_dashboard_url().'/plugins.php',
@@ -220,18 +287,41 @@
220 287 'admin_url' => get_admin_url(),
221 288 'plugin_url' => get_dashboard_url().'/plugins.php',
222 289 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings'
223 290
224 - ));
291 + ));
292 +
293 +// wp_enqueue_style(
294 +// 'wpstream-broadcaster-css',
295 +// plugin_dir_url(__FILE__) . 'public/css/broadcaster.css',
296 +// array(),
297 +// filemtime(plugin_dir_path(__FILE__) . 'public/css/broadcaster.css' ),
298 +// );
299 +//
300 +// wp_enqueue_script(
301 +// 'wpstream-broadcaster',
302 +// plugin_dir_url(__FILE__) . 'public/js/broadcaster.js',
303 +// array('jquery'),
304 +// WPSTREAM_PLUGIN_VERSION,
305 +// true
306 +// );
307 +
308 + // Add localized variables for broadcaster
309 + wp_localize_script('wpstream-broadcaster', 'wpstream_broadcaster_vars', array(
310 + 'ajax_url' => admin_url('admin-ajax.php'),
311 + 'nonce' => wp_create_nonce('wpstream_broadcaster_nonce'),
312 + 'plugin_url' => plugin_dir_url(__FILE__),
313 +
314 + ));
225 315
226 316 }
227 317
228 318
229 319 /**
230 - * Add Plugin Administation menu
231 - *
232 - * @since 3.0.1
233 - */
320 + * Add Plugin Administation menu
321 + *
322 + * @since 3.0.1
323 + */
234 324
235 325 public function wpstream_manage_admin_menu() {
236 326
237 327 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 );
@@ -291,9 +381,9 @@
291 381
292 382 $event_list = new WP_Query($args);
293 383 global $live_event_for_user;
294 384 $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();
385 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_new_general_set');
296 386
297 387 $this->main->show_user_data($pack_details);
298 388 if( $event_list->have_posts()){
299 389
@@ -331,8 +421,14 @@
331 421
332 422
333 423 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
334 424 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
425 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_new_general_set');
426 + if( isset($pack_details['available_data_mb'])){
427 + if ($pack_details['available_data_mb'] <= 0){
428 + print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
429 + }
430 + }
335 431 $current_user = wp_get_current_user();
336 432 $allowded_html = array();
337 433 $userID = $current_user->ID;
338 434 $user_live_streams = get_user_meta($userID,'live_shows');
@@ -513,13 +609,17 @@
513 609
514 610 if( $live_event_for_user=='' && $is_front=='front' ){
515 611 $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
516 612 }
517 - $channel_status = esc_html__('Channel is OFF','wpstream');
613 + $channel_status = '<div class="spinner" style="visibility: visible"></div>';
614 + $button_status = '<div class="spinner" style="visibility: visible"></div>';
518 615 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
519 616 $pending_streaming_class = 'pending_trigger';
520 617 $live_data_url = get_post_meta($the_id,'qos_url',true);
521 618 // $channel_status = esc_html__('Channel is on','wpstream');
619 + } else {
620 + $channel_status = esc_html__('Channel is OFF','wpstream');
621 + $button_status = esc_html__('TURN ON','wpstream');
522 622 }
523 623
524 624 $server_id = get_post_meta($the_id,'server_id',true);
525 625 $obs_uri = get_post_meta($the_id,'obs_uri',true);
@@ -541,13 +641,13 @@
541 641 /* print '***</br>'.get_post_meta($the_id,'obs_uri',true) .'***</br>'.
542 642 get_post_meta($the_id,'obs_stream',true).'***</br>'.
543 643 get_post_meta($the_id,'broadcast_url',true);
544 644 */
545 - print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
645 + print '<div class="wpstream_channel_item_id">'.esc_html( '#ID' ).' '.$the_id.'</div>';
546 646 print '</div>';
547 647
548 648
549 - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream');
649 + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > ' . $button_status;
550 650 print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
551 651 print '</div>';
552 652
553 653 print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
@@ -594,8 +694,186 @@
594 694 print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
595 695 if($is_front==''){
596 696 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 697
698 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('
699 + Turn OFF the channel to change its settings.','wpestream').'</div>';
700 + print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
701 +
702 + print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
703 + <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"/>
704 + </svg>
705 + </div>';
706 +
707 +
708 + 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.'"">';
709 + print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
710 + print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
711 + <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"/>
712 + </svg>';
713 + print '</a>';
714 + }
715 +
716 + print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
717 + print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
718 + print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
719 + <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"/>
720 + <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"/>
721 + </svg>';
722 + print '</a>';
723 +
724 +
725 + 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.'"">';
726 + print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
727 + print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
728 + <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"/>
729 + </svg>';
730 + print '</div>';
731 + print '</div>';
732 +
733 + $this->wpstream_display_modal_seetings($the_id);
734 + $this->wpstream_display_modal_share($the_id);
735 + $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
736 +
737 + print '</div>';
738 +
739 + }
740 +
741 +
742 +
743 +
744 + /**
745 + * Shows event unit card in admin - theme version
746 + *
747 + * @since 3.0.1
748 + */
749 + public function wpstream_live_stream_unit_for_theme($the_id,$is_front=''){
750 + global $live_event_for_user;
751 + global $wpstream_plugin;
752 + $current_user = wp_get_current_user();
753 +
754 + if( !current_user_can('administrator')){
755 + if($is_front=='' ){
756 + print '<div class="event_list_unit">';
757 + esc_html_e('You are not allowed to broadcast.','wpstream');
758 + print '</div>';
759 + return;
760 + }
761 +
762 + }
763 +
764 + if( !$this->main->wpstream_check_user_can_stream() ){
765 + print '<div class="event_list_unit">';
766 + esc_html_e('You are not allowed to broadcast','wpstream');
767 + print '</div>';
768 + return;
769 + }
770 +
771 +
772 + $live_class='';
773 + if(isset($live_event_for_user[$the_id])) {
774 + $live_class=" wpstream_show_started";
775 + }
776 +
777 +
778 + if(has_post_thumbnail($the_id)){
779 + $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
780 + }else{
781 + $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
782 + }
783 +
784 + $pending_streaming_class = 'hide_stream_data';
785 + $external_software_streaming_class = '';
786 + $obs_uri = '';
787 + $obs_stream = '';
788 + $live_data_url = '';
789 +
790 + if( $live_event_for_user=='' && $is_front=='front' ){
791 + $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
792 + }
793 +
794 + $spinner_url = admin_url('images/spinner-2x.gif');
795 + $button_status = '<div class="spinner" style="background-image: url(' . $spinner_url . ')"></div>';
796 + $channel_status = '';
797 + if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
798 + $pending_streaming_class = 'pending_trigger';
799 + $live_data_url = get_post_meta($the_id,'qos_url',true);
800 + // $channel_status = esc_html__('Channel is on','wpstream');
801 + } else {
802 + $channel_status = esc_html__('Channel is OFF','wpstream');
803 + $button_status = esc_html__('TURN ON', 'wpstream');
804 + }
805 +
806 + $server_id = get_post_meta($the_id,'server_id',true);
807 + $obs_uri = get_post_meta($the_id,'obs_uri',true);
808 + $obs_stream = get_post_meta($the_id,'obs_stream',true);
809 + $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
810 + $rtmp_ip_uri = '';
811 +
812 + 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.'"">';
813 +
814 + print '<div class="wpstream_channel_status" style="' . ($channel_status ? '' : 'display: none') . '">'.$channel_status.'</div>';
815 +
816 + print '<div class="server_notification"></div>';
817 +
818 + print '<div class="wpstream_theme_event_thumb_wrapper">';
819 + print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
820 + print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10);
821 + print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
822 + print '</div>';
823 + print '</div>';
824 +
825 + print '<div class="wpstream_theme_control_bar_wrapper">';
826 +
827 +
828 + print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
829 +
830 + 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.'"">';
831 +
832 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
833 + print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
834 +
835 + print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
836 + <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"/>
837 + </svg>';
838 + esc_html_e('Webcam','wpstream');
839 + print '</div>';
840 +
841 +
842 + 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.'"">';
843 +
844 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
845 + print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
846 +
847 + print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
848 + <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"/>
849 + <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"/>
850 + </svg>';
851 + esc_html_e('External App','wpstream');
852 + print '</div>';
853 +
854 +
855 +
856 +
857 + 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.'" >';
858 +
859 + print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
860 + print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
861 +
862 + print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
863 + <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"/>
864 + <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"/>
865 + <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"/>
866 + <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"/>
867 + </svg>';
868 + esc_html_e('Statistics','wpstream');
869 + print '</a>';
870 + print '</div>';
871 +
872 + print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
873 + if($is_front==''){
874 + 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').'">';
875 +
598 876 print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
599 877 print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
600 878
601 879 print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -617,8 +895,9 @@
617 895 print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
618 896 <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 897 <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 898 </svg>';
899 + esc_html_e('View','wpstream');
621 900 print '</a>';
622 901
623 902
624 903 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 +904,18 @@
625 904 print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
626 905 print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
627 906 <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 907 </svg>';
908 + esc_html_e('Share','wpstream');
629 909 print '</div>';
630 910 print '</div>';
631 911
632 -
912 +
913 + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '. $button_status;
914 + print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
915 + print '</div>';
916 +
917 + print '</div>';
633 918
634 919
635 920
636 921
@@ -642,9 +927,8 @@
642 927
643 928 }
644 929
645 930
646 -
647 931 /*
648 932 *
649 933 * Close modal button
650 934 *
@@ -653,30 +937,60 @@
653 937 public function wpstream_close_modal_button(){
654 938 print '<div class="wpstream_close_modal"></div>';
655 939 }
656 940
941 + public function wpstream_local_event_options_toggle() {
942 + $use_global_event_options = get_post_meta(get_the_ID(), 'use_global_event_options', true );
943 + $local_event_options = get_post_meta( get_the_ID(), 'local_event_options', true );
944 + $use_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
945 + ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
946 +
947 + print '<div class="wpstream_local_event_options_toggle_wrapper">';
948 + print '<div class="wpstream_local_event_options_toggle_info">';
949 + print '<label for="local_event_options_enabled" class="wpstream_local_event_options_label">'.esc_html__('Edit settings for this channel','wpstream').'</label>';
950 + print '<span>'.sprintf(esc_html__('When is OFF, the settings from %s will be applied','wpstream'), '<a href="' . admin_url('admin.php?page=wpstream_settings&tab=default_options') . '" target="_blank">'.esc_html__('Default Channel Settings','wpstream').'</a>').'</span>';
951 + print '</div>';
952 + print '<label class="wpstream_switch">';
953 + print '<input id="local_event_options_enabled" type="checkbox" class="wpstream_local_event_options_toggle" ' . ($use_local_event_options_enabled === true ? 'checked' : '') . '>';
954 + print '<span class="wpstream_slider round"></span>';
955 + print '</label>';
956 + print '</div>';
957 + }
958 +
657 959 /*
658 960 *
659 961 * Display modal settings
660 962 *
661 963 */
662 -
964 +
663 965 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>';
966 + print '<div class="wpstream_modal_form wpestate_settings_modal">';
967 + $this->wpstream_close_modal_button();
968 + print '<h3>';
667 969 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') ;
970 + print '</h3>';
971 +
972 + $this->wpstream_local_event_options_toggle();
973 +
974 + $local_event_options = get_post_meta($the_id,'local_event_options',true);
975 + $use_global_event_options = get_post_meta($the_id, 'use_global_event_options',true);
976 + $is_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
977 + ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
978 +
979 + if( !$is_local_event_options_enabled ) {
980 + $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
672 981 }
673 982
674 983 $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt');
675 -
984 +
676 985 print '<div class="wpstream_event_streaming_local">';
677 - $this->user_streaming_global_channel_options('',$local_event_options, $local_array_exclude);
678 - print '</div>';
986 + $this->user_streaming_global_channel_options(
987 + '',
988 + $local_event_options,
989 + $local_array_exclude,
990 + !$is_local_event_options_enabled,
991 + );
992 + print '</div>';
679 993 print '</div>';
680 994 }
681 995
682 996
@@ -758,9 +1072,9 @@
758 1072 <li>1. Click Settings in the OBS Window and then Select Stream.</li>
759 1073 <li>2. Choose Custom Streaming Server in the Stream Type dropdown menu.</li>
760 1074 <li>3. In the URL box, type/paste your Server.</li>
761 1075 <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>';
1076 + <li>5. Save changes.Close the Settings window and click on the "Start Streaming" button in the main window of OBS.</li></ul>';
763 1077
764 1078 print '</div>';
765 1079
766 1080
@@ -866,9 +1180,9 @@
866 1180 <li>1. Click Broadcast in the XSplit Window and then click "Set up a new output".</li>
867 1181 <li>2. Choose Custom RTMP in the Set up a new output dropdown menu.</li>
868 1182 <li>3. In the URL box, type/paste your RTMP Url.</li>
869 1183 <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>';
1184 + <li>5. Save changes and click on the "Stream" button in the main window.</li></ul>';
871 1185 print '</div>';
872 1186
873 1187 print '</div>';
874 1188 }
@@ -992,27 +1306,36 @@
992 1306
993 1307
994 1308
995 1309 /*
996 - * Set Settings
997 - *
998 - *
999 - */
1310 + * Set Settings
1311 + *
1312 + *
1313 + */
1000 1314
1001 1315 public function wpstream_settings(){
1316 +
1317 + if( !current_user_can('administrator') ){
1318 + die('Only for administrators');
1319 + }
1320 +
1002 1321
1003 - if($_SERVER['REQUEST_METHOD'] === 'POST'){
1322 + if($_SERVER['REQUEST_METHOD'] === 'POST'){
1323 + if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){
1324 + die('Security check');
1325 + }
1326 +
1004 1327 $allowed_html = array();
1005 1328 $exclude_array = array();
1006 1329 $allowed_html = array();
1007 1330
1008 -
1009 -
1331 +
1332 +
1010 1333 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
1011 1334 update_option( sanitize_key('wpstream_stream_role'), '' );
1012 1335 }
1013 -
1014 - foreach($_POST as $variable=>$value){
1336 +
1337 + foreach($_POST as $variable=>$value){
1015 1338 if ($variable!='submit'){
1016 1339 if (!in_array($variable, $exclude_array) ){
1017 1340 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
1018 1341 }
@@ -1020,9 +1343,9 @@
1020 1343 if($variable=='stream_role'){
1021 1344 update_option( sanitize_key('wpstream_stream_role'), $value );
1022 1345 }
1023 1346
1024 - }
1347 + }
1025 1348 }
1026 1349
1027 1350
1028 1351 if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){
@@ -1037,15 +1360,15 @@
1037 1360 }
1038 1361 update_option('wpstream_user_streaming_global_channel_options',$event_settings);
1039 1362 }
1040 1363
1041 -
1042 -
1043 -
1364 +
1365 +
1366 +
1044 1367 // reset permalinkgs
1045 - global $wp_rewrite;
1046 -
1047 - update_option( "rewrite_rules", FALSE );
1368 + global $wp_rewrite;
1369 +
1370 + update_option( "rewrite_rules", FALSE );
1048 1371 $wp_rewrite->flush_rules( true );
1049 1372
1050 1373 }
1051 1374
@@ -1149,10 +1472,60 @@
1149 1472 'label' => esc_html__('You are not live message','wpstream'),
1150 1473 'name' => 'you_are_not_live',
1151 1474 'type' => 'text',
1152 1475 'details' => esc_html__('This message will be displayed in player.','wpstream'),
1153 - 'default' => esc_html__('We are not live at this moment. Please check back later.','wpstream'),
1476 + 'default' => esc_html__('We are not live at this moment','wpstream'),
1154 1477 ),
1478 +
1479 + 14 => array(
1480 + 'tab' => 'general_options',
1481 + 'label' => esc_html__('Video player theme','wpstream'),
1482 + 'name' => 'video_player_theme',
1483 + 'type' => 'select',
1484 + 'select_values'=>array(
1485 + 'default' => esc_html__('Default','wpstream'),
1486 + 'city' => esc_html__('City','wpstream'),
1487 + 'forest' => esc_html__('Forest','wpstream'),
1488 + 'fantasy' => esc_html__('Fantasy','wpstream'),
1489 + 'sea' => esc_html__('Sea','wpstream'),
1490 + ),
1491 + 'details' => esc_html__('Choose the video player theme to have a different look for the player.','wpstream'),
1492 + ),
1493 + 'wpstream_player_logo' => array(
1494 + 'tab' => 'general_options',
1495 + 'name' => 'player_logo',
1496 + 'label' => esc_html__('Logo for the video player','wpstream'),
1497 + 'type' => 'image',
1498 + 'details' => esc_html__('This logo will be displayed on the the video player.','wpstream'),
1499 + 'default' => '',
1500 + 'image_size' => 'thumbnail',
1501 + ),
1502 + // hide the video player logo opacity for now
1503 +// 'wpstream_player_logo_opacity' => array(
1504 +// 'tab' => 'general_options',
1505 +// 'name' => 'player_logo_opacity',
1506 +// 'label' => esc_html__('Opacity of the video player logo','wpstream'),
1507 +// 'type' => 'range',
1508 +// 'details' => esc_html__('Set the opacity of the logo','wpstream'),
1509 +// 'default' => '',
1510 +// 'image_size' => 'thumbnail',
1511 +// ),
1512 + 'wpsteram_player_logo_position' => array(
1513 + 'tab' => 'general_options',
1514 + 'name' => 'player_logo_position',
1515 + 'label' => esc_html__('Position of the video player logo','wpstream'),
1516 + 'type' => 'select',
1517 + 'select_values'=>array(
1518 + 'top-left' => esc_html__('Top Left','wpstream'),
1519 + 'top-right' => esc_html__('Top Right','wpstream'),
1520 + 'bottom-left' => esc_html__('Bottom Left','wpstream'),
1521 + 'bottom-right' => esc_html__('Bottom Right','wpstream'),
1522 + ),
1523 + 'details' => esc_html__('Choose the position of the logo on the video player.','wpstream'),
1524 + 'default' => '',
1525 + ),
1526 +
1527 +
1155 1528
1156 1529 99 => array(
1157 1530 'tab' => 'default_options',
1158 1531 'label' => esc_html__('Events Options ','wpstream'),
@@ -1159,8 +1532,61 @@
1159 1532 'name' => 'user_streaming_global_channel_options',
1160 1533 'type' => 'user_streaming_global_channel_options',
1161 1534 'details' => esc_html__('Global Options for live events.','wpstream'),
1162 1535 ),
1536 +
1537 + 100 => array(
1538 + 'tab' => 'default_options_vod',
1539 + 'label' => esc_html__('Autoplay','wpstream'),
1540 + 'name' => 'vod_autoplay',
1541 + 'type' => 'slidertoogle',
1542 + 'details' => esc_html__('If enabled, video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
1543 + ),
1544 +
1545 +
1546 + 101 => array(
1547 + 'tab' => 'default_options_vod',
1548 + 'label' => esc_html__('Start Muted','wpstream'),
1549 + 'name' => 'vod_start_muted',
1550 + 'type' => 'slidertoogle',
1551 + 'details' => esc_html__('If enabled, video will start muted. This may increase the rate of autoplay in some browsers.','wpstream'),
1552 + ),
1553 +
1554 + 102 => array(
1555 + 'tab' => 'default_options_vod',
1556 + 'label' => esc_html__('Lock To Website','wpstream'),
1557 + 'name' => 'vod_domain_lock',
1558 + 'type' => 'slidertoogle',
1559 + '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') ),
1560 + ),
1561 +
1562 + 103 => array(
1563 + 'tab' => 'default_options_vod',
1564 + 'label' => esc_html__('Encrypt Video','wpstream'),
1565 + 'name' => 'vod_encrypt',
1566 + 'type' => 'slidertoogle',
1567 + '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'),
1568 + ),
1569 +
1570 + /* 'vod_domain_lock' =>array(
1571 + 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'),
1572 + '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') ),
1573 + 'defaults' => 'no',
1574 + ),
1575 + 'vod_encrypt' =>array(
1576 + 'name' => esc_html__('Encrypt Video on Demand','wpstream'),
1577 + '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'),
1578 + 'defaults' => 'no',
1579 + ),*/
1580 +
1581 + 104 => array(
1582 + 'tab' => 'support_tab',
1583 + 'label' => esc_html__('Logs','wpstream'),
1584 + 'name' => 'logs',
1585 + 'type' => 'logs_table',
1586 + 'details' => esc_html__('This is the error log of the plugin.','wpstream'),
1587 + )
1588 +
1163 1589 );
1164 1590
1165 1591 $active_tab = 'general_options';
1166 1592 if( isset( $_GET[ 'tab' ] ) ) {
@@ -1172,15 +1598,16 @@
1172 1598 <h1>'.__('WpStream Settings','wpstream').'</h1>
1173 1599 <form method="post" action="" >';
1174 1600
1175 1601 print '<h2 class="nav-tab-wrapper">
1176 - <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">General Options</a>
1177 - <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">Default Channel Settings</a>
1178 - <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : ''; echo '">Subscription Options</a>
1179 - <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">Customize Messages</a>
1180 -
1602 + <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>
1603 + <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>
1604 + <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>
1605 + <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>
1606 + <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Customize Messages','wpstream').'</a>
1607 + <a href="?page=wpstream_settings&tab=support_tab" class="nav-tab '; echo $active_tab == 'support_tab' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Support','wpstream').'</a>
1181 1608 </h2>';
1182 -
1609 + $help_link='';
1183 1610 print '<div class="wpstream_option_wrapper">';
1184 1611
1185 1612 switch ($active_tab) {
1186 1613 case 'general_options':
@@ -1186,10 +1613,13 @@
1186 1613 case 'general_options':
1187 1614 $help_link='https://docs.wpstream.net/docs/general-settings/';
1188 1615 break;
1189 1616 case 'default_options':
1190 - $help_link='https://docs.wpstream.net/docs/default-settings/';
1617 + $help_link='https://docs.wpstream.net/docs/default-channel-settings/';
1191 1618 break;
1619 + case 'default_options_vod':
1620 + $help_link='https://docs.wpstream.net/docs/vod-settings/';
1621 + break;
1192 1622 case 'subscription_options':
1193 1623 $help_link='https://docs.wpstream.net/docs/subscription-options/';
1194 1624 break;
1195 1625 case 'messages_options':
@@ -1196,33 +1626,35 @@
1196 1626 $help_link='https://docs.wpstream.net/docs/customize-messages/';
1197 1627 break;
1198 1628 }
1199 1629
1200 - print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >Video Help</a></div>';
1201 -
1630 + print '<div class="options_wrapper">';
1202 1631 foreach ($wpstream_settings_array as $key=>$option){
1203 1632 if($option['tab']!=$active_tab){
1204 1633 continue;
1205 1634 }
1206 -
1635 +
1636 + if ( $option['type']=='user_streaming_global_channel_options' ) {
1637 + print '<div class="default-channel-settings-info">';
1638 + print esc_html__( 'These settings will apply to newly created channels; existing channels will not change settings if you change them here', 'wpstream');
1639 + print '</div>';
1640 +
1641 + }
1207 1642 print '<div class="wpstream_option">';
1208 1643 $options_value = get_option('wpstream_'.$option['name']) ;
1209 1644
1210 1645
1211 - if($option['type']=='user_roles'){
1212 -
1646 + switch( $option['type'] ) {
1647 + case 'user_roles':
1213 1648 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1214 1649 print $this->wpstream_select_user_roles($option['name'],$options_value);
1215 1650 print '<div class="settings_details">'.$option['details'].'</div>';
1216 -
1217 - }else if($option['type']=='user_streaming_global_channel_options'){
1218 -
1651 + break;
1652 + case 'user_streaming_global_channel_options':
1219 1653 $exclude_array=array();
1220 1654 $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array);
1221 -
1222 -
1223 - }else if($option['type']=='text'){
1224 -
1655 + break;
1656 + case 'text':
1225 1657 if($options_value==''){
1226 1658 $options_value='';
1227 1659 if(isset($option['default'])){
1228 1660 $options_value=$option['default'];
@@ -1227,15 +1659,14 @@
1227 1659 if(isset($option['default'])){
1228 1660 $options_value=$option['default'];
1229 1661 }
1230 1662 }
1231 -
1663 +
1232 1664 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1233 - print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1665 + print '<input class="wpstream-text-input-setting" id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1234 1666 print '<div class="settings_details">'.$option['details'].'</div>';
1235 -
1236 - } else if($option['type']=='select'){
1237 -
1667 + break;
1668 + case 'select':
1238 1669 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1239 1670 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
1240 1671 foreach($option['select_values'] as $key=>$value){
1241 1672 print '<option value="'.$key.'" ';
@@ -1246,38 +1677,359 @@
1246 1677 }
1247 1678 print '</select>';
1248 1679 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
1249 1680 print '<div class="settings_details">'.$option['details'].'</div>';
1250 -
1251 - } else if($option['type']=='slidertoogle'){
1681 + break;
1682 + case 'slidertoogle':
1252 1683 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1684 + print '<div style="display: flex; gap: 25px; justify-content: space-between;">';
1685 + print '<div class="settings_details">'.$option['details'].'</div>';
1253 1686 print '<label class="wpstream_switch">
1254 1687 <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" >
1255 1688 <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" ';
1256 -
1257 - if( intval($options_value) !==0 ){
1258 - print ' checked ';
1259 - }
1260 -
1689 + if( intval($options_value) !==0 ){
1690 + print ' checked ';
1691 + }
1692 + print '> <span class="wpstream_slider round"></span>';
1693 + print '</label>';
1694 + print '</div>';
1695 + break;
1696 + case 'image':
1697 + $image_url = $options_value ? esc_url($options_value) : '';
1698 + $has_image = !empty($image_url);
1261 1699
1700 + print '<label for="' . $option['name'] . '">' . $option['label'] . '</label>';
1701 + print '<div class="wpstream-image-upload-wrapper">';
1702 + print '<input type="hidden" id="' . $option['name'] . '" name="' . $option['name'] . '" value="' . $image_url . '" />';
1262 1703
1263 - print '> <span class="wpstream_slider round"></span>';
1264 - print '</label>';
1265 - print '<div class="settings_details">'.$option['details'].'</div>';
1266 - }
1704 + // Preview area
1705 + print '<div class="wpstream-image-preview" style="' . (!$has_image ? 'display:none;' : '') . '">';
1706 + print '<img src="' . $image_url . '" alt="Preview" />';
1707 + print '</div>';
1708 +
1709 + // Upload/remove buttons
1710 + print '<div class="wpstream-image-upload-buttons">';
1711 + print '<button type="button" class="wpstream-upload-image button">' . esc_html__('Upload Image', 'wpstream') . '</button>';
1712 + print '<button type="button" class="wpstream-remove-image button" style="' . (!$has_image ? 'display:none;' : '') . '">' . esc_html__('Remove Image', 'wpstream') . '</button>';
1713 + print '</div>';
1714 +
1715 + print '</div>';
1716 + print '<div class="settings_details">' . $option['details'] . '</div>';
1717 + break;
1718 + case 'range':
1719 + print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1720 + 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).'" />';
1721 + print '<div class="settings_details">'.$option['details'].'</div>';
1722 + break;
1723 + case 'logs_table':
1724 + $this->wpstream_support_tab();
1725 + break;
1726 + }
1267 1727 print '</div>';
1268 1728 }
1729 + print '</div>'; // options wrapper
1730 + if($help_link!==''){
1731 + print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >'.esc_html__('Video Help','wpstream').'</a></div>';
1732 + }
1269 1733 print '</div>';
1270 1734
1271 1735
1736 + if ( $active_tab != 'support_tab') {
1737 + print '<div class="wpstream-save-settings">';
1272 1738 print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1739 + print '<div class="spinner"></div>';
1740 + print '</div>';
1741 + }
1273 1742
1274 -
1743 + print '<input id="wpstream-settings-nonce" name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> ';
1275 1744 print '</form>';
1276 1745 print '</div>';
1277 1746
1278 1747 }
1279 -
1748 +
1749 + /**
1750 + * Get system information for support tab
1751 + *
1752 + * @return array System information
1753 + */
1754 + private function get_system_info() {
1755 + global $wp_version;
1756 +
1757 + $php_version = phpversion();
1758 + $wp_version_info = $wp_version;
1759 + $site_debug_mode = (defined('WP_DEBUG') && WP_DEBUG);
1760 + $wp_memory_limit = WP_MEMORY_LIMIT;
1761 +
1762 + $wpstream_version = WPSTREAM_PLUGIN_VERSION;
1763 + $wpstream_plugin_outdated = false;
1764 +
1765 + // Check if plugin is outdated
1766 + $update_plugins = get_site_transient('update_plugins');
1767 + if (isset($update_plugins->response['plugin/wpstream.php'])) {
1768 + $wpstream_plugin_outdated = true;
1769 + }
1770 +
1771 + // Check API status
1772 + $api_status = false;
1773 + if (method_exists($this->main->wpstream_live_connection, 'wpstream_get_token')) {
1774 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
1775 + $api_status = !empty($token);
1776 + }
1777 +
1778 + return array(
1779 + 'php_version' => $php_version,
1780 + 'wp_version' => $wp_version_info,
1781 + 'site_debug_mode' => $site_debug_mode,
1782 + 'wp_memory_limit' => $wp_memory_limit,
1783 + 'wpstream_version' => $wpstream_version,
1784 + 'wpstream_plugin_outdated' => $wpstream_plugin_outdated,
1785 + 'api_status' => $api_status
1786 + );
1787 + }
1788 +
1789 + /**
1790 + * Render system information HTML
1791 + */
1792 + private function render_system_info() {
1793 + $system_info = $this->get_system_info();
1794 + ?>
1795 +
1796 + <div class="wpstream-system-info">
1797 + <h3><?php esc_html_e('System Information', 'wpstream'); ?></h3>
1798 + <table class="widefat">
1799 + <tbody>
1800 + <tr>
1801 + <td><strong><?php esc_html_e('PHP Version', 'wpstream'); ?></strong></td>
1802 + <td><?php echo esc_html($system_info['php_version']); ?></td>
1803 + <td>
1804 + <?php if (version_compare($system_info['php_version'], '7.4', '<')): ?>
1805 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1806 + <?php esc_html_e('We recommend PHP 7.4 or higher', 'wpstream'); ?>
1807 + <?php else: ?>
1808 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1809 + <?php endif; ?>
1810 + </td>
1811 + </tr>
1812 + <tr>
1813 + <td><strong><?php esc_html_e('WordPress Version', 'wpstream'); ?></strong></td>
1814 + <td><?php echo esc_html($system_info['wp_version']); ?></td>
1815 + <td>
1816 + <?php if (version_compare($system_info['wp_version'], '5.6', '<')): ?>
1817 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1818 + <?php esc_html_e('We recommend WordPress 5.6 or higher', 'wpstream'); ?>
1819 + <?php else: ?>
1820 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1821 + <?php endif; ?>
1822 + </td>
1823 + </tr>
1824 + <tr>
1825 + <td><strong><?php esc_html_e('WP Debug Mode', 'wpstream'); ?></strong></td>
1826 + <td><?php echo $system_info['site_debug_mode'] ? esc_html__('Enabled', 'wpstream') : esc_html__('Disabled', 'wpstream'); ?></td>
1827 + <td>
1828 + <?php if ($system_info['site_debug_mode']): ?>
1829 + <span class="dashicons dashicons-info" style="color: #00a0d2;"></span>
1830 + <?php esc_html_e('Debug mode should be disabled on production sites', 'wpstream'); ?>
1831 + <?php else: ?>
1832 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1833 + <?php endif; ?>
1834 + </td>
1835 + </tr>
1836 + <tr>
1837 + <td><strong><?php esc_html_e('WP Memory Limit', 'wpstream'); ?></strong></td>
1838 + <td><?php echo esc_html($system_info['wp_memory_limit']); ?></td>
1839 + <td>
1840 + <?php
1841 + $memory_limit = wp_convert_hr_to_bytes($system_info['wp_memory_limit']);
1842 + if ($memory_limit < 64 * 1024 * 1024): // 64MB
1843 + ?>
1844 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1845 + <?php esc_html_e('We recommend at least 64MB', 'wpstream'); ?>
1846 + <?php else: ?>
1847 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1848 + <?php endif; ?>
1849 + </td>
1850 + </tr>
1851 + <tr>
1852 + <td><strong><?php esc_html_e('WpStream Version', 'wpstream'); ?></strong></td>
1853 + <td><?php echo esc_html($system_info['wpstream_version']); ?></td>
1854 + <td style="display: flex; align-items: center; gap: 5px;">
1855 + <?php if ($system_info['wpstream_plugin_outdated']): ?>
1856 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1857 + <?php esc_html_e('Update available', 'wpstream'); ?>
1858 + <div class="update-button-wrapper">
1859 + <button class="wpstream-update-plugin-button button button-primary" data-plugin="wpstream/wpstream.php">
1860 + <?php esc_html_e('Update Now', 'wpstream'); ?>
1861 + </button>
1862 + </div>
1863 + <?php else: ?>
1864 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1865 + <?php endif; ?>
1866 + </td>
1867 + </tr>
1868 + <tr>
1869 + <td><strong><?php esc_html_e('API Connection', 'wpstream'); ?></strong></td>
1870 + <td><?php echo $system_info['api_status'] ? esc_html__('Connected', 'wpstream') : esc_html__('Disconnected', 'wpstream'); ?></td>
1871 + <td>
1872 + <?php if (!$system_info['api_status']): ?>
1873 + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1874 + <?php esc_html_e('API connection issue', 'wpstream'); ?>
1875 + <?php else: ?>
1876 + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1877 + <?php endif; ?>
1878 + </td>
1879 + </tr>
1880 + </tbody>
1881 + </table>
1882 + </div>
1883 + <?php
1884 + }
1885 +
1886 + /**
1887 + * Render support tab content
1888 + */
1889 + public function wpstream_support_tab() {
1890 + ?>
1891 + <div class="wrap">
1892 + <div class="wpstream-support-tab-root">
1893 + <?php $this->render_system_info(); ?>
1894 +
1895 + <div class="wpstream-plugins-table-container">
1896 + <h3><?php esc_html_e('Active Plugins', 'wpstream'); ?></h3>
1897 + <table class="widefat wpstream-plugins-table">
1898 + <thead>
1899 + <tr>
1900 + <th><?php esc_html_e('Plugin', 'wpstream'); ?></th>
1901 + <th><?php esc_html_e('Version', 'wpstream'); ?></th>
1902 + </tr>
1903 + </thead>
1904 + <tbody>
1905 + <?php
1906 + $plugins_data = $this->wpstream_get_plugins_data();
1907 + if (empty($plugins_data)) {
1908 + echo '<tr><td colspan="3">' . esc_html__('No WPStream plugins found.', 'wpstream') . '</td></tr>';
1909 + } else {
1910 + foreach ($plugins_data as $plugin) {
1911 + echo '<tr>';
1912 + echo '<td>' . esc_html($plugin['name']) . '</td>';
1913 + echo '<td>';
1914 + echo esc_html($plugin['version']);
1915 + if ( isset($plugin['new_version']) ) {
1916 + echo '<div class="wpstream-tooltip-container">';
1917 + echo '<span class="dashicons dashicons-info wpstream-tooltip" title="' . esc_attr($plugin['new_version']) . '">';
1918 + echo '</span>';
1919 + echo '<div class="wpstream-custom-tooltip">' . sprintf(
1920 + esc_html__('A new version is available: %s', 'wpstream'),
1921 + esc_html($plugin['new_version'])
1922 + ) . '</div>';
1923 + echo '</div>';
1924 + }
1925 + echo '</td>';
1926 + echo '</tr>';
1927 + }
1928 + }
1929 + ?>
1930 + </tbody>
1931 + </table>
1932 + </div>
1933 +
1934 + <div class="wpstream-logs-table-container">
1935 + <h3><?php esc_html_e('Recent Logs', 'wpstream'); ?></h3>
1936 + <table class="widefat wpstream-logs-table">
1937 + <thead>
1938 + <tr>
1939 + <th><?php esc_html_e('Time', 'wpstream'); ?></th>
1940 + <th><?php esc_html_e('Type', 'wpstream'); ?></th>
1941 + <th><?php esc_html_e('Description', 'wpstream'); ?></th>
1942 + </tr>
1943 + </thead>
1944 + <tbody>
1945 + <?php
1946 + $logs = get_option('wpstream_logs');
1947 + if ( !is_array($logs) || empty($logs) ) {
1948 + echo '<tr><td colspan="3">' . esc_html__('No logs found.', 'wpstream') . '</td></tr>';
1949 + } else {
1950 + foreach ($logs as $log) {
1951 + echo '<tr>';
1952 + echo '<td>' . esc_html(date('Y-m-d H:i:s', $log['timestamp'] ) ) . '</td>';
1953 + echo '<td>' . esc_html($log['type']) . '</td>';
1954 + echo '<td>' . esc_html($log['description']) . '</td>';
1955 + echo '</tr>';
1956 + }
1957 + }
1958 + ?>
1959 + </tbody>
1960 + </table>
1961 + </div>
1962 + </div>
1963 + </div>
1964 + <?php
1965 + }
1966 +
1967 + /**
1968 + * Get plugins data.
1969 + *
1970 + * @return array
1971 + */
1972 + public function wpstream_get_plugins_data() {
1973 + if (!function_exists('get_plugins')) {
1974 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
1975 + }
1976 +
1977 + // Get all installed plugins
1978 + $all_plugins = get_plugins();
1979 + $update_data = get_site_transient('update_plugins');
1980 + $all_plugins_info = [];
1981 +
1982 + // We want to get data only for the WpStream plugins
1983 + $wpstream_plugins = array(
1984 + 'WpStream' => array(
1985 + 'path' => 'wpstream/wpstream.php',
1986 + ),
1987 + 'WooCommerce' => array(
1988 + 'path' => 'woocommerce/woocommerce.php',
1989 + ),
1990 + 'Meta Box' => array(
1991 + 'path' => 'meta-box/meta-box.php',
1992 + ),
1993 + 'One Click Demo Import' => array(
1994 + 'path' => 'one-click-demo-import/one-click-demo-import.php',
1995 + ),
1996 + 'Better Messages' => array(
1997 + 'path' => 'bp-better-messages/bp-better-messages.php',
1998 + ),
1999 +
2000 + );
2001 +
2002 + foreach ($all_plugins as $plugin_path => $plugin_data) {
2003 + $is_active = is_plugin_active( $plugin_path );
2004 + $has_update = isset( $update_data->response[$plugin_path] );
2005 +
2006 + $plugin_info = [
2007 + 'name' => $plugin_data['Name'],
2008 + 'version' => $plugin_data['Version'],
2009 + 'path' => $plugin_path,
2010 + 'active' => $is_active ? 'Yes' : 'No',
2011 + 'needs_update' => $has_update ? 'Yes' : 'No'
2012 + ];
2013 +
2014 + if ($has_update) {
2015 + $plugin_info['new_version'] = $update_data->response[$plugin_path]->new_version;
2016 + }
2017 +
2018 + $all_plugins_info[] = $plugin_info;
2019 + }
2020 +
2021 + // Filter out the elements from $all_plugins_info that are not in $wpstream_plugins
2022 + foreach ( $all_plugins_info as $key => $plugin_info ) {
2023 + // compare $plugin_info['path'] against the path property on each $wpstream_plugins element item
2024 + // if the path is not in $wpstream_plugins, unset the element
2025 + if ( !in_array( $plugin_info['path'], array_column( $wpstream_plugins, 'path' ) ) ) {
2026 + unset( $all_plugins_info[$key] );
2027 + }
2028 + }
2029 +
2030 + return $all_plugins_info;
2031 + }
1280 2032
1281 2033
1282 2034 /**
1283 2035 * Set user roles
@@ -1284,17 +2036,19 @@
1284 2036 *
1285 2037 * @since 3.0.1
1286 2038 */
1287 2039
1288 - public function user_streaming_global_channel_options($name,$value,$local_array=''){
2040 + public function user_streaming_global_channel_options( $name, $value, $local_array='', $disabled = false ){
1289 2041
1290 2042 foreach($this->global_event_options as $key=>$option){
1291 2043
1292 2044 if( is_array($local_array) && !in_array($key,$local_array)){
1293 - print '<div class="wpstream_setting_event_unit_wrapper">';
2045 + print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">';
1294 2046
1295 2047 print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
1296 2048
2049 + print '<div style="display: flex; gap: 25px; justify-content: space-between;">';
2050 + print '<div class="settings_details">'.$option['details'].'</div>';
1297 2051 print '
1298 2052 <label class="wpstream_switch">
1299 2053 <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
1300 2054 if( isset($value[$key]) ){
@@ -1305,13 +2059,16 @@
1305 2059 if($option['defaults']=='yes') {
1306 2060 print ' checked ';
1307 2061 }
1308 2062 }
2063 + if ($disabled) {
2064 + print ' disabled ';
2065 + }
1309 2066
1310 2067
1311 2068 print '> <span class="wpstream_slider round"></span>';
1312 2069 print '</label>';
1313 - print '<div class="settings_details">'.$option['details'].'</div>';
2070 + print '</div>';
1314 2071
1315 2072
1316 2073 print '</div>';
1317 2074 }
@@ -1363,19 +2120,26 @@
1363 2120 * @since 3.0.1
1364 2121 */
1365 2122 public function wpstream_set_wpstream_credentials(){
1366 2123
1367 - if($_SERVER['REQUEST_METHOD'] === 'POST'){
2124 + if($_SERVER['REQUEST_METHOD'] === 'POST'){
1368 2125 $allowed_html = array();
1369 2126 $exclude_array = array();
1370 2127 $allowed_html = array();
1371 2128
1372 - foreach($_POST as $variable=>$value){
2129 + foreach($_POST as $variable=>$value){
1373 2130 if ($variable!='submit'){
1374 2131 if (!in_array($variable, $exclude_array) ){
1375 - update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
1376 - }
1377 - }
2132 + switch ( $variable ) {
2133 + case 'api_username':
2134 + update_option( sanitize_key('wpstream_api_username'), sanitize_text_field($value) );
2135 + break;
2136 + case 'api_password':
2137 + update_option( sanitize_key('wpstream_api_password'), $value );
2138 + break;
2139 + }
2140 + }
2141 + }
1378 2142 }
1379 2143
1380 2144
1381 2145
@@ -1407,9 +2171,9 @@
1407 2171 );
1408 2172
1409 2173
1410 2174 $token = $this->main->wpstream_live_connection->wpstream_get_token();
1411 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2175 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_set_wpstream_credentials');
1412 2176
1413 2177 $this->main->show_user_data($pack_details);
1414 2178
1415 2179 print '<form method="post" action="" >';
@@ -1423,9 +2187,12 @@
1423 2187 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);
1424 2188 echo '</div>';
1425 2189
1426 2190 }else if($token==''){
1427 - 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>';
2191 + $text = get_option('wpstream_curl_failed') === "0" ?
2192 + ' 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.' :
2193 + 'Not connected to WpStream. Please note the errors above and contact support.';
2194 + echo '<div class="api_not_conected">'.__($text,'wpstream').'</div>';
1428 2195 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
1429 2196 echo '<div class="api_conected">'.__('Connected to WpStream.net!','wpstream').'</div>';
1430 2197 }else{
1431 2198 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
@@ -1479,9 +2246,9 @@
1479 2246 * @since 3.0.1
1480 2247 */
1481 2248
1482 2249 public function wpstream_media_management(){
1483 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2250 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_media_management');
1484 2251
1485 2252 $this->main->show_user_data($pack_details);
1486 2253
1487 2254
@@ -1553,18 +2320,23 @@
1553 2320 */
1554 2321 public function wpstream_present_media_upload(){
1555 2322 $to_return='';
1556 2323 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
1557 -
1558 -
1559 -
1560 2324
1561 - if($formInputs['success'] === 'notenough'){
1562 - $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough streaming data or storage to upload a video!','wpstream').'</div>';
2325 + if( !$formInputs['success'] ){
2326 + if ($formInputs['error'] == 'not_connected'){
2327 + $to_return.='<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
2328 + }
2329 + else {
2330 + $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>';
2331 + }
1563 2332 return $to_return;
1564 2333 }
1565 2334
1566 - if($formInputs['success'] ===true):
2335 + if($formInputs['success'] ===true){
2336 +
2337 +
2338 +
1567 2339 $to_return.='<div class="wpstream_upload_container">';
1568 2340 $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>';
1569 2341 $to_return.='<form action="https://wpstream-video.s3.amazonaws.com/"
1570 2342 method="POST"
@@ -1574,18 +2346,19 @@
1574 2346 data-limitConcurrentUploads="1"
1575 2347 class="direct-upload">';
1576 2348
1577 2349 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
1578 - $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>';
2350 + $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>';
1579 2351
1580 2352
1581 2353 $to_return.='<div class="wpstream_file_drop_color">';
1582 2354 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
1583 - $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:
2355 + $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:<br>
1584 2356
1585 - Container: <strong>MP4</strong>,
1586 - Video codec: <strong>H264</strong>,
1587 - Audio codec: <strong>AAC</strong>. Media will fail to play if it does not follow the above settings.
2357 + Container: <strong>MP4</strong>,<br>
2358 + Video codec: <strong>H264</strong>,<br>
2359 + Audio codec: <strong>AAC</strong>.<br>
2360 + Media will fail to play if it does not follow the above settings.
1588 2361 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>';
1589 2362 if(is_array($formInputs)){
1590 2363 foreach ($formInputs['ref'] as $name => $value) {
1591 2364 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
@@ -1596,9 +2369,9 @@
1596 2369 <div class="progress-bar-area"></div></div>
1597 2370 </form>';
1598 2371
1599 2372 $to_return.='</div>';
1600 - endif;
2373 + }
1601 2374
1602 2375 return $to_return;
1603 2376
1604 2377 }
@@ -1614,22 +2387,42 @@
1614 2387 */
1615 2388 public function wpstream_present_file_management(){
1616 2389 $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api();
1617 2390
1618 - $video_list_raw_array=array();
1619 - if(isset($video_list_raw['items'])){
1620 - $video_list_raw_array=$video_list_raw['items'];
2391 + if ( $video_list_raw === false ) {
2392 + return '<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
1621 2393 }
1622 -
1623 - $keys = array_column($video_list_raw_array, 'time');
2394 +
2395 + $video_list_raw_array = [];
2396 + if( isset( $video_list_raw['items'] ) ){
2397 + $video_list_raw_array = $video_list_raw['items'];
2398 + }
2399 +
2400 + $keys = array_column( $video_list_raw_array, 'time' );
1624 2401 array_multisort($keys, SORT_DESC , $video_list_raw_array);
1625 2402
1626 2403 $to_return='';
1627 -
1628 - if(is_array($video_list_raw['items'])){
2404 +
2405 + // show pending items
2406 + if ( key_exists( 'pending', $video_list_raw ) && is_array( $video_list_raw['pending'] ) ) {
2407 + foreach ( $video_list_raw['pending'] as $key => $video ) {
2408 + $video_size = intval($video['size']/1048576);
2409 + $video_name = esc_html($video['name']);
2410 + if($video_name!=''):
2411 + $to_return.='<div class="wpstream_video_wrapper">';
2412 + $to_return.='<div class="wpstream_video_title">';
2413 + $to_return.='<div class="wpstream_video_notice"></div></div>';
2414 + $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>';
2415 + $to_return.='<div class="wpstream_video_pending">' . esc_html__( 'The video is still processing', 'wpstream') . '</div>';
2416 + $to_return.='</div>';
2417 + endif;
2418 +
2419 + }
2420 + }
2421 +
2422 + // show uploaded items
2423 + if( is_array($video_list_raw['items'] ) ) {
1629 2424 foreach ($video_list_raw_array as $key =>$video){
1630 -
1631 -
1632 2425 $video_size = intval($video['size']/1048576);
1633 2426 $video_name = esc_html($video['name']);
1634 2427 if($video_name!=''):
1635 2428 $to_return.='<div class="wpstream_video_wrapper">';
@@ -1635,9 +2428,9 @@
1635 2428 $to_return.='<div class="wpstream_video_wrapper">';
1636 2429
1637 2430 $to_return.='<div class="wpstream_video_title">';
1638 2431 $to_return.='<div class="wpstream_video_notice"></div></div>';
1639 - $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>';
2432 + $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>';
1640 2433 $to_return.=' <div class="wpstream_delete_media" ';
1641 2434 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video_name.'?\')" data-filename="'.$video_name.'">'.esc_html__('delete file','wpstream').'</div>';
1642 2435 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video_name.'">'.esc_html__('download','wpstream').'</div>';
1643 2436 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
@@ -1647,19 +2440,22 @@
1647 2440
1648 2441
1649 2442
1650 2443 $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>';
1651 - $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>';
1652 -
2444 + if (class_exists('WooCommerce')) {
2445 + $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>';
2446 + }
2447 +
1653 2448 $to_return.='</div>';
1654 2449 endif;
1655 2450
1656 2451 }
1657 2452 $current_page= get_current_screen();
1658 -
1659 -
1660 - } else {
1661 - $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
2453 + }
2454 +
2455 + // no items to show
2456 + if ( !is_array( $video_list_raw['items'] ) || ( key_exists( 'pending', $video_list_raw ) && !is_array( $video_list_raw['pending'] ) ) ) {
2457 + $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
1662 2458 }
1663 2459 return $to_return;
1664 2460 }
1665 2461
@@ -1742,10 +2538,36 @@
1742 2538 * save meta options
1743 2539 *
1744 2540 * @since 3.0.1
1745 2541 */
1746 - public function add_wpstream_product_metaboxes() {
1747 - add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default');
2542 + public function add_wpstream_product_metaboxes() {
2543 + global $post;
2544 + $post_id = $post->ID;
2545 +
2546 +
2547 +
2548 +
2549 + add_meta_box( 'add_wpstream_product_metaboxes-sectionid', esc_html__( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default');
2550 + add_meta_box( 'custom_metabox_video_collection', esc_html__( 'Video Collection', 'wpstream' ), 'wpstream_bundle_custom_metabox_callback', 'wpstream_bundles', 'normal', 'high' );
2551 + add_meta_box( 'woocommerce-product-data', esc_html__( 'Product Data', 'wpstream' ), 'woocommerce_product_data_box', 'product', 'normal', 'default' );
2552 +
2553 + if(function_exists('wc_get_product')):
2554 + $product = wc_get_product( $post_id );
2555 + if ( $product ) {
2556 +
2557 + if ( $product->get_type() === 'wpstream_bundle' ) {
2558 + add_meta_box(
2559 + 'wpstream_woo_custom_metabox',
2560 + esc_html__( 'Video Collection Options', 'wpstream' ),
2561 + 'wpstream_bundle_custom_metabox_callback',
2562 + 'product',
2563 + 'normal',
2564 + 'default'
2565 + );
2566 + }
2567 + }
2568 + endif;
2569 +
1748 2570 }
1749 2571
1750 2572
1751 2573 /**
@@ -1759,10 +2581,12 @@
1759 2581 global $post;
1760 2582 if(isset($post->ID)){
1761 2583 if ( $post->post_type !== 'product' ) return;
1762 2584 $term_list = wp_get_post_terms($post->ID, 'product_type');
1763 - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
1764 - update_post_meta( $post->ID, '_virtual', 'yes' );
2585 + if( $term_list[0]->name=='video_on_demand' ||
2586 + $term_list[0]->name=='live_stream' ||
2587 + $term_list[0]->name=='wpstream_bundle'){
2588 + update_post_meta( $post->ID, '_virtual', 'yes' );
1765 2589 }
1766 2590 }
1767 2591 }
1768 2592
@@ -1847,9 +2671,9 @@
1847 2671 $show_recording='style="display:none"';
1848 2672 $show_external='';
1849 2673 }
1850 2674 print '<p '.$show_recording.' class="wpstream_option_vod_source wpstream_show_recording">'.esc_html__('Choose one of your existing recordings.','wpstream').'</p>';
1851 - 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>';
2675 + print '<p '. $show_external.' class="wpstream_option_vod_source wpstream_show_external">'.esc_html__('Upload a video from your computer or paste the URL of a YouTube/external video.','wpstream').'</p>';
1852 2676
1853 2677 print '</p> ';
1854 2678 }
1855 2679
@@ -1869,11 +2693,26 @@
1869 2693 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
1870 2694
1871 2695 return $types;
1872 2696 }
1873 -
1874 -
1875 -
2697 +
2698 + public function wpstream_add_products_class( $classname, $product_type ) {
2699 + if ( 'live_stream' === $product_type ) {
2700 + $classname = 'WC_Product_Live_Stream';
2701 + }
2702 + if ( 'video_on_demand' === $product_type ) {
2703 + $classname = 'WC_Product_Video_On_Demand';
2704 + }
2705 + return $classname;
2706 + }
2707 +
2708 + public function wpstream_add_custom_wc_products() {
2709 + if( class_exists( 'WooCommerce' ) ){
2710 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php';
2711 + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php';
2712 + }
2713 + }
2714 +
1876 2715 /**
1877 2716 * Js action to do when user pick live stream or video on demand
1878 2717 *
1879 2718 * @since 3.0.1
@@ -1888,10 +2727,14 @@
1888 2727 <script type='text/javascript'>
1889 2728 jQuery( document ).ready( function() {
1890 2729 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
1891 2730 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
2731 + jQuery('.options_group.pricing' ).addClass ( 'show_if_wpstream_bundle' ).show();
2732 +
1892 2733 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
1893 2734 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
2735 + jQuery('._sold_individually_field').parent().addClass('show_if_wpstream_bundle').show();
2736 +
1894 2737 jQuery('._sold_individually_field').show();
1895 2738
1896 2739 var selected = jQuery('#product-type').val();
1897 2740 });
@@ -1907,13 +2750,12 @@
1907 2750 * @since 3.0.1
1908 2751 */
1909 2752
1910 2753 public function wpstream_hide_attributes_data_panel( $tabs) {
1911 -
1912 - $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand';
1913 - $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1914 - // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1915 -
2754 +
2755 + $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand hide_if_wpstream_bundle';
2756 + $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand show_if_wpstream_bundle';
2757 +
1916 2758 return $tabs;
1917 2759 }
1918 2760
1919 2761
@@ -1929,12 +2771,12 @@
1929 2771 $product_id=$product->get_id();
1930 2772
1931 2773 $term_list = wp_get_post_terms($product_id, 'product_type');
1932 2774
1933 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
2775 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1934 2776
1935 2777 if($subscription_model==1){ // if we have Neflix mode
1936 - if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' ){
2778 + if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='wpstream_bundle' ){
1937 2779 return false;
1938 2780 }
1939 2781 }
1940 2782
@@ -1952,8 +2794,9 @@
1952 2794 * @since 3.0.1
1953 2795 */
1954 2796
1955 2797 public function wpstream_add_custom_general_fields() {
2798 +
1956 2799
1957 2800 global $woocommerce, $post;
1958 2801 if(function_exists('wcs_user_has_subscription')){
1959 2802 echo '<div class="options_group show_if_subscription">';
@@ -1968,8 +2811,10 @@
1968 2811 }
1969 2812
1970 2813 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
1971 2814 echo '<div class="options_group show_if_video_on_demand">';
2815 +
2816 +
1972 2817 $selected='';
1973 2818 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
1974 2819 $selected=esc_html($_GET['new_video_name']);
1975 2820 }
@@ -1975,18 +2820,21 @@
1975 2820 }
1976 2821 if($selected==''){
1977 2822 $selected= get_post_meta($post->ID,'_movie_url',true);
1978 2823 }
1979 -
1980 - woocommerce_wp_select(
1981 - array(
1982 - 'id' => '_movie_url',
1983 - 'label' => __( 'Choose video', 'woocommerce' ),
1984 - 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
1985 - 'selected'=> true,
1986 - 'value' => $selected
1987 - )
1988 - );
2824 + if( !current_user_can('administrator') ){
2825 + print '<div style="margin:10px;">'.esc_html('You need to be an administrator in order to assign videos','wpstream').'</div>';
2826 + }else{
2827 + woocommerce_wp_select(
2828 + array(
2829 + 'id' => '_movie_url',
2830 + 'label' => __( 'Choose video', 'woocommerce' ),
2831 + 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
2832 + 'selected'=> true,
2833 + 'value' => $selected
2834 + )
2835 + );
2836 + }
1989 2837
1990 2838
1991 2839
1992 2840 echo '</div>';
@@ -2188,9 +3036,16 @@
2188 3036 public function wpstream_startstreaming_sidebar_meta() {
2189 3037 global $post;
2190 3038 $term_list = wp_get_post_terms($post->ID, 'product_type');
2191 3039
2192 - add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
3040 + add_meta_box(
3041 + 'wpstream-sidebar-meta',
3042 + esc_html__('Live Streaming', 'wpstream'),
3043 + array($this,'wpstream_start_stream_meta'),
3044 + 'wpstream_product',
3045 + 'side',
3046 + 'high'
3047 + );
2193 3048
2194 3049 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
2195 3050 if(!is_wp_error( $term_list )){
2196 3051 if( isset($term_list[0]->name) ){
@@ -2217,11 +3072,17 @@
2217 3072 $local_event_options = get_post_meta ($post->ID,'local_event_options','');
2218 3073
2219 3074
2220 3075
2221 - if( get_post_status($post->ID)!='auto-draft' ){
3076 + if( get_post_status( $post->ID ) === 'publish' ) {
2222 3077 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
2223 3078 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
3079 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_start_stream_meta');
3080 + if( isset($pack_details['available_data_mb'])){
3081 + if ($pack_details['available_data_mb'] <= 0){
3082 + print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
3083 + }
3084 + }
2224 3085
2225 3086 $this->wpstream_live_stream_unit($post->ID);
2226 3087 print '<div class="wpstream_modal_background"></div>';
2227 3088 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
@@ -2226,9 +3087,9 @@
2226 3087 print '<div class="wpstream_modal_background"></div>';
2227 3088 print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
2228 3089 <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
2229 3090 </div>';
2230 - }else{
3091 + } else {
2231 3092 esc_html_e('To Go Live, please publish your channel first !','wpstream');
2232 3093 }
2233 3094 }
2234 3095
@@ -2290,9 +3151,9 @@
2290 3151 *
2291 3152 */
2292 3153
2293 3154 public function wpstream_pre_onboard_display(){
2294 - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
3155 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_pre_onboard_display');
2295 3156
2296 3157 $this->main->show_user_data($pack_details);
2297 3158
2298 3159
@@ -2303,12 +3164,9 @@
2303 3164 <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
2304 3165
2305 3166 <h1><?php print esc_html__('WpStream','wpstream').' <span class="header_special">'.esc_html__('Quick Start','wpstream').'</span>';?></h1>
2306 3167
2307 - <?php
2308 - if( !wp_is_mobile()){
2309 - ?>
2310 -
3168 +
2311 3169 <p>
2312 3170 <?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');?>
2313 3171 </p>
2314 3172
@@ -2313,18 +3171,14 @@
2313 3171 </p>
2314 3172
2315 3173 <div id="wpstream_trigger_quick_start" class="wpstream_button wpstream_button_action"><?php esc_html_e('Start the Guide','wpstream');?></div>
2316 3174
2317 - <?php }else{
2318 - print'<p>'.esc_html__('The quick start guide is not working on mobile devices','wpstream').'</p>';
2319 - } ?>
3175 +
2320 3176
2321 3177 </div>
2322 3178
2323 3179
2324 - <?php
2325 - if( !wp_is_mobile()){
2326 - ?>
3180 +
2327 3181 <script type="text/javascript">
2328 3182 //<![CDATA[
2329 3183 jQuery(document).ready(function(){
2330 3184 jQuery(".wpstream_on_boarding_wrapper").show();
@@ -2334,10 +3188,9 @@
2334 3188 //]]>
2335 3189 </script>
2336 3190
2337 3191 <?php
2338 - }//end is mobile
2339 -
3192 +
2340 3193 }
2341 3194
2342 3195
2343 3196
@@ -2401,9 +3254,9 @@
2401 3254 </div>
2402 3255
2403 3256
2404 3257 <div class="wpstream_check_account_status">
2405 - Checking if you are already logged.....
3258 + <?php esc_html_e( 'Checking if you are already logged.....', 'wpstream' ); ?>
2406 3259 </div>
2407 3260
2408 3261 <div class="wpstream_onboarding_notification"></div>
2409 3262
@@ -2449,9 +3302,9 @@
2449 3302
2450 3303 if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
2451 3304 $url = 'user/getcapthca';
2452 3305 $curl_post_fields = array();
2453 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
3306 + $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true);
2454 3307 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
2455 3308
2456 3309 }
2457 3310
@@ -2486,10 +3339,10 @@
2486 3339
2487 3340 <div id="wpstream_on_board" class="wpstream_action_next_step" data-nextthing="wpstream_step_2" style="display:none;" >Move to step 2</div>
2488 3341 </div>
2489 3342 <?php
2490 -
2491 - if(trim($token)!==''){
3343 +
3344 + if( !is_null( $token ) && trim( $token ) !== '' ) {
2492 3345 print '<div id="wpstream_have_token"></div>';
2493 3346 }
2494 3347 }
2495 3348
@@ -2553,9 +3406,9 @@
2553 3406
2554 3407 <div class="wpstream_step_wrapper wpstream_step_3 wpstream_onboarding_live" id="wpstream_step_3">
2555 3408 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream'); ?></h1>
2556 3409
2557 - <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>
3410 + <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>
2558 3411 <div class="wpstram_or">or</div>
2559 3412 <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>
2560 3413
2561 3414 <div class="wpstream_initial_onboarding_controls_wrapper">
@@ -2607,9 +3460,9 @@
2607 3460
2608 3461 public function wpstream_onboarding_step_3_B_live_streaming_pay_per_view(){
2609 3462 ?>
2610 3463
2611 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3b">
3464 + <div class="wpstream_step_wrapper wpstream_step_3b wpstream_onboarding_live" id="wpstream_step_3b">
2612 3465 <h1><?php esc_html_e('Make your live stream Pay Per View','wpstream');?></h1>
2613 3466 <?php
2614 3467 if ( class_exists( 'WooCommerce' ) ) {
2615 3468 ?>
@@ -2667,13 +3520,12 @@
2667 3520 ?>
2668 3521 <div class="wpstream_step_wrapper wpstream_step_4 wpstream_onboarding_vod" id="wpstream_step_4">
2669 3522 <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream');?></h1>
2670 3523
2671 - <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>
3524 + <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>
2672 3525 <div class="wpstram_or">or</div>
2673 - <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>
2674 -
2675 -
3526 + <input type="hidden" id="wpstream_onboarding_video_list_nonce" value="<?php echo wp_create_nonce( "wpstream_onboarding_video_list_nonce" ); ?>">
3527 + <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>
2676 3528 <div class="wpstream_initial_onboarding_controls_wrapper">
2677 3529 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
2678 3530 </div>
2679 3531
@@ -2692,39 +3544,24 @@
2692 3544 $current_screen=get_current_screen();
2693 3545 if($current_screen->base !=='wpstream_page_wpstream_onboard'){
2694 3546 return;
2695 3547 }
3548 + ?>
2696 3549
2697 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
2698 - $video_list = array();
2699 - if($token!=''){
2700 - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2701 - }
2702 -
2703 - ?>
2704 -
2705 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4a">
3550 + <div class="wpstream_step_wrapper wpstream_step_4a wpstream_onboarding_live" id="wpstream_step_4a">
2706 3551 <h1><?php esc_html_e('Let’s create your first Free-To-View VOD','wpstream');?></h1>
2707 -
2708 -
2709 -
2710 - <?php
2711 - if( count($video_list) !== 0 ) {
2712 - ?>
2713 - <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div>
2714 - <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
3552 + <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div>
3553 + <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
3554 + <div class="spinner"></div>
3555 + <div class="wpstream-step-container" style="display: none">
2715 3556 <label><?php esc_html_e('Name your FTV Video-On-Demand','wpstream')?></label>
2716 3557 <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');?>" >
2717 - <?php $this->wpstream_show_vod_dropdown_onboarding($video_list); ?>
2718 - <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 FTV VOD','wpstream');?>" />
3558 + <div id="wpstream_free_vod_dropdown_videos_list"></div>
3559 + <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">
2719 3560 </div>
3561 + </div>
3562 + <?php $this->wpstream_obboarding_file_warning(); ?>
2720 3563
2721 - <?php }else{
2722 - $this->wpstream_obboarding_file_warning();
2723 - } ?>
2724 -
2725 -
2726 -
2727 3564 <div class="wpstream_initial_onboarding_controls_wrapper">
2728 3565 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
2729 3566 </div>
2730 3567
@@ -2738,34 +3575,10 @@
2738 3575 *
2739 3576 *
2740 3577 *
2741 3578 */
2742 -
2743 - public function wpstream_show_vod_dropdown_onboarding($video_list,$appendix=''){
2744 -
2745 - print '<label>'.esc_html__('Choose Recording','wpstream').'</label>
2746 - <select name="wpstream_free_vod_file_name" id="wpstream_free_vod_file_name'.$appendix.'">
2747 - <option value="">'.esc_html__('Please select a recording from the list','wpstream').'</option>';
2748 -
2749 - if(is_array($video_list)){
2750 - foreach ($video_list as $key=>$value){
2751 - print '<option value="'.$key.'"';
2752 - print '>'.$value.'</option>';
2753 - }
2754 - }
2755 - print'</select>';
2756 -
2757 - }
2758 -
2759 -
2760 -
2761 - /*
2762 - *
2763 - *
2764 - *
2765 - */
2766 3579 public function wpstream_obboarding_file_warning(){
2767 - print '<div class="wpstream_warning_onboarding">
3580 + print '<div class="wpstream_warning_onboarding" style="display: none">
2768 3581 '.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').'
2769 3582 </br>
2770 3583 <div class="wpstream_upload_video">'.esc_html__('Upload Video','wpstream').'</div>
2771 3584
@@ -2772,11 +3585,8 @@
2772 3585 <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
2773 3586 </div>';
2774 3587 }
2775 3588
2776 -
2777 -
2778 -
2779 3589 /*
2780 3590 *
2781 3591 *
2782 3592 *
@@ -2786,53 +3596,35 @@
2786 3596
2787 3597 if($current_screen->base !=='wpstream_page_wpstream_onboard'){
2788 3598 return;
2789 3599 }
2790 -
2791 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
2792 - $video_list = array();
2793 - if($token!=''){
2794 - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2795 - }
2796 3600 ?>
2797 -
2798 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4b">
3601 +
3602 + <div class="wpstream_step_wrapper wpstream_step_4b wpstream_onboarding_live" id="wpstream_step_4b">
2799 3603 <h1><?php esc_html_e('Let\'s create your first Pay-Per-View VOD','wpstream');?></h1>
2800 3604
2801 3605 <div id="wpstream_onboard_vod_ppv_notice" class="wpstream_onboarding_notification"></div>
2802 - <?php
2803 - if( count($video_list) !== 0 ) {
2804 - if ( class_exists( 'WooCommerce' ) ) {
2805 - ?>
2806 - <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
2807 - <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
2808 - <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');?>">
2809 -
2810 - <?php $this->wpstream_show_vod_dropdown_onboarding($video_list,'_for_ppv'); ?>
2811 -
2812 - <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
2813 - <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
2814 - <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');?>" />
2815 -
2816 - </div>
2817 - <?php }else{
2818 - $this->wpstream_onboarding_woo_warning();
2819 - }
2820 -
2821 -
2822 - }else{
2823 - $this->wpstream_obboarding_file_warning();
2824 - }
2825 - ?>
2826 -
2827 -
3606 + <?php
3607 + if ( class_exists( 'WooCommerce' ) ) { ?>
3608 + <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
3609 + <div class="spinner"></div>
3610 + <div class="wpstream-step-container" style="display: none">
3611 + <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
3612 + <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');?>">
3613 + <div id="wpstream_ppv_vod_dropdown_videos_list"></div>
3614 + <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
3615 + <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
3616 + <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');?>" />
3617 + </div>
3618 + </div>
3619 + <?php $this->wpstream_obboarding_file_warning(); ?>
3620 + <?php } else {
3621 + $this->wpstream_onboarding_woo_warning();
3622 + } ?>
2828 3623 <div class="wpstream_initial_onboarding_controls_wrapper">
2829 3624 <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
2830 3625 </div>
2831 -
2832 3626 </div>
2833 -
2834 -
2835 3627 <?php
2836 3628 }
2837 3629
2838 3630
@@ -2865,9 +3657,8 @@
2865 3657 *
2866 3658 */
2867 3659 public function onboarding_wizard_footer() {
2868 3660 ?>
2869 - <div class="wpstream_modal_back"></div>
2870 3661 </div>
2871 3662 <div class="wpstream_modal_background_onboard"></div>
2872 3663 <?php
2873 3664 }
@@ -2894,14 +3685,20 @@
2894 3685 'post_status' => 'publish',
2895 3686 'post_type' => 'product',
2896 3687 'post_author' => $current_user->ID
2897 3688 );
2898 -
3689 +
2899 3690 // Insert the post into the database
2900 3691 $post_id = wp_insert_post( $my_post );
2901 3692
2902 3693 if(is_wp_error($post_id)){
2903 - echo json_encode( array('succes'=>false) );
3694 + $logger = new WPStream_Logger();
3695 + $log_entry = new WpStream_Log_Entry([
3696 + 'type' => 'error',
3697 + 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(),
3698 + ]);
3699 + $logger->add( $log_entry );
3700 + echo json_encode( array('succes'=>false) );
2904 3701 }else{
2905 3702
2906 3703 $product = wc_get_product($post_id);
2907 3704 $price = wc_format_decimal($channel_price);
@@ -2955,36 +3752,36 @@
2955 3752
2956 3753 // Insert the post into the database
2957 3754 $post_id = wp_insert_post( $my_post );
2958 3755
2959 - if(is_wp_error($post_id)){
2960 - echo json_encode( array('succes'=>false) );
2961 - }else{
3756 + if( is_wp_error( $post_id ) ) {
3757 + $logger = new WPStream_Logger();
3758 + $log_entry = new WpStream_Log_Entry([
3759 + 'type' => 'error',
3760 + 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(),
3761 + ]);
3762 + $logger->add( $log_entry );
3763 + echo json_encode( array('succes'=>false) );
3764 + } else {
2962 3765 $permalink = get_edit_post_link($post_id);
2963 3766
2964 3767 $permalink= add_query_arg( 'onboard', 'yes', $permalink );
2965 3768 $permalink= add_query_arg( 'branch', '1', $permalink );
2966 -
2967 -
3769 +
2968 3770 echo json_encode( array(
2969 - 'success'=> true,
2970 - 'link' => ($permalink)
3771 + 'success'=> true,
3772 + 'link' => ($permalink)
2971 3773 ));
2972 3774 }
2973 -
2974 3775 }
2975 3776 die();
2976 3777 }
2977 3778
2978 -
2979 -
2980 3779 /*
2981 3780 *
2982 3781 * On Boarding create free vod
2983 3782 *
2984 3783 */
2985 -
2986 -
2987 3784 public function wpstream_on_board_create_free_vod(){
2988 3785 $current_user = wp_get_current_user();
2989 3786 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
2990 3787 if(current_user_can('administrator')){
@@ -2996,14 +3793,20 @@
2996 3793 'post_status' => 'publish',
2997 3794 'post_type' => 'wpstream_product_vod',
2998 3795 'post_author' => $current_user->ID
2999 3796 );
3000 -
3001 - // Insert the post into the database
3797 +
3798 + // Insert the post into the database
3002 3799 $post_id = wp_insert_post( $my_post );
3003 3800
3004 3801 if(is_wp_error($post_id)){
3005 - echo json_encode( array('succes'=>false) );
3802 + $logger = new WPStream_Logger();
3803 + $log_entry = new WpStream_Log_Entry([
3804 + 'type' => 'error',
3805 + 'description' => 'Couldn\'t create free VOD during onboarding because of error: ' . $post_id->get_error_message(),
3806 + ]);
3807 + $logger->add( $log_entry );
3808 + echo json_encode( array('succes'=>false) );
3006 3809 }else{
3007 3810 update_post_meta($post_id, 'wpstream_product_type', 2);
3008 3811 update_post_meta($post_id, 'wpstream_free_video', $file_name);
3009 3812
@@ -3047,15 +3850,21 @@
3047 3850 'post_status' => 'publish',
3048 3851 'post_type' => 'product',
3049 3852 'post_author' => $current_user->ID
3050 3853 );
3051 -
3854 +
3052 3855 // Insert the post into the database
3053 3856 $post_id = wp_insert_post( $my_post );
3054 3857
3055 - if(is_wp_error($post_id)){
3056 - echo json_encode( array('succes'=>false) );
3057 - }else{
3858 + if( is_wp_error( $post_id ) ) {
3859 + $logger = new WPStream_Logger();
3860 + $log_entry = new WpStream_Log_Entry([
3861 + 'type' => 'error',
3862 + 'description' => 'Couldn\'t create PPV VOD during onboarding because of error: ' . $post_id->get_error_message(),
3863 + ]);
3864 + $logger->add( $log_entry );
3865 + echo json_encode( array('succes'=>false) );
3866 + } else {
3058 3867
3059 3868 $product = wc_get_product($post_id);
3060 3869 $price = wc_format_decimal($vod_price);
3061 3870
@@ -3097,18 +3906,31 @@
3097 3906 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3098 3907
3099 3908 if(current_user_can('administrator')){
3100 3909 $username = sanitize_text_field($_POST['api_username']);
3101 - $password = sanitize_text_field($_POST['api_password']);
3910 + $password = $_POST['api_password'];
3102 3911 update_option('wpstream_api_username',$username);
3103 3912 update_option('wpstream_api_password',$password);
3104 3913
3105 3914 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3106 -
3107 - echo json_encode( array(
3108 - 'success'=> true,
3109 - 'token' => ($token)
3110 - ));
3915 + $videos_list = $this->main->wpstream_live_connection->wpstream_get_videos();
3916 + // cleanup any previous echo before sending json
3917 + ob_end_clean();
3918 + // !DO NOT SEND TOKEN TO THE CLIENT!
3919 + if ($token){
3920 + echo json_encode( array(
3921 + 'success'=> true
3922 + ));
3923 + }
3924 + else {
3925 + $text = get_option('wpstream_curl_failed') ?
3926 + 'Login failed with critical error: ' . get_option('wpstream_curl_failed') :
3927 + 'Wrong username or password!';
3928 + echo json_encode( array(
3929 + 'success'=> false,
3930 + 'error' => $text,
3931 + ));
3932 + }
3111 3933
3112 3934 }else{
3113 3935 echo json_encode( array(
3114 3936 'success'=> false,
@@ -3131,19 +3953,20 @@
3131 3953 * On Boarding login
3132 3954 *
3133 3955 */
3134 3956 public function wpstream_on_board_register(){
3135 -
3136 3957 check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3137 3958
3138 3959 if(current_user_can('administrator')){
3139 3960 $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']);
3140 - $wpstream_register_password = sanitize_text_field($_POST['wpstream_register_password']);
3961 + $wpstream_register_password = $_POST['wpstream_register_password'];
3141 3962 $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']);
3142 3963 $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']);
3143 3964
3144 3965 $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password);
3145 3966 if(!$validate['success']){
3967 + // cleanup any previous echo before sending json
3968 + ob_end_clean();
3146 3969 echo json_encode($validate);
3147 3970 die();
3148 3971 }
3149 3972
@@ -3156,9 +3979,9 @@
3156 3979 );
3157 3980
3158 3981
3159 3982
3160 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
3983 + $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true);
3161 3984 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
3162 3985
3163 3986
3164 3987
@@ -3171,8 +3994,10 @@
3171 3994 update_option('wpstream_api_password',$wpstream_register_password);
3172 3995
3173 3996 $token = $this->main->wpstream_live_connection->wpstream_get_token();
3174 3997
3998 + // cleanup any previous echo before sending json
3999 + ob_end_clean();
3175 4000 echo json_encode( array(
3176 4001 'success' => true,
3177 4002 'token' => $token ,
3178 4003 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'),
@@ -3180,8 +4005,10 @@
3180 4005 ));
3181 4006 die();
3182 4007 }else{
3183 4008
4009 + // cleanup any previous echo before sending json
4010 + ob_end_clean();
3184 4011 echo json_encode( array(
3185 4012 'success'=> false,
3186 4013 'message'=> $curl_response_decoded['request']['message'],
3187 4014 'curl'=>$curl_response_decoded,
@@ -3193,12 +4020,13 @@
3193 4020
3194 4021
3195 4022
3196 4023 }else{
3197 -
4024 + // cleanup any previous echo before sending json
4025 + ob_end_clean();
3198 4026 echo json_encode( array(
3199 4027 'success'=> false,
3200 - 'message'=> esc_html__('Register action could not be completed. Please register on wpstream.net','wpstream'),
4028 + 'message'=> esc_html__('Registration could not be completed. Please try again or register on wpstream.net','wpstream'),
3201 4029
3202 4030 ));
3203 4031 die();
3204 4032 }
@@ -3210,8 +4038,10 @@
3210 4038
3211 4039
3212 4040
3213 4041 }else{
4042 + // cleanup any previous echo before sending json
4043 + ob_end_clean();
3214 4044 echo json_encode( array(
3215 4045 'success'=> false,
3216 4046 'message' => esc_html('You are not an administrator','wpstream')
3217 4047 ));
@@ -3245,9 +4075,9 @@
3245 4075
3246 4076 if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) {
3247 4077 $return= array(
3248 4078 'success'=> false,
3249 - 'message' => esc_html('The email doesn\'t look right !','wpstream')
4079 + 'message' => esc_html__("The email doesn't look right !",'wpstream')
3250 4080 );
3251 4081 return $return;die();
3252 4082 }
3253 4083
@@ -3255,9 +4085,9 @@
3255 4085 $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1);
3256 4086 if( $domain!='' && !checkdnsrr ($domain) ){
3257 4087 $return= array(
3258 4088 'success'=> false,
3259 - 'message' => esc_html('The email doesn\'t look right !','wpstream')
4089 + 'message' => esc_html__("The email doesn't look right !",'wpstream')
3260 4090 );
3261 4091 return $return;die();
3262 4092 }
3263 4093
@@ -3272,5 +4102,144 @@
3272 4102 }
3273 4103
3274 4104 return $return;die();
3275 4105 }
3276 -}
4106 +
4107 + /**
4108 + * Handle the AJAX request to initiate a multipart upload
4109 + *
4110 + * @since 3.0.1
4111 + */
4112 + public function handle_initiate_multipart_upload() {
4113 + // Security check - only admins can do this
4114 + if (!current_user_can('administrator')) {
4115 + wp_send_json_error('Unauthorized access');
4116 + return;
4117 + }
4118 +
4119 + // Get file details from request
4120 + $file_name = sanitize_text_field($_POST['file_name']);
4121 + $file_size = intval($_POST['file_size']);
4122 + $content_type = sanitize_text_field($_POST['content_type']);
4123 + $num_parts = intval($_POST['parts']);
4124 +
4125 + if (empty($file_name) || $file_size <= 0 || $num_parts <= 0) {
4126 + wp_send_json_error('Invalid file information');
4127 + return;
4128 + }
4129 +
4130 + // Prepare a clean filename (similar to the standard upload process)
4131 + $file_name_array = explode(".", $file_name);
4132 + $file_extension = $file_name_array[count($file_name_array) - 1];
4133 + $temp_file_name = $file_name_array[0];
4134 + $temp_file_name = str_replace(' ', '_', $temp_file_name);
4135 + $temp_file_name = preg_replace('/\W/', '', $temp_file_name);
4136 + $clean_file_name = $temp_file_name . '.' . $file_extension;
4137 +
4138 + // Make API call to initiate multipart upload
4139 + $url = 'video/upload';
4140 + $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
4141 +
4142 + if (!$access_token) {
4143 + wp_send_json_error('Not connected to WPStream service');
4144 + return;
4145 + }
4146 +
4147 + $api_params = array(
4148 + 'access_token' => $access_token,
4149 + 'size' => $file_size,
4150 + 'name' => $clean_file_name,
4151 + 'content_type' => $content_type,
4152 + 'parts' => $num_parts
4153 + );
4154 +
4155 + $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true);
4156 + $response_data = json_decode($response, true);
4157 +
4158 + if (!isset($response_data['success']) || $response_data['success'] !== true) {
4159 + $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to initiate multipart upload';
4160 + wp_send_json_error($error_message);
4161 + return;
4162 + }
4163 +
4164 + // Return the upload ID and pre-signed URLs for each part
4165 + wp_send_json_success($response_data);
4166 + }
4167 +
4168 + /**
4169 + * Handle the AJAX request to complete a multipart upload
4170 + *
4171 + * @since 3.0.1
4172 + */
4173 + public function handle_complete_multipart_upload() {
4174 + // Security check - only admins can do this
4175 + if (!current_user_can('administrator')) {
4176 + wp_send_json_error('Unauthorized access');
4177 + return;
4178 + }
4179 +
4180 + // Get completion details
4181 + $parts = json_decode(stripslashes($_POST['parts']), true);
4182 + $file_name = sanitize_text_field($_POST['file_name']);
4183 + $handle = sanitize_text_field($_POST['handle']);
4184 +
4185 + if (empty($parts) || !is_numeric($parts) || empty($file_name)) {
4186 + wp_send_json_error('Invalid completion information');
4187 + return;
4188 + }
4189 +
4190 + // Make API call to complete the multipart upload
4191 + $url = 'video/upload';
4192 + $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
4193 +
4194 + if (!$access_token) {
4195 + wp_send_json_error('Not connected to WPStream service');
4196 + return;
4197 + }
4198 +
4199 + $api_params = array(
4200 + 'access_token' => $access_token,
4201 + 'parts' => $parts,
4202 + 'name' => $file_name,
4203 + 'handle' => $handle,
4204 + 'action' => 'complete'
4205 + );
4206 +
4207 + $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true);
4208 + $response_data = json_decode($response, true);
4209 +
4210 + if (!isset($response_data['success']) || $response_data['success'] !== true) {
4211 + $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to complete multipart upload';
4212 + wp_send_json_error($error_message);
4213 + return;
4214 + }
4215 +
4216 + // Return success
4217 + wp_send_json_success();
4218 + }
4219 +
4220 + public function wpstream_settings_tab_update_plugin() {
4221 + if ( !current_user_can( 'update_plugins' ) ) {
4222 + wp_send_json_error( __( 'Not enough permissions to make this change', 'wpstream' ) );
4223 + }
4224 +
4225 + include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
4226 + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
4227 + include_once ABSPATH . 'wp-admin/includes/file.php';
4228 +
4229 + $credentials = request_filesystem_credentials('');
4230 + if ( !WP_Filesystem( $credentials ) ) {
4231 + wp_send_json_error( __( 'Failed to connect to the filesystem', 'wpstream' ) );
4232 + }
4233 +
4234 + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
4235 + $plugin_path = plugin_basename( WPSTREAM_PLUGIN_PATH . 'wpstream.php' );
4236 + $result = $upgrader->upgrade( $plugin_path );
4237 + activate_plugin( $plugin_path );
4238 +
4239 + if ( is_wp_error( $result ) ) {
4240 + wp_send_json_error( __( 'Update failed due to', 'wpstream' ) . $result->get_error_message() );
4241 + }
4242 +
4243 + wp_send_json_success();
4244 + }
4245 +}