PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.8
WpStream – Live Streaming, Video on Demand, Pay Per View v3.8
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 +593 -3763 4.133.8 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,175 +63,97 @@
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;
69 + $this->plugin_name = $plugin_name;
70 + $this->version = $version;
71 + $this->main = $plugin_main;
72 +
73 + $this->global_event_options = array(
74 + 'record' =>array(
75 + 'name' => esc_html__('Record Live Stream','wpstream'),
76 + 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'),
77 + 'defaults' => 'no',
78 +
79 + ),
80 + 'view_count' =>array(
81 + 'name' => esc_html__('Display Viewer Count','wpstream'),
82 + 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'),
83 + 'defaults' => 'yes',
84 + ),
85 + 'domain_lock'=>array(
86 + 'name' => esc_html__('Lock To Website','wpstream'),
87 + 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),home_url() ),
88 + 'defaults' => 'yes',
89 + ),
90 + 'autoplay' =>array(
91 + 'name' => esc_html__('Autoplay','wpstream'),
92 + 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
93 + 'defaults' => 'yes',
94 + ),
95 + 'mute' =>array(
96 + 'name' => esc_html__('Start Muted','wpstream'),
97 + 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'),
98 + 'defaults' => 'no',
72 99
73 - add_action('init', array($this, 'load_global_event_options'));
74 - }
100 + ),
101 + );
75 102
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 - }
103 + }
130 104
131 - /**
132 - * Register the stylesheets for the admin area.
133 - *
134 - * @since 3.0.1
135 - */
136 - public function enqueue_styles() {
105 + /**
106 + * Register the stylesheets for the admin area.
107 + *
108 + * @since 3.0.1
109 + */
110 + public function enqueue_styles() {
137 111
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 - */
149 - wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
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 - );
112 + /**
113 + * This function is provided for demonstration purposes only.
114 + *
115 + * An instance of this class should be passed to the run() function
116 + * defined in Wpstream_Loader as all of the hooks are defined
117 + * in that particular class.
118 + *
119 + * The Wpstream_Loader will then create the relationship
120 + * between the defined hooks and the functions defined in this
121 + * class.
122 + */
123 + wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" );
124 + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' );
157 125
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 - );
164 -
165 - if (!did_action('wp_enqueue_media')) {
166 - wp_enqueue_media();
167 - }
168 - }
126 + }
169 127
170 - /**
171 - * Register the JavaScript for the admin area.
172 - *
173 - * @since 3.0.1
174 - */
175 - public function enqueue_scripts() {
128 + /**
129 + * Register the JavaScript for the admin area.
130 + *
131 + * @since 3.0.1
132 + */
133 + public function enqueue_scripts() {
176 134
177 135 wp_enqueue_script("jquery-ui-slider");
178 136 wp_enqueue_script("jquery-ui-datepicker");
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);
137 + wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js',array(), WPSTREAM_PLUGIN_VERSION, true);
138 + wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js',array(), WPSTREAM_PLUGIN_VERSION, true);
183 139 wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars',
184 140 array(
185 - 'admin_url' => get_admin_url(),
186 - 'multipart_upload_nonce' => wp_create_nonce( 'wpstream_multipart_upload_nonce' ),
187 - 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
188 - 'download_mess' => esc_html__('Click to download!','wpstream'),
189 - 'uploading' => esc_html__('We are uploading your file. Do not close this window!','wpstream'),
190 - 'upload_complete2' => esc_html__('Upload Complete! You can upload another file!','wpstream'),
191 - 'not_accepted' => esc_html__('The file is not an accepted video format','wpstream'),
192 - 'upload_complete' => esc_html__('Upload Complete!','wpstream'),
193 - 'no_band' => esc_html__('Not enough streaming data.','wpsteam'),
194 - 'no_band_no_store' => esc_html__('Not enough streaming data or storage.','wpsteam'),
195 - 'no_streaming_hours' => esc_html__('Not enough streaming hours.','wpstream'),
196 - 'exceeding_limit' => esc_html__('File size exceeds 5GB. Initiating multipart upload...','wpsteam'),
197 - 'upload_failed' => esc_html__('Upload Failed!','wpstream'),
198 - 'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'),
199 - 'choose_a_file' => esc_html__('Choose a file…','wpstream'),
200 - 'preparing_multipart' => esc_html__('Preparing multipart upload...','wpstream'),
201 - 'uploading_part' => esc_html__('Uploading part {part} of {total}...','wpstream'),
202 - 'upload_failed_part' => esc_html__('Failed to upload part {part}. Please try again.','wpstream'),
203 - 'completing_upload' => esc_html__('Completing upload. Please wait...','wpstream'),
204 - 'upload_failed_part_retry' => esc_html__('Failed to upload part {part}. Retrying...','wpstream'),
205 - 'choose_recording' => esc_html__( 'Choose Recording', 'wpstream' ),
206 - 'select_recording' => esc_html__( 'Please select a recording from the list', 'wpstream' ),
207 - 'invalid_response' => esc_html__('Invalid response from server. Missing required upload data.', 'wpstream'),
208 - 'video_processing' => esc_html__( 'The video is still processing', 'wpstream' ),
209 - 'file_name_text' => esc_html__('File Name:','wpstream'),
210 - 'channel_create_error' => esc_html__('Something did not work. Please try again.', 'wpstream'),
211 - 'select_caption_file' => esc_html__('Select .vtt Captions File', 'wpstream'),
212 - 'select_button' => esc_html__('Select', 'wpstream'),
213 - 'remove_button' => esc_html__('Remove', 'wpstream'),
214 - 'use_streaming_hours' => $this->wpstream_get_start_streaming_localization_flags()['use_streaming_hours'],
141 + 'admin_url' => get_admin_url(),
142 + 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
143 + 'download_mess' => esc_html__('Click to download!','wpstream'),
144 + 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
145 + 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
146 + 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
147 + 'upload_complete' => esc_html('Upload Complete!','wpstream'),
148 + 'no_band' => esc_html('Not enough bandwidth.','wpsteam'),
149 + 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
150 +
215 151 ));
216 152
217 - wp_enqueue_script('wpstream-recordings-videos-list', plugin_dir_url( __FILE__ ) .'js/recordings_videos_list.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
218 - wp_localize_script( 'wpstream-recordings-videos-list', 'wpstream_recordings_videos_list_vars',
219 - array(
220 - 'delete_file' => esc_html__('Delete file', 'wpstream'),
221 - 'download' => esc_html__( 'Download', 'wpstream'),
222 - 'download_available' => esc_html__( 'Click to download! The url will work for the next 20 minutes!', 'wpstream'),
223 - 'add_free_video_url' => esc_url( admin_url( 'post-new.php?post_type=wpstream_product_vod') . '&new_video_name=' ),
224 - 'create_ftv_vod' => esc_html__( 'Create new Free-To-View VOD from this recording' , 'wpstream' ),
225 - 'woocommerce_exists' => class_exists( 'WooCommerce' ),
226 - 'add_paid_video_url' => esc_url( admin_url( 'post-new.php?post_type=product').'&new_video_name=' ),
227 - 'create_ptv_vod' => esc_html__( 'Create new Pay-Per-View VOD from this recording' , 'wpstream' ),
228 - )
229 - );
230 -
231 - $modified_start_streaming_file_time = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'public/js/start_streaming.js' ) );
232 - wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'public/js/start_streaming.js', array(), $modified_start_streaming_file_time, true);
233 - $streaming_localization_flags = $this->wpstream_get_start_streaming_localization_flags();
153 +
154 +
155 + wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js',array(), WPSTREAM_PLUGIN_VERSION, true);
234 156 wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars',
235 157 array(
236 158 'admin_url' => get_admin_url(),
237 159 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif',
@@ -239,136 +161,34 @@
239 161 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'),
240 162 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'),
241 163 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'),
242 164 'upload_complete' => esc_html('Upload Complete!','wpstream'),
243 - 'no_band' => esc_html('Not enough streaming data.','wpsteam'),
244 - 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam'),
165 + 'no_band' => esc_html('Not enough bandwidth.','wpsteam'),
166 + 'no_band_no_store' => esc_html('Not enough bandwidth or storage.','wpsteam')
245 167
246 - 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'),
247 - 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'),
248 - 'start_streaming' => esc_html__('TURN ON','wpstream'),
249 - 'stop_streaming' => esc_html__('TURN OFF','wpstream'),
250 - 'failed_fetching' => esc_html__('Failed to get channel info. Please try again.','wpstream'),
251 - 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'),
252 - 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'),
253 - 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'),
254 - 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'),
255 - 'error1' => esc_html__('You don\'t have enough data to start a new event!','wpstream'),
256 - 'failed_event_creation' => esc_html__('Failed to start the channel. Please try again in a few minutes.','wpstream'),
257 - 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'),
258 - 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'),
259 - 'channel_on' => esc_html__('Channel is ON','wpstream'),
260 - 'channel_off' => esc_html__('Channel is OFF','wpstream'),
261 - 'turn_off_confirm' => esc_html__(
262 - 'ARE YOU SURE you\'d like to TURN OFF the channel now? ' . PHP_EOL . PHP_EOL .
263 - '- Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).' . PHP_EOL .
264 - '- Manual TURN OFF is only useful if you require to change the channel settings immediately.' . PHP_EOL .
265 - '- If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.',
266 - 'wpstream'
267 - ),
268 - 'is_basic_streaming' => $streaming_localization_flags['is_basic_streaming'],
269 - 'use_streaming_hours' => $streaming_localization_flags['use_streaming_hours'],
270 - 'basic_streaming_warning' => esc_html__(
271 - 'You’ve used all available broadcast or viewer hours.' . PHP_EOL . PHP_EOL .
272 - 'Some live channel features will be limited, including recording, viewer count, browser broadcasting, and content protection.' . PHP_EOL . PHP_EOL .
273 - 'Top up your resources or upgrade your plan to use all features, or choose OK to start anyway.',
274 - 'wpstream'
275 - ),
276 - 'basic_streaming_warning_traffic' => esc_html__(
277 - 'Your account is now in BASIC STREAMING mode.' . PHP_EOL . PHP_EOL .
278 - '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 .
279 - 'Certain features, such as recording, viewer count, browser broadcasting, and content protection are unavailable.' . PHP_EOL . PHP_EOL .
280 - '- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL .
281 - '- Otherwise, choose OK to start your channel with these limitations.' . PHP_EOL . PHP_EOL .
282 - 'ARE YOU SURE you want to continue with Basic Streaming?',
283 - 'wpstream'
284 - ),
285 - 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
286 - 'is_onboarding' => isset($_GET['onboard']) && $_GET['onboard'] === 'yes' ? 'yes' : 'no',
287 168 ));
288 -
289 - wp_enqueue_script('wpstream-settings', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream_settings.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true);
290 - wp_localize_script('wpstream-settings', 'wpstream_settings_vars', array(
291 - 'error_message' => esc_html__( 'Failed to save settings. Please try again.', 'wpstream'),
292 - 'choose_image_text' => esc_html__( 'Choose Logo Image', 'wpstream'),
293 - 'select_image_text' => esc_html__( 'Select Image', 'wpstream'),
294 - 'update_successful' => esc_html__( 'Update Successful.', 'wpstream'),
295 - 'update_failed' => esc_html__( 'Something went wrong. Try again.', 'wpstream'),
296 - 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ),
297 - ));
298 -
299 -
300 - $branch = isset($_GET['branch']) ? sanitize_text_field( wp_unslash( $_GET['branch'] ) ) : '';
301 - wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',array(), WPSTREAM_PLUGIN_VERSION, true);
302 - wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars',
303 - array(
304 - 'admin_url' => get_admin_url(),
305 - 'plugin_url' => get_dashboard_url().'/plugins.php',
306 - 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings',
307 - 'branch' => $branch
308 - ));
309 -
310 - $current_screen=get_current_screen();
311 - // enqueue the file only on the on-boarding page and wpstream_product post type
312 - $is_wpstream_onboarding_page = $current_screen->base ==='wpstream_page_wpstream_onboard';
313 - $is_wpstream_onboarding_post_type_page = isset($_GET['onboard']) && $_GET['onboard'] === 'yes';
314 - $onboarding_visible = $is_wpstream_onboarding_page || $is_wpstream_onboarding_post_type_page;
315 - if( $onboarding_visible) {
316 - wp_enqueue_script('wpstream-on-boarding-page-js', plugin_dir_url( __DIR__ ) .'admin/js/wpstream-onboarding-page.js',array(), WPSTREAM_PLUGIN_VERSION, true);
317 - wp_localize_script( 'wpstream-on-boarding-page-js', 'wpstream_onboarding_page_vars',
318 - array(
319 - 'admin_url' => get_admin_url(),
320 - 'request_url' => WPSTREAM_CLICK,
321 - 'wps_user' => get_option('wpstream_api_username_from_token'),
322 - 'current_page' => $is_wpstream_onboarding_post_type_page ? 'post_edit' : 'onboarding',
323 - 'plugin_version' => WPSTREAM_PLUGIN_VERSION,
324 - 'branch' => $branch,
325 - )
326 - );
327 - }
328 -
329 - if ( in_array( $current_screen->base, ['toplevel_page_wpstream_credentials', 'wpstream_page_wpstream_live_channels', 'wpstream_page_wpstream_recordings', 'wpstream_page_wpstream_onboard'] ) ) {
330 - wp_enqueue_script( 'wpstream-user-quota-update', plugin_dir_url( __DIR__ ) . 'admin/js/wpstream-user-quota.js', array(), WPSTREAM_PLUGIN_VERSION, true );
331 - wp_localize_script( 'wpstream-user-quota-update', 'wpstream_user_quota_vars', array(
332 - 'admin_url' => get_admin_url()
333 - ));
334 - }
335 -
336 - // Add localized variables for broadcaster
337 - wp_localize_script('wpstream-broadcaster', 'wpstream_broadcaster_vars', array(
338 - 'ajax_url' => admin_url('admin-ajax.php'),
339 - 'nonce' => wp_create_nonce('wpstream_broadcaster_nonce'),
340 - 'plugin_url' => plugin_dir_url(__FILE__),
341 -
342 - ));
343 169
344 170 }
345 171
346 172
347 173 /**
348 - * Add Plugin Administation menu
349 - *
350 - * @since 3.0.1
351 - */
174 + * Add Plugin Administation menu
175 + *
176 + * @since 3.0.1
177 + */
352 178
353 179 public function wpstream_manage_admin_menu() {
354 -
355 - 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 );
356 - add_submenu_page( 'wpstream_credentials', __('WpStream Credentials','wpestream'), __('Credentials','wpestream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials') );
357 - add_submenu_page( 'wpstream_credentials', __('WpStream Live Channels','wpestream'), __('All Channels','wpestream'), 'administrator', 'wpstream_live_channels', array( $this,'wpstream_new_general_set'));
358 - add_submenu_page( 'wpstream_credentials', __('WpStream Recordings','wpestream'), __('Recordings','wpestream'), 'administrator', 'wpstream_recordings', array($this,'wpstream_media_management'));
359 - add_submenu_page( 'wpstream_credentials', __('WpStream Settings','wpestream'), __('Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings'));
180 +
181 + add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
182 + add_submenu_page( 'wpstream_plugin_options', __('WpStream Credentials','wpestream'), __('WpStream Credentials','wpestream'), 'administrator', 'wpstream_plugin_options', array($this,'wpstream_set_wpstream_credentials') );
183 + add_submenu_page( 'wpstream_plugin_options', __('WpStream Channels','wpestream'), __('WpStream Channels','wpestream'), 'administrator', 'wpstream_new_general_set', array( $this,'wpstream_new_general_set'));
184 + add_submenu_page( 'wpstream_plugin_options', __('WpStream Media Management','wpestream'), __('WpStream Media Management','wpestream'), 'administrator', 'wpstream_media_management', array($this,'wpstream_media_management'));
185 + add_submenu_page( 'wpstream_plugin_options', __('WpStream Settings','wpestream'), __('WpStream Settings','wpestream'), 'administrator', 'wpstream_settings', array($this,'wpstream_settings'));
360 186
361 - add_submenu_page( 'wpstream_credentials', __('WpStream Quick Start','wpestream'), __('WpStream Quick Start','wpestream'), 'administrator', 'wpstream_onboard', array($this,'wpstream_pre_onboard_display'));
362 -
363 -
364 -
365 -
366 187 }
367 188
368 -
369 -
370 189
190 +
371 191 /**
372 192 * Shows events wpstream
373 193 *
374 194 * @since 3.0.1
@@ -408,12 +228,16 @@
408 228
409 229
410 230 $event_list = new WP_Query($args);
411 231 global $live_event_for_user;
412 - $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
413 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
232 + $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
233 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
414 234
415 235 $this->main->show_user_data($pack_details);
236 +
237 +
238 +
239 +
416 240 if( $event_list->have_posts()){
417 241
418 242
419 243 print '<div class="pack_details_wrapper_transparent">
@@ -418,12 +242,12 @@
418 242
419 243 print '<div class="pack_details_wrapper_transparent">
420 244 <h3>'.__('Your Pay-Per-View Channel List','wpstream').'</h3>';
421 245
422 -
246 +
423 247 $link_new = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
424 248
425 - print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new Pay-Per-View channel.','wpstream').'</a>';
249 + print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new pay-per-view channel.','wpstream').'</a>';
426 250 print '</div>';
427 251
428 252 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
429 253
@@ -449,9 +273,8 @@
449 273
450 274
451 275 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
452 276 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
453 -
454 277 $current_user = wp_get_current_user();
455 278 $allowded_html = array();
456 279 $userID = $current_user->ID;
457 280 $user_live_streams = get_user_meta($userID,'live_shows');
@@ -467,10 +290,19 @@
467 290 $args_free = array(
468 291 'posts_per_page' => -1,
469 292 'post_type' => 'wpstream_product',
470 293 'post_status' => 'publish',
471 -
294 + 'meta_query' => array(
295 + 'relation' => 'AND',
296 + array(
297 + 'key' => 'wpstream_product_type',
298 + 'value' => 1,
299 + 'compare' => '==',
300 + ),
472 301
302 + ),
303 +
304 +
473 305 );
474 306 $event_list_free = new WP_Query($args_free);
475 307
476 308
@@ -475,12 +307,12 @@
475 307
476 308
477 309 if( $event_list_free->have_posts()){
478 310 print '<div class="pack_details_wrapper_transparent">
479 - <h3>'.__('Free-To-View Channels','wpstream').'</h3>';
311 + <h3>'.__('Your Free Channel List','wpstream').'</h3>';
480 312
481 313 $link_new = admin_url('post-new.php?post_type=wpstream_product');
482 - print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new Free-To-View channel.','wpstream').'</a>';
314 + print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new free channel.','wpstream').'</a>';
483 315 print '</div>';
484 316 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
485 317
486 318 while ($event_list_free->have_posts()): $event_list_free->the_post();
@@ -493,12 +325,9 @@
493 325 }
494 326
495 327 endwhile;
496 328
497 - print'</div><div class="wpstream_modal_background"></div>';
498 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er2</div>
499 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
500 - </div>';
329 + print'</div>';
501 330 $no_channel=1;
502 331 }else{
503 332 $no_channel=0;
504 333 }
@@ -504,98 +333,40 @@
504 333 }
505 334
506 335
507 336
508 -
337 + if($no_channel==0){
509 338 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
510 339 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
511 - print '<div class="no_events_warning"> ';
512 - if($event_list->found_posts==0){
513 - print '<div class="no_events_warning_mes">'.__('* You do not have any Pay-Per-View channels!','wpstream').'</div>';
514 - }
515 - if($event_list_free->found_posts==0){
516 - print '<div class="no_events_warning_mes">'. __('* You do not have any free channels!','wpstream').'</div>';
517 - }
518 -
519 - print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new Free-To-View channel ','wpstream').'</a>';
520 - print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new Pay-Per-View channel ','wpstream').'</a>';
340 + print '<div class="no_events_warning"> '.__('* You don\'t have any live channels!','wpstream');
521 341
342 + print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new free channel ','wpstream').'</a>';
343 + print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new pay-per-view channel ','wpstream').'</a>';
344 +
522 345 print '</div>';
523 -
346 + }
524 347
525 348
526 349
350 +
527 351 }
528 352 // end wpstream_new_general_set
529 353
530 354
531 - /**
532 - * Social share
533 - *
534 - * @since 3.0.1
535 - */
536 355
537 - public function wpstream_social_share($the_id){
538 - $protocol = is_ssl() ? 'https' : 'http';
539 - $pinterest = wp_get_attachment_image_src(get_post_thumbnail_id($the_id), 'full');
540 - $link = esc_url ( get_permalink($the_id) );
541 - $title = get_the_title($the_id);
542 - $twiter_status = urlencode( $title.' '.$link);
543 - $email_link = 'subject='.urlencode ( $title ) .'&body='. urlencode( esc_url($link));
544 -
545 - $facebook_link = esc_html($protocol).'://www.facebook.com/sharer.php?u='. esc_url($link) .'&amp;t='. urlencode(get_the_title());
546 -
547 - ?>
548 - <div class="wpstream_social_share_wrapper">
549 -
550 - <a href="<?php print esc_url( $facebook_link); ?>" target="_blank" class="social_facebook wpstream_sharing_social">
551 - <span class="dashicons dashicons-facebook-alt"></span>
552 - </a>
553 -
554 - <a href="<?php print esc_html($protocol);?>://twitter.com/intent/tweet?text=<?php echo esc_html($twiter_status); ?>" class="social_tweet wpstream_sharing_social" target="_blank">
555 - <span class="dashicons dashicons-twitter"></span>
556 - </a>
557 -
558 - <a href="<?php print esc_html($protocol);?>://pinterest.com/pin/create/button/?url=<?php echo esc_url($link); ?>&amp;media=<?php if (isset( $pinterest[0])){ echo esc_url($pinterest[0]); }?>&amp;description=<?php echo urlencode(get_the_title()); ?>" target="_blank" class="social_pinterest wpstream_sharing_social">
559 - <span class="dashicons dashicons-pinterest"></span>
560 - </a>
561 -
562 - <a href="<?php print esc_html($protocol);?>://api.whatsapp.com/send?text=<?php echo urlencode( get_the_title().' '. esc_url( $link )); ?>" class="social_whatsup wpstream_sharing_social" target="_blank">
563 - <span class="dashicons dashicons-whatsapp"></span>
564 - </a>
565 -
566 - <a href="<?php print esc_html($protocol);?>://www.linkedin.com/sharing/share-offsite/?url=<?php echo urlencode(esc_url($link)); ?>" class="social_linkedin wpstream_sharing_social" target="_blank">
567 - <span class="dashicons dashicons-linkedin"></span>
568 - </a>
569 -
570 - <a href="<?php print esc_html($protocol);?>:///www.reddit.com/submit?url==<?php echo urlencode(esc_url($link)); ?>" class="social_linkedin wpstream_sharing_social" target="_blank">
571 - <span class="dashicons dashicons-reddit"></span>
572 - </a>
573 -
574 - <a href="mailto:email@email.com?<?php echo trim(esc_html($email_link));?>" data-action="share email" class="social_email wpstream_sharing_social">
575 - <span class="dashicons dashicons-email-alt"></span>
576 - </a>
577 -
578 - <div class="wpstream_modal_explanations"> <?php print esc_html__('Spread the word! To let people know about your channel, click on the corresponding icon and share on the social platforms of your choice. The more the merrier!','wpstream'); ?> </div>
579 - <?php
580 - print '</div>';
581 - }
582 356
583 357
584 358
585 -
586 359 /**
587 360 * Shows event unit card in admin
588 361 *
589 362 * @since 3.0.1
590 363 */
591 -
592 364 public function wpstream_live_stream_unit($the_id,$is_front=''){
593 365 global $live_event_for_user;
594 - global $wpstream_plugin;
595 366 $current_user = wp_get_current_user();
596 367
597 - if( !current_user_can('administrator')){
368 + if(!current_user_can('administrator')){
598 369 if($is_front=='' ){
599 370 print '<div class="event_list_unit">';
600 371 esc_html_e('You are not allowed to broadcast.','wpstream');
601 372 print '</div>';
@@ -602,17 +373,18 @@
602 373 return;
603 374 }
604 375
605 376 }
606 -
607 - if( !$this->main->wpstream_check_user_can_stream() ){
377 +
378 + if( !$this->main->wpstream_check_user_can_stream() ){
608 379 print '<div class="event_list_unit">';
609 380 esc_html_e('You are not allowed to broadcast','wpstream');
610 381 print '</div>';
611 382 return;
383 +
612 384 }
613 -
614 -
385 +
386 +
615 387 $live_class='';
616 388 if(isset($live_event_for_user[$the_id])) {
617 389 $live_class=" wpstream_show_started";
618 390 }
@@ -617,790 +389,215 @@
617 389 $live_class=" wpstream_show_started";
618 390 }
619 391
620 392
621 - if(has_post_thumbnail($the_id)){
622 - $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
623 - }else{
624 - $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
625 - }
393 + print '<div class="event_list_unit '.$live_class.' event_unit_style_'.esc_attr($is_front).'">';
394 + if(has_post_thumbnail($the_id)){
395 + $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
396 + }else{
397 + $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_150.png';
398 + }
626 399
627 - $pending_streaming_class = 'hide_stream_data';
628 - $external_software_streaming_class = '';
629 - $obs_uri = '';
630 - $obs_stream = '';
631 - $live_data_url = '';
400 + global $wpstream_plugin;
401 +
402 +
403 + print '<div class="event_thumb_wrapper"><img class="event_thumb" src="'.$thumb.'" alt="show_imagge"></div>';
404 + print '<h3 data-prodid="'.$the_id.'">'.get_the_title($the_id).' - '.esc_html__('Id','wpstream').': '.$the_id.'<a class="view_channel" href="'.get_permalink($the_id).'" target="_blank">'.esc_html__('View Channel','wprentals').'</a></h3> ';
632 405
633 - if( $live_event_for_user=='' && $is_front=='front' ){
634 - $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
635 - }
636 - $channel_status = '<div class="spinner" style="visibility: visible"></div>';
637 - $button_status = '<div class="spinner" style="visibility: visible"></div>';
638 - if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
639 - $pending_streaming_class = 'pending_trigger';
640 - $live_data_url = get_post_meta($the_id,'qos_url',true);
641 - // $channel_status = esc_html__('Channel is on','wpstream');
642 - } else {
643 - $channel_status = esc_html__('Channel is OFF','wpstream');
644 - $button_status = esc_html__('TURN ON','wpstream');
645 - }
646 -
647 - $server_id = get_post_meta($the_id,'server_id',true);
648 - $obs_uri = get_post_meta($the_id,'obs_uri',true);
649 - $obs_stream = get_post_meta($the_id,'obs_stream',true);
650 - $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
651 - $rtmp_ip_uri = '';
652 -
653 - $ajax_nonce = wp_create_nonce( 'wpstream_start_event_nonce' );
654 - print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
655 - print '<div class="event_list_unit '.$live_class.' '.$pending_streaming_class.' event_unit_style_'.esc_attr($is_front).'" data-show-id="'.intval($the_id).'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'"">';
656 -
657 - print '<div class="wpstream_channel_status">'.$channel_status.'</div>';
658 -
659 - print '<div class="server_notification"></div>';
660 -
661 - print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
662 406
663 - print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10);
407 +
408 + $live_event_stream_name = get_post_meta($the_id,'live_event_stream_name',true);
409 + $live_event_array = get_post_meta($the_id,'live_event_uri',true);
410 + $live_event_uri = '';
664 411
665 -
666 - /* print '***</br>'.get_post_meta($the_id,'obs_uri',true) .'***</br>'.
667 - get_post_meta($the_id,'obs_stream',true).'***</br>'.
668 - get_post_meta($the_id,'broadcast_url',true);
669 - */
670 - print '<div class="wpstream_channel_item_id">'.esc_html( '#ID' ).' '.$the_id.'</div>';
671 - print '</div>';
672 -
673 412
674 - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" data-nonce="' . esc_attr( $ajax_nonce ) . '" > ' . $button_status;
675 - print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
676 - print '</div>';
677 -
678 - print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
679 -
680 - 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.'"">';
681 -
682 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
683 - print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
684 -
685 - print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
686 - <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"/>
687 - </svg>';
688 - print '</div>';
689 -
690 -
691 - 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.'"">';
692 -
693 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
694 - print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
695 -
696 - print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
697 - <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"/>
698 - <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"/>
699 - </svg>';
700 - print '</div>';
701 -
702 -
703 -
413 + $pending_streaming_class = '';
414 + $wpstream_ready_to_stream_class = '';
415 + $external_software_streaming_class = '';
416 + $wpstream_no_stream_class = '';
417 + $carnat_key1 = '';
418 + $carnat_key2 = '';
419 + $uri = '';
420 + $webcaster_url = '';
421 + $rtmp_ip_uri = '';
422 + $uri_ip = '';
423 + $server_id = '';
424 + $obs_uri = '';
425 + $obs_stream = '';
426 + $webCasterUrl = '';
427 +
428 + if( $live_event_for_user=='' && $is_front=='front' ){
429 + $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
430 + }
431 +
432 +
704 433
705 - 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.'" >';
706 -
707 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
708 - print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
434 + if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
709 435
710 - print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
711 - <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"/>
712 - <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"/>
713 - <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"/>
714 - <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"/>
715 - </svg>';
716 - print '</a>';
717 - print '</div>';
436 + $pending_streaming_class = 'show_stream_data pending_trigger';
437 + $wpstream_ready_to_stream_class = 'hide_stream_data';
438 + $external_software_streaming_class = 'show_stream_data';
439 + $wpstream_no_stream_class = 'hide_stream_data';
440 + if(isset($live_event_for_user[$the_id]['live_uri'])){
441 + $explode = explode('wpstream.net/', $live_event_for_user[$the_id]['live_uri']);
442 + $uri = $explode[0].'wpstream.net/wpstream/';
443 + $stream_name = get_post_meta($the_id,'live_event_stream_name',true);
444 + $carnat_key1 = $live_event_for_user[$the_id]['carnat1'];
445 + $carnat_key2 = $live_event_for_user[$the_id]['carnat2'];
446 + $webcaster_url = 'https://'.$live_event_for_user[$the_id]['subdomain_key'].'.live.streamer.wpstream.net:8443/'.$live_event_for_user[$the_id]['carnat2'];
718 447
719 - print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
720 - if($is_front==''){
721 - 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').'">';
448 + $rtmp_ip_uri = 'http://'.$live_event_for_user[$the_id]['ip'].':8444';
449 + $uri_ip= 'rtmp://'.$live_event_for_user[$the_id]['ip'].'/wpstream/';
722 450
723 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('
724 - Turn OFF the channel to change its settings.','wpestream').'</div>';
725 - print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
451 + // starting from 2.0
452 + $server_id = get_post_meta($the_id,'server_id',true);
453 + $obs_uri = get_post_meta($the_id,'obs_uri',true);
454 + $obs_stream = get_post_meta($the_id,'obs_stream',true);
455 + $webCasterUrl= get_post_meta($the_id,'webCasterUrl',true);
456 +
457 + // if local server id diffrens than wpstream server id it means call was made via api and we use wpstream ip
458 + if( $server_id != $live_event_for_user[$the_id]['api20_event_id'] && $live_event_for_user[$the_id]['api20_event_id']!='' ){
459 +
460 + $server_id=esc_html($live_event_for_user[$the_id]['api20_event_id']);
461 + }
462 +
463 + }
726 464
727 - print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
728 - <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"/>
729 - </svg>
730 - </div>';
731 -
465 + }else{
732 466
733 - 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.'"">';
734 - print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
735 - print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
736 - <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"/>
737 - </svg>';
738 - print '</a>';
467 + $pending_streaming_class = 'hide_stream_data';
468 + $wpstream_ready_to_stream_class = 'hide_stream_data';
469 + $external_software_streaming_class = 'hide_stream_data';
470 + $wpstream_no_stream_class = 'show_stream_data';
739 471 }
740 472
741 - print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
742 - print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
743 - print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
744 - <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"/>
745 - <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"/>
746 - </svg>';
747 - print '</a>';
748 473
749 474
750 - 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.'"">';
751 - print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
752 - print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
753 - <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"/>
754 - </svg>';
755 - print '</div>';
756 - print '</div>';
757 475
758 - $this->wpstream_display_modal_seetings($the_id);
759 - $this->wpstream_display_modal_share($the_id);
760 - $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
476 + print' <div class="pending_streaming '.$pending_streaming_class.' " data-show-id="'.$the_id.'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'">';
477 + print'<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'.esc_html__('Your Event is starting. Please wait...','wprentals').' ';
478 + print '<img class="server_loading_new" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/loading.gif" alt="loading" /></div>';
479 + print '<div class="multiple_warning_events"> '.esc_html__('To go Live on a Channel, you need to start an Event. It will stop automatically after an hour of inactivity.','wpstream').'</div>';
480 + print '</div>';
761 481
762 - print '</div>';
763 482
764 - }
483 + print '<div class="wpstream_ready_to_stream '.$wpstream_ready_to_stream_class.'">';
484 + print '<div class="wpstream_channel_status"><span class="dashicons dashicons-yes"></span>'.esc_html__('Ready to Go Live !','wpstream').'</div>';
485 + print '<div class="start_webcaster wpstream_button" data-webcaster-url="'.$webCasterUrl.'" >'.esc_html__('Go Live from Browser','wpstream').'</div>';
486 + print '<div class="start_external wpstream_button" >'.esc_html__('Go Live with External Broadcaster','wpstream').'</div>';
487 + print '<div class="stop_server wpstream_button" data-show-id="'.$the_id.'">'.esc_html__('Turn Off Channel','wpstream').'</div>';
488 + $ajax_nonce_stop = wp_create_nonce( "wpstream_stop_event_nonce" );
489 + print '<input type="hidden" id="wpstream_stop_event_nonce" value="'.$ajax_nonce_stop.'">';
490 + print '</div>';
765 491
766 492
767 -
768 493
769 - /**
770 - * Shows event unit card in admin - theme version
771 - *
772 - * @since 3.0.1
773 - */
774 - public function wpstream_live_stream_unit_for_theme($the_id,$is_front=''){
775 - global $live_event_for_user;
776 - global $wpstream_plugin;
777 - $current_user = wp_get_current_user();
778 -
779 - if( !current_user_can('administrator')){
780 - if($is_front=='' ){
781 - print '<div class="event_list_unit">';
782 - esc_html_e('You are not allowed to broadcast.','wpstream');
783 - print '</div>';
784 - return;
785 - }
786 -
787 - }
788 -
789 - if( !$this->main->wpstream_check_user_can_stream() ){
790 - print '<div class="event_list_unit">';
791 - esc_html_e('You are not allowed to broadcast','wpstream');
792 - print '</div>';
793 - return;
794 - }
795 -
494 + print '<div class="external_software_streaming '. $external_software_streaming_class.' ">';
495 + print '<div class="event_list_unit_notificationx"><strong>'.__('Server:').' </strong> <div class="wpstream_live_uri_text">' . $obs_uri.'</div><div class="copy_live_uri">'.__('copy to clipboard','wpstream').'</div>';
496 + print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong><div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy to clipboard','wpstream').'</div></div>';
497 + print '<div class="warning_stream">'.
498 + sprintf(esc_html__('Use %s on your Windows or Mac computer, or the Larix Broadcaster app on your %s or %s smartphone/tablet. Various other Apps and devices are compatible. See %s for more details.','wpstream'),'<a href="https://obsproject.com/download" target="_blank">OBS Studio</a>','<a href="https://apps.apple.com/us/app/larix-broadcaster/id1042474385" target="_blank"> iOS</a>','<a href="https://play.google.com/store/apps/details?id=com.wmspanel.larix_broadcaster&hl=en" target="_blank">Android</a>','<a href="https://wpstream.net/external-broadcasters/" target="_blank">this page</a>').'</div>';
499 + print ' <img class="how_to" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/how_to_obs.jpg" alt="show_imagge">';
500 + print'</div>';
501 + print'</div>';
796 502
797 - $live_class='';
798 - if(isset($live_event_for_user[$the_id])) {
799 - $live_class=" wpstream_show_started";
800 - }
503 +
801 504
802 505
803 - if(has_post_thumbnail($the_id)){
804 - $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
805 - }else{
806 - $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/plugin-logo.png';
807 - }
808 -
809 - $pending_streaming_class = 'hide_stream_data';
810 - $external_software_streaming_class = '';
811 - $obs_uri = '';
812 - $obs_stream = '';
813 - $live_data_url = '';
814 -
815 - if( $live_event_for_user=='' && $is_front=='front' ){
816 - $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
817 - }
818 -
819 - $spinner_url = admin_url('images/spinner-2x.gif');
820 - $button_status = '<div class="spinner" style="background-image: url(' . $spinner_url . ')"></div>';
821 - $channel_status = '';
822 - if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
823 - $pending_streaming_class = 'pending_trigger';
824 - $live_data_url = get_post_meta($the_id,'qos_url',true);
825 - // $channel_status = esc_html__('Channel is on','wpstream');
826 - } else {
827 - $channel_status = esc_html__('Channel is OFF','wpstream');
828 - $button_status = esc_html__('TURN ON', 'wpstream');
829 - }
830 -
831 - $server_id = get_post_meta($the_id,'server_id',true);
832 - $obs_uri = get_post_meta($the_id,'obs_uri',true);
833 - $obs_stream = get_post_meta($the_id,'obs_stream',true);
834 - $webcaster_url = get_post_meta($the_id,'webcaster_url',true);
835 - $rtmp_ip_uri = '';
836 -
837 - 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.'"">';
838 -
839 - print '<div class="wpstream_channel_status" style="' . ($channel_status ? '' : 'display: none') . '">'.$channel_status.'</div>';
840 -
841 - print '<div class="server_notification"></div>';
842 -
843 - print '<div class="wpstream_theme_event_thumb_wrapper">';
844 - print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>';
845 - print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10);
846 - print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>';
847 - print '</div>';
848 - print '</div>';
849 -
850 - print '<div class="wpstream_theme_control_bar_wrapper">';
851 -
852 -
853 - print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">';
854 -
855 - 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.'"">';
856 -
857 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
858 - print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>';
859 -
860 - print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg">
861 - <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"/>
862 - </svg>';
863 - esc_html_e('Webcam','wpstream');
864 - print '</div>';
865 -
866 -
867 - 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.'"">';
506 + print '<div class="wpstream_no_stream '.$wpstream_no_stream_class.' ">';
507 + print '<div class="event_list_unit_notificationx"><span class="server_notification">'.__('Broadcast Offline.','wpestream').' <img class="server_loading" src="'.plugins_url().'/wpstream/img/loading.gif" alt="loading" /></span></div>';
508 +
509 + print '<input class="start_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Start Live Event','wpstream').'">';
510 +
511 + if($is_front==''){
512 + print '<input class="close_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Delete Channel','wpstream').'">';
513 + print '<input class="wpstream_show_settings wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">';
514 + }
515 +
516 + print '<div class="multiple_warning_events"> '.esc_html__('To go Live on a Channel, you need to start an Event. It will stop automatically after an hour of inactivity.','wpstream').'</div>';
517 +
868 518
869 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>';
870 - print '<div class="wpstream_tooltip">'.esc_html__('Go Live with external streaming app','wpestream').'</div>';
871 -
872 - print '<svg width="51" height="38" viewBox="0 0 51 38" fill="none" xmlns="http://www.w3.org/2000/svg">
873 - <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"/>
874 - <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"/>
875 - </svg>';
876 - esc_html_e('External App','wpstream');
877 - print '</div>';
878 -
879 -
880 -
881 -
882 - 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.'" >';
883 -
884 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to see live stats.','wpestream').'</div>';
885 - print '<div class="wpstream_tooltip">'.esc_html__('Live Statistics','wpestream').'</div>';
886 -
887 - print'<svg width="50" height="42" viewBox="0 0 50 42" fill="none" xmlns="http://www.w3.org/2000/svg">
888 - <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"/>
889 - <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"/>
890 - <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"/>
891 - <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"/>
892 - </svg>';
893 - esc_html_e('Statistics','wpstream');
894 - print '</a>';
895 - print '</div>';
896 -
897 - print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">';
898 - if($is_front==''){
899 - 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').'">';
900 519
901 - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>';
902 - print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>';
520 +
521 + if($is_front==''){
522 +
523 + $local_event_options = get_post_meta($the_id,'local_event_options',true);
524 +
525 + if(!is_array($local_event_options)){
526 + $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
527 + }
528 +
529 +
530 + print '<div class="wpstream_event_streaming_local">';
531 + $this->user_streaming_global_channel_options('',$local_event_options);
532 + print '</div>';
533 +
534 +
903 535
904 - print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
905 - <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"/>
906 - </svg>
907 - </div>';
908 -
536 + print '<div class="wpstream_social_media_broadcast">';
909 537
910 - 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.'"">';
911 - print '<div class="wpstream_tooltip">'.esc_html__('Edit Channel','wpestream').'</div>';
912 - print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
913 - <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"/>
914 - </svg>';
915 - print '</a>';
916 - }
538 + print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_facebook" id="wpstream_on_facebook'.$the_id.'"><label for="wpstream_on_facebook'.$the_id.'">'.esc_html__('Stream on Facebook','wpstream').'</label>';
539 + print '</div>';
917 540
918 - print '<a href="'.get_permalink($the_id).'" target="_blank" class="wpstream_view_channel wpstream-button-icon wpstream_tooltip_wrapper" data-show-id="'.$the_id.'"">';
919 - print '<div class="wpstream_tooltip">'.esc_html__('View Channel','wpestream').'</div>';
920 - print '<svg width="50" height="32" viewBox="0 0 50 32" fill="none" xmlns="http://www.w3.org/2000/svg">
921 - <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"/>
922 - <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"/>
923 - </svg>';
924 - esc_html_e('View','wpstream');
925 - print '</a>';
541 + print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_youtube" id="wpstream_on_youtube'.$the_id.'"><label for="wpstream_on_youtube'.$the_id.'">'.esc_html__('Stream on Youtube','wpstream').'</label>';
542 + print '</div>';
926 543
927 544
928 - 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.'"">';
929 - print '<div class="wpstream_tooltip">'.esc_html__('Share Channel','wpestream').'</div>';
930 - print '<svg width="44" height="50" viewBox="0 0 44 50" fill="none" xmlns="http://www.w3.org/2000/svg">
931 - <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"/>
932 - </svg>';
933 - esc_html_e('Share','wpstream');
934 - print '</div>';
935 - print '</div>';
545 + print '<div class="wpstream_social_media_unit"><input type="checkbox" class="wpstream_on_twich" id="wpstream_on_twich'.$the_id.'"><label for="wpstream_on_twich'.$the_id.'">'.esc_html__('Stream on Twich','wpstream').'</label>';
546 + print '</div>';
936 547
937 -
938 - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '. $button_status;
939 - print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>';
940 - print '</div>';
941 -
942 - print '</div>';
548 + print '<div class="wpstream_on_facebook_container wpstream_social_stream_container">';
549 + print 'Some Facebook Settings for event '.$the_id;
550 + print '</div>';
943 551
944 -
552 + print '<div class="wpstream_on_youtube_container wpstream_social_stream_container">';
553 + print '<label for="wpstream_youtube_rtmp'.$the_id.'">'.esc_html__('Youtube RTMP','wpstream').'</label>';
554 + print '<input type="text" class="wpstream_youtube_rtmp" id="wpstream_youtube_rtmp'.$the_id.'" value="'.esc_html(get_post_meta($the_id,'wpstream_youtube_rtmp',true )).'">';
555 + print '</div>';
945 556
557 + print '<div class="wpstream_on_twich_container wpstream_social_stream_container">';
558 + print '<label for="wpstream_twich_rtmp'.$the_id.'">'.esc_html__('Twich RTMP','wpstream').'</label>';
559 + print '<input type="text" class="wpstream_twich_rtmp" id="wpstream_twich_rtmp'.$the_id.'" value="'.esc_html(get_post_meta($the_id,'wpstream_twich_rtmp',true )).'">';
560 + print '</div>';
946 561
947 - $this->wpstream_display_modal_seetings($the_id);
948 - $this->wpstream_display_modal_share($the_id);
949 - $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream);
950 562
951 - print '</div>';
563 + print '</div>';
564 + }
565 + print '</div>';
952 566
953 - }
954 567
955 -
956 - /*
957 - *
958 - * Close modal button
959 - *
960 - */
961 -
962 - public function wpstream_close_modal_button(){
963 - print '<div class="wpstream_close_modal"></div>';
964 - }
965 -
966 - public function wpstream_local_event_options_toggle( $is_basic_stream_mode = false ) {
967 - $use_global_event_options = get_post_meta(get_the_ID(), 'use_global_event_options', true );
968 - $local_event_options = get_post_meta( get_the_ID(), 'local_event_options', true );
969 - $use_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
970 - ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
971 -
972 - if ( $is_basic_stream_mode ) {
973 - $this->wpstream_basic_stream_mode_message();
974 - }
975 -
976 - print '<div class="wpstream_local_event_options_toggle_wrapper">';
977 - print '<div class="wpstream_local_event_options_toggle_info">';
978 - print '<label for="local_event_options_enabled" class="wpstream_local_event_options_label">'.esc_html__('Edit settings for this channel','wpstream').'</label>';
979 - 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>';
980 - print '</div>';
981 - print '<label class="wpstream_switch">';
982 - print '<input id="local_event_options_enabled" type="checkbox" class="wpstream_local_event_options_toggle" ' . ($use_local_event_options_enabled === true ? 'checked' : '') . ' ' . ( $is_basic_stream_mode ? 'disabled' : '' ) . '>';
983 - print '<span class="wpstream_slider round"></span>';
984 - print '</label>';
985 568 print '</div>';
986 569 }
987 570
988 - public function wpstream_basic_stream_mode_message() {
989 - print '<div class="basic-mode-notice">';
990 - if ( $this->wpstream_is_use_streaming_hours() ) {
991 - print sprintf(
992 - wp_kses(
993 - __(
994 - 'You’ve used all available broadcast or viewer hours. Default channel settings will be used for now. To edit channel settings, <a href="%s" target="_blank">top up</a> your resources or <a href="%s" target="_blank">upgrade</a> your plan.',
995 - 'wpstream'
996 - ),
997 - array( 'a' => array(
998 - 'href' => array(),
999 - 'target' => array()
1000 - )
1001 - )
1002 - ),
1003 - esc_url( 'https://wpstream.net/pricing/' ),
1004 - esc_url( 'https://wpstream.net/pricing/' )
1005 - );
1006 - } else {
1007 - print sprintf(
1008 - wp_kses(
1009 - __(
1010 - 'You are currently in Basic Streaming Mode. The default channel settings will be used instead. Please <a href="%s" target="_blank">upgrade</a> your plan to edit the channel settings.',
1011 - 'wpstream'
1012 - ),
1013 - array(
1014 - 'a' => array(
1015 - 'href' => array()
1016 - )
1017 - )
1018 - ),
1019 - esc_url( 'https://wpstream.net/pricing/' )
1020 - );
1021 - }
1022 - print '</div>';
1023 - }
1024 571
1025 - /*
1026 - *
1027 - * Display modal settings
1028 - *
1029 - */
1030 -
1031 - public function wpstream_display_modal_seetings($the_id){
1032 - $is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
1033 -
1034 - print '<div class="wpstream_modal_form wpestate_settings_modal">';
1035 - $this->wpstream_close_modal_button();
1036 - print '<h3>';
1037 - printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id);
1038 - print '</h3>';
1039 -
1040 - $this->wpstream_local_event_options_toggle( $is_basic_stream_mode );
1041 -
1042 - $local_event_options = get_post_meta($the_id,'local_event_options',true);
1043 - $use_global_event_options = get_post_meta($the_id, 'use_global_event_options',true);
1044 - $is_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) ||
1045 - ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 );
1046 -
1047 - $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt');
1048 -
1049 - print '<div class="wpstream_event_streaming_local">';
1050 - $this->user_streaming_global_channel_options(
1051 - '',
1052 - $local_event_options,
1053 - $local_array_exclude,
1054 - !$is_local_event_options_enabled,
1055 - $is_basic_stream_mode
1056 - );
1057 - print '</div>';
1058 - print '</div>';
1059 - }
1060 -
1061 572
1062 - /*
1063 - *
1064 - * Display share settings
1065 - *
1066 - */
1067 - public function wpstream_display_modal_share($the_id){
1068 - print '<div class="wpstream_modal_form wpestate_share_modal">';
1069 - $this->wpstream_close_modal_button();
1070 - print '<h3>'.esc_html__('Share your Channel','wpstream').'</h3>';
1071 - $this->wpstream_social_share($the_id);
1072 - print '</div>';
573 + public function wpstream_show_settings_per_event(){
574 +
1073 575 }
1074 -
1075 -
1076 - /*
1077 - *
1078 - * Display broadcast modal
1079 - *
1080 - */
1081 -
1082 - public function wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream){
1083 - print '<div class="wpstream_modal_form wpestate_broadcast_modal">';
1084 - $this->wpstream_close_modal_button();
1085 - print '<h3>'.esc_html__('Go Live with External Streaming App','wpstream').'</h3>';
1086 -
1087 - print '<div class="wpstream_modal_explanations">'.esc_html__('Please choose your RTMP encoder/broadcaster','wpstream').'</div>';
1088 -
1089 - print '<select class="wpstream_external_broadcast_options">';
1090 - print '<option value="wpstream_obs_settings">'.esc_html('OBS','wpstream').'</option>';
1091 - print '<option value="wpstream_streamyard_settings">'.esc_html('StreamYard','wpstream').'</option>';
1092 - print '<option value="wpstream_restream_settings">'.esc_html('Restream','wpstream').'</option>';
1093 - print '<option value="wpstream_wimx_settings">'.esc_html('vMix','wpstream').'</option>';
1094 - print '<option value="wpstream_wirecast_settings">'.esc_html('Wirecast','wpstream').'</option>';
1095 - print '<option value="wpstream_xplit_settings">'.esc_html('XSplit','wpstream').'</option>';
1096 - print '<option value="wpstream_larix_settings">'.esc_html('Larix Broadcaster','wpstream').'</option>';
1097 576
1098 - print '</select>';
1099 -
1100 - $this->wpstream_obs_settings($obs_uri,$obs_stream);
1101 - $this->wpstream_streamyard_settings($obs_uri,$obs_stream);
1102 - $this->wpstream_restream_settings($obs_uri,$obs_stream);
1103 - $this->wpstream_wmix_settings($obs_uri,$obs_stream);
1104 - $this->wpstream_wirecast_settings($obs_uri,$obs_stream);
1105 - $this->wpstream_xplit_settings($obs_uri,$obs_stream);
1106 - $this->wpstream_larix_settings($obs_uri,$obs_stream);
1107 -
1108 - print '</div>';
1109 - }
1110 -
1111 577
1112 -
1113 -
1114 - /*
1115 - *
1116 - * Display OBS settings
1117 - *
1118 - */
1119 -
1120 - public function wpstream_obs_settings($obs_uri,$obs_stream){
1121 -
1122 - print '<div class="external_software_streaming wpstream_obs_settings" style="display:block;">';
1123 -
1124 - print '<div class="external_software_streaming_details">';
1125 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('Server:').' </strong>';
1126 - print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1127 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1128 -
1129 - print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1130 - <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1131 - print '</div>';
1132 -
1133 - print'</div>';
1134 -
1135 - print ' <div class="wpstream_modal_explanations">';
1136 - print '<ul>
1137 - <li>1. Click Settings in the OBS Window and then Select Stream.</li>
1138 - <li>2. Choose Custom Streaming Server in the Stream Type dropdown menu.</li>
1139 - <li>3. In the URL box, type/paste your Server.</li>
1140 - <li>4. In the Stream key, type/paste your Stream key.</li>
1141 - <li>5. Save changes.Close the Settings window and click on the "Start Streaming" button in the main window of OBS.</li></ul>';
1142 -
1143 - print '</div>';
1144 -
1145 -
1146 - print'</div>';
1147 - }
1148 -
1149 - /*
1150 - *
1151 - * Display StreamYard settings
1152 - *
1153 - */
1154 -
1155 - public function wpstream_streamyard_settings($obs_uri,$obs_stream){
1156 -
1157 - print '<div class="external_software_streaming wpstream_streamyard_settings">';
1158 -
1159 - print '<div class="external_software_streaming_details">';
1160 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP server URL:').' </strong>';
1161 - print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1162 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1163 -
1164 - print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong>
1165 - <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1166 - print '</div>';
1167 -
1168 - print'</div>';
1169 -
1170 - print ' <div class="wpstream_modal_explanations">';
1171 - print '<ul>
1172 - <li>1. Set up your destination by going to your StreamYard account.</li>
1173 - <li>2. Choose "Custom RTMP" and add the RTMP server URL and Stream key from WpStream.</li>
1174 - <li>3. Go to "Broadcasts" then "create a broadcast".</li>
1175 - <li>4. Enter Live Studio.</li>
1176 - <li>5. Adjust all your preferred settings and Click on "Go Live".</li></ul>';
1177 -
1178 - print '</div>';
1179 -
1180 -
1181 - print'</div>';
1182 - }
1183 -
1184 -
1185 -
1186 - /*
1187 - *
1188 - * Display StreamYard settings
1189 - *
1190 - */
1191 -
1192 - public function wpstream_restream_settings($obs_uri,$obs_stream){
1193 -
1194 - print '<div class="external_software_streaming wpstream_restream_settings">';
1195 -
1196 - print '<div class="external_software_streaming_details">';
1197 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP URL:').' </strong>';
1198 - print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1199 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1200 -
1201 - print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong>
1202 - <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1203 - print '</div>';
1204 -
1205 - print'</div>';
1206 -
1207 - print ' <div class="wpstream_modal_explanations">';
1208 - print '<ul>
1209 - <li>1. Go to your Restream account and set up a destination or channel.</li>
1210 - <li>2. Choose "Custom RTMP" and add the RTMP URL and Stream Key from WpStream.</li>
1211 - <li>3. Click on "Add Channel".</li>
1212 - <li>4. Enter Live Studio.</li>
1213 - <li>5. Adjust your preferred settings and Go Live.</li></ul>';
1214 -
1215 - print '</div>';
1216 -
1217 -
1218 - print'</div>';
1219 - }
1220 -
1221 -
1222 -
1223 - /*
1224 - *
1225 - * Display Xplit settings
1226 - *
1227 - */
1228 -
1229 -
1230 - public function wpstream_xplit_settings($obs_uri,$obs_stream){
1231 - print '<div class="external_software_streaming wpstream_xplit_settings" style="display:none;">';
1232 - print '<div class="external_software_streaming_details">';
1233 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP Url:').' </strong>';
1234 - print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1235 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1236 -
1237 - print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1238 - <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1239 - print '</div>';
1240 -
1241 - print'</div>';
1242 -
1243 - print ' <div class="wpstream_modal_explanations">';
1244 - print '<ul>
1245 - <li>1. Click Broadcast in the XSplit Window and then click "Set up a new output".</li>
1246 - <li>2. Choose Custom RTMP in the Set up a new output dropdown menu.</li>
1247 - <li>3. In the URL box, type/paste your RTMP Url.</li>
1248 - <li>4. In the Stream key, type/paste your Stream key.</li>
1249 - <li>5. Save changes and click on the "Stream" button in the main window.</li></ul>';
1250 - print '</div>';
1251 -
1252 - print '</div>';
1253 - }
1254 -
1255 -
1256 -
1257 - /*
1258 - *
1259 - * Display WireCast settings
1260 - *
1261 - */
1262 -
1263 -
1264 - public function wpstream_wirecast_settings($obs_uri,$obs_stream){
1265 - print '<div class="external_software_streaming wpstream_wirecast_settings" style="display:none;">';
1266 -
1267 - print '<div class="external_software_streaming_details">';
1268 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('Address:').' </strong>';
1269 - print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1270 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1271 -
1272 - print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream:').' </strong>
1273 - <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1274 - print '</div>';
1275 -
1276 - print'</div>';
1277 -
1278 - print ' <div class="wpstream_modal_explanations">';
1279 - print '<ul>
1280 - <li>1. Click Output on the top of the screen and then Select Output Settings.</li>
1281 - <li>2. In the destination, choose RTMP Server and click OK.</li>
1282 - <li>3. In the Address box, type/paste your Address.</li>
1283 - <li>4. In the Stream box, type/paste your Stream key.</li>
1284 - <li>5. Click on OK to save changes just click the Output on the top of the screen and then Start/Stop Broadcasting.</li></ul>';
1285 - print '</div>';
1286 -
1287 - print '</div>';
1288 - }
1289 -
1290 -
1291 -
1292 - /*
1293 - *
1294 - * Display Larix settings
1295 - *
1296 - */
1297 -
1298 -
1299 - public function wpstream_larix_settings($obs_uri,$obs_stream){
1300 - print '<div class="external_software_streaming wpstream_larix_settings" style="display:none;">';
1301 - $larix_rtmp=$obs_uri.$obs_stream;
1302 - print '<div class="external_software_streaming_details">';
1303 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('RTMP:').'</strong>';
1304 - print '<div class="wpstream_live_uri_text wpstream_larix_rtmp"></div>
1305 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1306 -
1307 - print '</div>';
1308 -
1309 - print'</div>';
1310 -
1311 - print ' <div class="wpstream_modal_explanations">';
1312 - print '<ul>
1313 - <li>A. Scan the QR code.</li>
1314 - <li>or</li>
1315 - <li>B. Manually configure Larix with the above RTMP</li>';
1316 - if(wp_is_mobile() ){
1317 - print '
1318 - <li>or</li>
1319 - <li>C. Click on the button below </li></ul>';
1320 - }
1321 -
1322 -
1323 - print '</div>';
1324 -
1325 -
1326 - print '<img class="print_qrcode" src="" />';
1327 - if(wp_is_mobile() ){
1328 - print '<a href="" class="wpstream_start_with_larix_mobile" >Start Streaming with Larix</a>';
1329 - }
1330 -
1331 -
1332 -
1333 - print '</div>';
1334 - }
1335 -
1336 -
1337 -
1338 -
1339 - /*
1340 - *
1341 - * Display Wmix settings
1342 - *
1343 - */
1344 -
1345 -
1346 - public function wpstream_wmix_settings($obs_uri,$obs_stream){
1347 - print '<div class="external_software_streaming wpstream_wimx_settings" style="display:none;">';
1348 -
1349 - print '<div class="external_software_streaming_details">';
1350 - print '<div class="event_list_unit_notificationx"><strong>'.esc_html__('URL:').' </strong>';
1351 - print '<div class="wpstream_live_uri_text">' . $obs_uri.'</div>
1352 - <div class="copy_live_uri">'.__('copy','wpstream').'</div>';
1353 -
1354 - print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream Key:').' </strong>
1355 - <div class="wpstream_live_key_text">'. $obs_stream.'</div><div class="copy_live_key">'.__('copy','wpstream').'</div></div>';
1356 - print '</div>';
1357 -
1358 - print'</div>';
1359 -
1360 - print ' <div class="wpstream_modal_explanations">';
1361 - print '<ul>
1362 - <li>1. Click on the gear icon near the stream button on the bottom.</li>
1363 - <li>2. Choose a custom RTMP Server in destination.</li>
1364 - <li>3. In the URL box, type/paste your URL.</li>
1365 - <li>4. In the Stream key, type/paste your Stream key.</li>
1366 - <li>5. Save changes. You can start streaming by clicking on the stream button at the bottom of the dashboard.</li></ul>';
1367 - print '</div>';
1368 -
1369 - print '</div>';
1370 - }
1371 -
1372 -
1373 578
1374 - /*
1375 - * Set Settings
1376 - *
1377 - *
1378 - */
579 + /**
580 + * Set Settings
581 + *
582 + *
583 + */
1379 584
1380 - public function wpstream_settings(){
1381 -
1382 - if( !current_user_can('administrator') ){
1383 - die('Only for administrators');
1384 - }
1385 -
585 + public function wpstream_settings(){
1386 586
1387 - if($_SERVER['REQUEST_METHOD'] === 'POST'){
1388 - if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){
1389 - die('Security check');
1390 - }
1391 -
587 + if($_SERVER['REQUEST_METHOD'] === 'POST'){
1392 588 $allowed_html = array();
1393 589 $exclude_array = array();
1394 590 $allowed_html = array();
1395 591
1396 -
1397 -
592 +
593 +
1398 594 if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){
1399 595 update_option( sanitize_key('wpstream_stream_role'), '' );
1400 596 }
1401 -
1402 - foreach($_POST as $variable=>$value){
597 +
598 +
599 + foreach($_POST as $variable=>$value){
1403 600 if ($variable!='submit'){
1404 601 if (!in_array($variable, $exclude_array) ){
1405 602 update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) );
1406 603 }
@@ -1408,32 +605,30 @@
1408 605 if($variable=='stream_role'){
1409 606 update_option( sanitize_key('wpstream_stream_role'), $value );
1410 607 }
1411 608
1412 - }
609 + }
1413 610 }
1414 611
612 + $event_settings=array();
613 + foreach($this->global_event_options as $key=>$option){
614 + $event_settings[$key]='';
615 + if(isset($_POST['wpstream_event_set_'.$key]) && $_POST['wpstream_event_set_'.$key]=='on'){
616 + $event_settings[$key]=1;
617 + }else{
618 + $event_settings[$key]=0;
619 + }
620 + }
621 + update_option('wpstream_user_streaming_global_channel_options',$event_settings);
622 +
1415 623
1416 - if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){
1417 - $event_settings=array();
1418 - foreach($this->global_event_options as $key=>$option){
1419 - $event_settings[$key]='';
1420 - if(isset($_POST['wpstream_event_set_'.$key]) && $_POST['wpstream_event_set_'.$key]=='on'){
1421 - $event_settings[$key]=1;
1422 - }else{
1423 - $event_settings[$key]=0;
1424 - }
1425 - }
1426 - update_option('wpstream_user_streaming_global_channel_options',$event_settings);
1427 - }
1428 624
1429 -
1430 -
1431 -
625 +
626 +
1432 627 // reset permalinkgs
1433 - global $wp_rewrite;
1434 -
1435 - update_option( "rewrite_rules", FALSE );
628 + global $wp_rewrite;
629 +
630 + update_option( "rewrite_rules", FALSE );
1436 631 $wp_rewrite->flush_rules( true );
1437 632
1438 633 }
1439 634
@@ -1438,318 +633,84 @@
1438 633 }
1439 634
1440 635 $wpstream_settings_array =array(
1441 636 1 => array(
1442 - 'tab' => 'general_options',
1443 - 'label' => esc_html__('Slug for free video/channel pages ','wpstream'),
637 + 'label' => esc_html__('Slug for wpstream free videos/channels','wpstream'),
1444 638 'name' => 'free_media_slug',
1445 639 'type' => 'text',
1446 - 'details' => esc_html__('This will replace the default "wpstream" of all your free video/channel urls. Special characters like "&" are not permitted. To have your new slug show up you need to re-save the "Permalinks Settings" under Settings -> Permalinks, even if not making any changes.','wpstream'),
640 + 'details' => esc_html__('It will replace wpstream in the free videos/channels url with your new slug. You cannot use special characters like "&". After changing the url go to Settings - Permalinks and Save again the "Permalinks Settings" - option "Post name" ','wpstream'),
1447 641 ),
1448 -
1449 - 'free_vod_slug' => array(
1450 - 'tab' => 'general_options',
1451 - 'label' => esc_html__('Slug for free VOD pages ','wpstream'),
1452 - 'name' => 'free_media_slug_vod',
1453 - 'type' => 'text',
1454 - 'details' => esc_html__('This will replace the default "wpstream_vod" of all your free VOD urls. Special characters like "&" are not permitted. To have your new slug show up you need to re-save the "Permalinks Settings" under Settings -> Permalinks, even if not making any changes.','wpstream'),
1455 - ),
1456 642
1457 643 2 => array(
1458 - 'tab' => 'general_options',
1459 - 'label' => esc_html__('Non-Admin User Roles Allowed to Broadcast','wpstream'),
644 + 'label' => esc_html__('Extra roles who can stream via wpstream shortcodes / blocks','wpstream'),
1460 645 'name' => 'stream_role',
1461 646 'type' => 'user_roles',
1462 - 'details' => esc_html__('These types of users can stream via frontend shortcodes / blocks. Single individual channels are automaticlally created for streaming by non-admins.','wpstream'),
647 + 'details' => esc_html__('A non admin user will be able to stream only on one channel only that will be automaticaly created.','wpstream'),
1463 648
1464 649 ),
1465 650 3 => array(
1466 - 'tab' => 'general_options',
1467 - 'label' => esc_html__('Non Admin Streamers Channel Type.','wpstream'),
651 + 'label' => esc_html__('Type channel on wich non admin users can stream ','wpstream'),
1468 652 'name' => 'user_streaming_channel_type',
1469 653 'type' => 'select',
1470 654 'select_values'=>array(
1471 - 'free' => esc_html__('Free Live Channel','wpstream'),
1472 - 'paid' => esc_html__('Pay-Per-View','wpstream')
655 + 'free' => esc_html__('Free Live Channels','wpstream'),
656 + 'paid' => esc_html__('Pay per view (WooCommerce product)','wpstream')
1473 657 ),
1474 - 'details' => esc_html__('Choose whether the channels assigned to non-admins are free-for-all or pay-per-view (WooCommerce product).','wpstream'),
658 + 'details' => esc_html__('The product type channel is a WooCommerce product (pay per view) while Free Channels is visible to all types of visitors ','wpstream'),
1475 659 ),
1476 660
1477 661 4 => array(
1478 - 'tab' => 'general_options',
1479 - 'label' => esc_html__('Default Pay-Per-View Price','wpstream'),
662 + 'label' => esc_html__('Default Price ','wpstream'),
1480 663 'name' => 'user_streaming_default_price',
1481 664 'type' => 'text',
1482 - 'details' => esc_html__('Default price of pay-per-view channels assigned to non-admins.','wpstream'),
665 + 'details' => esc_html__('If non admins can stream on a product channel then you can set here the default price here.','wpstream'),
1483 666 ),
1484 667
1485 -
1486 -
1487 - 6 => array(
1488 - 'tab' => 'subscription_options',
1489 - 'label' => esc_html__('Use Global Subscription Mode','wpstream'),
1490 - 'name' => 'global_sub',
1491 - 'type' => 'slidertoogle',
1492 - 'details' => esc_html__('If enabled, a client can access all the media products (live and VOD) by purchasing a single subscription. The "WooCommerce Subscriptions" plugin is required.','wpstream'),
1493 - ),
1494 -
1495 - 7 => array(
1496 - 'tab' => 'subscription_options',
1497 - 'label' => esc_html__('Subscription ID for Global Subscription Mode','wpstream'),
1498 - 'name' => 'global_sub_id',
1499 - 'type' => 'text',
1500 - 'details' => esc_html__('ID of the subscription product to be purchased for global access to media. All non-subscription video products that are not already attached to a subscription will be accessible to users that have purchased it.','wpstream'),
1501 - ),
1502 - 8 => array(
1503 - 'tab' => 'messages_options',
1504 - 'label' => esc_html__('PPV not logged in message','wpstream'),
1505 - 'name' => 'product_not_login',
1506 - 'type' => 'text',
1507 - 'details' => esc_html__('This message will be displayed on top of the media player for pay-per-view items when user is not logged in.','wpstream'),
1508 - 'default' => esc_html__('You must be logged in to watch this video.','wpstream'),
1509 - ),
1510 - 9 => array(
1511 - 'tab' => 'messages_options',
1512 - 'label' => esc_html__('PPV not purchased message','wpstream'),
1513 - 'name' => 'product_not_bought',
1514 - 'type' => 'text',
1515 - 'details' => esc_html__('This message will be displayed on top of the media player for common pay-per-view items that have not been purchased.','wpstream'),
1516 - 'default' => esc_html__('You did not yet purchase this item.','wpstream'),
1517 - ),
1518 - 10 => array(
1519 - 'tab' => 'messages_options',
1520 - 'label' => esc_html__('Subscription not purchased message','wpstream'),
1521 - 'name' => 'product_not_subscribe',
1522 - 'type' => 'text',
1523 - 'details' => esc_html__('This message will be displayed on top of the media player for subscription-type pay-per-view items that have not been purchased.','wpstream'),
1524 - 'default' => esc_html__(' You did not yet subscribe to this item.','wpstream'),
1525 - ),
1526 - 11 => array(
1527 - 'tab' => 'messages_options',
1528 - 'label' => esc_html__('Thank you message','wpstream'),
1529 - 'name' => 'product_thankyou',
1530 - 'type' => 'text',
1531 - 'details' => esc_html__('This message will be displayed on the thank you page (after purchase) and the confirmation email.','wpstream'),
1532 - 'default' => esc_html__('Thanks for your purchase. You can access your item at any time by visiting the following page: {item_link}','wpstream'),
1533 - ),
1534 -
1535 - 12 => array(
1536 - 'tab' => 'messages_options',
1537 - 'label' => esc_html__('Subscription Active message','wpstream'),
1538 - 'name' => 'subscription_active',
1539 - 'type' => 'text',
1540 - 'details' => esc_html__('This message will be displayed on subscription product page.','wpstream'),
1541 - 'default' => esc_html__('Your Subscription is Active','wpstream'),
1542 - ),
1543 - 13 => array(
1544 - 'tab' => 'messages_options',
1545 - 'label' => esc_html__('You are not live message','wpstream'),
1546 - 'name' => 'you_are_not_live',
1547 - 'type' => 'text',
1548 - 'details' => esc_html__('This message will be displayed in player.','wpstream'),
1549 - 'default' => esc_html__('We are not live at this moment','wpstream'),
1550 - ),
1551 -
1552 - 14 => array(
1553 - 'tab' => 'general_options',
1554 - 'label' => esc_html__('Video player theme','wpstream'),
1555 - 'name' => 'video_player_theme',
1556 - 'type' => 'select',
1557 - 'select_values'=>array(
1558 - 'default' => esc_html__('Default','wpstream'),
1559 - 'city' => esc_html__('City','wpstream'),
1560 - 'forest' => esc_html__('Forest','wpstream'),
1561 - 'fantasy' => esc_html__('Fantasy','wpstream'),
1562 - 'sea' => esc_html__('Sea','wpstream'),
1563 - ),
1564 - 'details' => esc_html__('Choose the video player theme to have a different look for the player.','wpstream'),
1565 - ),
1566 - 'wpstream_player_logo' => array(
1567 - 'tab' => 'general_options',
1568 - 'name' => 'player_logo',
1569 - 'label' => esc_html__('Logo for the video player','wpstream'),
1570 - 'type' => 'image',
1571 - 'details' => esc_html__('This logo will be displayed on the the video player.','wpstream'),
1572 - 'default' => '',
1573 - 'image_size' => 'thumbnail',
1574 - ),
1575 - // hide the video player logo opacity for now
1576 -// 'wpstream_player_logo_opacity' => array(
1577 -// 'tab' => 'general_options',
1578 -// 'name' => 'player_logo_opacity',
1579 -// 'label' => esc_html__('Opacity of the video player logo','wpstream'),
1580 -// 'type' => 'range',
1581 -// 'details' => esc_html__('Set the opacity of the logo','wpstream'),
1582 -// 'default' => '',
1583 -// 'image_size' => 'thumbnail',
1584 -// ),
1585 - 'wpsteram_player_logo_position' => array(
1586 - 'tab' => 'general_options',
1587 - 'name' => 'player_logo_position',
1588 - 'label' => esc_html__('Position of the video player logo','wpstream'),
1589 - 'type' => 'select',
1590 - 'select_values'=>array(
1591 - 'top-left' => esc_html__('Top Left','wpstream'),
1592 - 'top-right' => esc_html__('Top Right','wpstream'),
1593 - 'bottom-left' => esc_html__('Bottom Left','wpstream'),
1594 - 'bottom-right' => esc_html__('Bottom Right','wpstream'),
1595 - ),
1596 - 'details' => esc_html__('Choose the position of the logo on the video player.','wpstream'),
1597 - 'default' => '',
1598 - ),
1599 -
1600 -
1601 -
1602 - 99 => array(
1603 - 'tab' => 'default_options',
668 + 5 => array(
1604 669 'label' => esc_html__('Events Options ','wpstream'),
1605 670 'name' => 'user_streaming_global_channel_options',
1606 671 'type' => 'user_streaming_global_channel_options',
1607 672 'details' => esc_html__('Global Options for live events.','wpstream'),
1608 673 ),
1609 -
1610 - 100 => array(
1611 - 'tab' => 'default_options_vod',
1612 - 'label' => esc_html__('Autoplay','wpstream'),
1613 - 'name' => 'vod_autoplay',
1614 - 'type' => 'slidertoogle',
1615 - 'details' => esc_html__('If enabled, video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'),
1616 - ),
1617 -
1618 -
1619 - 101 => array(
1620 - 'tab' => 'default_options_vod',
1621 - 'label' => esc_html__('Start Muted','wpstream'),
1622 - 'name' => 'vod_start_muted',
1623 - 'type' => 'slidertoogle',
1624 - 'details' => esc_html__('If enabled, video will start muted. This may increase the rate of autoplay in some browsers.','wpstream'),
1625 - ),
1626 -
1627 - 102 => array(
1628 - 'tab' => 'default_options_vod',
1629 - 'label' => esc_html__('Lock To Website','wpstream'),
1630 - 'name' => 'vod_domain_lock',
1631 - 'type' => 'slidertoogle',
1632 - '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') ),
1633 - ),
1634 -
1635 - 103 => array(
1636 - 'tab' => 'default_options_vod',
1637 - 'label' => esc_html__('Encrypt Video','wpstream'),
1638 - 'name' => 'vod_encrypt',
1639 - 'type' => 'slidertoogle',
1640 - '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'),
1641 - ),
1642 -
1643 - /* 'vod_domain_lock' =>array(
1644 - 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'),
1645 - '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') ),
1646 - 'defaults' => 'no',
1647 - ),
1648 - 'vod_encrypt' =>array(
1649 - 'name' => esc_html__('Encrypt Video on Demand','wpstream'),
1650 - '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'),
1651 - 'defaults' => 'no',
1652 - ),*/
1653 -
1654 - 104 => array(
1655 - 'tab' => 'support_tab',
1656 - 'label' => esc_html__('Logs','wpstream'),
1657 - 'name' => 'logs',
1658 - 'type' => 'logs_table',
1659 - 'details' => esc_html__('This is the error log of the plugin.','wpstream'),
1660 - )
1661 -
674 +
1662 675 );
1663 676
1664 - $active_tab = 'general_options';
1665 - if( isset( $_GET[ 'tab' ] ) ) {
1666 - $active_tab = $_GET[ 'tab' ];
1667 - }
1668 -
1669 -
1670 - print '<div class="theme_options_tab_wpstream" style="display:block;" >
1671 - <h1>'.__('WpStream Settings','wpstream').'</h1>
1672 - <form method="post" action="" >';
677 +
678 +
679 + print '<form method="post" action="" >';
680 + print '<div class="theme_options_tab_wpstream" style="display:block;" >
681 + <h1>'.__('WpStream Settings','wpstream').'</h1>';
1673 682
1674 - print '<h2 class="nav-tab-wrapper">
1675 - <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>
1676 - <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>
1677 - <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>
1678 - <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>
1679 - <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>
1680 - <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>
1681 - </h2>';
1682 - $help_link='';
1683 683
1684 - $is_basic_stream_mode = $this->wpstream_is_basic_streaming_mode();
1685 - print '<div class="wpstream_option_wrapper">';
1686 684
1687 - switch ($active_tab) {
1688 - case 'general_options':
1689 - $help_link='https://docs.wpstream.net/docs/general-settings/';
1690 - break;
1691 - case 'default_options':
1692 - $help_link='https://docs.wpstream.net/docs/default-channel-settings/';
1693 - break;
1694 - case 'default_options_vod':
1695 - $help_link='https://docs.wpstream.net/docs/vod-settings/';
1696 - break;
1697 - case 'subscription_options':
1698 - $help_link='https://docs.wpstream.net/docs/subscription-options/';
1699 - break;
1700 - case 'messages_options':
1701 - $help_link='https://docs.wpstream.net/docs/customize-messages/';
1702 - break;
1703 - }
1704 -
1705 - print '<div class="options_wrapper">';
1706 - foreach ($wpstream_settings_array as $key=>$option){
1707 - if($option['tab']!=$active_tab){
1708 - continue;
1709 - }
1710 -
1711 - if ( $option['type']=='user_streaming_global_channel_options' ) {
1712 - print '<div class="default-channel-settings-info">';
1713 - print esc_html__( 'These settings will apply to newly created channels; existing channels will not change settings if you change them here', 'wpstream');
1714 - if ( $is_basic_stream_mode ) {
1715 - $this->wpstream_basic_stream_mode_message();
1716 - }
1717 - print '</div>';
1718 -
1719 - }
685 + print '<div class="wpstream_option_wrapper">';
686 + foreach ($wpstream_settings_array as $key=>$option){
1720 687 print '<div class="wpstream_option">';
1721 688 $options_value = get_option('wpstream_'.$option['name']) ;
1722 -
1723 689
1724 - switch( $option['type'] ) {
1725 - case 'user_roles':
690 +
691 +
692 +
693 + if($option['type']=='user_roles'){
694 +
1726 695 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1727 696 print $this->wpstream_select_user_roles($option['name'],$options_value);
1728 697 print '<div class="settings_details">'.$option['details'].'</div>';
1729 - break;
1730 - case 'user_streaming_global_channel_options':
1731 - $exclude_array=array();
1732 - $this->user_streaming_global_channel_options(
1733 - $option['name'],
1734 - $options_value,
1735 - $exclude_array,
1736 - $is_basic_stream_mode
1737 - );
1738 - break;
1739 - case 'text':
1740 - if($options_value==''){
1741 - $options_value='';
1742 - if(isset($option['default'])){
1743 - $options_value=$option['default'];
1744 - }
1745 - }
1746 698
699 + }else if($option['type']=='user_streaming_global_channel_options'){
700 +
701 +
702 + $this->user_streaming_global_channel_options($option['name'],$options_value);
703 +
704 +
705 + }else if($option['type']=='text'){
706 +
1747 707 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1748 - print '<input class="wpstream-text-input-setting" id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
708 + print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />';
1749 709 print '<div class="settings_details">'.$option['details'].'</div>';
1750 - break;
1751 - case 'select':
710 +
711 + } else if($option['type']=='select'){
712 +
1752 713 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1753 714 print '<select id="'.$option['name'].'" name="'.$option['name'].'" >';
1754 715 foreach($option['select_values'] as $key=>$value){
1755 716 print '<option value="'.$key.'" ';
@@ -1760,446 +721,72 @@
1760 721 }
1761 722 print '</select>';
1762 723 print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >';
1763 724 print '<div class="settings_details">'.$option['details'].'</div>';
1764 - break;
1765 - case 'slidertoogle':
1766 - print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1767 - print '<div style="display: flex; gap: 25px; justify-content: space-between;">';
1768 - print '<div class="settings_details">'.$option['details'].'</div>';
1769 - print '<label class="wpstream_switch">
1770 - <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" >
1771 - <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" ';
1772 - if( intval($options_value) !==0 ){
1773 - print ' checked ';
1774 - }
1775 - print '> <span class="wpstream_slider round"></span>';
1776 - print '</label>';
1777 - print '</div>';
1778 - break;
1779 - case 'image':
1780 - $image_url = $options_value ? esc_url($options_value) : '';
1781 - $has_image = !empty($image_url);
1782 -
1783 - print '<label for="' . $option['name'] . '">' . $option['label'] . '</label>';
1784 - print '<div class="wpstream-image-upload-wrapper">';
1785 - print '<input type="hidden" id="' . $option['name'] . '" name="' . $option['name'] . '" value="' . $image_url . '" />';
1786 -
1787 - // Preview area
1788 - print '<div class="wpstream-image-preview" style="' . (!$has_image ? 'display:none;' : '') . '">';
1789 - print '<img src="' . $image_url . '" alt="Preview" />';
1790 - print '</div>';
1791 -
1792 - // Upload/remove buttons
1793 - print '<div class="wpstream-image-upload-buttons">';
1794 - print '<button type="button" class="wpstream-upload-image button">' . esc_html__('Upload Image', 'wpstream') . '</button>';
1795 - print '<button type="button" class="wpstream-remove-image button" style="' . (!$has_image ? 'display:none;' : '') . '">' . esc_html__('Remove Image', 'wpstream') . '</button>';
1796 - print '</div>';
1797 -
1798 - print '</div>';
1799 - print '<div class="settings_details">' . $option['details'] . '</div>';
1800 - break;
1801 - case 'range':
1802 - print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
1803 - 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).'" />';
1804 - print '<div class="settings_details">'.$option['details'].'</div>';
1805 - break;
1806 - case 'logs_table':
1807 - $this->wpstream_support_tab();
1808 - break;
1809 - }
725 +
726 + }
727 +
1810 728 print '</div>';
1811 729 }
1812 - print '</div>'; // options wrapper
1813 - if($help_link!==''){
1814 - print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >'.esc_html__('Video Help','wpstream').'</a></div>';
1815 - }
1816 730 print '</div>';
1817 731
1818 732
1819 - if ( $active_tab != 'support_tab') {
1820 - print '<div class="wpstream-save-settings">';
1821 - print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
1822 - print '<div class="spinner"></div>';
1823 - print '</div>';
1824 - }
733 + print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
1825 734
1826 - print '<input id="wpstream-settings-nonce" name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> ';
735 +
736 +
737 + print '</div>';
1827 738 print '</form>';
1828 - print '</div>';
739 + }
740 +
1829 741
1830 - }
1831 -
1832 - /**
1833 - * Get system information for support tab
1834 - *
1835 - * @return array System information
1836 - */
1837 - private function get_system_info() {
1838 - global $wp_version;
1839 -
1840 - $php_version = phpversion();
1841 - $wp_version_info = $wp_version;
1842 - $site_debug_mode = (defined('WP_DEBUG') && WP_DEBUG);
1843 - $wp_memory_limit = WP_MEMORY_LIMIT;
1844 -
1845 - $wpstream_version = WPSTREAM_PLUGIN_VERSION;
1846 - $wpstream_plugin_outdated = false;
1847 -
1848 - // Check if plugin is outdated
1849 - $update_plugins = get_site_transient('update_plugins');
1850 - if (isset($update_plugins->response['plugin/wpstream.php'])) {
1851 - $wpstream_plugin_outdated = true;
1852 - }
1853 -
1854 - // Check API status
1855 - $api_status = false;
1856 - if (method_exists($this->main->wpstream_live_connection, 'wpstream_get_token')) {
1857 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
1858 - $api_status = !empty($token);
1859 - }
1860 -
1861 - return array(
1862 - 'php_version' => $php_version,
1863 - 'wp_version' => $wp_version_info,
1864 - 'site_debug_mode' => $site_debug_mode,
1865 - 'wp_memory_limit' => $wp_memory_limit,
1866 - 'wpstream_version' => $wpstream_version,
1867 - 'wpstream_plugin_outdated' => $wpstream_plugin_outdated,
1868 - 'api_status' => $api_status
1869 - );
1870 - }
1871 -
1872 - /**
1873 - * Render system information HTML
1874 - */
1875 - private function render_system_info() {
1876 - $system_info = $this->get_system_info();
1877 - ?>
1878 -
1879 - <div class="wpstream-system-info">
1880 - <h3><?php esc_html_e('System Information', 'wpstream'); ?></h3>
1881 - <table class="widefat">
1882 - <tbody>
1883 - <tr>
1884 - <td><strong><?php esc_html_e('PHP Version', 'wpstream'); ?></strong></td>
1885 - <td><?php echo esc_html($system_info['php_version']); ?></td>
1886 - <td>
1887 - <?php if (version_compare($system_info['php_version'], '7.4', '<')): ?>
1888 - <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1889 - <?php esc_html_e('We recommend PHP 7.4 or higher', 'wpstream'); ?>
1890 - <?php else: ?>
1891 - <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1892 - <?php endif; ?>
1893 - </td>
1894 - </tr>
1895 - <tr>
1896 - <td><strong><?php esc_html_e('WordPress Version', 'wpstream'); ?></strong></td>
1897 - <td><?php echo esc_html($system_info['wp_version']); ?></td>
1898 - <td>
1899 - <?php if (version_compare($system_info['wp_version'], '5.6', '<')): ?>
1900 - <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1901 - <?php esc_html_e('We recommend WordPress 5.6 or higher', 'wpstream'); ?>
1902 - <?php else: ?>
1903 - <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1904 - <?php endif; ?>
1905 - </td>
1906 - </tr>
1907 - <tr>
1908 - <td><strong><?php esc_html_e('WP Debug Mode', 'wpstream'); ?></strong></td>
1909 - <td><?php echo $system_info['site_debug_mode'] ? esc_html__('Enabled', 'wpstream') : esc_html__('Disabled', 'wpstream'); ?></td>
1910 - <td>
1911 - <?php if ($system_info['site_debug_mode']): ?>
1912 - <span class="dashicons dashicons-info" style="color: #00a0d2;"></span>
1913 - <?php esc_html_e('Debug mode should be disabled on production sites', 'wpstream'); ?>
1914 - <?php else: ?>
1915 - <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1916 - <?php endif; ?>
1917 - </td>
1918 - </tr>
1919 - <tr>
1920 - <td><strong><?php esc_html_e('WP Memory Limit', 'wpstream'); ?></strong></td>
1921 - <td><?php echo esc_html($system_info['wp_memory_limit']); ?></td>
1922 - <td>
1923 - <?php
1924 - $memory_limit = wp_convert_hr_to_bytes($system_info['wp_memory_limit']);
1925 - if ($memory_limit < 64 * 1024 * 1024): // 64MB
1926 - ?>
1927 - <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1928 - <?php esc_html_e('We recommend at least 64MB', 'wpstream'); ?>
1929 - <?php else: ?>
1930 - <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1931 - <?php endif; ?>
1932 - </td>
1933 - </tr>
1934 - <tr>
1935 - <td><strong><?php esc_html_e('WpStream Version', 'wpstream'); ?></strong></td>
1936 - <td><?php echo esc_html($system_info['wpstream_version']); ?></td>
1937 - <td style="display: flex; align-items: center; gap: 5px;">
1938 - <?php if ($system_info['wpstream_plugin_outdated']): ?>
1939 - <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1940 - <?php esc_html_e('Update available', 'wpstream'); ?>
1941 - <div class="update-button-wrapper">
1942 - <button class="wpstream-update-plugin-button button button-primary" data-plugin="wpstream/wpstream.php">
1943 - <?php esc_html_e('Update Now', 'wpstream'); ?>
1944 - </button>
1945 - </div>
1946 - <?php else: ?>
1947 - <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1948 - <?php endif; ?>
1949 - </td>
1950 - </tr>
1951 - <tr>
1952 - <td><strong><?php esc_html_e('API Connection', 'wpstream'); ?></strong></td>
1953 - <td><?php echo $system_info['api_status'] ? esc_html__('Connected', 'wpstream') : esc_html__('Disconnected', 'wpstream'); ?></td>
1954 - <td>
1955 - <?php if (!$system_info['api_status']): ?>
1956 - <span class="dashicons dashicons-warning" style="color: #ffb900;"></span>
1957 - <?php esc_html_e('API connection issue', 'wpstream'); ?>
1958 - <?php else: ?>
1959 - <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span>
1960 - <?php endif; ?>
1961 - </td>
1962 - </tr>
1963 - </tbody>
1964 - </table>
1965 - </div>
1966 - <?php
1967 - }
1968 -
1969 - /**
1970 - * Render support tab content
1971 - */
1972 - public function wpstream_support_tab() {
1973 - ?>
1974 - <div class="wrap">
1975 - <div class="wpstream-support-tab-root">
1976 - <?php $this->render_system_info(); ?>
1977 -
1978 - <div class="wpstream-plugins-table-container">
1979 - <h3><?php esc_html_e('Active Plugins', 'wpstream'); ?></h3>
1980 - <table class="widefat wpstream-plugins-table">
1981 - <thead>
1982 - <tr>
1983 - <th><?php esc_html_e('Plugin', 'wpstream'); ?></th>
1984 - <th><?php esc_html_e('Version', 'wpstream'); ?></th>
1985 - </tr>
1986 - </thead>
1987 - <tbody>
1988 - <?php
1989 - $plugins_data = $this->wpstream_get_plugins_data();
1990 - if (empty($plugins_data)) {
1991 - echo '<tr><td colspan="3">' . esc_html__('No WPStream plugins found.', 'wpstream') . '</td></tr>';
1992 - } else {
1993 - foreach ($plugins_data as $plugin) {
1994 - echo '<tr>';
1995 - echo '<td>' . esc_html($plugin['name']) . '</td>';
1996 - echo '<td>';
1997 - echo esc_html($plugin['version']);
1998 - if ( isset($plugin['new_version']) ) {
1999 - echo '<div class="wpstream-tooltip-container">';
2000 - echo '<span class="dashicons dashicons-info wpstream-tooltip" title="' . esc_attr($plugin['new_version']) . '">';
2001 - echo '</span>';
2002 - echo '<div class="wpstream-custom-tooltip">' . sprintf(
2003 - esc_html__('A new version is available: %s', 'wpstream'),
2004 - esc_html($plugin['new_version'])
2005 - ) . '</div>';
2006 - echo '</div>';
2007 - }
2008 - echo '</td>';
2009 - echo '</tr>';
2010 - }
2011 - }
2012 - ?>
2013 - </tbody>
2014 - </table>
2015 - </div>
2016 -
2017 - <div class="wpstream-logs-table-container">
2018 - <h3><?php esc_html_e('Recent Logs', 'wpstream'); ?></h3>
2019 - <table class="widefat wpstream-logs-table">
2020 - <thead>
2021 - <tr>
2022 - <th><?php esc_html_e('Time', 'wpstream'); ?></th>
2023 - <th><?php esc_html_e('Type', 'wpstream'); ?></th>
2024 - <th><?php esc_html_e('Description', 'wpstream'); ?></th>
2025 - </tr>
2026 - </thead>
2027 - <tbody>
2028 - <?php
2029 - $logs = get_option('wpstream_logs');
2030 - if ( !is_array($logs) || empty($logs) ) {
2031 - echo '<tr><td colspan="3">' . esc_html__('No logs found.', 'wpstream') . '</td></tr>';
2032 - } else {
2033 - foreach ($logs as $log) {
2034 - echo '<tr>';
2035 - echo '<td>' . esc_html(date('Y-m-d H:i:s', $log['timestamp'] ) ) . '</td>';
2036 - echo '<td>' . esc_html($log['type']) . '</td>';
2037 - echo '<td>' . esc_html($log['description']) . '</td>';
2038 - echo '</tr>';
2039 - }
2040 - }
2041 - ?>
2042 - </tbody>
2043 - </table>
2044 - </div>
2045 - </div>
2046 - </div>
2047 - <?php
2048 - }
2049 -
2050 - /**
2051 - * Get plugins data.
742 +
743 + /**
744 + * Set user roles
2052 745 *
2053 - * @return array
2054 - */
2055 - public function wpstream_get_plugins_data() {
2056 - if (!function_exists('get_plugins')) {
2057 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
2058 - }
2059 -
2060 - // Get all installed plugins
2061 - $all_plugins = get_plugins();
2062 - $update_data = get_site_transient('update_plugins');
2063 - $all_plugins_info = [];
2064 -
2065 - // We want to get data only for the WpStream plugins
2066 - $wpstream_plugins = array(
2067 - 'WpStream' => array(
2068 - 'path' => 'wpstream/wpstream.php',
2069 - ),
2070 - 'WooCommerce' => array(
2071 - 'path' => 'woocommerce/woocommerce.php',
2072 - ),
2073 - 'Meta Box' => array(
2074 - 'path' => 'meta-box/meta-box.php',
2075 - ),
2076 - 'One Click Demo Import' => array(
2077 - 'path' => 'one-click-demo-import/one-click-demo-import.php',
2078 - ),
2079 - 'Better Messages' => array(
2080 - 'path' => 'bp-better-messages/bp-better-messages.php',
2081 - ),
2082 -
2083 - );
2084 -
2085 - foreach ($all_plugins as $plugin_path => $plugin_data) {
2086 - $is_active = is_plugin_active( $plugin_path );
2087 - $has_update = isset( $update_data->response[$plugin_path] );
2088 -
2089 - $plugin_info = [
2090 - 'name' => $plugin_data['Name'],
2091 - 'version' => $plugin_data['Version'],
2092 - 'path' => $plugin_path,
2093 - 'active' => $is_active ? 'Yes' : 'No',
2094 - 'needs_update' => $has_update ? 'Yes' : 'No'
2095 - ];
2096 -
2097 - if ($has_update) {
2098 - $plugin_info['new_version'] = $update_data->response[$plugin_path]->new_version;
2099 - }
2100 -
2101 - $all_plugins_info[] = $plugin_info;
2102 - }
2103 -
2104 - // Filter out the elements from $all_plugins_info that are not in $wpstream_plugins
2105 - foreach ( $all_plugins_info as $key => $plugin_info ) {
2106 - // compare $plugin_info['path'] against the path property on each $wpstream_plugins element item
2107 - // if the path is not in $wpstream_plugins, unset the element
2108 - if ( !in_array( $plugin_info['path'], array_column( $wpstream_plugins, 'path' ) ) ) {
2109 - unset( $all_plugins_info[$key] );
2110 - }
2111 - }
2112 -
2113 - return $all_plugins_info;
2114 - }
2115 -
2116 - public function wpstream_render_outdated_plugin_notice() {
2117 - $has_update = get_site_transient('update_plugins');
2118 - if (isset($has_update->response['plugin/wpstream.php'])) {
2119 - ?>
2120 - <div class="notice notice-warning is-dismissible">
2121 - <p>
2122 - <?php
2123 - printf(
2124 - /* translators: 1: Link to update page */
2125 - esc_html__('A new version of WpStream is available. Please update to the latest version for the best experience. Go to the %1$s to update now.', 'wpstream'),
2126 - '<a href="' . esc_url(admin_url('update-core.php')) . '">' . esc_html__('updates page', 'wpstream') . '</a>'
2127 - );
2128 - ?>
2129 - </p>
2130 - </div>
2131 - <?php
2132 - }
2133 - }
2134 -
2135 -
2136 - /**
2137 - * Set user roles
2138 - *
2139 - * @since 3.0.1
2140 - */
2141 -
2142 - public function user_streaming_global_channel_options(
2143 - $name,
2144 - $value,
2145 - $local_array='',
2146 - $disabled = false,
2147 - $is_basic_stream_mode = false
2148 - ) {
2149 -
746 + * @since 3.0.1
747 + */
748 + public function user_streaming_global_channel_options($name,$value){
749 +
750 +
751 +
2150 752 foreach($this->global_event_options as $key=>$option){
2151 -
2152 - if( is_array($local_array) && !in_array($key,$local_array)){
2153 - print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">';
2154 -
2155 - print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
2156 -
2157 - print '<div style="display: flex; gap: 25px; justify-content: space-between;">';
2158 - print '<div class="settings_details">'.$option['details'].'</div>';
2159 - print '
2160 - <label class="wpstream_switch">
2161 - <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
2162 - if( isset($value[$key]) ){
2163 - if( intval($value[$key]) !==0 ){
2164 - print ' checked ';
2165 - }
2166 - }else{
2167 - if($option['defaults']=='yes') {
2168 - print ' checked ';
2169 - }
753 + print '<div class="wpstream_setting_event_unit_wrapper">';
754 +
755 + print '<label for="'.$option['name'].'">'.$option['name'].'</label>';
756 +
757 + print '
758 + <label class="wpstream_switch">
759 + <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" ';
760 + if( isset($value[$key]) ){
761 + if( intval($value[$key]) !==0 ){
762 + print ' checked ';
2170 763 }
2171 - if ( $disabled || $is_basic_stream_mode ) {
2172 - print ' disabled ';
764 + }else{
765 + if($option['defaults']=='yes') {
766 + print ' checked ';
2173 767 }
2174 -
2175 -
2176 - print '> <span class="wpstream_slider round"></span>';
2177 - print '</label>';
2178 - print '</div>';
2179 -
2180 -
2181 - print '</div>';
2182 - }
768 + }
769 +
770 +
771 + print '> <span class="slider round"></span>';
772 + print '</label>';
773 + print '<div class="settings_details">'.$option['details'].'</div>';
774 +
775 +
776 + print '</div>';
2183 777 }
2184 778
2185 779
2186 780 }
2187 781
2188 -
2189 -
2190 -
2191 -
2192 -
2193 -
2194 782
2195 783
2196 - /*
2197 - * Set user roles
2198 - *
2199 - * @since 3.0.1
2200 - */
2201 -
784 + /**
785 + * Set user roles
786 + *
787 + * @since 3.0.1
788 + */
2202 789 public function wpstream_select_user_roles($name,$value){
2203 790 if($value==''){
2204 791 $value=array();
2205 792 }
@@ -2220,34 +807,27 @@
2220 807
2221 808 return $return;
2222 809 }
2223 810
2224 -
2225 - /*
2226 - * Set credential admin function
2227 - *
2228 - * @since 3.0.1
2229 - */
811 +
812 + /**
813 + * Set credential admin function
814 + *
815 + * @since 3.0.1
816 + */
2230 817 public function wpstream_set_wpstream_credentials(){
2231 818
2232 - if($_SERVER['REQUEST_METHOD'] === 'POST'){
819 + if($_SERVER['REQUEST_METHOD'] === 'POST'){
2233 820 $allowed_html = array();
2234 821 $exclude_array = array();
2235 822 $allowed_html = array();
2236 823
2237 - foreach($_POST as $variable=>$value){
824 + foreach($_POST as $variable=>$value){
2238 825 if ($variable!='submit'){
2239 826 if (!in_array($variable, $exclude_array) ){
2240 - switch ( $variable ) {
2241 - case 'api_username':
2242 - update_option( sanitize_key('wpstream_api_username'), sanitize_text_field($value) );
2243 - break;
2244 - case 'api_password':
2245 - update_option( sanitize_key('wpstream_api_password'), $value );
2246 - break;
2247 - }
2248 - }
2249 - }
827 + update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
828 + }
829 + }
2250 830 }
2251 831
2252 832
2253 833
@@ -2253,16 +833,15 @@
2253 833
2254 834
2255 835 update_option('wp_estate_token_expire',0);
2256 836 update_option('wp_estate_curent_token',' ');
2257 - delete_transient( 'wpstream_token_api');
2258 - delete_transient('wpstream_token_request_30');
2259 - delete_transient('wpstream_request_pack_data_per_user_transient');
837 + delete_transient( 'wpstream_token_request');
838 +
2260 839 }
2261 840
2262 841
2263 842 $allowed_html = array();
2264 -
843 + $api_key = esc_html( get_option('wpstream_api_key','') );
2265 844
2266 845
2267 846 $wpstream_options_array =array(
2268 847 2 => array(
@@ -2278,11 +857,11 @@
2278 857
2279 858 );
2280 859
2281 860
2282 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
2283 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_set_wpstream_credentials' );
2284 -
861 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
862 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
863 +
2285 864 $this->main->show_user_data($pack_details);
2286 865
2287 866 print '<form method="post" action="" >';
2288 867 print '<div class="theme_options_tab_wpstream" style="display:block;" >
@@ -2288,21 +867,14 @@
2288 867 print '<div class="theme_options_tab_wpstream" style="display:block;" >
2289 868 <h1>'.__('WpStream Credentials','wpstream').'</h1>';
2290 869
2291 870
2292 - if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== '' ){
2293 - echo '<div class="api_not_conected wpstream_orange">';
2294 - $admin_url_onboard=get_admin_url().'admin.php?page=wpstream_onboard';
2295 - 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);
2296 - echo '</div>';
2297 -
871 + if( get_option('wpstream_api_username')=='' || get_option('wpstream_api_password')== ' '){
872 + echo '<div class="api_not_conected wpstream_orange">'.__('To connect your plugin, enter your WpStream credentials below or go <a href="https://wpstream.net/my-account/" target="_blank">here</a> to create an account.','wpstream').'</div>';
2298 873 }else if($token==''){
2299 - $text = get_option('wpstream_curl_failed') === "0" ?
2300 - ' 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.' :
2301 - 'Not connected to WpStream. Please note the errors above and contact support.';
2302 - echo '<div class="api_not_conected">'.__($text,'wpstream').'</div>';
874 + 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>';
2303 875 }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){
2304 - echo '<div class="api_conected">'.__('Connected to WpStream.net!','wpstream').'</div>';
876 + echo '<div class="api_conected">'.__('Conected to WpStream.net!','wpstream').'</div>';
2305 877 }else{
2306 878 echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>';
2307 879 }
2308 880 print '<div class="wpstream_option_wrapper">';
@@ -2317,30 +889,23 @@
2317 889 }
2318 890 print '</div>';
2319 891
2320 892
2321 - print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />';
893 + print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
2322 894
2323 - print '<h3>Video Tutorials</h3>';
2324 -
2325 - print '<a class="how_to_videos" target="_blank" href="https://youtu.be/9DQrxsKcpmQ">How to Live Stream to WordPress with OBS</a>';
2326 - print '<a class="how_to_videos" target="_blank" href="https://youtu.be/qMSjJCskAfM">How to Live Stream to WordPress in less than 3 Minutes</a>';
2327 - print '<a class="how_to_videos" target="_blank" href="https://youtu.be/h6myD_vhKcg">How to Live-Stream to WordPress using your iPhone</a>';
2328 -
2329 - print '<a style="margin-top:10px;" href="https://www.youtube.com/channel/UCIjItiJc4Z7aJApj3W6ArJA" target="_blank" class="how_to_videos">More Tutorials On Our YouTube Channel</a>';
2330 -
2331 895
896 +
2332 897 print '</div>';
2333 898 print '</form>';
2334 899
2335 900 print '<div class="theme_options_tab_wpstream" style="display:block;" >';
2336 - $link_new = admin_url('admin.php?page=wpstream_live_channels');
901 + $link_new = admin_url('admin.php?page=wpstream_new_general_set');
2337 902 $link_new_paid = admin_url('post-new.php?post_type=product').'&new_stream='. rawurlencode('new');
2338 903 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
2339 904
2340 905
2341 - print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new Free-To-View channel','wpstream').'</a>';
2342 - print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create Pay-Per-View channel','wpstream').'</a>';
906 + print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new free channel','wpstream').'</a>';
907 + print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create pay-per-view channel','wpstream').'</a>';
2343 908 print '<a href="'.esc_url($link_new).'" class="wpstream_no_chanel_add_channel">'.esc_html('My Channels','wpstream').'</a>';
2344 909 print '</div>';
2345 910
2346 911
@@ -2348,378 +913,169 @@
2348 913
2349 914
2350 915
2351 916 /**
2352 - * Media Management
2353 - *
2354 - * @since 3.0.1
2355 - */
2356 -
917 + * Media Management
918 + *
919 + * @since 3.0.1
920 + */
2357 921 public function wpstream_media_management(){
2358 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_media_management' );
922 + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
2359 923
2360 924 $this->main->show_user_data($pack_details);
2361 925
2362 926
2363 - print '<div id="wpstream_media_upload"><h3>'.__('Upload New Recording','wpstream').'</h3>'.$this->wpstream_present_media_upload().'</div>';
927 + print '<div id="wpstream_media_upload"><h3>'.__('Media Upload','wpstream').'</h3>'.$this->wpstream_present_media_upload().'</div>';
2364 928
2365 - print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Your Recordings','wpstream').'</h3>'.$this->wpstream_present_file_management().'</div>';
929 + print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Video Management','wpstream').'</h3>'.$this->wpstream_present_file_management().'</div>';
2366 930
2367 -
2368 931 }
2369 932
2370 933
2371 -
2372 -
2373 - /**
2374 - *
2375 - *
2376 - * WpStream Pagination
2377 - *
2378 - * @since 3.0.1
2379 - *
2380 - *
2381 - */
2382 -
2383 - public function wpstream_pagination($pages , $range = 2) {
2384 - $return='';
2385 - $showitems = ($range * 2) + 1;
2386 - $paged = ( isset( $_GET['paged'] ) ) ? intval($_GET['paged']) : 1;
2387 -
2388 -
2389 - if (1 != $pages && $pages != 0) {
2390 - $return.= '<ul class="pagination wpstream_pagination">';
2391 - $return.= "<li class=\"roundleft\"><a href='" . get_pagenum_link($paged - 1) . "'><</a></li>";
2392 -
2393 - $last_page = get_pagenum_link($pages);
2394 - for ($i = 1; $i <= $pages; $i++) {
2395 - if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) {
2396 - if ($paged == $i) {
2397 - $return.= '<li class="active"><a href="' . esc_url(get_pagenum_link($i)) . '" >' . $i . '</a><li>';
2398 - } else {
2399 - $return.= '<li><a href="' . esc_url(get_pagenum_link($i)) . '" >' . $i . '</a><li>';
2400 - }
2401 - }
2402 - }
2403 -
2404 - $prev_page = get_pagenum_link($paged + 1);
2405 - if (($paged + 1) > $pages) {
2406 - $prev_page = get_pagenum_link($paged);
2407 - } else {
2408 - $prev_page = get_pagenum_link($paged + 1);
2409 - }
2410 -
2411 -
2412 - $return.= "<li class=\"roundright\"><a href='" . $prev_page . "'>></a><li>";
2413 - $return.= "<li class=\"roundright\"><a href='" . $last_page . "'>>><li>";
2414 - $return.= "</ul>";
2415 - }
2416 - return $return;
2417 - }
2418 -
2419 -
2420 -
2421 -
2422 -
2423 934
2424 935 /**
2425 - * Media upload
2426 - *
2427 - * @since 3.0.1
2428 - */
936 + * Media upload
937 + *
938 + * @since 3.0.1
939 + */
2429 940 public function wpstream_present_media_upload(){
2430 941 $to_return='';
2431 -
2432 - if ( ! $this->main->quota_manager->has_storage_quota( null, 'recordings_screen' ) ) {
2433 - return '<div class="wpstream_upload_alert">'.esc_html__('You don\'t have enough cloud storage or data to upload a new item. Please delete some videos or upgrade your plan.','wpstream').'</div>';
2434 - }
2435 -
2436 942 $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data();
2437 943
2438 - if( !$formInputs['success'] ){
2439 - if ($formInputs['error'] == 'not_connected'){
2440 - $to_return.='<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
2441 - }
2442 - else {
2443 - $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>';
2444 - }
944 + if($formInputs === 'notenough'){
945 + $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough bandwidth or storage to upload a video!','wpstream').'</div>';
2445 946 return $to_return;
2446 947 }
2447 948
2448 - if($formInputs['success'] ===true){
2449 949
2450 -
950 + $to_return.='<div class="wpstream_upload_container">';
951 + $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>';
952 + $to_return.='<form action="https://wpstream-videos.s3.amazonaws.com/"
953 + method="POST"
954 + enctype="multipart/form-data"
955 + class="direct-upload">';
2451 956
2452 - $to_return.='<div class="wpstream_upload_container">';
2453 - $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>';
2454 - $to_return.='<form action="https://wpstream-video.s3.amazonaws.com/"
2455 - method="POST"
2456 - enctype="multipart/form-data"
2457 - data-singleFileUploads="true"
2458 - data-limitMultiFileUploads="1"
2459 - data-limitConcurrentUploads="1"
2460 - class="direct-upload">';
957 + $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
958 + $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>';
2461 959
2462 - $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
2463 - $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>';
2464 960
961 + $to_return.='<div class="wpstream_file_drop_color">';
962 + $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
963 + $to_return.='<div class="wpstream_form_ex_details">'.esc_html__('The Video File must be encoded with the following settings:
2465 964
2466 - $to_return.='<div class="wpstream_file_drop_color">';
2467 - $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
2468 - $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:<br>
965 + Container: MP4,
966 + Video codec: H264,
967 + Audio codec: AAC. Media will fail to play back if it does not follow the above settings.
968 + 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>';
969 + if(is_array($formInputs)){
970 + foreach ($formInputs as $name => $value) {
971 + $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
972 + }
973 + }
2469 974
2470 - Container: <strong>MP4</strong>,<br>
2471 - Video codec: <strong>H264</strong>,<br>
2472 - Audio codec: <strong>AAC</strong>.<br>
2473 - Media will fail to play if it does not follow the above settings.
2474 - 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>';
2475 - if(is_array($formInputs)){
2476 - foreach ($formInputs['ref'] as $name => $value) {
2477 - $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
2478 - }
2479 - }
975 + $to_return.='
976 + <div class="progress-bar-area"></div></div>
977 + </form>';
2480 978
2481 - $to_return.='
2482 - <div class="progress-bar-area"></div></div>
2483 - </form>';
2484 -
2485 - $to_return.='</div>';
2486 - }
2487 -
979 + $to_return.='</div>';
2488 980 return $to_return;
2489 981
2490 982 }
2491 983
2492 -
2493 984
2494 985
2495 -
2496 986 /**
2497 - * Display movie list
2498 - *
2499 - * @since 3.0.1
2500 - */
987 + * Display movie list
988 + *
989 + * @since 3.0.1
990 + */
2501 991 public function wpstream_present_file_management(){
2502 - $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api();
992 + $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_storage_raw_data();
2503 993
2504 - if ( $video_list_raw === false ) {
2505 - return '<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>';
2506 - }
2507 -
2508 - $video_list_raw_array = [];
2509 - if( isset( $video_list_raw['items'] ) ){
2510 - $video_list_raw_array = $video_list_raw['items'];
2511 - }
2512 -
2513 - $keys = array_column( $video_list_raw_array, 'time' );
2514 - array_multisort($keys, SORT_DESC , $video_list_raw_array);
2515 -
2516 994 $to_return='';
995 + if(is_array($video_list_raw)){
996 + foreach ($video_list_raw as $key =>$video){
997 + $to_return.='<div class="wpstream_video_wrapper">';
2517 998
2518 - // show pending items
2519 - if ( key_exists( 'pending', $video_list_raw ) && is_array( $video_list_raw['pending'] ) ) {
2520 - foreach ( $video_list_raw['pending'] as $key => $video ) {
2521 - $video_size = intval($video['size']/1048576);
2522 - $video_name = esc_html($video['name']);
2523 - if($video_name!=''):
2524 - $to_return.='<div class="wpstream_video_wrapper">';
2525 - $to_return.='<div class="wpstream_video_title">';
2526 - $to_return.='<div class="wpstream_video_notice"></div></div>';
2527 - $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>';
2528 - $to_return.='<div class="wpstream_video_pending">' . esc_html__( 'The video is still processing', 'wpstream') . '</div>';
2529 - $to_return.='</div>';
2530 - endif;
999 + $to_return.='<div class="wpstream_video_title">';
1000 + $to_return.='<div class="wpstream_video_notice"></div></div>';
1001 + $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['video_name_storage'].'</span></div>';
1002 + $to_return.=' <div class="wpstream_delete_media" ';
1003 + $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video['video_name_storage'].'?\')" data-filename="'.$video['video_name_storage'].'">'.esc_html__('delete file','wpstream').'</div>';
1004 + $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video['video_name_storage'].'">'.esc_html__('get download link','wpstream').'</div>';
1005 + $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
2531 1006
2532 - }
2533 - }
1007 + $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product').'&new_video_name='. rawurlencode($video['video_name_storage']);
1008 + $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video['video_name_storage']);
2534 1009
2535 - // show uploaded items
2536 - if( is_array($video_list_raw['items'] ) ) {
2537 - foreach ($video_list_raw_array as $key =>$video){
2538 - $video_size = intval($video['size']/1048576);
2539 - $video_name = esc_html($video['name']);
2540 - if($video_name!=''):
2541 - $to_return.='<div class="wpstream_video_wrapper">';
2542 1010
2543 - $to_return.='<div class="wpstream_video_title">';
2544 - $to_return.='<div class="wpstream_video_notice"></div></div>';
2545 - $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>';
2546 - $to_return.=' <div class="wpstream_delete_media" ';
2547 - $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video_name.'?\')" data-filename="'.$video_name.'">'.esc_html__('delete file','wpstream').'</div>';
2548 - $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video_name.'">'.esc_html__('download','wpstream').'</div>';
2549 - $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
2550 1011
2551 - $add_free_video_url=admin_url('post-new.php?post_type=wpstream_product_vod').'&new_video_name='. rawurlencode($video_name);
2552 - $add_paid_video_url=admin_url('post-new.php?post_type=product').'&new_video_name='. rawurlencode($video_name);
1012 + $to_return .='<a class="create_new_free_video" href="'.esc_url($add_free_video_url).'">'.esc_html__('Create new free VOD from this video').'</a>';
1013 + $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create pay-per-view VOD from this video').'</a>';
2553 1014
1015 + $to_return.='</div>';
2554 1016
2555 -
2556 - $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>';
2557 - if (class_exists('WooCommerce')) {
2558 - $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>';
2559 - }
2560 -
2561 - $to_return.='</div>';
2562 - endif;
2563 -
2564 1017 }
2565 - $current_page= get_current_screen();
2566 - }
2567 -
2568 - // no items to show
2569 - if ( !is_array( $video_list_raw['items'] ) || ( key_exists( 'pending', $video_list_raw ) && !is_array( $video_list_raw['pending'] ) ) ) {
2570 - $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
1018 + } else {
1019 + $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
2571 1020 }
2572 1021 return $to_return;
2573 1022 }
2574 1023
2575 1024
2576 - /**
2577 - * Set defualt channels values
2578 - *
2579 - * @since 3.0.1
2580 - */
2581 -
2582 -
2583 -
2584 -
2585 - public function wpstream_publish_wpstream_product($post_id,$post){
2586 - if( $post->post_type == 'wpstream_product' ){
2587 - update_post_meta ($post_id,'local_event_options_test','working_on_'.$post_id);
2588 - update_post_meta ($post_id, 'use_global_event_options', true);
2589 - $to_save_option=array();
2590 -
2591 - $global_options= get_option('wpstream_user_streaming_global_channel_options');
2592 -
2593 - $local_events = get_post_meta ($post_id ,'local_event_options',true) ;
2594 -
2595 - if( $local_events =='' ){
2596 - if( is_array($global_options) ){
2597 - foreach($global_options as $key=>$value){
2598 - $to_save_option[sanitize_key($key)]=sanitize_text_field($value);
2599 - }
2600 -
2601 - update_post_meta ($post_id,'local_event_options',$to_save_option);
2602 -
2603 - }
2604 - }
2605 -
2606 -
2607 - }
2608 - }
2609 -
2610 - public function wpstream_create_remote_channel_on_publish( $post_id, $post ) {
2611 - $is_free_channel = $post->post_type == 'wpstream_product';
2612 - $is_paid_channel = $post->post_type == 'product' && has_term( 'live_stream', 'product_type', $post_id );
2613 -
2614 - if ( !$is_free_channel && !$is_paid_channel ) {
2615 - return;
2616 - }
2617 -
2618 - if ( defined( 'DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
2619 - return;
2620 - }
2621 - if ( wp_is_post_revision( $post_id ) ) {
2622 - return;
2623 - }
2624 - if ( get_post_meta( $post_id, '_wpstream_remote_channel_created', true ) ) {
2625 - return;
2626 - }
2627 -
2628 - $response = $this->main->wpstream_live_connection->wpstream_create_channel( $post_id );
2629 - error_log('channel/create response for post ' . $post_id . ' is ' . print_r($response, true));
2630 -
2631 - if ( $response && ! empty( $response['success'] ) ) {
2632 - if ( isset($response['channel_id']) && $response['channel_id'] !== '' ) {
2633 - update_post_meta( $post_id, 'channelId', $response['channel_id'] );
2634 - update_post_meta( $post_id, 'embedUrl', LIVE_PLAYER_URL_PREFIX . '?' . http_build_query( array( 'channelId' => $response['channel_id'] ) ) );
2635 - update_post_meta( $post_id, '_wpstream_remote_channel_created', 1 );
2636 - }
2637 - }
2638 - }
2639 -
1025 +
1026 +
1027 +
2640 1028 /**
2641 - * save meta options
2642 - *
2643 - * @since 3.0.1
2644 - */
1029 + * save meta options
1030 + *
1031 + * @since 3.0.1
1032 + */
2645 1033 public function wpstream_free_product_update_post($post_id,$post){
2646 -
1034 +
2647 1035 if(!is_object($post) || !isset($post->post_type)) {
2648 1036 return;
2649 1037 }
2650 1038
1039 + if($post->post_type!='wpstream_product'){
1040 + return;
1041 + }
2651 1042
2652 -
2653 1043
1044 + $allowed_keys=array(
1045 + 'wpstream_product_type',
1046 + 'wpstream_free_video',
1047 + 'wpstream_free_video_external'
1048 + );
2654 1049
1050 + $allowed_html=array();
2655 1051
2656 -
2657 - if( $post->post_type == 'wpstream_product' ||
2658 - $post->post_type == 'wpstream_product_vod' ):
2659 -
2660 - $allowed_keys=array(
2661 - 'wpstream_product_type',
2662 - 'wpstream_free_video',
2663 - 'wpstream_free_video_external',
2664 - 'wpstream_closed_captions_file'
2665 - );
2666 -
2667 -
2668 - foreach ($_POST as $key => $value) {
2669 - if( !is_array ($value) ){
2670 - if (in_array ($key, $allowed_keys)) {
2671 - $postmeta = sanitize_text_field ( $value );
2672 - update_post_meta($post_id, sanitize_key($key), $postmeta );
2673 - }
2674 - }
2675 - }
2676 -
2677 - endif;
2678 -
1052 + foreach ($_POST as $key => $value) {
1053 + if( !is_array ($value) ){
1054 + if (in_array ($key, $allowed_keys)) {
1055 + $postmeta = wp_kses ( $value,$allowed_html );
1056 + update_post_meta($post_id, sanitize_key($key), $postmeta );
1057 + }
1058 + }
1059 + }
2679 1060 }
2680 1061
2681 1062
2682 1063 /**
2683 - * save meta options
2684 - *
2685 - * @since 3.0.1
2686 - */
2687 - public function add_wpstream_product_metaboxes() {
2688 - global $post;
2689 - $post_id = $post->ID;
2690 -
2691 -
2692 -
2693 -
2694 - 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');
2695 - add_meta_box( 'custom_metabox_video_collection', esc_html__( 'Video Collection', 'wpstream' ), 'wpstream_bundle_custom_metabox_callback', 'wpstream_bundles', 'normal', 'high' );
2696 -
2697 - if(function_exists('wc_get_product')):
2698 - $product = wc_get_product( $post_id );
2699 - if ( $product ) {
2700 -
2701 - if ( $product->get_type() === 'wpstream_bundle' ) {
2702 - add_meta_box(
2703 - 'wpstream_woo_custom_metabox',
2704 - esc_html__( 'Video Collection Options', 'wpstream' ),
2705 - 'wpstream_bundle_custom_metabox_callback',
2706 - 'product',
2707 - 'normal',
2708 - 'default'
2709 - );
2710 - }
2711 - }
2712 - endif;
2713 -
1064 + * save meta options
1065 + *
1066 + * @since 3.0.1
1067 + */
1068 + public function add_wpstream_product_metaboxes() {
1069 + add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Live Channel/Video Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product' ,'normal','default');
2714 1070 }
2715 1071
2716 1072
2717 1073 /**
2718 - * make woocomerce virtual products
2719 - *
2720 - * @since 3.0.1
2721 - */
1074 + * make woocomerce virtual products
1075 + *
1076 + * @since 3.0.1
1077 + */
2722 1078
2723 1079
2724 1080 public function wpstream_make_product_virtual($post_id,$post){
2725 1081 global $post;
@@ -2725,12 +1081,9 @@
2725 1081 global $post;
2726 1082 if(isset($post->ID)){
2727 1083 if ( $post->post_type !== 'product' ) return;
2728 1084 $term_list = wp_get_post_terms($post->ID, 'product_type');
2729 - if( !empty($term_list) &&
2730 - isset($term_list[0]->name) &&
2731 - in_array($term_list[0]->name, ['live_stream', 'video_on_demand', 'wpstream_bundle'])
2732 - ){
1085 + if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
2733 1086 update_post_meta( $post->ID, '_virtual', 'yes' );
2734 1087 }
2735 1088 }
2736 1089 }
@@ -2736,13 +1089,13 @@
2736 1089 }
2737 1090
2738 1091
2739 1092
2740 - /**
2741 - * render meta options
2742 - *
2743 - * @since 3.0.1
2744 - */
1093 + /**
1094 + * render meta options
1095 + *
1096 + * @since 3.0.1
1097 + */
2745 1098 public function display_meta_options( $post ) {
2746 1099 wp_nonce_field( plugin_basename( __FILE__ ), 'estate_agent_noncename' );
2747 1100 global $post;
2748 1101
@@ -2772,67 +1125,47 @@
2772 1125 print'
2773 1126 <p class="meta-options">
2774 1127 <label for="wpstream_product_type">'.__('Media Type:','wpstream').' </label><br />
2775 1128 <select id="wpstream_product_type" name="wpstream_product_type">
2776 - <option value="2" '.$is_video.'>'.__('Recording','wpstream').'</option>
2777 - <option value="3" '.$is_video_external.'>'.__('Self Hosted or External Video','wpstream').'</option>
1129 + <option value="1" '.$is_live.'>'.__('Free Live Channel - encrypted streaming & copy protection','wpstream').'</option>
1130 + <option value="2" '.$is_video.'>'.__('Free Video - encrypted streaming & copy protection','wpstream').'</option>
1131 + <option value="3" '.$is_video_external.'>'.__('Free Video - unprotected','wpstream').'</option>
2778 1132 </select>
2779 1133 </p>
2780 1134 ';
2781 1135
2782 1136
2783 - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2784 -
2785 1137
2786 - print '<div class="meta-options video_free">';
2787 - print '<p class="meta-option wpstream_free_video">';
2788 - print '<label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
1138 + print '
1139 + <p class="meta-options video_free">
1140 + <label for="wpstream_free_video">'.__('Choose video:','wpstream').' </label><br />
2789 1141 <select id="wpstream_free_video" name="wpstream_free_video">';
1142 + $video_list = $this->main->wpstream_live_connection->wpstream_get_videos();
2790 1143
2791 - if( is_array( $video_list ) ) {
2792 - foreach ($video_list as $key=>$value){
2793 - print '<option value="'.$key.'"';
2794 - if($wpstream_free_video === $key){
2795 - print ' selected ';
1144 + if(is_array($video_list)){
1145 + foreach ($video_list as $key=>$value){
1146 + print '<option value="'.$key.'"';
1147 + if($wpstream_free_video === $key){
1148 + print ' selected ';
1149 + }
1150 + print '>'.$value.'</option>';
1151 + }
2796 1152 }
2797 - print '>'.$value.'</option>';
2798 - }
2799 - }
2800 - print'</select>';
2801 - print '</p> ';
1153 + print'
1154 + </select>
1155 + </p>
1156 + ';
2802 1157
2803 - $wpstream_closed_captions_file = get_post_meta($post->ID, 'wpstream_closed_captions_file', true);
1158 + $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
1159 + print '<p class="meta-options1 video_free_external">
1160 + <label for="wpstream_free_video_external">'.__('Choose video:','wpstream').' </label><br />
2804 1161
2805 - $button_style = $wpstream_closed_captions_file ? 'style="display:none;"' : '';
1162 + <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
1163 + <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />
2806 1164
2807 - print '<p class="meta-option wpstream_vod_captions_url">';
2808 - print '<label for="wpstream_vod_captions_url_button">'.__('Captions file (optional):','wpstream').' </label><br />
2809 - <input type="hidden" id="wpstream_closed_captions_file" name="wpstream_closed_captions_file" value="'.esc_attr($wpstream_closed_captions_file).'" />
2810 - <input id="wpstream_vod_captions_url_button" type="button" class="upload_button button" value="'.esc_html__('Select .vtt Captions File','wpstream').'" '.$button_style.' />
2811 - <span class="wpstream_caption_file_display">'.( $wpstream_closed_captions_file ? esc_html( basename( $wpstream_closed_captions_file ) ) : '' ).'</span>';
2812 - if ( $wpstream_closed_captions_file ) {
2813 - print '<input type="button" class="button wpstream_remove_caption" value="'.esc_html__('Remove','wpstream').'" style="margin-left: 5px;" />';
2814 - }
2815 - print '</p> ';
2816 - print '</div>';
1165 + <p>'.esc_html__('You can choose a video from your computer or use the url from external source or use the url of a YouTube Video or use the url from a Vimeo video.','wpstream').'</p>
2817 1166
2818 - $wpstream_free_video_external= esc_html(get_post_meta($post->ID, 'wpstream_free_video_external', true));
2819 - print '<div class="meta-options1 video_free_external">
2820 - <label for="wpstream_free_video_external">'.__('Video:','wpstream').' </label><br />
2821 -
2822 - <input id="wpstream_free_video_external" type="text" size="36" name="wpstream_free_video_external" value="'.$wpstream_free_video_external.'" />
2823 - <input id="wpstream_free_video_external_button" type="button" size="40" class="upload_button button" value="'.esc_html__('Select Video','wpstream').'" />';
2824 - if($wpstream_product_type==2){
2825 - $show_recording='';
2826 - $show_external='style="display:none"';
2827 - }else{
2828 - $show_recording='style="display:none"';
2829 - $show_external='';
2830 - }
2831 - print '<p '.$show_recording.' class="wpstream_option_vod_source wpstream_show_recording">'.esc_html__('Choose one of your existing recordings.','wpstream').'</p>';
2832 - 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>';
2833 -
2834 - print '</div> ';
1167 + </p> ';
2835 1168 }
2836 1169
2837 1170
2838 1171
@@ -2850,92 +1183,29 @@
2850 1183 $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' );
2851 1184
2852 1185 return $types;
2853 1186 }
2854 -
2855 - public function wpstream_add_products_class( $classname, $product_type ) {
2856 - if ( 'live_stream' === $product_type ) {
2857 - $classname = 'WC_Product_Live_Stream';
2858 - }
2859 - if ( 'video_on_demand' === $product_type ) {
2860 - $classname = 'WC_Product_Video_On_Demand';
2861 - }
2862 - return $classname;
2863 - }
2864 -
2865 - public function wpstream_add_custom_wc_products() {
2866 - if( class_exists( 'WooCommerce' ) ){
2867 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php';
2868 - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php';
2869 - }
2870 - }
2871 -
1187 +
1188 +
1189 +
2872 1190 /**
2873 1191 * Js action to do when user pick live stream or video on demand
2874 1192 *
2875 1193 * @since 3.0.1
2876 - */
2877 -
2878 - /**
2879 - * Whether WpStream WooCommerce product UI should load for this product.
2880 - *
2881 - * Skips simple, course, and other non-WpStream types so LearnDash and
2882 - * other integrations can use the General product data tab without conflict.
2883 - *
2884 - * @param int $post_id Product post ID. Uses global $post when 0.
2885 - * @return bool
2886 - */
2887 - public function wpstream_is_wpstream_wc_product_context( $post_id = 0 ) {
2888 - if ( isset( $_GET['new_stream'] ) || isset( $_GET['new_video_name'] ) ) {
2889 - return true;
2890 - }
2891 -
2892 - if ( ! $post_id ) {
2893 - global $post;
2894 - $post_id = ( $post && isset( $post->ID ) ) ? (int) $post->ID : 0;
2895 - }
2896 -
2897 - if ( ! $post_id || ! function_exists( 'wc_get_product' ) ) {
2898 - return false;
2899 - }
2900 -
2901 - $product = wc_get_product( $post_id );
2902 - if ( ! $product ) {
2903 - return false;
2904 - }
2905 -
2906 - return in_array(
2907 - $product->get_type(),
2908 - array( 'live_stream', 'video_on_demand', 'wpstream_bundle', 'subscription' ),
2909 - true
2910 - );
2911 - }
2912 -
2913 - /**
2914 - * Js action to do when user pick live stream or video on demand
2915 - *
2916 - * @since 3.0.1
2917 - */
1194 + */
1195 +
2918 1196 public function wpstream_products_custom_js() {
2919 1197 if ( 'product' != get_post_type() ) :
2920 1198 return;
2921 1199 endif;
2922 1200
2923 - if ( ! $this->wpstream_is_wpstream_wc_product_context() ) {
2924 - return;
2925 - }
2926 -
2927 1201 ?>
2928 1202 <script type='text/javascript'>
2929 1203 jQuery( document ).ready( function() {
2930 1204 jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show();
2931 1205 jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show();
2932 - jQuery('.options_group.pricing' ).addClass ( 'show_if_wpstream_bundle' ).show();
2933 -
2934 1206 jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show();
2935 1207 jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show();
2936 - jQuery('._sold_individually_field').parent().addClass('show_if_wpstream_bundle').show();
2937 -
2938 1208 jQuery('._sold_individually_field').show();
2939 1209
2940 1210 var selected = jQuery('#product-type').val();
2941 1211 });
@@ -2951,45 +1221,17 @@
2951 1221 * @since 3.0.1
2952 1222 */
2953 1223
2954 1224 public function wpstream_hide_attributes_data_panel( $tabs) {
2955 -
2956 - $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand hide_if_wpstream_bundle';
2957 - $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand show_if_wpstream_bundle';
2958 -
1225 +
1226 + $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand';
1227 + $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1228 + // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand';
1229 +
2959 1230 return $tabs;
2960 1231 }
2961 1232
2962 1233
2963 -
2964 - /**
2965 - * Hide buy now on products if Netflix mode
2966 - *
2967 - * @since 3.12
2968 - */
2969 -
2970 -
2971 - public function wpstream_hide_buy_now_subscription_mode( $purchaseable_product_wpblog,$product){
2972 - $product_id=$product->get_id();
2973 -
2974 - $term_list = wp_get_post_terms($product_id, 'product_type');
2975 -
2976 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
2977 -
2978 - if($subscription_model==1){ // if we have Neflix mode
2979 - if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='wpstream_bundle' ){
2980 - return false;
2981 - }
2982 - }
2983 -
2984 - return $purchaseable_product_wpblog;
2985 - }
2986 -
2987 -
2988 -
2989 -
2990 -
2991 -
2992 1234 /**
2993 1235 * Add custom fields to custom product types
2994 1236 *
2995 1237 * @since 3.0.1
@@ -2995,20 +1237,17 @@
2995 1237 * @since 3.0.1
2996 1238 */
2997 1239
2998 1240 public function wpstream_add_custom_general_fields() {
1241 +
2999 1242 global $woocommerce, $post;
3000 -
3001 - if ( ! $this->wpstream_is_wpstream_wc_product_context( isset( $post->ID ) ? (int) $post->ID : 0 ) ) {
3002 - return;
3003 - }
3004 1243 if(function_exists('wcs_user_has_subscription')){
3005 - echo '<div class="options_group show_if_subscription">';
1244 + echo '<div class="options_group show_if_subscription">';
3006 1245 woocommerce_wp_select(
3007 1246 array(
3008 1247 'id' => '_subscript_live_event',
3009 1248 'label' => __( 'Is a subscription based live channel ?', 'woocommerce' ),
3010 - 'options' => array("yes"=>"yes","no"=>"no", "none" => "none")
1249 + 'options' => array("yes"=>"yes","no"=>"no")
3011 1250 )
3012 1251 );
3013 1252 echo '</div>';
3014 1253 }
@@ -3014,10 +1253,8 @@
3014 1253 }
3015 1254
3016 1255 echo '<div class="options_group show_if_live_stream" style="border:none;"></div>';
3017 1256 echo '<div class="options_group show_if_video_on_demand">';
3018 -
3019 -
3020 1257 $selected='';
3021 1258 if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){
3022 1259 $selected=esc_html($_GET['new_video_name']);
3023 1260 }
@@ -3023,87 +1260,21 @@
3023 1260 }
3024 1261 if($selected==''){
3025 1262 $selected= get_post_meta($post->ID,'_movie_url',true);
3026 1263 }
3027 - if( !current_user_can('administrator') ){
3028 - print '<div style="margin:10px;">'.esc_html('You need to be an administrator in order to assign videos','wpstream').'</div>';
3029 - }else{
3030 - woocommerce_wp_select(
3031 - array(
3032 - 'id' => '_movie_url',
3033 - 'label' => __( 'Choose video', 'woocommerce' ),
3034 - 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
3035 - 'selected'=> true,
3036 - 'value' => $selected
3037 - )
3038 - );
3039 - }
3040 -
3041 -
3042 1264
3043 - echo '</div>';
3044 -
3045 - if(function_exists('wcs_user_has_subscription')){
3046 - $selected_sub='';
3047 - echo '<div class="options_group show_if_video_on_demand show_if_live_stream">';
3048 - if( isset( $_GET['wpstream_parent_sub']) && $_GET['wpstream_parent_sub']!='' ){
3049 - $selected_sub=esc_html($_GET['wpstream_parent_sub']);
3050 - }
3051 - if($selected_sub==''){
3052 - $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
3053 - }
3054 - woocommerce_wp_select(
1265 + woocommerce_wp_select(
3055 1266 array(
3056 - 'id' => '_wpstream_parent_sub',
3057 - 'name' => '_wpstream_parent_sub[]',
3058 - 'label' => __( 'Attach to subscription', 'woocommerce' ),
3059 - 'options' => $this->wpstream_return_subscriptions_created(),
1267 + 'id' => '_movie_url',
1268 + 'label' => __( 'Select the video file.', 'woocommerce' ),
1269 + 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(),
3060 1270 'selected'=> true,
3061 - 'value' => $selected_sub,
3062 - 'custom_attributes' => array('multiple' => 'multiple')
1271 + 'value' => $selected
3063 1272 )
3064 1273 );
3065 -
3066 - echo '</div>';
3067 -
3068 - }
1274 +
1275 + echo '</div>';
3069 1276 }
3070 -
3071 -
3072 - public function wpstream_return_subscriptions_created(){
3073 - $return=array('0'=>'none');
3074 -
3075 - $args = array(
3076 - 'post_type' => 'product',
3077 - 'posts_per_page' => -1,
3078 - 'orderby' => 'title',
3079 - 'order' => 'ASC',
3080 - 'tax_query' => array(
3081 - 'relation' => 'AND',
3082 - array(
3083 - 'taxonomy' => 'product_type',
3084 - 'field' => 'slug',
3085 - 'terms' => array( 'subscription'),
3086 - )
3087 - )
3088 - );
3089 -
3090 - $subscriptions = new WP_Query($args);
3091 - if($subscriptions->have_posts()):
3092 - while ($subscriptions->have_posts()): $subscriptions->the_post();
3093 - $return[ get_the_ID() ] = get_the_title();
3094 - endwhile;
3095 - endif;
3096 -
3097 - wp_reset_postdata();
3098 - return $return;
3099 -
3100 - }
3101 -
3102 -
3103 -
3104 -
3105 -
3106 1277
3107 1278 /**
3108 1279 * Save custom fields
3109 1280 *
@@ -3110,38 +1281,22 @@
3110 1281 * @since 3.0.1
3111 1282 */
3112 1283
3113 1284 public function wpstream_add_custom_general_fields_save( $post_id ){
3114 - if ( ! $this->wpstream_is_wpstream_wc_product_context( (int) $post_id ) ) {
3115 - return;
3116 - }
3117 1285
3118 1286 $permited_values = array(
3119 1287 '_movie_url',
3120 - '_subscript_live_event',
3121 - '_wpstream_parent_sub',
3122 -
1288 + '_subscript_live_event'
3123 1289 );
3124 -
3125 -
3126 -
1290 + $allowed_html=array();
3127 1291 foreach($_POST as $key=>$value){
3128 1292 update_post_meta( $post_id, 'event_passed', 0 );
3129 1293 if( in_array($key, $permited_values) ){
3130 1294 if( !empty( $_POST[$key] ) ){
3131 - $key = sanitize_key($key);
3132 - $value = sanitize_text_field($_POST[$key]);
3133 -
3134 - if($key=='_wpstream_parent_sub'){
3135 - $value= $_POST[$key];
3136 - $value = array_map("sanitize_text_field", $value);
3137 -
3138 - }
3139 - update_post_meta( $post_id, $key, $value );
1295 + update_post_meta( $post_id, wp_kses ($key,$allowed_html), wp_kses ( $_POST[$key],$allowed_html) );
3140 1296 }
3141 1297 }
3142 1298 }
3143 - //die();
3144 1299
3145 1300 }
3146 1301
3147 1302 /**
@@ -3180,24 +1335,14 @@
3180 1335 public function wpstream_admin_notice() {
3181 1336 global $pagenow;
3182 1337 global $typenow;
3183 1338
3184 - $wpstream_notices = get_option('wpstream_notices');
3185 1339
3186 - /*
3187 1340 if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
3188 - if( !is_array($wpstream_notices) ||
3189 - !isset($wpstream_notices['wpstream_woo_notice']) ||
3190 - ( isset($wpestate_notices['wpstream_woo_notice']) && $wpestate_notices['wpstream_woo_notice']!='yes') ){
3191 -
3192 -
3193 - print '<div class="notice wpstream_notices notice-error is-dismissible" data-notice-type="wpstream_woo_notice" >
3194 - <p>'.__( 'WpStream Pay-Per-View Live Streaming and VOD only works with WooCommerce - Please enable and activate the WooCommerce plugin if you want to monetize your Live Events or Recorded Videos', 'wpstream' ).'</p>
1341 + print '<div class="notice notice-error is-dismissible">
1342 + <p>'.__( 'WpStream Pay Per View / Subscription mode works only with WooCommerce - If you want to charge money for your live events or videos you need to activate WooCommerce plugin', 'wpstream' ).'</p>
3195 1343 </div>';
3196 - }
3197 1344 }
3198 - */
3199 -
3200 1345 if( !in_array ('curl', get_loaded_extensions())) {
3201 1346 print '<div class="notice notice-error is-dismissible">
3202 1347 <p>'.__( 'The php CURL library is not enabled on your server. WpStream plugin needs this library in order to work. Please address this issue with your hosting provider.', 'wpstream' ).'</p>
3203 1348 </div>';
@@ -3203,98 +1348,28 @@
3203 1348 </div>';
3204 1349 }
3205 1350
3206 1351
3207 - $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
3208 - print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
1352 + $wpestate_notices = get_option('wp_stream_notices');
3209 1353
3210 - }
1354 + if( !is_array($wpestate_notices) ||
1355 + !isset($wpestate_notices['wpstream_update_1021']) ||
1356 + ( isset($wpestate_notices['wpstream_update_1021']) && $wpestate_notices['wpstream_update_1021']!='yes') ){
3211 1357
3212 - /**
3213 - * Get plugin latest update release date from WordPress.org
3214 - * @param $plugin_slug
3215 - * @param $version
3216 - *
3217 - * @return bool
3218 - */
3219 - public function get_plugin_release_date( $plugin_slug, $version = null ) {
3220 - $api_url = 'https://api.wordpress.org/plugins/info/1.0/' . $plugin_slug . '.json';
3221 - $response = wp_remote_get( $api_url );
3222 -
3223 - if ( is_wp_error( $response ) ) {
3224 - return false;
1358 + print '<div id ="setting-error-wprentals-cache" data-notice-type="wpstream_update_1021" data-dismissible="disable-done-notice-forever" class="wpestate_notices updated settings-error notice is-dismissible">
1359 + <p>'.esc_html__( 'New! We just released WpStream WordPress Theme - a turn key solution for video delivery & live streaming. This theme is built around WpStream plugin and is the perfect solution for video streaming or rentals platform. ','wpstream').'<a href="https://wpstream.net/wpstream-theme-a-live-streaming-wordpress-theme" target="_blank">'.esc_html__('Download Theme','wpstream').'</a></p>
1360 + </div>';
3225 1361 }
3226 1362
3227 - $body = wp_remote_retrieve_body( $response );
3228 - $data = json_decode( $body, true );
3229 1363
3230 - if ( !$data || !isset( $data['versions'] ) ) {
3231 - return false;
3232 - }
3233 1364
3234 - // no version provided, get the latest version
3235 - if ( !$version ) {
3236 - $version = $data['version'];
3237 - }
3238 1365
3239 - // check if the version exists in the versions array
3240 - if ( !isset( $data['versions'][ $version ] ) ) {
3241 - return false;
3242 - }
3243 1366
3244 - if ( isset( $data['last_updated'] ) ) {
3245 - return date('Y-m-d', strtotime( $data['last_updated'] ) );
3246 - }
1367 + $ajax_nonce = wp_create_nonce( "wpstream_notice_nonce" );
1368 + print '<input type="hidden" id="wpstream_notice_nonce" value="'.esc_html($ajax_nonce).'"/>';
3247 1369
3248 - return false;
3249 1370 }
3250 -
3251 - /**
3252 - * Adds notice for the WpStream update availability
3253 - * when the update is not older than 30 days
3254 - */
3255 - public function wpstream_plugin_update_available_notice() {
3256 - if (!current_user_can('update_plugins')) {
3257 - return;
3258 - }
3259 -
3260 - $plugin_slug = 'wpstream/wpstream.php';
3261 - $update_data = get_site_transient('update_plugins');
3262 -
3263 - if ( is_object( $update_data ) &&
3264 - property_exists( $update_data, 'response' ) &&
3265 - is_array($update_data->response) &&
3266 - key_exists($plugin_slug, $update_data->response)
3267 - ) {
3268 - $new_version = $update_data->response[$plugin_slug]->new_version;
3269 -
3270 - $release_date = $this->get_plugin_release_date( 'wpstream', $new_version );
3271 -
3272 - if ( $release_date ) {
3273 - $days_since_release = ( time() - strtotime( $release_date ) ) / DAY_IN_SECONDS;
3274 -
3275 - // if there's an update newer than 7 days, do not show the notice
3276 - if ( $days_since_release < 7 ) {
3277 - return;
3278 - }
3279 - }
3280 - $update_url = wp_nonce_url(
3281 - self_admin_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin_slug)),
3282 - 'upgrade-plugin_' . $plugin_slug
3283 - );
3284 -
3285 - echo '<div class="notice notice-warning is-dismissible">';
3286 - echo '<p><strong>' . __('WpStream Plugin Update Available', 'wpstream') . '</strong></p>';
3287 - echo '<p>' . sprintf(
3288 - __('Version %s is available. Please update to the latest version for new features and security improvements.', 'wpstream'),
3289 - '<strong>' . esc_html($new_version) . '</strong>'
3290 - ) . '</p>';
3291 - echo '<p><a href="' . esc_url($update_url) . '" class="button button-primary">' .
3292 - __('Update Now', 'wpstream') . '</a></p>';
3293 - echo '</div>';
3294 - }
3295 - }
3296 -
1371 +
3297 1372 /**
3298 1373 * Admin notices
3299 1374 *
3300 1375 * @since 3.0.1
@@ -3311,13 +1386,12 @@
3311 1386 }
3312 1387
3313 1388 $notices[$notice_type]='yes';
3314 1389
3315 - update_option('wpstream_notices',$notices);
1390 + update_option('wp_stream_notices',$notices);
3316 1391 die();
3317 1392 }
3318 1393
3319 -
3320 1394
3321 1395
3322 1396 /**
3323 1397 * Activate metaboxes for Streaming controls on sidebar
@@ -3326,19 +1400,15 @@
3326 1400 */
3327 1401 public function wpstream_startstreaming_sidebar_meta() {
3328 1402 global $post;
3329 1403 $term_list = wp_get_post_terms($post->ID, 'product_type');
3330 -
3331 - add_meta_box(
3332 - 'wpstream-sidebar-meta',
3333 - esc_html__('Live Streaming', 'wpstream'),
3334 - array($this,'wpstream_start_stream_meta'),
3335 - 'wpstream_product',
3336 - 'side',
3337 - 'high'
3338 - );
1404 + if( get_post_meta($post->ID, 'wpstream_product_type', true)==1 ){
1405 + add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high');
1406 + }
3339 1407
3340 1408 $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true));
1409 +
1410 +
3341 1411 if(!is_wp_error( $term_list )){
3342 1412 if( isset($term_list[0]->name) ){
3343 1413 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
3344 1414 add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'product', 'side', 'high');
@@ -3347,11 +1417,9 @@
3347 1417 }
3348 1418
3349 1419 }
3350 1420
3351 - /**
3352 - * edited 4.0
3353 - *
1421 + /**
3354 1422 * Show Streaming controls on sidebar
3355 1423 *
3356 1424 * @since 3.0.1
3357 1425 */
@@ -3356,1251 +1424,13 @@
3356 1424 * @since 3.0.1
3357 1425 */
3358 1426 public function wpstream_start_stream_meta(){
3359 1427 global $live_event_for_user;
3360 - $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user();
3361 -
3362 1428 global $post;
3363 - $local_event_options = get_post_meta ($post->ID,'local_event_options','');
3364 -
3365 -
3366 -
3367 - if( get_post_status( $post->ID ) === 'publish' ) {
3368 - $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
3369 - print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
3370 -
3371 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_new_general_set' );
3372 - if( isset($pack_details['available_data_mb'])){
3373 - if ($pack_details['available_data_mb'] <= 0){
3374 - print '<input type="hidden" id="wpstream_basic_streaming" value="true">';
3375 - }
3376 - }
3377 -
3378 - $this->wpstream_live_stream_unit($post->ID);
3379 - print '<div class="wpstream_modal_background"></div>';
3380 - print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div>
3381 - <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div>
3382 - </div>';
3383 - } else {
3384 - esc_html_e('To Go Live, please publish your channel first !','wpstream');
3385 - }
3386 - }
3387 -
3388 -
3389 - public function wpstream_is_basic_streaming_mode(){
3390 - return $this->main->quota_manager->is_basic_streaming_mode( null, 'wpstream_is_basic_streaming_mode' );
3391 - }
3392 -
3393 - public function wpstream_is_use_streaming_hours() {
3394 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_start_channel' );
3395 - return $this->main->quota_manager->uses_streaming_hours( $pack_details );
3396 - }
3397 -
3398 - /**
3399 - * Cached-only flags for start_streaming.js localization (no API on cold cache).
3400 - *
3401 - * @return array{is_basic_streaming: bool, use_streaming_hours: bool}
3402 - */
3403 - public function wpstream_get_start_streaming_localization_flags() {
3404 - return $this->main->quota_manager->get_streaming_ui_flags_from_cache();
3405 - }
3406 -
3407 -
3408 -
3409 - /**
3410 - *
3411 - *
3412 - *
3413 - */
3414 - public function add_dashboard_page() {
3415 - add_dashboard_page( '', '', 'administrator', 'wpstream-onboarding', '' );
3416 - }
3417 -
3418 -
3419 -
3420 -
3421 -
3422 - public function wpstream_load_onboarding_wizard() {
3423 -
3424 - // Check for wizard-specific parameter
3425 - // Allow plugins to disable the onboarding wizard
3426 - // Check if current user is allowed to save settings.
3427 -
3428 -
3429 - // Don't load the interface if doing an ajax call.
3430 - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
3431 - return;
3432 - }
3433 -
3434 - set_current_screen();
3435 -
3436 - // Remove an action in the Gutenberg plugin ( not core Gutenberg ) which throws an error.
3437 - remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );
3438 -
3439 - $this->actual_load_onboarding_wizard();
3440 -
3441 - }
3442 -
3443 -
3444 - /*
3445 - * Add on boarding to footer
3446 - */
3447 -
3448 -
3449 -
3450 - public function wpstream_admin_footer_onboarding(){
3451 - if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') {
3452 - $this->wpstream_onboard_display();
3453 - }
3454 - }
3455 -
3456 -
3457 - /*
3458 - * On Board Display
3459 - *
3460 - */
3461 -
3462 - public function wpstream_pre_onboard_display(){
3463 - $pack_details = $this->main->quota_manager->get_live_quota_data( 'wpstream_pre_onboard_display' );
3464 - $this->main->show_user_data($pack_details);
3465 -
3466 - $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3467 - ?>
3468 - <div id="wpstream-onboarding-root"></div>
3469 - <div class="wpstream_quick_start_wrapper">
3470 - <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
3471 -
3472 - <h1><?php print esc_html__('WpStream','wpstream').' <span class="header_special">'.esc_html__('Quick Start','wpstream').'</span>';?></h1>
3473 -
3474 -
3475 - <p>
3476 - <?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');?>
3477 - </p>
3478 -
3479 - <div id="wpstream_trigger_quick_start" class="wpstream_button wpstream_button_action"><?php esc_html_e('Start the Guide','wpstream');?></div>
3480 -
3481 -
3482 -
3483 - </div>
3484 -
3485 -
3486 -
3487 - <script type="text/javascript">
3488 - //<![CDATA[
3489 - jQuery(document).ready(function(){
3490 - jQuery(".wpstream_on_boarding_wrapper").show();
3491 - jQuery(".wpstream_modal_background_onboard").show();
3492 - });
3493 -
3494 - //]]>
3495 - </script>
3496 -
3497 - <?php
3498 -
3499 - }
3500 -
3501 -
3502 -
3503 -
3504 -
3505 -
3506 -
3507 -
3508 - /*
3509 - *
3510 - * On Boarding Content
3511 - *
3512 - */
3513 -
3514 -
3515 - public function wpstream_onboard_display() {
3516 - $this->onboarding_wizard_header();
3517 - $this->wpstream_onboarding_step1();
3518 - $this->wpstream_onboarding_step2();
3519 - $this->wpstream_onboarding_step3_live_streaming();
3520 - $this->wpstream_onboarding_step_3_A_live_streaming_free_view();
3521 - $this->wpstream_onboarding_step_3_B_live_streaming_pay_per_view();
3522 - $this->wpstream_onboarding_step4_vod();
3523 - $this->wpstream_onboarding_step_4_free_vod();
3524 - $this->wpstream_onboarding_step_4_ppv_vod();
3525 - $this->onboarding_wizard_footer();
3526 - }
3527 -
3528 -
3529 - /*
3530 - *
3531 - * On Boarding Step 1 - the login/register
3532 - *
3533 - */
3534 -
3535 -
3536 - public function wpstream_onboarding_step1(){
3537 -
3538 - $wpstream_options_array =array(
3539 - 2 => array(
3540 - 'label' => 'WpStream.net Username or Email',
3541 - 'name' => 'api_username',
3542 - 'type' => 'text',
3543 - ),
3544 - 3 => array(
3545 - 'label' => 'WpStream.net Password',
3546 - 'name' => 'api_password',
3547 - 'type' => 'password',
3548 - ),
3549 -
3550 - );
3551 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
3552 -
3553 - ?>
3554 - <div class="wpstream_step_wrapper wpstream_step_1" id="wpstream_step_1">
3555 - <div class="wpstream_has_credential">
3556 - <h1><?php esc_html_e('WpStream Account','wpstream');?></h1>
3557 -
3558 - <div class="wpstream_on_board_login_wrapper_explanations">
3559 - <?php esc_html_e('A WpStream account is required to make use of the plugin.','wpstream');?>
3560 - </div>
3561 -
3562 -
3563 - <div class="wpstream_check_account_status">
3564 - <?php esc_html_e( 'Checking if you are already logged.....', 'wpstream' ); ?>
3565 - </div>
3566 -
3567 - <div class="wpstream_onboarding_notification"></div>
3568 -
3569 - <div class="wpstream_option_wrapper wpstream_on_board_login_wrapper">
3570 - <h2><?php esc_html_e('Login with your WpStream Account','wpstream');?></h2>
3571 - <?php
3572 -
3573 - foreach ($wpstream_options_array as $key=>$option){
3574 - print '<div class="wpstream_option">';
3575 -
3576 - $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
3577 - print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
3578 - print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
3579 -
3580 - print '</div>';
3581 - }
3582 - ?>
3583 - <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_login" value="<?php esc_html_e('Login','wpstream');?>" />
3584 - </div>
3585 -
3586 -
3587 -
3588 -
3589 - <div class="wpstream_on_board_register_wrapper">
3590 - <h2><?php esc_html_e('Register for a WpStream Account','wpstream');?></h2>
3591 - <div class="wpstream_option">
3592 - <label for="wpstream_register_email"><?php esc_html_e('Your Email','wpstream');?></label>
3593 - <input id="wpstream_register_email" type="text" size="36" name="wpstream_register_email" value="<?php echo get_option('admin_email'); ?>" />
3594 -
3595 - </div>
3596 -
3597 - <div class="wpstream_option">
3598 -<!-- <label for="wpstream_register_password">--><?php //esc_html_e('Your Password','wpstream');?><!--</label>-->
3599 - <input id="wpstream_register_password" hidden type="text" size="36" name="wpstream_register_password" value="<?php echo $this->randomPassword();?>" />
3600 - <span class="" ><?php esc_html_e('We\'ll send the password to the email you attached. ', 'wpstream') ?></span>
3601 - </div>
3602 -
3603 -
3604 - <!-- Altcha Widget (requires HTTPS/secure context) -->
3605 - <?php if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ) : ?>
3606 - <script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist/altcha.min.js" type="module"></script>
3607 - <div class="wpstream_option" style="display:none;">
3608 - <altcha-widget
3609 - challengeurl="<?php echo esc_url( WPSTREAM_API . '/v2/user/getcaptcha' ); ?>"
3610 - name="altcha"
3611 - auto="onload"
3612 - hidefooter
3613 - hidelogo
3614 - strings='{"label": "<?php esc_html_e('I am not a robot', 'wpstream'); ?>", "error": "<?php esc_html_e('Verification failed', 'wpstream'); ?>", "wait": "<?php esc_html_e('Verifying...', 'wpstream'); ?>"}'
3615 - ></altcha-widget>
3616 - </div>
3617 - <?php endif; ?>
3618 -
3619 - <div class="wpstream_option wpstream_terms_agreement">
3620 - <!-- Add "by registering you agree to the privacy terms" checkbox-->
3621 - <input id="wpstream_register_privacy" type="checkbox" name="wpstream_register_privacy" />
3622 - <label for="wpstream_register_privacy">
3623 - <?php printf(
3624 - esc_html__('By registering you agree to the %sPrivacy Policy%s','wpstream'),
3625 - '<a href="https://wpstream.net/privacy-policy/" target="_blank">',
3626 - '</a>'
3627 - );?>
3628 - </label>
3629 - </div>
3630 - <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_register" value="<?php esc_html_e('register','wpstream');?>" />
3631 - </div>
3632 -
3633 -
3634 - <div id="wpstream_onboarding_action_login"><?php esc_html_e('I already have a WpStream Account','wpstream');?></div>
3635 -
3636 - <div id="wpstream_onboarding_action_register"><?php esc_html_e('Back to Registration','wpstream');?></div>
3637 -
3638 - </div>
3639 -
3640 -
3641 - <?php
3642 - $ajax_nonce = wp_create_nonce( "wpstream_onboarding_nonce");
3643 - print'<input type="hidden" id="wpstream_onboarding_nonce" value="'.esc_html($ajax_nonce).'" /> ';
3644 -
3645 - ?>
3646 -
3647 -
3648 - <div id="wpstream_on_board" class="wpstream_action_next_step" data-nextthing="wpstream_step_2" style="display:none;" >Move to step 2</div>
3649 - </div>
3650 - <?php
3651 -
3652 - if( !is_null( $token ) && trim( $token ) !== '' ) {
3653 - print '<div id="wpstream_have_token"></div>';
3654 - }
3655 - }
3656 -
3657 -
3658 -
3659 -
3660 -
3661 -
3662 -
3663 -
3664 -
3665 -
3666 - /*
3667 - *
3668 - * Generate random pass
3669 - *
3670 - */
3671 -
3672 - public function randomPassword() {
3673 - $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
3674 - $pass = array(); //remember to declare $pass as an array
3675 - $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
3676 - for ($i = 0; $i < 16; $i++) {
3677 - $n = random_int(0, $alphaLength);
3678 - $pass[] = $alphabet[$n];
3679 - }
3680 - return implode($pass); //turn the array into a string
3681 - }
3682 -
3683 -
3684 - /*
3685 - *
3686 - *
3687 - *
3688 - */
3689 -
3690 - public function wpstream_onboarding_step2(){
3691 - ?>
3692 1429
3693 - <div class="wpstream_step_wrapper wpstream_step_2" id="wpstream_step_2">
3694 - <h1>Welcome to <span class="header_special">WpStream</span>! How would you like to start?</h1>
1430 + $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
1431 + print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
1432 + $live_event_for_user = $this->main->wpstream_live_connection->api20_wpstream_request_live_stream_for_user();
1433 + $this->wpstream_live_stream_unit($post->ID);
3695 1434
3696 - <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3a" ><?php esc_html_e('Go LIVE!','wpstream');?></div>
3697 - <div class="wpstram_or">or</div>
3698 - <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_2_create_vod" data-nextthing="wpstream_step_4a" ><?php esc_html_e('Create a Video-On-Demand (VOD)','wpstream');?></div>
3699 -
3700 - </div>
3701 -
3702 -
3703 - <?php
3704 1435 }
3705 -
3706 - /*
3707 - *
3708 - *
3709 - *
3710 - */
3711 -
3712 - public function wpstream_onboarding_step3_live_streaming(){
3713 - ?>
3714 -
3715 - <div class="wpstream_step_wrapper wpstream_step_3 wpstream_onboarding_live" id="wpstream_step_3">
3716 - <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream'); ?></h1>
3717 -
3718 - <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>
3719 - <div class="wpstram_or">or</div>
3720 - <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>
3721 -
3722 - <div class="wpstream_initial_onboarding_controls_wrapper">
3723 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
3724 - </div>
3725 -
3726 - </div>
3727 -
3728 -
3729 - <?php
3730 - }
3731 -
3732 -
3733 - /*
3734 - *
3735 - *
3736 - *
3737 - */
3738 - public function wpstream_onboarding_step_3_A_live_streaming_free_view(){
3739 - ?>
3740 -
3741 - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3a">
3742 - <h1><?php esc_html_e('Let’s create your first FTV live channel','wpstream');?></h1>
3743 -
3744 - <div id="wpstream_onboard_live_notice" class="wpstream_onboarding_notification"></div>
3745 - <div id="wpstream_onboard_live" class="wpstream_accordion_container">
3746 - <label>Name your first Free-To-View channel</label>
3747 - <input type="text" name="channel_name" id="wpstream_onboarding_channel_name" class="wpstream_onboarding_channel_name" value="<?php esc_html_e('My first FTV channel','wpstream');?>" >
3748 - <input type="submit" name="submit" id="wpstream_on_board_create_channel" class="wpstream_button wpstream_button_action wpstream_onboard_live_action" value="<?php esc_html_e('Create Channel','wpstream');?>" />
3749 -
3750 - </div>
3751 -
3752 - <div class="wpstream_initial_onboarding_controls_wrapper">
3753 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
3754 - </div>
3755 -
3756 - </div>
3757 -
3758 -
3759 - <?php
3760 - }
3761 -
3762 -
3763 - /*
3764 - *
3765 - *
3766 - *
3767 - */
3768 -
3769 - public function wpstream_onboarding_step_3_B_live_streaming_pay_per_view(){
3770 - ?>
3771 -
3772 - <div class="wpstream_step_wrapper wpstream_step_3b wpstream_onboarding_live" id="wpstream_step_3b">
3773 - <h1><?php esc_html_e('Make your live stream Pay Per View','wpstream');?></h1>
3774 - <?php
3775 - if ( class_exists( 'WooCommerce' ) ) {
3776 - ?>
3777 - <div id="wpstream_onboard_live_ppv_notice" class="wpstream_onboarding_notification"></div>
3778 - <div id="wpstream_onboard_live_ppv" class="wpstream_accordion_container">
3779 - <label><?php esc_html_e('Choose a name for your channel','wpstream');?></label>
3780 - <input type="text" name="channel_name" id="wpstream_onboarding_channel_name_ppv" class="wpstream_onboarding_channel_name" value="<?php esc_html_e('My First PPV Channel','wpstream');?>">
3781 - <label><?php esc_html_e('Pay-Per-View Price ($)','wpstream');?></label>
3782 - <input type="text" name="channel_name" id="wpstream_onboarding_event_price_ppv" class="wpstream_onboarding_event_price" value="10">
3783 - <input type="submit" name="submit" id="wpstream_onboard_live_ppv_action" class="wpstream_button wpstream_button_action wpstream_onboard_live_ppv_action" value="<?php esc_html_e('Create Channel','wpstream');?>" />
3784 -
3785 - </div>
3786 - <?php
3787 - } else {
3788 - $this->wpstream_onboarding_woo_warning();
3789 - } ?>
3790 -
3791 -
3792 - <div class="wpstream_initial_onboarding_controls_wrapper">
3793 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
3794 - </div>
3795 - </div>
3796 - <?php
3797 - }
3798 -
3799 -
3800 -
3801 -
3802 -
3803 -
3804 - /*
3805 - * WooCommerce not installed Warning
3806 - *
3807 - *
3808 - */
3809 -
3810 - public function wpstream_onboarding_woo_warning(){
3811 - print'<div class="wpstream_warning_onboarding">
3812 - '.esc_html__('Pay-Per-View streaming requires WooCommerce. Please install the WooCommerce plugin and try again.','wpstream').'
3813 - </br>
3814 - <div class="wpstream_install_plugin">'. esc_html__('Install WooCommerce','wpstream').'</div>
3815 -
3816 - <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
3817 - </div>';
3818 - }
3819 -
3820 -
3821 - /*
3822 - *
3823 - *
3824 - *
3825 - */
3826 -
3827 - public function wpstream_onboarding_step4_vod(){
3828 - ?>
3829 - <div class="wpstream_step_wrapper wpstream_step_4 wpstream_onboarding_vod" id="wpstream_step_4">
3830 - <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream');?></h1>
3831 -
3832 - <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>
3833 - <div class="wpstram_or">or</div>
3834 - <input type="hidden" id="wpstream_onboarding_video_list_nonce" value="<?php echo wp_create_nonce( "wpstream_onboarding_video_list_nonce" ); ?>">
3835 - <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>
3836 - <div class="wpstream_initial_onboarding_controls_wrapper">
3837 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span>
3838 - </div>
3839 -
3840 - </div>
3841 - <?php
3842 - }
3843 -
3844 -
3845 - /*
3846 - *
3847 - *
3848 - *
3849 - */
3850 - public function wpstream_onboarding_step_4_free_vod(){
3851 -
3852 - $current_screen=get_current_screen();
3853 - if($current_screen->base !=='wpstream_page_wpstream_onboard'){
3854 - return;
3855 - }
3856 - ?>
3857 -
3858 - <div class="wpstream_step_wrapper wpstream_step_4a wpstream_onboarding_live" id="wpstream_step_4a">
3859 - <h1><?php esc_html_e('Let’s create your first Free-To-View VOD','wpstream');?></h1>
3860 - <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div>
3861 - <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container">
3862 - <div class="spinner"></div>
3863 - <div class="wpstream-step-container" style="display: none">
3864 - <label><?php esc_html_e('Name your FTV Video-On-Demand','wpstream')?></label>
3865 - <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');?>" >
3866 - <div id="wpstream_free_vod_dropdown_videos_list"></div>
3867 - <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">
3868 - </div>
3869 - </div>
3870 - <?php $this->wpstream_obboarding_file_warning(); ?>
3871 -
3872 - <div class="wpstream_initial_onboarding_controls_wrapper">
3873 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
3874 - </div>
3875 -
3876 - </div>
3877 -
3878 -
3879 - <?php
3880 - }
3881 -
3882 - /*
3883 - *
3884 - *
3885 - *
3886 - */
3887 - public function wpstream_obboarding_file_warning(){
3888 - print '<div class="wpstream_warning_onboarding" style="display: none">
3889 - '.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').'
3890 - </br>
3891 - <div class="wpstream_upload_video">'.esc_html__('Upload Video','wpstream').'</div>
3892 -
3893 - <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div>
3894 - </div>';
3895 - }
3896 -
3897 - /*
3898 - *
3899 - *
3900 - *
3901 - */
3902 - public function wpstream_onboarding_step_4_ppv_vod(){
3903 - $current_screen=get_current_screen();
3904 -
3905 - if($current_screen->base !=='wpstream_page_wpstream_onboard'){
3906 - return;
3907 - }
3908 - ?>
3909 -
3910 - <div class="wpstream_step_wrapper wpstream_step_4b wpstream_onboarding_live" id="wpstream_step_4b">
3911 - <h1><?php esc_html_e('Let\'s create your first Pay-Per-View VOD','wpstream');?></h1>
3912 -
3913 - <div id="wpstream_onboard_vod_ppv_notice" class="wpstream_onboarding_notification"></div>
3914 - <?php
3915 - if ( class_exists( 'WooCommerce' ) ) { ?>
3916 - <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container">
3917 - <div class="spinner"></div>
3918 - <div class="wpstream-step-container" style="display: none">
3919 - <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label>
3920 - <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');?>">
3921 - <div id="wpstream_ppv_vod_dropdown_videos_list"></div>
3922 - <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label>
3923 - <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10">
3924 - <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');?>" />
3925 - </div>
3926 - </div>
3927 - <?php $this->wpstream_obboarding_file_warning(); ?>
3928 - <?php } else {
3929 - $this->wpstream_onboarding_woo_warning();
3930 - } ?>
3931 - <div class="wpstream_initial_onboarding_controls_wrapper">
3932 - <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span>
3933 - </div>
3934 - </div>
3935 - <?php
3936 - }
3937 -
3938 -
3939 -
3940 -
3941 - /*
3942 - *
3943 - * On boarding Header
3944 - *
3945 - */
3946 - public function onboarding_wizard_header() {
3947 - $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/logo_onboarding.svg';
3948 - ?>
3949 -
3950 - <div class="wpstream_on_boarding_wrapper">
3951 - <div class="wpstream_close_onboarding wpstream_close_initial_onboarding"></div>
3952 - <img class="wpstream_onboarding_logo" src="<?php echo esc_url($thumb); ?>" />
3953 - <div class="wpstream_close_onboarding_warning"></div>
3954 -
3955 - <?php
3956 - }
3957 -
3958 -
3959 -
3960 -
3961 -
3962 - /*
3963 - *
3964 - * On Boarding Footer
3965 - *
3966 - */
3967 - public function onboarding_wizard_footer() {
3968 - ?>
3969 - </div>
3970 - <div class="wpstream_modal_background_onboard"></div>
3971 - <?php
3972 - }
3973 -
3974 -
3975 -
3976 - /*
3977 - *
3978 - * On Boarding create PPV channel
3979 - *
3980 - */
3981 -
3982 -
3983 - public function wpstream_on_board_create_channel_ppv(){
3984 - check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
3985 - $current_user = wp_get_current_user();
3986 -
3987 - if(current_user_can('administrator')){
3988 - $channel_name = sanitize_text_field($_POST['channel_name']);
3989 - $channel_price = floatval($_POST['channel_price']);
3990 - $my_post = array(
3991 - 'post_title' => $channel_name,
3992 - 'post_content' => '',
3993 - 'post_status' => 'publish',
3994 - 'post_type' => 'product',
3995 - 'post_author' => $current_user->ID
3996 - );
3997 -
3998 - // Insert the post into the database
3999 - $post_id = wp_insert_post( $my_post );
4000 -
4001 - if(is_wp_error($post_id)){
4002 - $logger = new WPStream_Logger();
4003 - $log_entry = new WpStream_Log_Entry([
4004 - 'type' => 'error',
4005 - 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(),
4006 - ]);
4007 - $logger->add( $log_entry );
4008 - echo json_encode( array('succes'=>false) );
4009 - }else{
4010 -
4011 - $product = wc_get_product($post_id);
4012 - $price = wc_format_decimal($channel_price);
4013 -
4014 - $product = wc_get_product( $post_id );
4015 - $product->set_price( $price );
4016 - $product->set_regular_price( $price ); // To be sure
4017 - $product->save();
4018 - update_post_meta ($post_id,'event_passed',0);
4019 - wp_set_object_terms( $post_id, 'live_stream', 'product_type' );
4020 -
4021 -
4022 -
4023 -
4024 - $permalink = get_edit_post_link($post_id);
4025 -
4026 - $permalink= add_query_arg( 'onboard', 'yes', $permalink );
4027 - $permalink= add_query_arg( 'branch', '2', $permalink );
4028 -
4029 -
4030 - echo json_encode( array(
4031 - 'success'=> true,
4032 - 'link' => ($permalink)
4033 - ));
4034 - }
4035 -
4036 - }
4037 - die();
4038 - }
4039 -
4040 - /*
4041 - *
4042 - * On Boarding create channel
4043 - *
4044 - */
4045 -
4046 -
4047 - public function wpstream_on_board_create_channel(){
4048 - check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
4049 - $current_user = wp_get_current_user();
4050 -
4051 - if(current_user_can('administrator')){
4052 - $channel_name=sanitize_text_field($_POST['channel_name']);
4053 - $my_post = array(
4054 - 'post_title' => $channel_name,
4055 - 'post_content' => '',
4056 - 'post_status' => 'publish',
4057 - 'post_type' => 'wpstream_product',
4058 - 'post_author' => $current_user->ID
4059 - );
4060 -
4061 - // Insert the post into the database
4062 - $post_id = wp_insert_post( $my_post );
4063 -
4064 - if( is_wp_error( $post_id ) ) {
4065 - $logger = new WPStream_Logger();
4066 - $log_entry = new WpStream_Log_Entry([
4067 - 'type' => 'error',
4068 - 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(),
4069 - ]);
4070 - $logger->add( $log_entry );
4071 - echo json_encode( array('succes'=>false) );
4072 - } else {
4073 - $permalink = get_edit_post_link($post_id);
4074 -
4075 - $permalink= add_query_arg( 'onboard', 'yes', $permalink );
4076 - $permalink= add_query_arg( 'branch', '1', $permalink );
4077 -
4078 - echo json_encode( array(
4079 - 'success'=> true,
4080 - 'link' => ($permalink)
4081 - ));
4082 - }
4083 - }
4084 - die();
4085 - }
4086 -
4087 - /*
4088 - *
4089 - * On Boarding create free vod
4090 - *
4091 - */
4092 - public function wpstream_on_board_create_free_vod(){
4093 - $current_user = wp_get_current_user();
4094 - check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
4095 - if(current_user_can('administrator')){
4096 - $channel_name =sanitize_text_field($_POST['channel_name']);
4097 - $file_name =sanitize_text_field($_POST['file_name']);
4098 - $my_post = array(
4099 - 'post_title' => $channel_name,
4100 - 'post_content' => '',
4101 - 'post_status' => 'publish',
4102 - 'post_type' => 'wpstream_product_vod',
4103 - 'post_author' => $current_user->ID
4104 - );
4105 -
4106 - // Insert the post into the database
4107 - $post_id = wp_insert_post( $my_post );
4108 -
4109 - if(is_wp_error($post_id)){
4110 - $logger = new WPStream_Logger();
4111 - $log_entry = new WpStream_Log_Entry([
4112 - 'type' => 'error',
4113 - 'description' => 'Couldn\'t create free VOD during onboarding because of error: ' . $post_id->get_error_message(),
4114 - ]);
4115 - $logger->add( $log_entry );
4116 - echo json_encode( array('succes'=>false) );
4117 - }else{
4118 - update_post_meta($post_id, 'wpstream_product_type', 2);
4119 - update_post_meta($post_id, 'wpstream_free_video', $file_name);
4120 -
4121 -
4122 - $permalink = get_edit_post_link($post_id);
4123 -
4124 - $permalink= add_query_arg( 'onboard', 'yes', $permalink );
4125 - $permalink= add_query_arg( 'branch', '3', $permalink );
4126 -
4127 -
4128 - echo json_encode( array(
4129 - 'success'=> true,
4130 - 'link' => ($permalink)
4131 - ));
4132 - }
4133 -
4134 - }
4135 - die();
4136 - }
4137 -
4138 -
4139 - /*
4140 - *
4141 - * On Boarding create ppv vod
4142 - *
4143 - */
4144 -
4145 -
4146 - public function wpstream_on_board_create_ppv_vod(){
4147 - $current_user = wp_get_current_user();
4148 - check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
4149 -
4150 - if(current_user_can('administrator')){
4151 - $channel_name = sanitize_text_field($_POST['channel_name']);
4152 - $vod_price = floatval($_POST['vod_price']);
4153 - $file_name = sanitize_text_field($_POST['file_name']);
4154 -
4155 - $my_post = array(
4156 - 'post_title' => $channel_name,
4157 - 'post_content' => '',
4158 - 'post_status' => 'publish',
4159 - 'post_type' => 'product',
4160 - 'post_author' => $current_user->ID
4161 - );
4162 -
4163 - // Insert the post into the database
4164 - $post_id = wp_insert_post( $my_post );
4165 -
4166 - if( is_wp_error( $post_id ) ) {
4167 - $logger = new WPStream_Logger();
4168 - $log_entry = new WpStream_Log_Entry([
4169 - 'type' => 'error',
4170 - 'description' => 'Couldn\'t create PPV VOD during onboarding because of error: ' . $post_id->get_error_message(),
4171 - ]);
4172 - $logger->add( $log_entry );
4173 - echo json_encode( array('succes'=>false) );
4174 - } else {
4175 -
4176 - $product = wc_get_product($post_id);
4177 - $price = wc_format_decimal($vod_price);
4178 -
4179 - $product = wc_get_product( $post_id );
4180 - $product->set_price( $price );
4181 - $product->set_regular_price( $price ); // To be sure
4182 - $product->save();
4183 - update_post_meta ($post_id,'event_passed',0);
4184 - update_post_meta ($post_id,'_movie_url', $file_name);
4185 - wp_set_object_terms( $post_id, 'video_on_demand', 'product_type' );
4186 -
4187 -
4188 -
4189 -
4190 - $permalink = get_edit_post_link($post_id);
4191 -
4192 - $permalink= add_query_arg( 'onboard', 'yes', $permalink );
4193 - $permalink= add_query_arg( 'branch', '4', $permalink );
4194 -
4195 -
4196 - echo json_encode( array(
4197 - 'success'=> true,
4198 - 'link' => ($permalink) ,
4199 - ' $file_name'=> $file_name,
4200 - ));
4201 - }
4202 -
4203 - }
4204 - die();
4205 - }
4206 -
4207 -
4208 - /*
4209 - *
4210 - * On Boarding login
4211 - *
4212 - */
4213 - public function wpstream_on_board_login(){
4214 - check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
4215 -
4216 - if(current_user_can('administrator')){
4217 - $username = sanitize_text_field($_POST['api_username']);
4218 - $password = $_POST['api_password'];
4219 - update_option('wpstream_api_username',$username);
4220 - update_option('wpstream_api_password',$password);
4221 -
4222 - delete_transient( 'wpstream_token_api' );
4223 -
4224 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
4225 - $videos_list = $this->main->wpstream_live_connection->wpstream_get_videos();
4226 - // cleanup any previous echo before sending json
4227 - ob_end_clean();
4228 - // !DO NOT SEND TOKEN TO THE CLIENT!
4229 - if ($token){
4230 - echo json_encode( array(
4231 - 'success'=> true
4232 - ));
4233 - }
4234 - else {
4235 - $text = get_option('wpstream_curl_failed') ?
4236 - 'Login failed with critical error: ' . get_option('wpstream_curl_failed') :
4237 - 'Wrong username or password!';
4238 - echo json_encode( array(
4239 - 'success'=> false,
4240 - 'error' => $text,
4241 - ));
4242 - }
4243 -
4244 - }else{
4245 - echo json_encode( array(
4246 - 'success'=> false,
4247 - 'token' => esc_html('You are not an administrator','wpstream')
4248 - ));
4249 - }
4250 - die();
4251 - }
4252 -
4253 -
4254 - public function wpstream_register_refresh_capthca(){
4255 -
4256 - if(current_user_can('administrator')){
4257 -
4258 - }
4259 - }
4260 -
4261 - /**
4262 - * AJAX proxy: fetch a captcha challenge from the baker API and return it.
4263 - * Used on HTTP sites where the Altcha widget cannot run (requires Web Crypto / HTTPS).
4264 - * The JS side solves the PoW locally and sends back the full base64 Altcha payload.
4265 - */
4266 - public function wpstream_get_captcha_challenge() {
4267 - $api_url = WPSTREAM_API . '/v2/user/getcaptcha';
4268 - $response = wp_remote_get( $api_url, array( 'timeout' => 10 ) );
4269 -
4270 - if ( is_wp_error( $response ) ) {
4271 - echo json_encode( array( 'success' => false, 'error' => 'Could not reach captcha service.' ) );
4272 - die();
4273 - }
4274 -
4275 - $body = wp_remote_retrieve_body( $response );
4276 - // Forward the challenge JSON directly to the browser
4277 - header( 'Content-Type: application/json' );
4278 - echo $body;
4279 - die();
4280 - }
4281 -
4282 - /**
4283 - * @param $challenge
4284 - * @param $difficulty
4285 - *
4286 - * @return int|null
4287 - */
4288 - private function solve_pow( $challenge, $difficulty ) {
4289 - $nonce = 0;
4290 - $target = str_repeat( "0", $difficulty );
4291 -
4292 - while ( $nonce < 5000000 ) {
4293 - $hash = hash( 'sha256', $challenge . $nonce );
4294 - if ( strpos( $hash, $target ) === 0 ) {
4295 - return $nonce;
4296 - }
4297 - $nonce++;
4298 - }
4299 - return null; // Return null if no solution is found within the max attempts
4300 - }
4301 -
4302 - /*
4303 - *
4304 - * On Boarding login
4305 - *
4306 - */
4307 - public function wpstream_on_board_register(){
4308 - check_ajax_referer( 'wpstream_onboarding_nonce', 'security' );
4309 - if(current_user_can('administrator')){
4310 - $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']);
4311 - $wpstream_register_password = $_POST['wpstream_register_password'];
4312 -
4313 - $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password);
4314 - if(!$validate['success']){
4315 - // cleanup any previous echo before sending json
4316 - ob_end_clean();
4317 - echo json_encode($validate);
4318 - die();
4319 - }
4320 -
4321 - $wpstream_altcha = isset($_POST['wpstream_altcha']) ? trim( $_POST['wpstream_altcha'] ) : '';
4322 - $is_https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
4323 -
4324 - if ( empty($wpstream_altcha) ) {
4325 - if ( $is_https ) {
4326 - $message = esc_html__('Captcha verification failed. Please try again.', 'wpstream');
4327 - } else {
4328 - $message = esc_html__('Security check not ready yet. Please wait a moment and try again.', 'wpstream');
4329 - }
4330 - echo json_encode( array( 'success' => false, 'message' => $message ) );
4331 - die();
4332 - }
4333 -
4334 - $url='v2/user/create';
4335 - $curl_post_fields=array(
4336 - 'email' => $wpstream_register_email,
4337 - 'password' => $wpstream_register_password,
4338 - 'solution' => $wpstream_altcha,
4339 - 'captcha_id' => '',
4340 - );
4341 -
4342 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true);
4343 - $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
4344 -
4345 - if($curl_response_decoded['success']){
4346 -
4347 - if($curl_response_decoded['request']['registred']){
4348 - // we are registerd
4349 -
4350 - update_option('wpstream_api_username',$wpstream_register_email);
4351 - update_option('wpstream_api_password',$wpstream_register_password);
4352 -
4353 - $token = $this->main->wpstream_live_connection->wpstream_get_token();
4354 -
4355 - // cleanup any previous echo before sending json
4356 - ob_end_clean();
4357 - echo json_encode( array(
4358 - 'success' => true,
4359 - 'token' => $token ,
4360 - 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'),
4361 -
4362 - ));
4363 - die();
4364 - }else{
4365 -
4366 - // cleanup any previous echo before sending json
4367 - ob_end_clean();
4368 - echo json_encode( array(
4369 - 'success'=> false,
4370 - 'message'=> $curl_response_decoded['request']['message'],
4371 - 'curl'=>$curl_response_decoded,
4372 -
4373 - ));
4374 - die();
4375 - }
4376 -
4377 -
4378 -
4379 -
4380 - }else{
4381 - // cleanup any previous echo before sending json
4382 - ob_end_clean();
4383 - echo json_encode( array(
4384 - 'success'=> false,
4385 - 'message'=> esc_html__('Registration could not be completed. Please try again or register on wpstream.net','wpstream'),
4386 -
4387 - ));
4388 - die();
4389 - }
4390 -
4391 -
4392 -
4393 -
4394 -
4395 -
4396 -
4397 -
4398 - }else{
4399 - // cleanup any previous echo before sending json
4400 - ob_end_clean();
4401 - echo json_encode( array(
4402 - 'success'=> false,
4403 - 'message' => esc_html('You are not an administrator','wpstream')
4404 - ));
4405 - die();
4406 - }
4407 -
4408 - die();
4409 - }
4410 -
4411 -
4412 - /*
4413 - *
4414 - * Validate for register
4415 - *
4416 - */
4417 -
4418 -
4419 - public function wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password){
4420 -
4421 - $return= array(
4422 - 'success'=>true
4423 - );
4424 -
4425 - if ($wpstream_register_email=='' ){
4426 - $return= array(
4427 - 'success'=> false,
4428 - 'message' => esc_html('The email Field is Empty','wpstream')
4429 - );
4430 - return $return;die();
4431 - }
4432 -
4433 - if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) {
4434 - $return= array(
4435 - 'success'=> false,
4436 - 'message' => esc_html__('The email doesn\'t look right !','wpstream')
4437 - );
4438 - return $return;die();
4439 - }
4440 -
4441 -
4442 - $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1);
4443 - if( $domain!='' && !checkdnsrr ($domain) ){
4444 - $return= array(
4445 - 'success'=> false,
4446 - 'message' => esc_html__('The email doesn\'t look right !','wpstream')
4447 - );
4448 - return $return;die();
4449 - }
4450 -
4451 -
4452 -
4453 - if(strlen($wpstream_register_password)<5){
4454 - $return= array(
4455 - 'success'=> false,
4456 - 'message' => esc_html('The password is too short. Please use at least 5 characters.','wpstream')
4457 - );
4458 - return $return;die();
4459 - }
4460 -
4461 - return $return;die();
4462 - }
4463 -
4464 - /**
4465 - * Handle the AJAX request to initiate a multipart upload
4466 - *
4467 - * @since 3.0.1
4468 - */
4469 - public function handle_initiate_multipart_upload() {
4470 - check_ajax_referer( 'wpstream_multipart_upload_nonce', 'security' );
4471 -
4472 - // Security check - only admins can do this
4473 - if (!current_user_can('administrator')) {
4474 - wp_send_json_error('Unauthorized access');
4475 - return;
4476 - }
4477 -
4478 - // Get file details from request
4479 - $file_name = sanitize_text_field($_POST['file_name']);
4480 - $file_size = intval($_POST['file_size']);
4481 - $content_type = sanitize_text_field($_POST['content_type']);
4482 - $num_parts = intval($_POST['parts']);
4483 -
4484 - if (empty($file_name) || $file_size <= 0 || $num_parts <= 0) {
4485 - wp_send_json_error('Invalid file information');
4486 - return;
4487 - }
4488 -
4489 - // Prepare a clean filename (similar to the standard upload process)
4490 - $file_name_array = explode(".", $file_name);
4491 - $file_extension = $file_name_array[count($file_name_array) - 1];
4492 - $temp_file_name = $file_name_array[0];
4493 - $temp_file_name = str_replace(' ', '_', $temp_file_name);
4494 - $temp_file_name = preg_replace('/\W/', '', $temp_file_name);
4495 - $clean_file_name = $temp_file_name . '.' . $file_extension;
4496 -
4497 - // Make API call to initiate multipart upload
4498 - $url = 'video/upload';
4499 - $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
4500 -
4501 - if (!$access_token) {
4502 - wp_send_json_error('Not connected to WPStream service');
4503 - return;
4504 - }
4505 -
4506 - $api_params = array(
4507 - 'access_token' => $access_token,
4508 - 'size' => $file_size,
4509 - 'name' => $clean_file_name,
4510 - 'content_type' => $content_type,
4511 - 'parts' => $num_parts
4512 - );
4513 -
4514 - $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true);
4515 - $response_data = json_decode($response, true);
4516 -
4517 - if (!isset($response_data['success']) || $response_data['success'] !== true) {
4518 - $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to initiate multipart upload';
4519 - wp_send_json_error($error_message);
4520 - return;
4521 - }
4522 -
4523 - // Return the upload ID and pre-signed URLs for each part
4524 - wp_send_json_success($response_data);
4525 - }
4526 -
4527 - /**
4528 - * Handle the AJAX request to complete a multipart upload
4529 - *
4530 - * @since 3.0.1
4531 - */
4532 - public function handle_complete_multipart_upload() {
4533 - check_ajax_referer( 'wpstream_multipart_upload_nonce', 'security' );
4534 -
4535 - // Security check - only admins can do this
4536 - if (!current_user_can('administrator')) {
4537 - wp_send_json_error('Unauthorized access');
4538 - return;
4539 - }
4540 -
4541 - // Get completion details
4542 - $parts = json_decode(stripslashes($_POST['parts']), true);
4543 - $file_name = sanitize_text_field($_POST['file_name']);
4544 - $handle = sanitize_text_field($_POST['handle']);
4545 -
4546 - if (empty($parts) || !is_numeric($parts) || empty($file_name)) {
4547 - wp_send_json_error('Invalid completion information');
4548 - return;
4549 - }
4550 -
4551 - // Make API call to complete the multipart upload
4552 - $url = 'video/upload';
4553 - $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
4554 -
4555 - if (!$access_token) {
4556 - wp_send_json_error('Not connected to WPStream service');
4557 - return;
4558 - }
4559 -
4560 - $api_params = array(
4561 - 'access_token' => $access_token,
4562 - 'parts' => $parts,
4563 - 'name' => $file_name,
4564 - 'handle' => $handle,
4565 - 'action' => 'complete'
4566 - );
4567 -
4568 - $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true);
4569 - $response_data = json_decode($response, true);
4570 -
4571 - if (!isset($response_data['success']) || $response_data['success'] !== true) {
4572 - $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to complete multipart upload';
4573 - wp_send_json_error($error_message);
4574 - return;
4575 - }
4576 -
4577 - // Return success
4578 - wp_send_json_success();
4579 - }
4580 -
4581 - public function wpstream_settings_tab_update_plugin() {
4582 - if ( !current_user_can( 'update_plugins' ) ) {
4583 - wp_send_json_error( __( 'Not enough permissions to make this change', 'wpstream' ) );
4584 - }
4585 -
4586 - include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
4587 - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
4588 - include_once ABSPATH . 'wp-admin/includes/file.php';
4589 -
4590 - $credentials = request_filesystem_credentials('');
4591 - if ( !WP_Filesystem( $credentials ) ) {
4592 - wp_send_json_error( __( 'Failed to connect to the filesystem', 'wpstream' ) );
4593 - }
4594 -
4595 - $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
4596 - $plugin_path = plugin_basename( WPSTREAM_PLUGIN_PATH . 'wpstream.php' );
4597 - $result = $upgrader->upgrade( $plugin_path );
4598 - activate_plugin( $plugin_path );
4599 -
4600 - if ( is_wp_error( $result ) ) {
4601 - wp_send_json_error( __( 'Update failed due to', 'wpstream' ) . $result->get_error_message() );
4602 - }
4603 -
4604 - wp_send_json_success();
4605 - }
4606 -}
1436 +}