| @@ -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,137 +63,168 @@ | ||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - public function __construct( $plugin_name, $version,$plugin_main ) { | |
| 67 | + public function __construct( $plugin_name, $version,$plugin_main ) { | |
| 68 | 68 | |
| 69 | - $this->plugin_name = $plugin_name; | |
| 70 | - $this->version = $version; | |
| 71 | - $this->main = $plugin_main; | |
| 72 | - | |
| 73 | - $this->global_event_options = array( | |
| 74 | - | |
| 75 | - 'record' =>array( | |
| 76 | - 'name' => esc_html__('Record Live Stream','wpstream'), | |
| 77 | - 'details' => esc_html__('If enabled, live streams will be recorded and saved to your library.','wpstream'), | |
| 78 | - 'defaults' => 'no', | |
| 79 | - | |
| 80 | - ), | |
| 81 | - 'view_count' =>array( | |
| 82 | - 'name' => esc_html__('Display Viewer Count','wpstream'), | |
| 83 | - 'details' => esc_html__('If enabled, the live viewer count will show up in the player.','wpstream'), | |
| 84 | - 'defaults' => 'yes', | |
| 85 | - ), | |
| 86 | - 'domain_lock'=>array( | |
| 87 | - 'name' => esc_html__('Lock To Website','wpstream'), | |
| 88 | - 'details' => sprintf ( esc_html__('If enabled, live video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ), | |
| 89 | - 'defaults' => 'no', | |
| 90 | - ), | |
| 91 | - 'autoplay' =>array( | |
| 92 | - 'name' => esc_html__('Autoplay','wpstream'), | |
| 93 | - 'details' => esc_html__('If enabled, live video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'), | |
| 94 | - 'defaults' => 'yes', | |
| 95 | - ), | |
| 96 | - 'mute' =>array( | |
| 97 | - 'name' => esc_html__('Start Muted','wpstream'), | |
| 98 | - 'details' => esc_html__('If enabled, live video will start muted. This may increase the rate of autoplay in some browsers. ','wpstream'), | |
| 99 | - 'defaults' => 'no', | |
| 69 | + $this->plugin_name = $plugin_name; | |
| 70 | + $this->version = $version; | |
| 71 | + $this->main = $plugin_main; | |
| 100 | 72 | |
| 101 | - ), | |
| 102 | - 'low_latency' =>array( | |
| 103 | - 'name' => esc_html__('Low Latency (beta)','wpstream'), | |
| 104 | - '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'), | |
| 105 | - 'defaults' => 'no', | |
| 106 | - ), | |
| 107 | - 'adaptive_bitrate' =>array( | |
| 108 | - 'name' => esc_html__('Adaptive Bitrate (beta)','wpstream'), | |
| 109 | - 'details' => esc_html__('Ensures a smooth and uninterrupted viewing experience by adjusting video quality for viewers with reduced network speed or device capabilities.','wpstream'), | |
| 110 | - 'defaults' => 'no', | |
| 111 | - ), | |
| 112 | - 'encrypt' =>array( | |
| 113 | - 'name' => esc_html__('Encrypt Live Stream','wpstream'), | |
| 114 | - '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'), | |
| 115 | - 'defaults' => 'no', | |
| 116 | - ), | |
| 117 | - 'ses_encrypt'=>array( | |
| 118 | - 'name' => esc_html__('Use Sessions with Encryption','wpstream'), | |
| 119 | - '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'), | |
| 120 | - 'defaults' => 'no', | |
| 121 | - ), | |
| 122 | - 'autostart' =>array( | |
| 123 | - 'name' => esc_html__('Auto TURN ON','wpstream'), | |
| 124 | - 'details' => esc_html__('If enabled, channel will TURN ON automatically when broadcasting with an External Streaming App (RTMP Encoder/Broadcaster)','wpstream'), | |
| 125 | - 'defaults' => 'no', | |
| 126 | - ), | |
| 73 | + add_action('init', array($this, 'load_global_event_options')); | |
| 74 | + } | |
| 127 | 75 | |
| 128 | - 'vod_domain_lock' =>array( | |
| 129 | - 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'), | |
| 130 | - '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') ), | |
| 131 | - 'defaults' => 'no', | |
| 132 | - ), | |
| 133 | - 'vod_encrypt' =>array( | |
| 134 | - 'name' => esc_html__('Encrypt Video on Demand','wpstream'), | |
| 135 | - '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'), | |
| 136 | - 'defaults' => 'no', | |
| 137 | - ), | |
| 138 | - ); | |
| 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 | + } | |
| 139 | 130 | |
| 140 | - } | |
| 131 | + /** | |
| 132 | + * Register the stylesheets for the admin area. | |
| 133 | + * | |
| 134 | + * @since 3.0.1 | |
| 135 | + */ | |
| 136 | + public function enqueue_styles() { | |
| 141 | 137 | |
| 142 | - /** | |
| 143 | - * Register the stylesheets for the admin area. | |
| 144 | - * | |
| 145 | - * @since 3.0.1 | |
| 146 | - */ | |
| 147 | - public function enqueue_styles() { | |
| 148 | - | |
| 149 | - /** | |
| 150 | - * This function is provided for demonstration purposes only. | |
| 151 | - * | |
| 152 | - * An instance of this class should be passed to the run() function | |
| 153 | - * defined in Wpstream_Loader as all of the hooks are defined | |
| 154 | - * in that particular class. | |
| 155 | - * | |
| 156 | - * The Wpstream_Loader will then create the relationship | |
| 157 | - * between the defined hooks and the functions defined in this | |
| 158 | - * class. | |
| 159 | - */ | |
| 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 | + */ | |
| 160 | 149 | wp_enqueue_style( 'wpstream-roboto', "https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700,900&display=swap&subset=latin-ext" ); |
| 161 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', array(), WPSTREAM_PLUGIN_VERSION, 'all' ); | |
| 150 | + wp_enqueue_style( | |
| 151 | + $this->plugin_name, | |
| 152 | + plugin_dir_url( __FILE__ ) . 'css/wpstream-admin.css', | |
| 153 | + array(), | |
| 154 | + filemtime(plugin_dir_path(__FILE__) . 'css/wpstream-admin.css' ), | |
| 155 | + 'all' | |
| 156 | + ); | |
| 162 | 157 | |
| 163 | - wp_enqueue_style( 'wpstream-on-boarding-css', plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css', array(), rand(1,999999999999), 'all' ); | |
| 158 | + wp_enqueue_style( | |
| 159 | + 'wpstream-on-boarding-css', | |
| 160 | + plugin_dir_url( __FILE__ ) . 'css/wpstream-admin-onboarding.css', | |
| 161 | + array(), | |
| 162 | + filemtime(plugin_dir_path(__FILE__) . 'css/wpstream-admin-onboarding.css'), | |
| 163 | + ); | |
| 164 | 164 | |
| 165 | - | |
| 166 | - } | |
| 165 | + if (!did_action('wp_enqueue_media')) { | |
| 166 | + wp_enqueue_media(); | |
| 167 | + } | |
| 168 | + } | |
| 167 | 169 | |
| 168 | - /** | |
| 169 | - * Register the JavaScript for the admin area. | |
| 170 | - * | |
| 171 | - * @since 3.0.1 | |
| 172 | - */ | |
| 173 | - public function enqueue_scripts() { | |
| 170 | + /** | |
| 171 | + * Register the JavaScript for the admin area. | |
| 172 | + * | |
| 173 | + * @since 3.0.1 | |
| 174 | + */ | |
| 175 | + public function enqueue_scripts() { | |
| 174 | 176 | |
| 175 | 177 | wp_enqueue_script("jquery-ui-slider"); |
| 176 | 178 | wp_enqueue_script("jquery-ui-datepicker"); |
| 177 | - wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 178 | - wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 179 | + wp_enqueue_script('jquery.fileupload', plugin_dir_url( __FILE__ ) .'js/jquery.fileupload.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 180 | + | |
| 181 | + wp_enqueue_script( 'wpstream-admin-utils', plugin_dir_url( __FILE__ ) .'js/utils/admin_utils.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 182 | + wp_enqueue_script('wpstream-admin-control', plugin_dir_url( __FILE__ ) .'js/admin_control.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 179 | 183 | wp_localize_script('wpstream-admin-control', 'wpstream_admin_control_vars', |
| 180 | 184 | array( |
| 181 | - 'admin_url' => get_admin_url(), | |
| 182 | - 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif', | |
| 183 | - 'download_mess' => esc_html__('Click to download!','wpstream'), | |
| 184 | - 'uploading' => esc_html('We are uploading your file.Do not close this window!','wpstream'), | |
| 185 | - 'upload_complete2' => esc_html('Upload Complete! You can upload another file!','wpstream'), | |
| 186 | - 'not_accepted' => esc_html('The file is not an accepted video format','wpstream'), | |
| 187 | - 'upload_complete' => esc_html('Upload Complete!','wpstream'), | |
| 188 | - 'no_band' => esc_html('Not enough streaming data.','wpsteam'), | |
| 189 | - 'no_band_no_store' => esc_html('Not enough streaming data or storage.','wpsteam') | |
| 190 | - | |
| 185 | + 'admin_url' => get_admin_url(), | |
| 186 | + 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif', | |
| 187 | + 'download_mess' => esc_html__('Click to download!','wpstream'), | |
| 188 | + 'uploading' => esc_html__('We are uploading your file. Do not close this window!','wpstream'), | |
| 189 | + 'upload_complete2' => esc_html__('Upload Complete! You can upload another file!','wpstream'), | |
| 190 | + 'not_accepted' => esc_html__('The file is not an accepted video format','wpstream'), | |
| 191 | + 'upload_complete' => esc_html__('Upload Complete!','wpstream'), | |
| 192 | + 'no_band' => esc_html__('Not enough streaming data.','wpsteam'), | |
| 193 | + 'no_band_no_store' => esc_html__('Not enough streaming data or storage.','wpsteam'), | |
| 194 | + 'exceeding_limit' => esc_html__('File size exceeds 5GB. Initiating multipart upload...','wpsteam'), | |
| 195 | + 'upload_failed' => esc_html__('Upload Failed!','wpstream'), | |
| 196 | + 'upload_failed2' => esc_html__('Upload Failed! Please Try again!','wpstream'), | |
| 197 | + 'choose_a_file' => esc_html__('Choose a file…','wpstream'), | |
| 198 | + 'preparing_multipart' => esc_html__('Preparing multipart upload...','wpstream'), | |
| 199 | + 'uploading_part' => esc_html__('Uploading part {part} of {total}...','wpstream'), | |
| 200 | + 'upload_failed_part' => esc_html__('Failed to upload part {part}. Please try again.','wpstream'), | |
| 201 | + 'completing_upload' => esc_html__('Completing upload. Please wait...','wpstream'), | |
| 202 | + 'upload_failed_part_retry' => esc_html__('Failed to upload part {part}. Retrying...','wpstream'), | |
| 203 | + 'choose_recording' => esc_html__( 'Choose Recording', 'wpstream' ), | |
| 204 | + 'select_recording' => esc_html__( 'Please select a recording from the list', 'wpstream' ), | |
| 205 | + 'invalid_response' => esc_html__('Invalid response from server. Missing required upload data.', 'wpstream'), | |
| 206 | + 'video_processing' => esc_html__( 'The video is still processing', 'wpstream' ), | |
| 207 | + 'file_name_text' => esc_html__('File Name:','wpstream'), | |
| 208 | + 'channel_create_error' => esc_html__('Something did not work. Please try again.', 'wpstream'), | |
| 191 | 209 | )); |
| 192 | 210 | |
| 193 | - | |
| 194 | - | |
| 195 | - wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'/public/js/start_streaming.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 211 | + wp_enqueue_script('wpstream-recordings-videos-list', plugin_dir_url( __FILE__ ) .'js/recordings_videos_list.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 212 | + wp_localize_script( 'wpstream-recordings-videos-list', 'wpstream_recordings_videos_list_vars', | |
| 213 | + array( | |
| 214 | + 'delete_file' => esc_html__('Delete file', 'wpstream'), | |
| 215 | + 'download' => esc_html__( 'Download', 'wpstream'), | |
| 216 | + 'download_available' => esc_html__( 'Click to download! The url will work for the next 20 minutes!', 'wpstream'), | |
| 217 | + 'add_free_video_url' => esc_url( admin_url( 'post-new.php?post_type=wpstream_product_vod') . '&new_video_name=' ), | |
| 218 | + 'create_ftv_vod' => esc_html__( 'Create new Free-To-View VOD from this recording' , 'wpstream' ), | |
| 219 | + 'woocommerce_exists' => class_exists( 'WooCommerce' ), | |
| 220 | + 'add_paid_video_url' => esc_url( admin_url( 'post-new.php?post_type=product').'&new_video_name=' ), | |
| 221 | + 'create_ptv_vod' => esc_html__( 'Create new Pay-Per-View VOD from this recording' , 'wpstream' ), | |
| 222 | + ) | |
| 223 | + ); | |
| 224 | + | |
| 225 | + $modified_start_streaming_file_time = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'public/js/start_streaming.js' ) ); | |
| 226 | + wp_enqueue_script('wpstream-start-streaming_admin', plugin_dir_url( __DIR__ ) .'public/js/start_streaming.js', array(), $modified_start_streaming_file_time, true); | |
| 196 | 227 | wp_localize_script('wpstream-start-streaming_admin', 'wpstream_start_streaming_vars', |
| 197 | 228 | array( |
| 198 | 229 | 'admin_url' => get_admin_url(), |
| 199 | 230 | 'loading_url' => WPSTREAM_PLUGIN_DIR_URL.'/img/loading.gif', |
| @@ -208,8 +239,9 @@ | ||
| 208 | 239 | 'start_streaming_action'=> esc_html__('TURNING ON','wpstream'), |
| 209 | 240 | 'stop_streaming_action' => esc_html__('TURNING OFF','wpstream'), |
| 210 | 241 | 'start_streaming' => esc_html__('TURN ON','wpstream'), |
| 211 | 242 | 'stop_streaming' => esc_html__('TURN OFF','wpstream'), |
| 243 | + 'failed_fetching' => esc_html__('Failed to get channel info. Please try again.','wpstream'), | |
| 212 | 244 | 'turned_on_tooltip' => esc_html__('Channel is now OFF. Click to turn ON.','wpstream'), |
| 213 | 245 | 'turned_off_tooltip' => esc_html__('Click to turn channel off. This will interrupt any ongoing broadcast.','wpstream'), |
| 214 | 246 | 'turning_on_tooltip' => esc_html__('Turning a channel on may take 1-2 minutes or more. Please be patient.','wpstream'), |
| 215 | 247 | 'turning_off_tooltip' => esc_html__('This may take a few minutes.','wpstream'), |
| @@ -218,13 +250,39 @@ | ||
| 218 | 250 | 'channel_turning_on' => esc_html__('Channel is turning on','wpstream'), |
| 219 | 251 | 'channel_turning_off' => esc_html__('Channel is turning off','wpstream'), |
| 220 | 252 | 'channel_on' => esc_html__('Channel is ON','wpstream'), |
| 221 | 253 | 'channel_off' => esc_html__('Channel is OFF','wpstream'), |
| 222 | - 'turn_off_confirm' => esc_html__('ARE YOU SURE you\'d like to TURN OFF the channel now? '.PHP_EOL.PHP_EOL.'Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).'.PHP_EOL.PHP_EOL.'Manual TURN OFF is only useful if you require to change the channel settings immediately.'.PHP_EOL.PHP_EOL.'Statistics may be unavailable or incomplete for up to an hour.'.PHP_EOL.PHP_EOL.'If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.','wpstream') | |
| 254 | + 'turn_off_confirm' => esc_html__( | |
| 255 | + 'ARE YOU SURE you\'d like to TURN OFF the channel now? ' . PHP_EOL . PHP_EOL . | |
| 256 | + '- Channels TURN OFF automatically after 1 hour of inactivity (no active broadcast).' . PHP_EOL . | |
| 257 | + '- Manual TURN OFF is only useful if you require to change the channel settings immediately.' . PHP_EOL . | |
| 258 | + '- If your channel is configured with Auto TURN ON, it will turn back on as soon as there is a broadcast.', | |
| 259 | + 'wpstream' | |
| 260 | + ), | |
| 261 | + 'basic_streaming_warning' => esc_html__( | |
| 262 | + 'Your account is now in BASIC STREAMING mode.' . PHP_EOL . PHP_EOL . | |
| 263 | + 'Instead of offloading to the WpStream Cloud, this mode relies on WordPress and hosting resources to process and deliver video. In some WP environments, streaming may be unreliable.' . PHP_EOL . | |
| 264 | + 'Certain features, such as recording, viewer count, browser broadcasting, and content protection are unavailable.' . PHP_EOL . PHP_EOL . | |
| 265 | + '- To take advantage of all features, please choose Cancel and upgrade your plan.' . PHP_EOL . | |
| 266 | + '- Otherwise, choose OK to start your channel with these limitations.' . PHP_EOL . PHP_EOL . | |
| 267 | + 'ARE YOU SURE you want to continue with Basic Streaming?', | |
| 268 | + 'wpstream' | |
| 269 | + ), | |
| 270 | + 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ), | |
| 223 | 271 | )); |
| 224 | 272 | |
| 273 | + wp_enqueue_script('wpstream-settings', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream_settings.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 274 | + wp_localize_script('wpstream-settings', 'wpstream_settings_vars', array( | |
| 275 | + 'error_message' => esc_html__( 'Failed to save settings. Please try again.', 'wpstream'), | |
| 276 | + 'choose_image_text' => esc_html__( 'Choose Logo Image', 'wpstream'), | |
| 277 | + 'select_image_text' => esc_html__( 'Select Image', 'wpstream'), | |
| 278 | + 'update_successful' => esc_html__( 'Update Successful.', 'wpstream'), | |
| 279 | + 'update_failed' => esc_html__( 'Something went wrong. Try again.', 'wpstream'), | |
| 280 | + 'broadcaster_url' => esc_url( esc_url(home_url('/broadcaster-page/') ) ), | |
| 281 | + )); | |
| 225 | 282 | |
| 226 | - wp_enqueue_script('wpstream-on-boarding-js', plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js?v='.time(),array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 283 | + | |
| 284 | + wp_enqueue_script('wpstream-on-boarding-js',plugin_dir_url( __DIR__ ) .'/admin/js/wpstream-onboarding2.js',array(), WPSTREAM_PLUGIN_VERSION, true); | |
| 227 | 285 | wp_localize_script('wpstream-on-boarding-js', 'wpstreamonboarding_js_vars', |
| 228 | 286 | array( |
| 229 | 287 | 'admin_url' => get_admin_url(), |
| 230 | 288 | 'plugin_url' => get_dashboard_url().'/plugins.php', |
| @@ -229,18 +287,41 @@ | ||
| 229 | 287 | 'admin_url' => get_admin_url(), |
| 230 | 288 | 'plugin_url' => get_dashboard_url().'/plugins.php', |
| 231 | 289 | 'upload_url' => get_dashboard_url().'admin.php?page=wpstream_recordings' |
| 232 | 290 | |
| 233 | - )); | |
| 291 | + )); | |
| 292 | + | |
| 293 | +// wp_enqueue_style( | |
| 294 | +// 'wpstream-broadcaster-css', | |
| 295 | +// plugin_dir_url(__FILE__) . 'public/css/broadcaster.css', | |
| 296 | +// array(), | |
| 297 | +// filemtime(plugin_dir_path(__FILE__) . 'public/css/broadcaster.css' ), | |
| 298 | +// ); | |
| 299 | +// | |
| 300 | +// wp_enqueue_script( | |
| 301 | +// 'wpstream-broadcaster', | |
| 302 | +// plugin_dir_url(__FILE__) . 'public/js/broadcaster.js', | |
| 303 | +// array('jquery'), | |
| 304 | +// WPSTREAM_PLUGIN_VERSION, | |
| 305 | +// true | |
| 306 | +// ); | |
| 307 | + | |
| 308 | + // Add localized variables for broadcaster | |
| 309 | + wp_localize_script('wpstream-broadcaster', 'wpstream_broadcaster_vars', array( | |
| 310 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 311 | + 'nonce' => wp_create_nonce('wpstream_broadcaster_nonce'), | |
| 312 | + 'plugin_url' => plugin_dir_url(__FILE__), | |
| 313 | + | |
| 314 | + )); | |
| 234 | 315 | |
| 235 | 316 | } |
| 236 | 317 | |
| 237 | 318 | |
| 238 | 319 | /** |
| 239 | - * Add Plugin Administation menu | |
| 240 | - * | |
| 241 | - * @since 3.0.1 | |
| 242 | - */ | |
| 320 | + * Add Plugin Administation menu | |
| 321 | + * | |
| 322 | + * @since 3.0.1 | |
| 323 | + */ | |
| 243 | 324 | |
| 244 | 325 | public function wpstream_manage_admin_menu() { |
| 245 | 326 | |
| 246 | 327 | add_menu_page( __('WpStream','wpestream'), __('WpStream ','wpstream'), 'administrator', 'wpstream_credentials', array($this,'wpstream_set_wpstream_credentials'), WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png',20 ); |
| @@ -300,9 +381,9 @@ | ||
| 300 | 381 | |
| 301 | 382 | $event_list = new WP_Query($args); |
| 302 | 383 | global $live_event_for_user; |
| 303 | 384 | $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user(); |
| 304 | - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); | |
| 385 | + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_new_general_set'); | |
| 305 | 386 | |
| 306 | 387 | $this->main->show_user_data($pack_details); |
| 307 | 388 | if( $event_list->have_posts()){ |
| 308 | 389 | |
| @@ -340,8 +421,14 @@ | ||
| 340 | 421 | |
| 341 | 422 | |
| 342 | 423 | $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" ); |
| 343 | 424 | print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">'; |
| 425 | + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_new_general_set'); | |
| 426 | + if( isset($pack_details['available_data_mb'])){ | |
| 427 | + if ($pack_details['available_data_mb'] <= 0){ | |
| 428 | + print '<input type="hidden" id="wpstream_basic_streaming" value="true">'; | |
| 429 | + } | |
| 430 | + } | |
| 344 | 431 | $current_user = wp_get_current_user(); |
| 345 | 432 | $allowded_html = array(); |
| 346 | 433 | $userID = $current_user->ID; |
| 347 | 434 | $user_live_streams = get_user_meta($userID,'live_shows'); |
| @@ -522,13 +609,17 @@ | ||
| 522 | 609 | |
| 523 | 610 | if( $live_event_for_user=='' && $is_front=='front' ){ |
| 524 | 611 | $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user(); |
| 525 | 612 | } |
| 526 | - $channel_status = esc_html__('Channel is OFF','wpstream'); | |
| 613 | + $channel_status = '<div class="spinner" style="visibility: visible"></div>'; | |
| 614 | + $button_status = '<div class="spinner" style="visibility: visible"></div>'; | |
| 527 | 615 | if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) { |
| 528 | 616 | $pending_streaming_class = 'pending_trigger'; |
| 529 | 617 | $live_data_url = get_post_meta($the_id,'qos_url',true); |
| 530 | 618 | // $channel_status = esc_html__('Channel is on','wpstream'); |
| 619 | + } else { | |
| 620 | + $channel_status = esc_html__('Channel is OFF','wpstream'); | |
| 621 | + $button_status = esc_html__('TURN ON','wpstream'); | |
| 531 | 622 | } |
| 532 | 623 | |
| 533 | 624 | $server_id = get_post_meta($the_id,'server_id',true); |
| 534 | 625 | $obs_uri = get_post_meta($the_id,'obs_uri',true); |
| @@ -550,13 +641,13 @@ | ||
| 550 | 641 | /* print '***</br>'.get_post_meta($the_id,'obs_uri',true) .'***</br>'. |
| 551 | 642 | get_post_meta($the_id,'obs_stream',true).'***</br>'. |
| 552 | 643 | get_post_meta($the_id,'broadcast_url',true); |
| 553 | 644 | */ |
| 554 | - print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>'; | |
| 645 | + print '<div class="wpstream_channel_item_id">'.esc_html( '#ID' ).' '.$the_id.'</div>'; | |
| 555 | 646 | print '</div>'; |
| 556 | 647 | |
| 557 | 648 | |
| 558 | - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream'); | |
| 649 | + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > ' . $button_status; | |
| 559 | 650 | print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>'; |
| 560 | 651 | print '</div>'; |
| 561 | 652 | |
| 562 | 653 | print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">'; |
| @@ -603,9 +694,10 @@ | ||
| 603 | 694 | print '<div class="wpstream_options_col2 wpstream_show_settings_wrapper">'; |
| 604 | 695 | if($is_front==''){ |
| 605 | 696 | print '<div class="wpstream_show_settings wpstream-button-icon wpstream-trigger-modal wpstream_tooltip_wrapper" data-modal="wpestate_settings_modal" data-show-id="'.$the_id.'" value="'.esc_html__('Settings','wpstream').'">'; |
| 606 | 697 | |
| 607 | - print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn OFF the channel to change its settings.','wpestream').'</div>'; | |
| 698 | + print '<div class="wpstream_tooltip_disabled">'.esc_html__(' | |
| 699 | + Turn OFF the channel to change its settings.','wpestream').'</div>'; | |
| 608 | 700 | print '<div class="wpstream_tooltip">'.esc_html__('Channel Settings','wpestream').'</div>'; |
| 609 | 701 | |
| 610 | 702 | print '<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 611 | 703 | <path d="M49.22 21.8648C48.82 21.6099 45.665 19.7247 44.415 19.15L42.8651 15.4C43.3251 14.1601 44.2099 10.6849 44.3652 10.0798H44.3649C44.4911 9.52035 44.3213 8.93514 43.9149 8.52987L41.47 6.09995C41.0658 5.69189 40.4795 5.52168 39.9201 5.65003C39.4601 5.75501 35.92 6.64994 34.5999 7.15012L30.8499 5.60021C30.3048 4.40012 28.4699 1.32529 28.1351 0.795199V0.79485C27.8337 0.301688 27.298 0.00069643 26.7201 0H23.2798C22.7057 0.000348769 22.1718 0.294715 21.8648 0.779859C21.6098 1.1799 19.7247 4.33487 19.15 5.58487L15.4 7.13478C14.1601 6.67476 10.6849 5.78996 10.0798 5.63469V5.63504C9.52035 5.50878 8.93513 5.67864 8.52987 6.08496L6.09995 8.52988C5.69189 8.9341 5.52168 9.52042 5.65003 10.0798C5.75501 10.5398 6.64994 14.0799 7.15012 15.4L5.60021 19.15C4.40012 19.6951 1.32529 21.53 0.795198 21.8648H0.79485C0.301688 22.1662 0.00069643 22.7019 0 23.2798V26.7149C0.000348751 27.2893 0.294715 27.8233 0.779858 28.1299C1.1799 28.3849 4.33486 30.27 5.58487 30.8448L7.13478 34.5948C6.67475 35.8347 5.78996 39.3099 5.63469 39.915H5.63504C5.50878 40.4747 5.67863 41.06 6.08496 41.4649L8.51487 43.8948V43.8951C8.9191 44.3032 9.50541 44.4731 10.0648 44.3451C10.5248 44.2401 14.0649 43.3451 15.385 42.845L19.135 44.3949C19.6801 45.595 21.515 48.6698 21.8498 49.1999C22.1525 49.6997 22.6956 50.0035 23.2798 50H26.7149C27.2893 49.9996 27.8233 49.7053 28.1299 49.2201C28.3849 48.8201 30.27 45.6651 30.8447 44.4151L34.5947 42.8652C35.8347 43.3252 39.3098 44.21 39.9149 44.3653V44.3649C40.4747 44.4912 41.0599 44.3213 41.4649 43.915L43.8948 41.4851H43.8951C44.3032 41.0809 44.473 40.4945 44.345 39.9352C44.2401 39.4751 43.3451 35.9351 42.8449 34.615L44.3949 30.865C45.5949 30.3198 48.6698 28.485 49.1999 28.1501C49.6997 27.8474 50.0034 27.3044 49.9999 26.7201V23.2799C50.0045 22.7047 49.7087 22.1683 49.2201 21.8649L49.22 21.8648ZM24.9995 35.8845C22.1099 35.882 19.3399 34.7314 17.2985 32.6866C15.2572 30.6414 14.1118 27.8694 14.1146 24.9798C14.1171 22.0903 15.2676 19.3199 17.3125 17.2785C19.3577 15.2372 22.1297 14.0921 25.0193 14.0946C27.9088 14.0974 30.6792 15.2477 32.7205 17.2928C34.7619 19.338 35.907 22.1101 35.9045 24.9996C35.8978 27.8879 34.7462 30.6557 32.7021 32.6964C30.6576 34.7367 27.8876 35.8834 24.9994 35.8845H24.9995Z" fill="black"/> |
| @@ -637,13 +729,8 @@ | ||
| 637 | 729 | </svg>'; |
| 638 | 730 | print '</div>'; |
| 639 | 731 | print '</div>'; |
| 640 | 732 | |
| 641 | - | |
| 642 | - | |
| 643 | - | |
| 644 | - | |
| 645 | - | |
| 646 | 733 | $this->wpstream_display_modal_seetings($the_id); |
| 647 | 734 | $this->wpstream_display_modal_share($the_id); |
| 648 | 735 | $this->wpstream_display_modal_broadcast($the_id,$external_software_streaming_class,$obs_uri,$obs_stream); |
| 649 | 736 | |
| @@ -702,13 +789,19 @@ | ||
| 702 | 789 | |
| 703 | 790 | if( $live_event_for_user=='' && $is_front=='front' ){ |
| 704 | 791 | $live_event_for_user = $this->main->wpstream_live_connection->wpstream_get_live_event_for_user(); |
| 705 | 792 | } |
| 706 | - $channel_status = esc_html__('Channel is OFF','wpstream'); | |
| 793 | + | |
| 794 | + $spinner_url = admin_url('images/spinner-2x.gif'); | |
| 795 | + $button_status = '<div class="spinner" style="background-image: url(' . $spinner_url . ')"></div>'; | |
| 796 | + $channel_status = ''; | |
| 707 | 797 | if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) { |
| 708 | 798 | $pending_streaming_class = 'pending_trigger'; |
| 709 | 799 | $live_data_url = get_post_meta($the_id,'qos_url',true); |
| 710 | 800 | // $channel_status = esc_html__('Channel is on','wpstream'); |
| 801 | + } else { | |
| 802 | + $channel_status = esc_html__('Channel is OFF','wpstream'); | |
| 803 | + $button_status = esc_html__('TURN ON', 'wpstream'); | |
| 711 | 804 | } |
| 712 | 805 | |
| 713 | 806 | $server_id = get_post_meta($the_id,'server_id',true); |
| 714 | 807 | $obs_uri = get_post_meta($the_id,'obs_uri',true); |
| @@ -717,15 +810,15 @@ | ||
| 717 | 810 | $rtmp_ip_uri = ''; |
| 718 | 811 | |
| 719 | 812 | print '<div class="wpstream_theme_event_list_unit event_list_unit '.$live_class.' '.$pending_streaming_class.' event_unit_style_'.esc_attr($is_front).'" data-show-id="'.intval($the_id).'" data-server-id="'.$server_id.'" data-server-url="'.$rtmp_ip_uri.'"">'; |
| 720 | 813 | |
| 721 | - print '<div class="wpstream_channel_status">'.$channel_status.'</div>'; | |
| 814 | + print '<div class="wpstream_channel_status" style="' . ($channel_status ? '' : 'display: none') . '">'.$channel_status.'</div>'; | |
| 722 | 815 | |
| 723 | 816 | print '<div class="server_notification"></div>'; |
| 724 | 817 | |
| 725 | 818 | print '<div class="wpstream_theme_event_thumb_wrapper">'; |
| 726 | 819 | print '<div class="event_thumb_wrapper" style="background-image:url('.$thumb.')"></div>'; |
| 727 | - print '<div class="event_title" data-prodid="'.$the_id.'">remove: '.wp_trim_words(get_the_title($the_id),10); | |
| 820 | + print '<div class="event_title" data-prodid="'.$the_id.'">'.wp_trim_words(get_the_title($the_id),10); | |
| 728 | 821 | print '<div class="wpstream_channel_item_id">'.esc_html('#ID','wpstream').' '.$the_id.'</div>'; |
| 729 | 822 | print '</div>'; |
| 730 | 823 | print '</div>'; |
| 731 | 824 | |
| @@ -734,9 +827,9 @@ | ||
| 734 | 827 | |
| 735 | 828 | print '<div class="wpstream_options_col1 wpstream_stream_browser_wrapper">'; |
| 736 | 829 | |
| 737 | 830 | print '<div class="wpstream_inactive_icon start_webcaster wpstream_stream_browser wpstream-button-icon wpstream_tooltip_wrapper" data-webcaster-url="'.$webcaster_url.'" data-show-id="'.$the_id.'"">'; |
| 738 | - | |
| 831 | + | |
| 739 | 832 | print '<div class="wpstream_tooltip_disabled">'.esc_html__('Turn ON the channel to go live.','wpestream').'</div>'; |
| 740 | 833 | print '<div class="wpstream_tooltip">'.esc_html__('Go live with your webcam','wpestream').'</div>'; |
| 741 | 834 | |
| 742 | 835 | print '<svg width="41" height="51" viewBox="0 0 41 51" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| @@ -816,9 +909,9 @@ | ||
| 816 | 909 | print '</div>'; |
| 817 | 910 | print '</div>'; |
| 818 | 911 | |
| 819 | 912 | |
| 820 | - print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '.esc_html__('TURN ON','wpstream'); | |
| 913 | + print '<div class="start_event wpstream_button wpstream_tooltip_wrapper" data-show-id="'.$the_id.'" > '. $button_status; | |
| 821 | 914 | print '<div class="wpstream_tooltip">'.esc_html__('Channel is now OFF. Click to turn ON.','wpestream').'</div>'; |
| 822 | 915 | print '</div>'; |
| 823 | 916 | |
| 824 | 917 | print '</div>'; |
| @@ -844,30 +937,60 @@ | ||
| 844 | 937 | public function wpstream_close_modal_button(){ |
| 845 | 938 | print '<div class="wpstream_close_modal"></div>'; |
| 846 | 939 | } |
| 847 | 940 | |
| 941 | + public function wpstream_local_event_options_toggle() { | |
| 942 | + $use_global_event_options = get_post_meta(get_the_ID(), 'use_global_event_options', true ); | |
| 943 | + $local_event_options = get_post_meta( get_the_ID(), 'local_event_options', true ); | |
| 944 | + $use_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) || | |
| 945 | + ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 ); | |
| 946 | + | |
| 947 | + print '<div class="wpstream_local_event_options_toggle_wrapper">'; | |
| 948 | + print '<div class="wpstream_local_event_options_toggle_info">'; | |
| 949 | + print '<label for="local_event_options_enabled" class="wpstream_local_event_options_label">'.esc_html__('Edit settings for this channel','wpstream').'</label>'; | |
| 950 | + print '<span>'.sprintf(esc_html__('When is OFF, the settings from %s will be applied','wpstream'), '<a href="' . admin_url('admin.php?page=wpstream_settings&tab=default_options') . '" target="_blank">'.esc_html__('Default Channel Settings','wpstream').'</a>').'</span>'; | |
| 951 | + print '</div>'; | |
| 952 | + print '<label class="wpstream_switch">'; | |
| 953 | + print '<input id="local_event_options_enabled" type="checkbox" class="wpstream_local_event_options_toggle" ' . ($use_local_event_options_enabled === true ? 'checked' : '') . '>'; | |
| 954 | + print '<span class="wpstream_slider round"></span>'; | |
| 955 | + print '</label>'; | |
| 956 | + print '</div>'; | |
| 957 | + } | |
| 958 | + | |
| 848 | 959 | /* |
| 849 | 960 | * |
| 850 | 961 | * Display modal settings |
| 851 | 962 | * |
| 852 | 963 | */ |
| 853 | - | |
| 964 | + | |
| 854 | 965 | public function wpstream_display_modal_seetings($the_id){ |
| 855 | - print '<div class="wpstream_modal_form wpestate_settings_modal">'; | |
| 856 | - $this->wpstream_close_modal_button(); | |
| 857 | - print '<h3>'; | |
| 966 | + print '<div class="wpstream_modal_form wpestate_settings_modal">'; | |
| 967 | + $this->wpstream_close_modal_button(); | |
| 968 | + print '<h3>'; | |
| 858 | 969 | printf( esc_html__('Channel Settings (#ID %s)','wpstream'),$the_id); |
| 859 | - print '</h3>'; | |
| 860 | - $local_event_options = get_post_meta($the_id,'local_event_options',true); | |
| 861 | - if(!is_array($local_event_options)){ | |
| 862 | - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ; | |
| 970 | + print '</h3>'; | |
| 971 | + | |
| 972 | + $this->wpstream_local_event_options_toggle(); | |
| 973 | + | |
| 974 | + $local_event_options = get_post_meta($the_id,'local_event_options',true); | |
| 975 | + $use_global_event_options = get_post_meta($the_id, 'use_global_event_options',true); | |
| 976 | + $is_local_event_options_enabled = ( is_array( $local_event_options ) && empty( $use_global_event_options ) ) || | |
| 977 | + ( !empty($use_global_event_options) && intval( $use_global_event_options ) === 0 ); | |
| 978 | + | |
| 979 | + if( !$is_local_event_options_enabled ) { | |
| 980 | + $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ; | |
| 863 | 981 | } |
| 864 | 982 | |
| 865 | 983 | $local_array_exclude=array('ses_encrypt','vod_domain_lock','vod_encrypt'); |
| 866 | - | |
| 984 | + | |
| 867 | 985 | print '<div class="wpstream_event_streaming_local">'; |
| 868 | - $this->user_streaming_global_channel_options('',$local_event_options, $local_array_exclude); | |
| 869 | - print '</div>'; | |
| 986 | + $this->user_streaming_global_channel_options( | |
| 987 | + '', | |
| 988 | + $local_event_options, | |
| 989 | + $local_array_exclude, | |
| 990 | + !$is_local_event_options_enabled, | |
| 991 | + ); | |
| 992 | + print '</div>'; | |
| 870 | 993 | print '</div>'; |
| 871 | 994 | } |
| 872 | 995 | |
| 873 | 996 | |
| @@ -949,9 +1072,9 @@ | ||
| 949 | 1072 | <li>1. Click Settings in the OBS Window and then Select Stream.</li> |
| 950 | 1073 | <li>2. Choose Custom Streaming Server in the Stream Type dropdown menu.</li> |
| 951 | 1074 | <li>3. In the URL box, type/paste your Server.</li> |
| 952 | 1075 | <li>4. In the Stream key, type/paste your Stream key.</li> |
| 953 | - <li>5. Save changes.Close the Settings window and click on the “Start Streaming” button in the main window of OBS.</li></ul>'; | |
| 1076 | + <li>5. Save changes.Close the Settings window and click on the "Start Streaming" button in the main window of OBS.</li></ul>'; | |
| 954 | 1077 | |
| 955 | 1078 | print '</div>'; |
| 956 | 1079 | |
| 957 | 1080 | |
| @@ -1057,9 +1180,9 @@ | ||
| 1057 | 1180 | <li>1. Click Broadcast in the XSplit Window and then click "Set up a new output".</li> |
| 1058 | 1181 | <li>2. Choose Custom RTMP in the Set up a new output dropdown menu.</li> |
| 1059 | 1182 | <li>3. In the URL box, type/paste your RTMP Url.</li> |
| 1060 | 1183 | <li>4. In the Stream key, type/paste your Stream key.</li> |
| 1061 | - <li>5. Save changes and click on the “Stream” button in the main window.</li></ul>'; | |
| 1184 | + <li>5. Save changes and click on the "Stream" button in the main window.</li></ul>'; | |
| 1062 | 1185 | print '</div>'; |
| 1063 | 1186 | |
| 1064 | 1187 | print '</div>'; |
| 1065 | 1188 | } |
| @@ -1183,12 +1306,12 @@ | ||
| 1183 | 1306 | |
| 1184 | 1307 | |
| 1185 | 1308 | |
| 1186 | 1309 | /* |
| 1187 | - * Set Settings | |
| 1188 | - * | |
| 1189 | - * | |
| 1190 | - */ | |
| 1310 | + * Set Settings | |
| 1311 | + * | |
| 1312 | + * | |
| 1313 | + */ | |
| 1191 | 1314 | |
| 1192 | 1315 | public function wpstream_settings(){ |
| 1193 | 1316 | |
| 1194 | 1317 | if( !current_user_can('administrator') ){ |
| @@ -1195,9 +1318,9 @@ | ||
| 1195 | 1318 | die('Only for administrators'); |
| 1196 | 1319 | } |
| 1197 | 1320 | |
| 1198 | 1321 | |
| 1199 | - if($_SERVER['REQUEST_METHOD'] === 'POST'){ | |
| 1322 | + if($_SERVER['REQUEST_METHOD'] === 'POST'){ | |
| 1200 | 1323 | if( !wp_verify_nonce($_POST['wpstream-settings-nonce'],'wpstream-settings-nonce') ){ |
| 1201 | 1324 | die('Security check'); |
| 1202 | 1325 | } |
| 1203 | 1326 | |
| @@ -1209,10 +1332,10 @@ | ||
| 1209 | 1332 | |
| 1210 | 1333 | if( isset($_POST['user_streaming_channel_type_hidden']) && intval($_POST['user_streaming_channel_type_hidden'])==1 && !isset($_POST['stream_role']) ){ |
| 1211 | 1334 | update_option( sanitize_key('wpstream_stream_role'), '' ); |
| 1212 | 1335 | } |
| 1213 | - | |
| 1214 | - foreach($_POST as $variable=>$value){ | |
| 1336 | + | |
| 1337 | + foreach($_POST as $variable=>$value){ | |
| 1215 | 1338 | if ($variable!='submit'){ |
| 1216 | 1339 | if (!in_array($variable, $exclude_array) ){ |
| 1217 | 1340 | update_option( sanitize_key('wpstream_'.$variable), sanitize_text_field ($value) ); |
| 1218 | 1341 | } |
| @@ -1220,9 +1343,9 @@ | ||
| 1220 | 1343 | if($variable=='stream_role'){ |
| 1221 | 1344 | update_option( sanitize_key('wpstream_stream_role'), $value ); |
| 1222 | 1345 | } |
| 1223 | 1346 | |
| 1224 | - } | |
| 1347 | + } | |
| 1225 | 1348 | } |
| 1226 | 1349 | |
| 1227 | 1350 | |
| 1228 | 1351 | if( isset($_GET['tab']) && $_GET['tab']=='default_options' ){ |
| @@ -1237,15 +1360,15 @@ | ||
| 1237 | 1360 | } |
| 1238 | 1361 | update_option('wpstream_user_streaming_global_channel_options',$event_settings); |
| 1239 | 1362 | } |
| 1240 | 1363 | |
| 1241 | - | |
| 1242 | - | |
| 1243 | - | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1244 | 1367 | // reset permalinkgs |
| 1245 | - global $wp_rewrite; | |
| 1246 | - | |
| 1247 | - update_option( "rewrite_rules", FALSE ); | |
| 1368 | + global $wp_rewrite; | |
| 1369 | + | |
| 1370 | + update_option( "rewrite_rules", FALSE ); | |
| 1248 | 1371 | $wp_rewrite->flush_rules( true ); |
| 1249 | 1372 | |
| 1250 | 1373 | } |
| 1251 | 1374 | |
| @@ -1352,10 +1475,57 @@ | ||
| 1352 | 1475 | 'details' => esc_html__('This message will be displayed in player.','wpstream'), |
| 1353 | 1476 | 'default' => esc_html__('We are not live at this moment','wpstream'), |
| 1354 | 1477 | ), |
| 1355 | 1478 | |
| 1356 | - | |
| 1479 | + 14 => array( | |
| 1480 | + 'tab' => 'general_options', | |
| 1481 | + 'label' => esc_html__('Video player theme','wpstream'), | |
| 1482 | + 'name' => 'video_player_theme', | |
| 1483 | + 'type' => 'select', | |
| 1484 | + 'select_values'=>array( | |
| 1485 | + 'default' => esc_html__('Default','wpstream'), | |
| 1486 | + 'city' => esc_html__('City','wpstream'), | |
| 1487 | + 'forest' => esc_html__('Forest','wpstream'), | |
| 1488 | + 'fantasy' => esc_html__('Fantasy','wpstream'), | |
| 1489 | + 'sea' => esc_html__('Sea','wpstream'), | |
| 1490 | + ), | |
| 1491 | + 'details' => esc_html__('Choose the video player theme to have a different look for the player.','wpstream'), | |
| 1492 | + ), | |
| 1493 | + 'wpstream_player_logo' => array( | |
| 1494 | + 'tab' => 'general_options', | |
| 1495 | + 'name' => 'player_logo', | |
| 1496 | + 'label' => esc_html__('Logo for the video player','wpstream'), | |
| 1497 | + 'type' => 'image', | |
| 1498 | + 'details' => esc_html__('This logo will be displayed on the the video player.','wpstream'), | |
| 1499 | + 'default' => '', | |
| 1500 | + 'image_size' => 'thumbnail', | |
| 1501 | + ), | |
| 1502 | + // hide the video player logo opacity for now | |
| 1503 | +// 'wpstream_player_logo_opacity' => array( | |
| 1504 | +// 'tab' => 'general_options', | |
| 1505 | +// 'name' => 'player_logo_opacity', | |
| 1506 | +// 'label' => esc_html__('Opacity of the video player logo','wpstream'), | |
| 1507 | +// 'type' => 'range', | |
| 1508 | +// 'details' => esc_html__('Set the opacity of the logo','wpstream'), | |
| 1509 | +// 'default' => '', | |
| 1510 | +// 'image_size' => 'thumbnail', | |
| 1511 | +// ), | |
| 1512 | + 'wpsteram_player_logo_position' => array( | |
| 1513 | + 'tab' => 'general_options', | |
| 1514 | + 'name' => 'player_logo_position', | |
| 1515 | + 'label' => esc_html__('Position of the video player logo','wpstream'), | |
| 1516 | + 'type' => 'select', | |
| 1517 | + 'select_values'=>array( | |
| 1518 | + 'top-left' => esc_html__('Top Left','wpstream'), | |
| 1519 | + 'top-right' => esc_html__('Top Right','wpstream'), | |
| 1520 | + 'bottom-left' => esc_html__('Bottom Left','wpstream'), | |
| 1521 | + 'bottom-right' => esc_html__('Bottom Right','wpstream'), | |
| 1522 | + ), | |
| 1523 | + 'details' => esc_html__('Choose the position of the logo on the video player.','wpstream'), | |
| 1524 | + 'default' => '', | |
| 1525 | + ), | |
| 1357 | 1526 | |
| 1527 | + | |
| 1358 | 1528 | |
| 1359 | 1529 | 99 => array( |
| 1360 | 1530 | 'tab' => 'default_options', |
| 1361 | 1531 | 'label' => esc_html__('Events Options ','wpstream'), |
| @@ -1362,8 +1532,61 @@ | ||
| 1362 | 1532 | 'name' => 'user_streaming_global_channel_options', |
| 1363 | 1533 | 'type' => 'user_streaming_global_channel_options', |
| 1364 | 1534 | 'details' => esc_html__('Global Options for live events.','wpstream'), |
| 1365 | 1535 | ), |
| 1536 | + | |
| 1537 | + 100 => array( | |
| 1538 | + 'tab' => 'default_options_vod', | |
| 1539 | + 'label' => esc_html__('Autoplay','wpstream'), | |
| 1540 | + 'name' => 'vod_autoplay', | |
| 1541 | + 'type' => 'slidertoogle', | |
| 1542 | + 'details' => esc_html__('If enabled, video will attempt to start playing automatically. This is only achievable in some browsers.','wpstream'), | |
| 1543 | + ), | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + 101 => array( | |
| 1547 | + 'tab' => 'default_options_vod', | |
| 1548 | + 'label' => esc_html__('Start Muted','wpstream'), | |
| 1549 | + 'name' => 'vod_start_muted', | |
| 1550 | + 'type' => 'slidertoogle', | |
| 1551 | + 'details' => esc_html__('If enabled, video will start muted. This may increase the rate of autoplay in some browsers.','wpstream'), | |
| 1552 | + ), | |
| 1553 | + | |
| 1554 | + 102 => array( | |
| 1555 | + 'tab' => 'default_options_vod', | |
| 1556 | + 'label' => esc_html__('Lock To Website','wpstream'), | |
| 1557 | + 'name' => 'vod_domain_lock', | |
| 1558 | + 'type' => 'slidertoogle', | |
| 1559 | + 'details' =>sprintf ( esc_html__('If enabled, video will only display on %1$s, otherwise it can show up on any website.','wpstream'),get_bloginfo('wpurl') ), | |
| 1560 | + ), | |
| 1561 | + | |
| 1562 | + 103 => array( | |
| 1563 | + 'tab' => 'default_options_vod', | |
| 1564 | + 'label' => esc_html__('Encrypt Video','wpstream'), | |
| 1565 | + 'name' => 'vod_encrypt', | |
| 1566 | + 'type' => 'slidertoogle', | |
| 1567 | + 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'), | |
| 1568 | + ), | |
| 1569 | + | |
| 1570 | + /* 'vod_domain_lock' =>array( | |
| 1571 | + 'name' => esc_html__('Video On Demand - Lock To Website','wpstream'), | |
| 1572 | + 'details' => sprintf ( esc_html__('If enabled, VODS will only display on %1$s, otherwise they can show up on any website.','wpstream'),get_bloginfo('wpurl') ), | |
| 1573 | + 'defaults' => 'no', | |
| 1574 | + ), | |
| 1575 | + 'vod_encrypt' =>array( | |
| 1576 | + 'name' => esc_html__('Encrypt Video on Demand','wpstream'), | |
| 1577 | + 'details' => esc_html__('If enabled, video data will be encrypted. Enabling encryption may lead to reduced website performance under certain configurations. Encrypted video may not display in all browsers.','wpstream'), | |
| 1578 | + 'defaults' => 'no', | |
| 1579 | + ),*/ | |
| 1580 | + | |
| 1581 | + 104 => array( | |
| 1582 | + 'tab' => 'support_tab', | |
| 1583 | + 'label' => esc_html__('Logs','wpstream'), | |
| 1584 | + 'name' => 'logs', | |
| 1585 | + 'type' => 'logs_table', | |
| 1586 | + 'details' => esc_html__('This is the error log of the plugin.','wpstream'), | |
| 1587 | + ) | |
| 1588 | + | |
| 1366 | 1589 | ); |
| 1367 | 1590 | |
| 1368 | 1591 | $active_tab = 'general_options'; |
| 1369 | 1592 | if( isset( $_GET[ 'tab' ] ) ) { |
| @@ -1375,15 +1598,16 @@ | ||
| 1375 | 1598 | <h1>'.__('WpStream Settings','wpstream').'</h1> |
| 1376 | 1599 | <form method="post" action="" >'; |
| 1377 | 1600 | |
| 1378 | 1601 | print '<h2 class="nav-tab-wrapper"> |
| 1379 | - <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">General Options</a> | |
| 1380 | - <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">Default Channel Settings</a> | |
| 1381 | - <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : ''; echo '">Subscription Options</a> | |
| 1382 | - <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">Customize Messages</a> | |
| 1383 | - | |
| 1602 | + <a href="?page=wpstream_settings&tab=general_options" class="nav-tab '; echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('General Options','wpstream').'</a> | |
| 1603 | + <a href="?page=wpstream_settings&tab=default_options" class="nav-tab '; echo $active_tab == 'default_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Default Channel Settings','wpstream').'</a> | |
| 1604 | + <a href="?page=wpstream_settings&tab=default_options_vod" class="nav-tab '; echo $active_tab == 'default_options_vod' ? 'nav-tab-active' : ''; echo '">'.esc_html__('VOD Settings','wpstream').'</a> | |
| 1605 | + <a href="?page=wpstream_settings&tab=subscription_options" class="nav-tab '; echo $active_tab == 'subscription_options' ? 'nav-tab-active' : '';echo '">'.esc_html__('Subscription Options','wpstream').'</a> | |
| 1606 | + <a href="?page=wpstream_settings&tab=messages_options" class="nav-tab '; echo $active_tab == 'messages_options' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Customize Messages','wpstream').'</a> | |
| 1607 | + <a href="?page=wpstream_settings&tab=support_tab" class="nav-tab '; echo $active_tab == 'support_tab' ? 'nav-tab-active' : ''; echo '">'.esc_html__('Support','wpstream').'</a> | |
| 1384 | 1608 | </h2>'; |
| 1385 | - | |
| 1609 | + $help_link=''; | |
| 1386 | 1610 | print '<div class="wpstream_option_wrapper">'; |
| 1387 | 1611 | |
| 1388 | 1612 | switch ($active_tab) { |
| 1389 | 1613 | case 'general_options': |
| @@ -1389,10 +1613,13 @@ | ||
| 1389 | 1613 | case 'general_options': |
| 1390 | 1614 | $help_link='https://docs.wpstream.net/docs/general-settings/'; |
| 1391 | 1615 | break; |
| 1392 | 1616 | case 'default_options': |
| 1393 | - $help_link='https://docs.wpstream.net/docs/default-settings/'; | |
| 1617 | + $help_link='https://docs.wpstream.net/docs/default-channel-settings/'; | |
| 1394 | 1618 | break; |
| 1619 | + case 'default_options_vod': | |
| 1620 | + $help_link='https://docs.wpstream.net/docs/vod-settings/'; | |
| 1621 | + break; | |
| 1395 | 1622 | case 'subscription_options': |
| 1396 | 1623 | $help_link='https://docs.wpstream.net/docs/subscription-options/'; |
| 1397 | 1624 | break; |
| 1398 | 1625 | case 'messages_options': |
| @@ -1399,33 +1626,35 @@ | ||
| 1399 | 1626 | $help_link='https://docs.wpstream.net/docs/customize-messages/'; |
| 1400 | 1627 | break; |
| 1401 | 1628 | } |
| 1402 | 1629 | |
| 1403 | - print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >Video Help</a></div>'; | |
| 1404 | - | |
| 1630 | + print '<div class="options_wrapper">'; | |
| 1405 | 1631 | foreach ($wpstream_settings_array as $key=>$option){ |
| 1406 | 1632 | if($option['tab']!=$active_tab){ |
| 1407 | 1633 | continue; |
| 1408 | 1634 | } |
| 1409 | - | |
| 1635 | + | |
| 1636 | + if ( $option['type']=='user_streaming_global_channel_options' ) { | |
| 1637 | + print '<div class="default-channel-settings-info">'; | |
| 1638 | + print esc_html__( 'These settings will apply to newly created channels; existing channels will not change settings if you change them here', 'wpstream'); | |
| 1639 | + print '</div>'; | |
| 1640 | + | |
| 1641 | + } | |
| 1410 | 1642 | print '<div class="wpstream_option">'; |
| 1411 | 1643 | $options_value = get_option('wpstream_'.$option['name']) ; |
| 1412 | 1644 | |
| 1413 | 1645 | |
| 1414 | - if($option['type']=='user_roles'){ | |
| 1415 | - | |
| 1646 | + switch( $option['type'] ) { | |
| 1647 | + case 'user_roles': | |
| 1416 | 1648 | print '<label for="'.$option['name'].'">'.$option['label'].'</label>'; |
| 1417 | 1649 | print $this->wpstream_select_user_roles($option['name'],$options_value); |
| 1418 | 1650 | print '<div class="settings_details">'.$option['details'].'</div>'; |
| 1419 | - | |
| 1420 | - }else if($option['type']=='user_streaming_global_channel_options'){ | |
| 1421 | - | |
| 1651 | + break; | |
| 1652 | + case 'user_streaming_global_channel_options': | |
| 1422 | 1653 | $exclude_array=array(); |
| 1423 | 1654 | $this->user_streaming_global_channel_options($option['name'],$options_value,$exclude_array); |
| 1424 | - | |
| 1425 | - | |
| 1426 | - }else if($option['type']=='text'){ | |
| 1427 | - | |
| 1655 | + break; | |
| 1656 | + case 'text': | |
| 1428 | 1657 | if($options_value==''){ |
| 1429 | 1658 | $options_value=''; |
| 1430 | 1659 | if(isset($option['default'])){ |
| 1431 | 1660 | $options_value=$option['default']; |
| @@ -1430,15 +1659,14 @@ | ||
| 1430 | 1659 | if(isset($option['default'])){ |
| 1431 | 1660 | $options_value=$option['default']; |
| 1432 | 1661 | } |
| 1433 | 1662 | } |
| 1434 | - | |
| 1663 | + | |
| 1435 | 1664 | print '<label for="'.$option['name'].'">'.$option['label'].'</label>'; |
| 1436 | - print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />'; | |
| 1665 | + print '<input class="wpstream-text-input-setting" id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_attr($options_value).'" />'; | |
| 1437 | 1666 | print '<div class="settings_details">'.$option['details'].'</div>'; |
| 1438 | - | |
| 1439 | - } else if($option['type']=='select'){ | |
| 1440 | - | |
| 1667 | + break; | |
| 1668 | + case 'select': | |
| 1441 | 1669 | print '<label for="'.$option['name'].'">'.$option['label'].'</label>'; |
| 1442 | 1670 | print '<select id="'.$option['name'].'" name="'.$option['name'].'" >'; |
| 1443 | 1671 | foreach($option['select_values'] as $key=>$value){ |
| 1444 | 1672 | print '<option value="'.$key.'" '; |
| @@ -1449,38 +1677,359 @@ | ||
| 1449 | 1677 | } |
| 1450 | 1678 | print '</select>'; |
| 1451 | 1679 | print '<input type="hidden" name="'.$option['name'].'_hidden" value="1" >'; |
| 1452 | 1680 | print '<div class="settings_details">'.$option['details'].'</div>'; |
| 1453 | - | |
| 1454 | - } else if($option['type']=='slidertoogle'){ | |
| 1681 | + break; | |
| 1682 | + case 'slidertoogle': | |
| 1455 | 1683 | print '<label for="'.$option['name'].'">'.$option['label'].'</label>'; |
| 1684 | + print '<div style="display: flex; gap: 25px; justify-content: space-between;">'; | |
| 1685 | + print '<div class="settings_details">'.$option['details'].'</div>'; | |
| 1456 | 1686 | print '<label class="wpstream_switch"> |
| 1457 | 1687 | <input type="hidden" class="wpstream_event_option_itemc" value="0" name="'.$option['name'].'" > |
| 1458 | 1688 | <input type="checkbox" class="wpstream_event_option_itemc" value="1" name="'.$option['name'].'" '; |
| 1459 | - | |
| 1460 | - if( intval($options_value) !==0 ){ | |
| 1461 | - print ' checked '; | |
| 1462 | - } | |
| 1463 | - | |
| 1689 | + if( intval($options_value) !==0 ){ | |
| 1690 | + print ' checked '; | |
| 1691 | + } | |
| 1692 | + print '> <span class="wpstream_slider round"></span>'; | |
| 1693 | + print '</label>'; | |
| 1694 | + print '</div>'; | |
| 1695 | + break; | |
| 1696 | + case 'image': | |
| 1697 | + $image_url = $options_value ? esc_url($options_value) : ''; | |
| 1698 | + $has_image = !empty($image_url); | |
| 1464 | 1699 | |
| 1700 | + print '<label for="' . $option['name'] . '">' . $option['label'] . '</label>'; | |
| 1701 | + print '<div class="wpstream-image-upload-wrapper">'; | |
| 1702 | + print '<input type="hidden" id="' . $option['name'] . '" name="' . $option['name'] . '" value="' . $image_url . '" />'; | |
| 1465 | 1703 | |
| 1466 | - print '> <span class="wpstream_slider round"></span>'; | |
| 1467 | - print '</label>'; | |
| 1468 | - print '<div class="settings_details">'.$option['details'].'</div>'; | |
| 1469 | - } | |
| 1704 | + // Preview area | |
| 1705 | + print '<div class="wpstream-image-preview" style="' . (!$has_image ? 'display:none;' : '') . '">'; | |
| 1706 | + print '<img src="' . $image_url . '" alt="Preview" />'; | |
| 1707 | + print '</div>'; | |
| 1708 | + | |
| 1709 | + // Upload/remove buttons | |
| 1710 | + print '<div class="wpstream-image-upload-buttons">'; | |
| 1711 | + print '<button type="button" class="wpstream-upload-image button">' . esc_html__('Upload Image', 'wpstream') . '</button>'; | |
| 1712 | + print '<button type="button" class="wpstream-remove-image button" style="' . (!$has_image ? 'display:none;' : '') . '">' . esc_html__('Remove Image', 'wpstream') . '</button>'; | |
| 1713 | + print '</div>'; | |
| 1714 | + | |
| 1715 | + print '</div>'; | |
| 1716 | + print '<div class="settings_details">' . $option['details'] . '</div>'; | |
| 1717 | + break; | |
| 1718 | + case 'range': | |
| 1719 | + print '<label for="'.$option['name'].'">'.$option['label'].'</label>'; | |
| 1720 | + print '<input class="wpstream-range-input" type="range" id="'.$option['name'].'" name="'.$option['name'].'" min="0" max="100" step="10" value="'.esc_attr($options_value).'" />'; | |
| 1721 | + print '<div class="settings_details">'.$option['details'].'</div>'; | |
| 1722 | + break; | |
| 1723 | + case 'logs_table': | |
| 1724 | + $this->wpstream_support_tab(); | |
| 1725 | + break; | |
| 1726 | + } | |
| 1470 | 1727 | print '</div>'; |
| 1471 | 1728 | } |
| 1729 | + print '</div>'; // options wrapper | |
| 1730 | + if($help_link!==''){ | |
| 1731 | + print '<div class="wpstream_options_help"><a href="'.esc_url($help_link).'" target="_blank" >'.esc_html__('Video Help','wpstream').'</a></div>'; | |
| 1732 | + } | |
| 1472 | 1733 | print '</div>'; |
| 1473 | 1734 | |
| 1474 | 1735 | |
| 1736 | + if ( $active_tab != 'support_tab') { | |
| 1737 | + print '<div class="wpstream-save-settings">'; | |
| 1475 | 1738 | print '<input type="submit" name="submit" class="wpstream_button wpstream_button_action" value="'.__('Save Changes','wpstream').'" />'; |
| 1739 | + print '<div class="spinner"></div>'; | |
| 1740 | + print '</div>'; | |
| 1741 | + } | |
| 1476 | 1742 | |
| 1477 | - print '<input name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> '; | |
| 1743 | + print '<input id="wpstream-settings-nonce" name="wpstream-settings-nonce" type="hidden" value="'.wp_create_nonce('wpstream-settings-nonce').'" /> '; | |
| 1478 | 1744 | print '</form>'; |
| 1479 | 1745 | print '</div>'; |
| 1480 | 1746 | |
| 1481 | 1747 | } |
| 1482 | - | |
| 1748 | + | |
| 1749 | + /** | |
| 1750 | + * Get system information for support tab | |
| 1751 | + * | |
| 1752 | + * @return array System information | |
| 1753 | + */ | |
| 1754 | + private function get_system_info() { | |
| 1755 | + global $wp_version; | |
| 1756 | + | |
| 1757 | + $php_version = phpversion(); | |
| 1758 | + $wp_version_info = $wp_version; | |
| 1759 | + $site_debug_mode = (defined('WP_DEBUG') && WP_DEBUG); | |
| 1760 | + $wp_memory_limit = WP_MEMORY_LIMIT; | |
| 1761 | + | |
| 1762 | + $wpstream_version = WPSTREAM_PLUGIN_VERSION; | |
| 1763 | + $wpstream_plugin_outdated = false; | |
| 1764 | + | |
| 1765 | + // Check if plugin is outdated | |
| 1766 | + $update_plugins = get_site_transient('update_plugins'); | |
| 1767 | + if (isset($update_plugins->response['plugin/wpstream.php'])) { | |
| 1768 | + $wpstream_plugin_outdated = true; | |
| 1769 | + } | |
| 1770 | + | |
| 1771 | + // Check API status | |
| 1772 | + $api_status = false; | |
| 1773 | + if (method_exists($this->main->wpstream_live_connection, 'wpstream_get_token')) { | |
| 1774 | + $token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 1775 | + $api_status = !empty($token); | |
| 1776 | + } | |
| 1777 | + | |
| 1778 | + return array( | |
| 1779 | + 'php_version' => $php_version, | |
| 1780 | + 'wp_version' => $wp_version_info, | |
| 1781 | + 'site_debug_mode' => $site_debug_mode, | |
| 1782 | + 'wp_memory_limit' => $wp_memory_limit, | |
| 1783 | + 'wpstream_version' => $wpstream_version, | |
| 1784 | + 'wpstream_plugin_outdated' => $wpstream_plugin_outdated, | |
| 1785 | + 'api_status' => $api_status | |
| 1786 | + ); | |
| 1787 | + } | |
| 1788 | + | |
| 1789 | + /** | |
| 1790 | + * Render system information HTML | |
| 1791 | + */ | |
| 1792 | + private function render_system_info() { | |
| 1793 | + $system_info = $this->get_system_info(); | |
| 1794 | + ?> | |
| 1795 | + | |
| 1796 | + <div class="wpstream-system-info"> | |
| 1797 | + <h3><?php esc_html_e('System Information', 'wpstream'); ?></h3> | |
| 1798 | + <table class="widefat"> | |
| 1799 | + <tbody> | |
| 1800 | + <tr> | |
| 1801 | + <td><strong><?php esc_html_e('PHP Version', 'wpstream'); ?></strong></td> | |
| 1802 | + <td><?php echo esc_html($system_info['php_version']); ?></td> | |
| 1803 | + <td> | |
| 1804 | + <?php if (version_compare($system_info['php_version'], '7.4', '<')): ?> | |
| 1805 | + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span> | |
| 1806 | + <?php esc_html_e('We recommend PHP 7.4 or higher', 'wpstream'); ?> | |
| 1807 | + <?php else: ?> | |
| 1808 | + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> | |
| 1809 | + <?php endif; ?> | |
| 1810 | + </td> | |
| 1811 | + </tr> | |
| 1812 | + <tr> | |
| 1813 | + <td><strong><?php esc_html_e('WordPress Version', 'wpstream'); ?></strong></td> | |
| 1814 | + <td><?php echo esc_html($system_info['wp_version']); ?></td> | |
| 1815 | + <td> | |
| 1816 | + <?php if (version_compare($system_info['wp_version'], '5.6', '<')): ?> | |
| 1817 | + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span> | |
| 1818 | + <?php esc_html_e('We recommend WordPress 5.6 or higher', 'wpstream'); ?> | |
| 1819 | + <?php else: ?> | |
| 1820 | + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> | |
| 1821 | + <?php endif; ?> | |
| 1822 | + </td> | |
| 1823 | + </tr> | |
| 1824 | + <tr> | |
| 1825 | + <td><strong><?php esc_html_e('WP Debug Mode', 'wpstream'); ?></strong></td> | |
| 1826 | + <td><?php echo $system_info['site_debug_mode'] ? esc_html__('Enabled', 'wpstream') : esc_html__('Disabled', 'wpstream'); ?></td> | |
| 1827 | + <td> | |
| 1828 | + <?php if ($system_info['site_debug_mode']): ?> | |
| 1829 | + <span class="dashicons dashicons-info" style="color: #00a0d2;"></span> | |
| 1830 | + <?php esc_html_e('Debug mode should be disabled on production sites', 'wpstream'); ?> | |
| 1831 | + <?php else: ?> | |
| 1832 | + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> | |
| 1833 | + <?php endif; ?> | |
| 1834 | + </td> | |
| 1835 | + </tr> | |
| 1836 | + <tr> | |
| 1837 | + <td><strong><?php esc_html_e('WP Memory Limit', 'wpstream'); ?></strong></td> | |
| 1838 | + <td><?php echo esc_html($system_info['wp_memory_limit']); ?></td> | |
| 1839 | + <td> | |
| 1840 | + <?php | |
| 1841 | + $memory_limit = wp_convert_hr_to_bytes($system_info['wp_memory_limit']); | |
| 1842 | + if ($memory_limit < 64 * 1024 * 1024): // 64MB | |
| 1843 | + ?> | |
| 1844 | + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span> | |
| 1845 | + <?php esc_html_e('We recommend at least 64MB', 'wpstream'); ?> | |
| 1846 | + <?php else: ?> | |
| 1847 | + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> | |
| 1848 | + <?php endif; ?> | |
| 1849 | + </td> | |
| 1850 | + </tr> | |
| 1851 | + <tr> | |
| 1852 | + <td><strong><?php esc_html_e('WpStream Version', 'wpstream'); ?></strong></td> | |
| 1853 | + <td><?php echo esc_html($system_info['wpstream_version']); ?></td> | |
| 1854 | + <td style="display: flex; align-items: center; gap: 5px;"> | |
| 1855 | + <?php if ($system_info['wpstream_plugin_outdated']): ?> | |
| 1856 | + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span> | |
| 1857 | + <?php esc_html_e('Update available', 'wpstream'); ?> | |
| 1858 | + <div class="update-button-wrapper"> | |
| 1859 | + <button class="wpstream-update-plugin-button button button-primary" data-plugin="wpstream/wpstream.php"> | |
| 1860 | + <?php esc_html_e('Update Now', 'wpstream'); ?> | |
| 1861 | + </button> | |
| 1862 | + </div> | |
| 1863 | + <?php else: ?> | |
| 1864 | + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> | |
| 1865 | + <?php endif; ?> | |
| 1866 | + </td> | |
| 1867 | + </tr> | |
| 1868 | + <tr> | |
| 1869 | + <td><strong><?php esc_html_e('API Connection', 'wpstream'); ?></strong></td> | |
| 1870 | + <td><?php echo $system_info['api_status'] ? esc_html__('Connected', 'wpstream') : esc_html__('Disconnected', 'wpstream'); ?></td> | |
| 1871 | + <td> | |
| 1872 | + <?php if (!$system_info['api_status']): ?> | |
| 1873 | + <span class="dashicons dashicons-warning" style="color: #ffb900;"></span> | |
| 1874 | + <?php esc_html_e('API connection issue', 'wpstream'); ?> | |
| 1875 | + <?php else: ?> | |
| 1876 | + <span class="dashicons dashicons-yes-alt" style="color: #46b450;"></span> | |
| 1877 | + <?php endif; ?> | |
| 1878 | + </td> | |
| 1879 | + </tr> | |
| 1880 | + </tbody> | |
| 1881 | + </table> | |
| 1882 | + </div> | |
| 1883 | + <?php | |
| 1884 | + } | |
| 1885 | + | |
| 1886 | + /** | |
| 1887 | + * Render support tab content | |
| 1888 | + */ | |
| 1889 | + public function wpstream_support_tab() { | |
| 1890 | + ?> | |
| 1891 | + <div class="wrap"> | |
| 1892 | + <div class="wpstream-support-tab-root"> | |
| 1893 | + <?php $this->render_system_info(); ?> | |
| 1894 | + | |
| 1895 | + <div class="wpstream-plugins-table-container"> | |
| 1896 | + <h3><?php esc_html_e('Active Plugins', 'wpstream'); ?></h3> | |
| 1897 | + <table class="widefat wpstream-plugins-table"> | |
| 1898 | + <thead> | |
| 1899 | + <tr> | |
| 1900 | + <th><?php esc_html_e('Plugin', 'wpstream'); ?></th> | |
| 1901 | + <th><?php esc_html_e('Version', 'wpstream'); ?></th> | |
| 1902 | + </tr> | |
| 1903 | + </thead> | |
| 1904 | + <tbody> | |
| 1905 | + <?php | |
| 1906 | + $plugins_data = $this->wpstream_get_plugins_data(); | |
| 1907 | + if (empty($plugins_data)) { | |
| 1908 | + echo '<tr><td colspan="3">' . esc_html__('No WPStream plugins found.', 'wpstream') . '</td></tr>'; | |
| 1909 | + } else { | |
| 1910 | + foreach ($plugins_data as $plugin) { | |
| 1911 | + echo '<tr>'; | |
| 1912 | + echo '<td>' . esc_html($plugin['name']) . '</td>'; | |
| 1913 | + echo '<td>'; | |
| 1914 | + echo esc_html($plugin['version']); | |
| 1915 | + if ( isset($plugin['new_version']) ) { | |
| 1916 | + echo '<div class="wpstream-tooltip-container">'; | |
| 1917 | + echo '<span class="dashicons dashicons-info wpstream-tooltip" title="' . esc_attr($plugin['new_version']) . '">'; | |
| 1918 | + echo '</span>'; | |
| 1919 | + echo '<div class="wpstream-custom-tooltip">' . sprintf( | |
| 1920 | + esc_html__('A new version is available: %s', 'wpstream'), | |
| 1921 | + esc_html($plugin['new_version']) | |
| 1922 | + ) . '</div>'; | |
| 1923 | + echo '</div>'; | |
| 1924 | + } | |
| 1925 | + echo '</td>'; | |
| 1926 | + echo '</tr>'; | |
| 1927 | + } | |
| 1928 | + } | |
| 1929 | + ?> | |
| 1930 | + </tbody> | |
| 1931 | + </table> | |
| 1932 | + </div> | |
| 1933 | + | |
| 1934 | + <div class="wpstream-logs-table-container"> | |
| 1935 | + <h3><?php esc_html_e('Recent Logs', 'wpstream'); ?></h3> | |
| 1936 | + <table class="widefat wpstream-logs-table"> | |
| 1937 | + <thead> | |
| 1938 | + <tr> | |
| 1939 | + <th><?php esc_html_e('Time', 'wpstream'); ?></th> | |
| 1940 | + <th><?php esc_html_e('Type', 'wpstream'); ?></th> | |
| 1941 | + <th><?php esc_html_e('Description', 'wpstream'); ?></th> | |
| 1942 | + </tr> | |
| 1943 | + </thead> | |
| 1944 | + <tbody> | |
| 1945 | + <?php | |
| 1946 | + $logs = get_option('wpstream_logs'); | |
| 1947 | + if ( !is_array($logs) || empty($logs) ) { | |
| 1948 | + echo '<tr><td colspan="3">' . esc_html__('No logs found.', 'wpstream') . '</td></tr>'; | |
| 1949 | + } else { | |
| 1950 | + foreach ($logs as $log) { | |
| 1951 | + echo '<tr>'; | |
| 1952 | + echo '<td>' . esc_html(date('Y-m-d H:i:s', $log['timestamp'] ) ) . '</td>'; | |
| 1953 | + echo '<td>' . esc_html($log['type']) . '</td>'; | |
| 1954 | + echo '<td>' . esc_html($log['description']) . '</td>'; | |
| 1955 | + echo '</tr>'; | |
| 1956 | + } | |
| 1957 | + } | |
| 1958 | + ?> | |
| 1959 | + </tbody> | |
| 1960 | + </table> | |
| 1961 | + </div> | |
| 1962 | + </div> | |
| 1963 | + </div> | |
| 1964 | + <?php | |
| 1965 | + } | |
| 1966 | + | |
| 1967 | + /** | |
| 1968 | + * Get plugins data. | |
| 1969 | + * | |
| 1970 | + * @return array | |
| 1971 | + */ | |
| 1972 | + public function wpstream_get_plugins_data() { | |
| 1973 | + if (!function_exists('get_plugins')) { | |
| 1974 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 1975 | + } | |
| 1976 | + | |
| 1977 | + // Get all installed plugins | |
| 1978 | + $all_plugins = get_plugins(); | |
| 1979 | + $update_data = get_site_transient('update_plugins'); | |
| 1980 | + $all_plugins_info = []; | |
| 1981 | + | |
| 1982 | + // We want to get data only for the WpStream plugins | |
| 1983 | + $wpstream_plugins = array( | |
| 1984 | + 'WpStream' => array( | |
| 1985 | + 'path' => 'wpstream/wpstream.php', | |
| 1986 | + ), | |
| 1987 | + 'WooCommerce' => array( | |
| 1988 | + 'path' => 'woocommerce/woocommerce.php', | |
| 1989 | + ), | |
| 1990 | + 'Meta Box' => array( | |
| 1991 | + 'path' => 'meta-box/meta-box.php', | |
| 1992 | + ), | |
| 1993 | + 'One Click Demo Import' => array( | |
| 1994 | + 'path' => 'one-click-demo-import/one-click-demo-import.php', | |
| 1995 | + ), | |
| 1996 | + 'Better Messages' => array( | |
| 1997 | + 'path' => 'bp-better-messages/bp-better-messages.php', | |
| 1998 | + ), | |
| 1999 | + | |
| 2000 | + ); | |
| 2001 | + | |
| 2002 | + foreach ($all_plugins as $plugin_path => $plugin_data) { | |
| 2003 | + $is_active = is_plugin_active( $plugin_path ); | |
| 2004 | + $has_update = isset( $update_data->response[$plugin_path] ); | |
| 2005 | + | |
| 2006 | + $plugin_info = [ | |
| 2007 | + 'name' => $plugin_data['Name'], | |
| 2008 | + 'version' => $plugin_data['Version'], | |
| 2009 | + 'path' => $plugin_path, | |
| 2010 | + 'active' => $is_active ? 'Yes' : 'No', | |
| 2011 | + 'needs_update' => $has_update ? 'Yes' : 'No' | |
| 2012 | + ]; | |
| 2013 | + | |
| 2014 | + if ($has_update) { | |
| 2015 | + $plugin_info['new_version'] = $update_data->response[$plugin_path]->new_version; | |
| 2016 | + } | |
| 2017 | + | |
| 2018 | + $all_plugins_info[] = $plugin_info; | |
| 2019 | + } | |
| 2020 | + | |
| 2021 | + // Filter out the elements from $all_plugins_info that are not in $wpstream_plugins | |
| 2022 | + foreach ( $all_plugins_info as $key => $plugin_info ) { | |
| 2023 | + // compare $plugin_info['path'] against the path property on each $wpstream_plugins element item | |
| 2024 | + // if the path is not in $wpstream_plugins, unset the element | |
| 2025 | + if ( !in_array( $plugin_info['path'], array_column( $wpstream_plugins, 'path' ) ) ) { | |
| 2026 | + unset( $all_plugins_info[$key] ); | |
| 2027 | + } | |
| 2028 | + } | |
| 2029 | + | |
| 2030 | + return $all_plugins_info; | |
| 2031 | + } | |
| 1483 | 2032 | |
| 1484 | 2033 | |
| 1485 | 2034 | /** |
| 1486 | 2035 | * Set user roles |
| @@ -1487,9 +2036,9 @@ | ||
| 1487 | 2036 | * |
| 1488 | 2037 | * @since 3.0.1 |
| 1489 | 2038 | */ |
| 1490 | 2039 | |
| 1491 | - public function user_streaming_global_channel_options($name,$value,$local_array=''){ | |
| 2040 | + public function user_streaming_global_channel_options( $name, $value, $local_array='', $disabled = false ){ | |
| 1492 | 2041 | |
| 1493 | 2042 | foreach($this->global_event_options as $key=>$option){ |
| 1494 | 2043 | |
| 1495 | 2044 | if( is_array($local_array) && !in_array($key,$local_array)){ |
| @@ -1496,8 +2045,10 @@ | ||
| 1496 | 2045 | print '<div class="wpstream_setting_event_unit_wrapper wpstream-setting-'.esc_attr($key).' ">'; |
| 1497 | 2046 | |
| 1498 | 2047 | print '<label for="'.$option['name'].'">'.$option['name'].'</label>'; |
| 1499 | 2048 | |
| 2049 | + print '<div style="display: flex; gap: 25px; justify-content: space-between;">'; | |
| 2050 | + print '<div class="settings_details">'.$option['details'].'</div>'; | |
| 1500 | 2051 | print ' |
| 1501 | 2052 | <label class="wpstream_switch"> |
| 1502 | 2053 | <input type="checkbox" class="wpstream_event_option_item" data-attr-ajaxname="'.esc_attr($key).'" name="wpstream_event_set_'.esc_attr($key).'" '; |
| 1503 | 2054 | if( isset($value[$key]) ){ |
| @@ -1508,13 +2059,16 @@ | ||
| 1508 | 2059 | if($option['defaults']=='yes') { |
| 1509 | 2060 | print ' checked '; |
| 1510 | 2061 | } |
| 1511 | 2062 | } |
| 2063 | + if ($disabled) { | |
| 2064 | + print ' disabled '; | |
| 2065 | + } | |
| 1512 | 2066 | |
| 1513 | 2067 | |
| 1514 | 2068 | print '> <span class="wpstream_slider round"></span>'; |
| 1515 | 2069 | print '</label>'; |
| 1516 | - print '<div class="settings_details">'.$option['details'].'</div>'; | |
| 2070 | + print '</div>'; | |
| 1517 | 2071 | |
| 1518 | 2072 | |
| 1519 | 2073 | print '</div>'; |
| 1520 | 2074 | } |
| @@ -1566,19 +2120,26 @@ | ||
| 1566 | 2120 | * @since 3.0.1 |
| 1567 | 2121 | */ |
| 1568 | 2122 | public function wpstream_set_wpstream_credentials(){ |
| 1569 | 2123 | |
| 1570 | - if($_SERVER['REQUEST_METHOD'] === 'POST'){ | |
| 2124 | + if($_SERVER['REQUEST_METHOD'] === 'POST'){ | |
| 1571 | 2125 | $allowed_html = array(); |
| 1572 | 2126 | $exclude_array = array(); |
| 1573 | 2127 | $allowed_html = array(); |
| 1574 | 2128 | |
| 1575 | - foreach($_POST as $variable=>$value){ | |
| 2129 | + foreach($_POST as $variable=>$value){ | |
| 1576 | 2130 | if ($variable!='submit'){ |
| 1577 | 2131 | if (!in_array($variable, $exclude_array) ){ |
| 1578 | - update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) ); | |
| 1579 | - } | |
| 1580 | - } | |
| 2132 | + switch ( $variable ) { | |
| 2133 | + case 'api_username': | |
| 2134 | + update_option( sanitize_key('wpstream_api_username'), sanitize_text_field($value) ); | |
| 2135 | + break; | |
| 2136 | + case 'api_password': | |
| 2137 | + update_option( sanitize_key('wpstream_api_password'), $value ); | |
| 2138 | + break; | |
| 2139 | + } | |
| 2140 | + } | |
| 2141 | + } | |
| 1581 | 2142 | } |
| 1582 | 2143 | |
| 1583 | 2144 | |
| 1584 | 2145 | |
| @@ -1610,9 +2171,9 @@ | ||
| 1610 | 2171 | ); |
| 1611 | 2172 | |
| 1612 | 2173 | |
| 1613 | 2174 | $token = $this->main->wpstream_live_connection->wpstream_get_token(); |
| 1614 | - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); | |
| 2175 | + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_set_wpstream_credentials'); | |
| 1615 | 2176 | |
| 1616 | 2177 | $this->main->show_user_data($pack_details); |
| 1617 | 2178 | |
| 1618 | 2179 | print '<form method="post" action="" >'; |
| @@ -1626,9 +2187,12 @@ | ||
| 1626 | 2187 | printf ( __('To connect your plugin, enter your WpStream credentials below or go <a href="%s" target="_blank">here</a> to create an account.','wpstream'),$admin_url_onboard); |
| 1627 | 2188 | echo '</div>'; |
| 1628 | 2189 | |
| 1629 | 2190 | }else if($token==''){ |
| 1630 | - echo '<div class="api_not_conected">'.__(' Incorrect username or password. Please check your credentials or go <a href="https://wpstream.net/my-account/edit-account/" target="_blank">here</a> to reset your password.','wpstream').'</div>'; | |
| 2191 | + $text = get_option('wpstream_curl_failed') === "0" ? | |
| 2192 | + ' Incorrect username or password. Please check your credentials or go <a href="https://wpstream.net/my-account/edit-account/" target="_blank">here</a> to reset your password.' : | |
| 2193 | + 'Not connected to WpStream. Please note the errors above and contact support.'; | |
| 2194 | + echo '<div class="api_not_conected">'.__($text,'wpstream').'</div>'; | |
| 1631 | 2195 | }else if( $this->main->wpstream_live_connection->wpstream_client_check_api_status() ){ |
| 1632 | 2196 | echo '<div class="api_conected">'.__('Connected to WpStream.net!','wpstream').'</div>'; |
| 1633 | 2197 | }else{ |
| 1634 | 2198 | echo '<div class="api_not_conected wpstream_brown">'.__('Failed to connect to WpStream.net. Please address CURL connectivity with your hosting provider.','wpstream').'</div>'; |
| @@ -1682,9 +2246,9 @@ | ||
| 1682 | 2246 | * @since 3.0.1 |
| 1683 | 2247 | */ |
| 1684 | 2248 | |
| 1685 | 2249 | public function wpstream_media_management(){ |
| 1686 | - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); | |
| 2250 | + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_media_management'); | |
| 1687 | 2251 | |
| 1688 | 2252 | $this->main->show_user_data($pack_details); |
| 1689 | 2253 | |
| 1690 | 2254 | |
| @@ -1756,14 +2320,16 @@ | ||
| 1756 | 2320 | */ |
| 1757 | 2321 | public function wpstream_present_media_upload(){ |
| 1758 | 2322 | $to_return=''; |
| 1759 | 2323 | $formInputs=$this->main->wpstream_live_connection->wpstream_get_signed_form_upload_data(); |
| 1760 | - | |
| 1761 | - | |
| 1762 | - | |
| 1763 | 2324 | |
| 1764 | 2325 | if( !$formInputs['success'] ){ |
| 1765 | - $to_return.='<div class="wpstream_upload_alert">'.esc_html__('There isn\'t enough storage space under your account to upload a new item. Please delete some videos or upgrade your subscription.','wpstream').'</div>'; | |
| 2326 | + if ($formInputs['error'] == 'not_connected'){ | |
| 2327 | + $to_return.='<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>'; | |
| 2328 | + } | |
| 2329 | + else { | |
| 2330 | + $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You don\'t have enough cloud storage and data to upload a new item. Please delete some videos or upgrade your plan.','wpstream').'</div>'; | |
| 2331 | + } | |
| 1766 | 2332 | return $to_return; |
| 1767 | 2333 | } |
| 1768 | 2334 | |
| 1769 | 2335 | if($formInputs['success'] ===true){ |
| @@ -1780,18 +2346,19 @@ | ||
| 1780 | 2346 | data-limitConcurrentUploads="1" |
| 1781 | 2347 | class="direct-upload">'; |
| 1782 | 2348 | |
| 1783 | 2349 | $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>'; |
| 1784 | - $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…</span></label>'; | |
| 2350 | + $to_return.='<label for="wpstream_upload"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span id="wpstream_label_action">' . esc_html__('Choose a file…','wpstream') . '</span></label>'; | |
| 1785 | 2351 | |
| 1786 | 2352 | |
| 1787 | 2353 | $to_return.='<div class="wpstream_file_drop_color">'; |
| 1788 | 2354 | $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>'; |
| 1789 | - $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings: | |
| 2355 | + $to_return.='<div class="wpstream_form_ex_details">'.__('The Video File must be encoded with the following settings:<br> | |
| 1790 | 2356 | |
| 1791 | - Container: <strong>MP4</strong>, | |
| 1792 | - Video codec: <strong>H264</strong>, | |
| 1793 | - Audio codec: <strong>AAC</strong>. Media will fail to play if it does not follow the above settings. | |
| 2357 | + Container: <strong>MP4</strong>,<br> | |
| 2358 | + Video codec: <strong>H264</strong>,<br> | |
| 2359 | + Audio codec: <strong>AAC</strong>.<br> | |
| 2360 | + Media will fail to play if it does not follow the above settings. | |
| 1794 | 2361 | You may use a tool like MediaInfo to verify your file. Also you may convert it with specialized software like HandBrake.','wpstream').'<strong> '.esc_html__('Accepted file extensions: .mp4, .mov','wpstream').'</strong></div>'; |
| 1795 | 2362 | if(is_array($formInputs)){ |
| 1796 | 2363 | foreach ($formInputs['ref'] as $name => $value) { |
| 1797 | 2364 | $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">'; |
| @@ -1820,22 +2387,42 @@ | ||
| 1820 | 2387 | */ |
| 1821 | 2388 | public function wpstream_present_file_management(){ |
| 1822 | 2389 | $video_list_raw = $this->main->wpstream_live_connection->wpstream_get_videos_from_api(); |
| 1823 | 2390 | |
| 1824 | - $video_list_raw_array=array(); | |
| 1825 | - if(isset($video_list_raw['items'])){ | |
| 1826 | - $video_list_raw_array=$video_list_raw['items']; | |
| 2391 | + if ( $video_list_raw === false ) { | |
| 2392 | + return '<div class="wpstream_upload_container">'.esc_html__('Not connected. Please connect to WpStream to upload videos.','wpstream').'</div>'; | |
| 1827 | 2393 | } |
| 1828 | - | |
| 1829 | - $keys = array_column($video_list_raw_array, 'time'); | |
| 2394 | + | |
| 2395 | + $video_list_raw_array = []; | |
| 2396 | + if( isset( $video_list_raw['items'] ) ){ | |
| 2397 | + $video_list_raw_array = $video_list_raw['items']; | |
| 2398 | + } | |
| 2399 | + | |
| 2400 | + $keys = array_column( $video_list_raw_array, 'time' ); | |
| 1830 | 2401 | array_multisort($keys, SORT_DESC , $video_list_raw_array); |
| 1831 | 2402 | |
| 1832 | 2403 | $to_return=''; |
| 1833 | - | |
| 1834 | - if(is_array($video_list_raw['items'])){ | |
| 2404 | + | |
| 2405 | + // show pending items | |
| 2406 | + if ( key_exists( 'pending', $video_list_raw ) && is_array( $video_list_raw['pending'] ) ) { | |
| 2407 | + foreach ( $video_list_raw['pending'] as $key => $video ) { | |
| 2408 | + $video_size = intval($video['size']/1048576); | |
| 2409 | + $video_name = esc_html($video['name']); | |
| 2410 | + if($video_name!=''): | |
| 2411 | + $to_return.='<div class="wpstream_video_wrapper">'; | |
| 2412 | + $to_return.='<div class="wpstream_video_title">'; | |
| 2413 | + $to_return.='<div class="wpstream_video_notice"></div></div>'; | |
| 2414 | + $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>'; | |
| 2415 | + $to_return.='<div class="wpstream_video_pending">' . esc_html__( 'The video is still processing', 'wpstream') . '</div>'; | |
| 2416 | + $to_return.='</div>'; | |
| 2417 | + endif; | |
| 2418 | + | |
| 2419 | + } | |
| 2420 | + } | |
| 2421 | + | |
| 2422 | + // show uploaded items | |
| 2423 | + if( is_array($video_list_raw['items'] ) ) { | |
| 1835 | 2424 | foreach ($video_list_raw_array as $key =>$video){ |
| 1836 | - | |
| 1837 | - | |
| 1838 | 2425 | $video_size = intval($video['size']/1048576); |
| 1839 | 2426 | $video_name = esc_html($video['name']); |
| 1840 | 2427 | if($video_name!=''): |
| 1841 | 2428 | $to_return.='<div class="wpstream_video_wrapper">'; |
| @@ -1841,9 +2428,9 @@ | ||
| 1841 | 2428 | $to_return.='<div class="wpstream_video_wrapper">'; |
| 1842 | 2429 | |
| 1843 | 2430 | $to_return.='<div class="wpstream_video_title">'; |
| 1844 | 2431 | $to_return.='<div class="wpstream_video_notice"></div></div>'; |
| 1845 | - $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>'; | |
| 2432 | + $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name:','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video_name.'</span><span class="storage_file_size">'.$video_size.' MB </span></div>'; | |
| 1846 | 2433 | $to_return.=' <div class="wpstream_delete_media" '; |
| 1847 | 2434 | $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video_name.'?\')" data-filename="'.$video_name.'">'.esc_html__('delete file','wpstream').'</div>'; |
| 1848 | 2435 | $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video_name.'">'.esc_html__('download','wpstream').'</div>'; |
| 1849 | 2436 | $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>'; |
| @@ -1853,19 +2440,22 @@ | ||
| 1853 | 2440 | |
| 1854 | 2441 | |
| 1855 | 2442 | |
| 1856 | 2443 | $to_return .='<a class="create_new_free_video" href="'.esc_url($add_free_video_url).'">'.esc_html__('Create new Free-To-View VOD from this recording').'</a>'; |
| 1857 | - $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>'; | |
| 1858 | - | |
| 2444 | + if (class_exists('WooCommerce')) { | |
| 2445 | + $to_return .='<a class="create_new_ppv_video" href="'.esc_url($add_paid_video_url).'">'.esc_html__('Create new Pay-Per-View VOD from this recording').'</a>'; | |
| 2446 | + } | |
| 2447 | + | |
| 1859 | 2448 | $to_return.='</div>'; |
| 1860 | 2449 | endif; |
| 1861 | 2450 | |
| 1862 | 2451 | } |
| 1863 | 2452 | $current_page= get_current_screen(); |
| 1864 | - | |
| 1865 | - | |
| 1866 | - } else { | |
| 1867 | - $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>'; | |
| 2453 | + } | |
| 2454 | + | |
| 2455 | + // no items to show | |
| 2456 | + if ( !is_array( $video_list_raw['items'] ) || ( key_exists( 'pending', $video_list_raw ) && !is_array( $video_list_raw['pending'] ) ) ) { | |
| 2457 | + $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>'; | |
| 1868 | 2458 | } |
| 1869 | 2459 | return $to_return; |
| 1870 | 2460 | } |
| 1871 | 2461 | |
| @@ -1948,10 +2538,36 @@ | ||
| 1948 | 2538 | * save meta options |
| 1949 | 2539 | * |
| 1950 | 2540 | * @since 3.0.1 |
| 1951 | 2541 | */ |
| 1952 | - public function add_wpstream_product_metaboxes() { | |
| 1953 | - add_meta_box( 'add_wpstream_product_metaboxes-sectionid', __( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default'); | |
| 2542 | + public function add_wpstream_product_metaboxes() { | |
| 2543 | + global $post; | |
| 2544 | + $post_id = $post->ID; | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + add_meta_box( 'add_wpstream_product_metaboxes-sectionid', esc_html__( 'Video On Demand Settings', 'wpstream' ),array($this,'display_meta_options'),'wpstream_product_vod' ,'normal','default'); | |
| 2550 | + add_meta_box( 'custom_metabox_video_collection', esc_html__( 'Video Collection', 'wpstream' ), 'wpstream_bundle_custom_metabox_callback', 'wpstream_bundles', 'normal', 'high' ); | |
| 2551 | + add_meta_box( 'woocommerce-product-data', esc_html__( 'Product Data', 'wpstream' ), 'woocommerce_product_data_box', 'product', 'normal', 'default' ); | |
| 2552 | + | |
| 2553 | + if(function_exists('wc_get_product')): | |
| 2554 | + $product = wc_get_product( $post_id ); | |
| 2555 | + if ( $product ) { | |
| 2556 | + | |
| 2557 | + if ( $product->get_type() === 'wpstream_bundle' ) { | |
| 2558 | + add_meta_box( | |
| 2559 | + 'wpstream_woo_custom_metabox', | |
| 2560 | + esc_html__( 'Video Collection Options', 'wpstream' ), | |
| 2561 | + 'wpstream_bundle_custom_metabox_callback', | |
| 2562 | + 'product', | |
| 2563 | + 'normal', | |
| 2564 | + 'default' | |
| 2565 | + ); | |
| 2566 | + } | |
| 2567 | + } | |
| 2568 | + endif; | |
| 2569 | + | |
| 1954 | 2570 | } |
| 1955 | 2571 | |
| 1956 | 2572 | |
| 1957 | 2573 | /** |
| @@ -1965,10 +2581,12 @@ | ||
| 1965 | 2581 | global $post; |
| 1966 | 2582 | if(isset($post->ID)){ |
| 1967 | 2583 | if ( $post->post_type !== 'product' ) return; |
| 1968 | 2584 | $term_list = wp_get_post_terms($post->ID, 'product_type'); |
| 1969 | - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){ | |
| 1970 | - update_post_meta( $post->ID, '_virtual', 'yes' ); | |
| 2585 | + if( $term_list[0]->name=='video_on_demand' || | |
| 2586 | + $term_list[0]->name=='live_stream' || | |
| 2587 | + $term_list[0]->name=='wpstream_bundle'){ | |
| 2588 | + update_post_meta( $post->ID, '_virtual', 'yes' ); | |
| 1971 | 2589 | } |
| 1972 | 2590 | } |
| 1973 | 2591 | } |
| 1974 | 2592 | |
| @@ -2075,11 +2693,26 @@ | ||
| 2075 | 2693 | $types[ 'video_on_demand' ] = __( 'Video On Demand','wpestream' ); |
| 2076 | 2694 | |
| 2077 | 2695 | return $types; |
| 2078 | 2696 | } |
| 2079 | - | |
| 2080 | - | |
| 2081 | - | |
| 2697 | + | |
| 2698 | + public function wpstream_add_products_class( $classname, $product_type ) { | |
| 2699 | + if ( 'live_stream' === $product_type ) { | |
| 2700 | + $classname = 'WC_Product_Live_Stream'; | |
| 2701 | + } | |
| 2702 | + if ( 'video_on_demand' === $product_type ) { | |
| 2703 | + $classname = 'WC_Product_Video_On_Demand'; | |
| 2704 | + } | |
| 2705 | + return $classname; | |
| 2706 | + } | |
| 2707 | + | |
| 2708 | + public function wpstream_add_custom_wc_products() { | |
| 2709 | + if( class_exists( 'WooCommerce' ) ){ | |
| 2710 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_live_stream.php'; | |
| 2711 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wc_product_video_on_demand.php'; | |
| 2712 | + } | |
| 2713 | + } | |
| 2714 | + | |
| 2082 | 2715 | /** |
| 2083 | 2716 | * Js action to do when user pick live stream or video on demand |
| 2084 | 2717 | * |
| 2085 | 2718 | * @since 3.0.1 |
| @@ -2094,10 +2727,14 @@ | ||
| 2094 | 2727 | <script type='text/javascript'> |
| 2095 | 2728 | jQuery( document ).ready( function() { |
| 2096 | 2729 | jQuery('.options_group.pricing' ).addClass ( 'show_if_live_stream' ).show(); |
| 2097 | 2730 | jQuery('.options_group.pricing' ).addClass ( 'show_if_video_on_demand' ).show(); |
| 2731 | + jQuery('.options_group.pricing' ).addClass ( 'show_if_wpstream_bundle' ).show(); | |
| 2732 | + | |
| 2098 | 2733 | jQuery('._sold_individually_field').parent().addClass('show_if_live_stream').show(); |
| 2099 | 2734 | jQuery('._sold_individually_field').parent().addClass('show_if_video_on_demand').show(); |
| 2735 | + jQuery('._sold_individually_field').parent().addClass('show_if_wpstream_bundle').show(); | |
| 2736 | + | |
| 2100 | 2737 | jQuery('._sold_individually_field').show(); |
| 2101 | 2738 | |
| 2102 | 2739 | var selected = jQuery('#product-type').val(); |
| 2103 | 2740 | }); |
| @@ -2113,13 +2750,12 @@ | ||
| 2113 | 2750 | * @since 3.0.1 |
| 2114 | 2751 | */ |
| 2115 | 2752 | |
| 2116 | 2753 | public function wpstream_hide_attributes_data_panel( $tabs) { |
| 2117 | - | |
| 2118 | - $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand'; | |
| 2119 | - $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand'; | |
| 2120 | - // $tabs['general']['class'][] = 'show_if_live_stream show_if_video_on_demand'; | |
| 2121 | - | |
| 2754 | + | |
| 2755 | + $tabs['shipping']['class'][] = 'hide_if_live_stream hide_if_video_on_demand hide_if_wpstream_bundle'; | |
| 2756 | + $tabs['inventory']['class'][] = 'show_if_live_stream show_if_video_on_demand show_if_wpstream_bundle'; | |
| 2757 | + | |
| 2122 | 2758 | return $tabs; |
| 2123 | 2759 | } |
| 2124 | 2760 | |
| 2125 | 2761 | |
| @@ -2138,9 +2774,9 @@ | ||
| 2138 | 2774 | |
| 2139 | 2775 | $subscription_model = intval( get_option('wpstream_global_sub','')) ; |
| 2140 | 2776 | |
| 2141 | 2777 | if($subscription_model==1){ // if we have Neflix mode |
| 2142 | - if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' ){ | |
| 2778 | + if( $term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='wpstream_bundle' ){ | |
| 2143 | 2779 | return false; |
| 2144 | 2780 | } |
| 2145 | 2781 | } |
| 2146 | 2782 | |
| @@ -2158,8 +2794,9 @@ | ||
| 2158 | 2794 | * @since 3.0.1 |
| 2159 | 2795 | */ |
| 2160 | 2796 | |
| 2161 | 2797 | public function wpstream_add_custom_general_fields() { |
| 2798 | + | |
| 2162 | 2799 | |
| 2163 | 2800 | global $woocommerce, $post; |
| 2164 | 2801 | if(function_exists('wcs_user_has_subscription')){ |
| 2165 | 2802 | echo '<div class="options_group show_if_subscription">'; |
| @@ -2174,8 +2811,10 @@ | ||
| 2174 | 2811 | } |
| 2175 | 2812 | |
| 2176 | 2813 | echo '<div class="options_group show_if_live_stream" style="border:none;"></div>'; |
| 2177 | 2814 | echo '<div class="options_group show_if_video_on_demand">'; |
| 2815 | + | |
| 2816 | + | |
| 2178 | 2817 | $selected=''; |
| 2179 | 2818 | if( isset( $_GET['new_video_name']) && $_GET['new_video_name']!='' ){ |
| 2180 | 2819 | $selected=esc_html($_GET['new_video_name']); |
| 2181 | 2820 | } |
| @@ -2181,18 +2820,21 @@ | ||
| 2181 | 2820 | } |
| 2182 | 2821 | if($selected==''){ |
| 2183 | 2822 | $selected= get_post_meta($post->ID,'_movie_url',true); |
| 2184 | 2823 | } |
| 2185 | - | |
| 2186 | - woocommerce_wp_select( | |
| 2187 | - array( | |
| 2188 | - 'id' => '_movie_url', | |
| 2189 | - 'label' => __( 'Choose video', 'woocommerce' ), | |
| 2190 | - 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(), | |
| 2191 | - 'selected'=> true, | |
| 2192 | - 'value' => $selected | |
| 2193 | - ) | |
| 2194 | - ); | |
| 2824 | + if( !current_user_can('administrator') ){ | |
| 2825 | + print '<div style="margin:10px;">'.esc_html('You need to be an administrator in order to assign videos','wpstream').'</div>'; | |
| 2826 | + }else{ | |
| 2827 | + woocommerce_wp_select( | |
| 2828 | + array( | |
| 2829 | + 'id' => '_movie_url', | |
| 2830 | + 'label' => __( 'Choose video', 'woocommerce' ), | |
| 2831 | + 'options' => $this->main->wpstream_live_connection->wpstream_get_videos(), | |
| 2832 | + 'selected'=> true, | |
| 2833 | + 'value' => $selected | |
| 2834 | + ) | |
| 2835 | + ); | |
| 2836 | + } | |
| 2195 | 2837 | |
| 2196 | 2838 | |
| 2197 | 2839 | |
| 2198 | 2840 | echo '</div>'; |
| @@ -2394,9 +3036,16 @@ | ||
| 2394 | 3036 | public function wpstream_startstreaming_sidebar_meta() { |
| 2395 | 3037 | global $post; |
| 2396 | 3038 | $term_list = wp_get_post_terms($post->ID, 'product_type'); |
| 2397 | 3039 | |
| 2398 | - add_meta_box('wpstream-sidebar-meta', esc_html__('Live Streaming', 'wpstream'), array($this,'wpstream_start_stream_meta'), 'wpstream_product', 'side', 'high'); | |
| 3040 | + add_meta_box( | |
| 3041 | + 'wpstream-sidebar-meta', | |
| 3042 | + esc_html__('Live Streaming', 'wpstream'), | |
| 3043 | + array($this,'wpstream_start_stream_meta'), | |
| 3044 | + 'wpstream_product', | |
| 3045 | + 'side', | |
| 3046 | + 'high' | |
| 3047 | + ); | |
| 2399 | 3048 | |
| 2400 | 3049 | $is_subscription_live_event = esc_html(get_post_meta($post->ID,'_subscript_live_event',true)); |
| 2401 | 3050 | if(!is_wp_error( $term_list )){ |
| 2402 | 3051 | if( isset($term_list[0]->name) ){ |
| @@ -2423,11 +3072,17 @@ | ||
| 2423 | 3072 | $local_event_options = get_post_meta ($post->ID,'local_event_options',''); |
| 2424 | 3073 | |
| 2425 | 3074 | |
| 2426 | 3075 | |
| 2427 | - if( get_post_status($post->ID)!='auto-draft' ){ | |
| 3076 | + if( get_post_status( $post->ID ) === 'publish' ) { | |
| 2428 | 3077 | $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" ); |
| 2429 | 3078 | print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">'; |
| 3079 | + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_start_stream_meta'); | |
| 3080 | + if( isset($pack_details['available_data_mb'])){ | |
| 3081 | + if ($pack_details['available_data_mb'] <= 0){ | |
| 3082 | + print '<input type="hidden" id="wpstream_basic_streaming" value="true">'; | |
| 3083 | + } | |
| 3084 | + } | |
| 2430 | 3085 | |
| 2431 | 3086 | $this->wpstream_live_stream_unit($post->ID); |
| 2432 | 3087 | print '<div class="wpstream_modal_background"></div>'; |
| 2433 | 3088 | print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div> |
| @@ -2432,9 +3087,9 @@ | ||
| 2432 | 3087 | print '<div class="wpstream_modal_background"></div>'; |
| 2433 | 3088 | print '<div class="wpstream_error_modal_notification"><div class="wpstream_error_content">er1</div> |
| 2434 | 3089 | <div class="wpstream_error_ok wpstream_button" type="button">'.esc_html__('Close','wpstream').'</div> |
| 2435 | 3090 | </div>'; |
| 2436 | - }else{ | |
| 3091 | + } else { | |
| 2437 | 3092 | esc_html_e('To Go Live, please publish your channel first !','wpstream'); |
| 2438 | 3093 | } |
| 2439 | 3094 | } |
| 2440 | 3095 | |
| @@ -2496,9 +3151,9 @@ | ||
| 2496 | 3151 | * |
| 2497 | 3152 | */ |
| 2498 | 3153 | |
| 2499 | 3154 | public function wpstream_pre_onboard_display(){ |
| 2500 | - $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); | |
| 3155 | + $pack_details = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_pre_onboard_display'); | |
| 2501 | 3156 | |
| 2502 | 3157 | $this->main->show_user_data($pack_details); |
| 2503 | 3158 | |
| 2504 | 3159 | |
| @@ -2599,9 +3254,9 @@ | ||
| 2599 | 3254 | </div> |
| 2600 | 3255 | |
| 2601 | 3256 | |
| 2602 | 3257 | <div class="wpstream_check_account_status"> |
| 2603 | - Checking if you are already logged..... | |
| 3258 | + <?php esc_html_e( 'Checking if you are already logged.....', 'wpstream' ); ?> | |
| 2604 | 3259 | </div> |
| 2605 | 3260 | |
| 2606 | 3261 | <div class="wpstream_onboarding_notification"></div> |
| 2607 | 3262 | |
| @@ -2647,9 +3302,9 @@ | ||
| 2647 | 3302 | |
| 2648 | 3303 | if( isset($_GET['page']) && $_GET['page']==='wpstream_onboard') { |
| 2649 | 3304 | $url = 'user/getcapthca'; |
| 2650 | 3305 | $curl_post_fields = array(); |
| 2651 | - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields); | |
| 3306 | + $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true); | |
| 2652 | 3307 | $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY); |
| 2653 | 3308 | |
| 2654 | 3309 | } |
| 2655 | 3310 | |
| @@ -2684,10 +3339,10 @@ | ||
| 2684 | 3339 | |
| 2685 | 3340 | <div id="wpstream_on_board" class="wpstream_action_next_step" data-nextthing="wpstream_step_2" style="display:none;" >Move to step 2</div> |
| 2686 | 3341 | </div> |
| 2687 | 3342 | <?php |
| 2688 | - | |
| 2689 | - if(trim($token)!==''){ | |
| 3343 | + | |
| 3344 | + if( !is_null( $token ) && trim( $token ) !== '' ) { | |
| 2690 | 3345 | print '<div id="wpstream_have_token"></div>'; |
| 2691 | 3346 | } |
| 2692 | 3347 | } |
| 2693 | 3348 | |
| @@ -2751,9 +3406,9 @@ | ||
| 2751 | 3406 | |
| 2752 | 3407 | <div class="wpstream_step_wrapper wpstream_step_3 wpstream_onboarding_live" id="wpstream_step_3"> |
| 2753 | 3408 | <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream'); ?></h1> |
| 2754 | 3409 | |
| 2755 | - <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3a"><?php esc_html_e('No - Free-To-View (FTV)','wpstream');?></div> | |
| 3410 | + <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_3a" data-nextthing="wpstream_step_3a"><?php esc_html_e('No - Free-To-View (FTV)','wpstream');?></div> | |
| 2756 | 3411 | <div class="wpstram_or">or</div> |
| 2757 | 3412 | <div class="wpstream_accordion_header wpstream_action_next_step" data-nextthing="wpstream_step_3b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream');?></div> |
| 2758 | 3413 | |
| 2759 | 3414 | <div class="wpstream_initial_onboarding_controls_wrapper"> |
| @@ -2805,9 +3460,9 @@ | ||
| 2805 | 3460 | |
| 2806 | 3461 | public function wpstream_onboarding_step_3_B_live_streaming_pay_per_view(){ |
| 2807 | 3462 | ?> |
| 2808 | 3463 | |
| 2809 | - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_3b"> | |
| 3464 | + <div class="wpstream_step_wrapper wpstream_step_3b wpstream_onboarding_live" id="wpstream_step_3b"> | |
| 2810 | 3465 | <h1><?php esc_html_e('Make your live stream Pay Per View','wpstream');?></h1> |
| 2811 | 3466 | <?php |
| 2812 | 3467 | if ( class_exists( 'WooCommerce' ) ) { |
| 2813 | 3468 | ?> |
| @@ -2865,13 +3520,12 @@ | ||
| 2865 | 3520 | ?> |
| 2866 | 3521 | <div class="wpstream_step_wrapper wpstream_step_4 wpstream_onboarding_vod" id="wpstream_step_4"> |
| 2867 | 3522 | <h1><?php esc_html_e('Do you want to charge a fee for watching?','wpstream');?></h1> |
| 2868 | 3523 | |
| 2869 | - <div class="wpstream_accordion_header wpstream_action_next_step" data-control="wpstream_onboard_vod_free" data-nextthing="wpstream_step_4a" ><?php esc_html_e('No - Free-To-View (FTV)','wpstream'); ?></div> | |
| 3524 | + <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_4a" data-control="wpstream_onboard_vod_free" data-nextthing="wpstream_step_4a" ><?php esc_html_e('No - Free-To-View (FTV)','wpstream'); ?></div> | |
| 2870 | 3525 | <div class="wpstram_or">or</div> |
| 2871 | - <div class="wpstream_accordion_header wpstream_action_next_step" data-control="wpstream_onboard_vod_ppv" data-nextthing="wpstream_step_4b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream'); ?></div> | |
| 2872 | - | |
| 2873 | - | |
| 3526 | + <input type="hidden" id="wpstream_onboarding_video_list_nonce" value="<?php echo wp_create_nonce( "wpstream_onboarding_video_list_nonce" ); ?>"> | |
| 3527 | + <div class="wpstream_accordion_header wpstream_action_next_step wpstream_step_4b" data-control="wpstream_onboard_vod_ppv" data-nextthing="wpstream_step_4b" ><?php esc_html_e('Yes - Pay-Per-View (PPV)','wpstream'); ?></div> | |
| 2874 | 3528 | <div class="wpstream_initial_onboarding_controls_wrapper"> |
| 2875 | 3529 | <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_2"><?php esc_html_e('Prev','wpstream');?></span> |
| 2876 | 3530 | </div> |
| 2877 | 3531 | |
| @@ -2890,39 +3544,24 @@ | ||
| 2890 | 3544 | $current_screen=get_current_screen(); |
| 2891 | 3545 | if($current_screen->base !=='wpstream_page_wpstream_onboard'){ |
| 2892 | 3546 | return; |
| 2893 | 3547 | } |
| 3548 | + ?> | |
| 2894 | 3549 | |
| 2895 | - $token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 2896 | - $video_list = array(); | |
| 2897 | - if($token!=''){ | |
| 2898 | - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos(); | |
| 2899 | - } | |
| 2900 | - | |
| 2901 | - ?> | |
| 2902 | - | |
| 2903 | - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4a"> | |
| 3550 | + <div class="wpstream_step_wrapper wpstream_step_4a wpstream_onboarding_live" id="wpstream_step_4a"> | |
| 2904 | 3551 | <h1><?php esc_html_e('Let’s create your first Free-To-View VOD','wpstream');?></h1> |
| 2905 | - | |
| 2906 | - | |
| 2907 | - | |
| 2908 | - <?php | |
| 2909 | - if( count($video_list) !== 0 ) { | |
| 2910 | - ?> | |
| 2911 | - <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div> | |
| 2912 | - <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container"> | |
| 3552 | + <div id="wpstream_onboard_vod_free_notice" class="wpstream_onboarding_notification"></div> | |
| 3553 | + <div id="wpstream_onboard_vod_free" class="wpstream_accordion_container"> | |
| 3554 | + <div class="spinner"></div> | |
| 3555 | + <div class="wpstream-step-container" style="display: none"> | |
| 2913 | 3556 | <label><?php esc_html_e('Name your FTV Video-On-Demand','wpstream')?></label> |
| 2914 | 3557 | <input type="text" name="channel_name" class="wpstream_onboarding_vod_name" id="wpstream_onboarding_vod_name" value="<?php esc_html_e('My First FTV VOD','wpstream');?>" > |
| 2915 | - <?php $this->wpstream_show_vod_dropdown_onboarding($video_list); ?> | |
| 2916 | - <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_free_action" id="wpstream_onboard_vod_free_action" value="<?php esc_html_e('Create FTV VOD','wpstream');?>" /> | |
| 3558 | + <div id="wpstream_free_vod_dropdown_videos_list"></div> | |
| 3559 | + <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_free_action" id="wpstream_onboard_vod_free_action" value="Create FTV VOD"> | |
| 2917 | 3560 | </div> |
| 3561 | + </div> | |
| 3562 | + <?php $this->wpstream_obboarding_file_warning(); ?> | |
| 2918 | 3563 | |
| 2919 | - <?php }else{ | |
| 2920 | - $this->wpstream_obboarding_file_warning(); | |
| 2921 | - } ?> | |
| 2922 | - | |
| 2923 | - | |
| 2924 | - | |
| 2925 | 3564 | <div class="wpstream_initial_onboarding_controls_wrapper"> |
| 2926 | 3565 | <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span> |
| 2927 | 3566 | </div> |
| 2928 | 3567 | |
| @@ -2936,34 +3575,10 @@ | ||
| 2936 | 3575 | * |
| 2937 | 3576 | * |
| 2938 | 3577 | * |
| 2939 | 3578 | */ |
| 2940 | - | |
| 2941 | - public function wpstream_show_vod_dropdown_onboarding($video_list,$appendix=''){ | |
| 2942 | - | |
| 2943 | - print '<label>'.esc_html__('Choose Recording','wpstream').'</label> | |
| 2944 | - <select name="wpstream_free_vod_file_name" id="wpstream_free_vod_file_name'.$appendix.'"> | |
| 2945 | - <option value="">'.esc_html__('Please select a recording from the list','wpstream').'</option>'; | |
| 2946 | - | |
| 2947 | - if(is_array($video_list)){ | |
| 2948 | - foreach ($video_list as $key=>$value){ | |
| 2949 | - print '<option value="'.$key.'"'; | |
| 2950 | - print '>'.$value.'</option>'; | |
| 2951 | - } | |
| 2952 | - } | |
| 2953 | - print'</select>'; | |
| 2954 | - | |
| 2955 | - } | |
| 2956 | - | |
| 2957 | - | |
| 2958 | - | |
| 2959 | - /* | |
| 2960 | - * | |
| 2961 | - * | |
| 2962 | - * | |
| 2963 | - */ | |
| 2964 | 3579 | public function wpstream_obboarding_file_warning(){ |
| 2965 | - print '<div class="wpstream_warning_onboarding"> | |
| 3580 | + print '<div class="wpstream_warning_onboarding" style="display: none"> | |
| 2966 | 3581 | '.esc_html__('A recording is needed to create a VOD from. There are no recordings under your account. You can create new recordings by recording a live channel or uploading video files directly.','wpstream').' |
| 2967 | 3582 | </br> |
| 2968 | 3583 | <div class="wpstream_upload_video">'.esc_html__('Upload Video','wpstream').'</div> |
| 2969 | 3584 | |
| @@ -2970,11 +3585,8 @@ | ||
| 2970 | 3585 | <div class="wpstream_onboarding_tryagain">'.esc_html__('Try Again','wpstream').'</div> |
| 2971 | 3586 | </div>'; |
| 2972 | 3587 | } |
| 2973 | 3588 | |
| 2974 | - | |
| 2975 | - | |
| 2976 | - | |
| 2977 | 3589 | /* |
| 2978 | 3590 | * |
| 2979 | 3591 | * |
| 2980 | 3592 | * |
| @@ -2984,53 +3596,35 @@ | ||
| 2984 | 3596 | |
| 2985 | 3597 | if($current_screen->base !=='wpstream_page_wpstream_onboard'){ |
| 2986 | 3598 | return; |
| 2987 | 3599 | } |
| 2988 | - | |
| 2989 | - $token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 2990 | - $video_list = array(); | |
| 2991 | - if($token!=''){ | |
| 2992 | - $video_list = $this->main->wpstream_live_connection->wpstream_get_videos(); | |
| 2993 | - } | |
| 2994 | 3600 | ?> |
| 2995 | - | |
| 2996 | - <div class="wpstream_step_wrapper wpstream_step_3a wpstream_onboarding_live" id="wpstream_step_4b"> | |
| 3601 | + | |
| 3602 | + <div class="wpstream_step_wrapper wpstream_step_4b wpstream_onboarding_live" id="wpstream_step_4b"> | |
| 2997 | 3603 | <h1><?php esc_html_e('Let\'s create your first Pay-Per-View VOD','wpstream');?></h1> |
| 2998 | 3604 | |
| 2999 | 3605 | <div id="wpstream_onboard_vod_ppv_notice" class="wpstream_onboarding_notification"></div> |
| 3000 | - <?php | |
| 3001 | - if( count($video_list) !== 0 ) { | |
| 3002 | - if ( class_exists( 'WooCommerce' ) ) { | |
| 3003 | - ?> | |
| 3004 | - <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container"> | |
| 3005 | - <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label> | |
| 3006 | - <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');?>"> | |
| 3007 | - | |
| 3008 | - <?php $this->wpstream_show_vod_dropdown_onboarding($video_list,'_for_ppv'); ?> | |
| 3009 | - | |
| 3010 | - <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label> | |
| 3011 | - <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10"> | |
| 3012 | - <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');?>" /> | |
| 3013 | - | |
| 3014 | - </div> | |
| 3015 | - <?php }else{ | |
| 3016 | - $this->wpstream_onboarding_woo_warning(); | |
| 3017 | - } | |
| 3018 | - | |
| 3019 | - | |
| 3020 | - }else{ | |
| 3021 | - $this->wpstream_obboarding_file_warning(); | |
| 3022 | - } | |
| 3023 | - ?> | |
| 3024 | - | |
| 3025 | - | |
| 3606 | + <?php | |
| 3607 | + if ( class_exists( 'WooCommerce' ) ) { ?> | |
| 3608 | + <div id="wpstream_onboard_vod_ppv" class="wpstream_accordion_container"> | |
| 3609 | + <div class="spinner"></div> | |
| 3610 | + <div class="wpstream-step-container" style="display: none"> | |
| 3611 | + <label><?php esc_html_e('Name your PPV Video-On-Demand','wpstream'); ?></label> | |
| 3612 | + <input type="text" name="channel_name" class="wpstream_onboarding_ppv_vod_name" id="wpstream_onboarding_ppv_vod_name" value="<?php esc_html_e('My First PPV VOD','wpstream');?>"> | |
| 3613 | + <div id="wpstream_ppv_vod_dropdown_videos_list"></div> | |
| 3614 | + <label><?php esc_html_e('Pay-Per-View Price','wpstream');?></label> | |
| 3615 | + <input type="text" name="channel_name" class="wpstream_onboarding_vod_price" id="wpstream_onboarding_vod_price" value="10"> | |
| 3616 | + <input type="submit" name="submit" class="wpstream_button wpstream_button_action wpstream_onboard_vod_ppv_action" id="wpstream_onboard_vod_ppv_action" value="<?php esc_html_e('Create PPV VOD','wpstream');?>" /> | |
| 3617 | + </div> | |
| 3618 | + </div> | |
| 3619 | + <?php $this->wpstream_obboarding_file_warning(); ?> | |
| 3620 | + <?php } else { | |
| 3621 | + $this->wpstream_onboarding_woo_warning(); | |
| 3622 | + } ?> | |
| 3026 | 3623 | <div class="wpstream_initial_onboarding_controls_wrapper"> |
| 3027 | 3624 | <span class="wpstream_onboard_initial_bubble_prev" data-step="wpstream_step_4"><?php esc_html_e('Prev','wpstream');?></span> |
| 3028 | 3625 | </div> |
| 3029 | - | |
| 3030 | 3626 | </div> |
| 3031 | - | |
| 3032 | - | |
| 3033 | 3627 | <?php |
| 3034 | 3628 | } |
| 3035 | 3629 | |
| 3036 | 3630 | |
| @@ -3063,9 +3657,8 @@ | ||
| 3063 | 3657 | * |
| 3064 | 3658 | */ |
| 3065 | 3659 | public function onboarding_wizard_footer() { |
| 3066 | 3660 | ?> |
| 3067 | - <div class="wpstream_modal_back"></div> | |
| 3068 | 3661 | </div> |
| 3069 | 3662 | <div class="wpstream_modal_background_onboard"></div> |
| 3070 | 3663 | <?php |
| 3071 | 3664 | } |
| @@ -3092,14 +3685,20 @@ | ||
| 3092 | 3685 | 'post_status' => 'publish', |
| 3093 | 3686 | 'post_type' => 'product', |
| 3094 | 3687 | 'post_author' => $current_user->ID |
| 3095 | 3688 | ); |
| 3096 | - | |
| 3689 | + | |
| 3097 | 3690 | // Insert the post into the database |
| 3098 | 3691 | $post_id = wp_insert_post( $my_post ); |
| 3099 | 3692 | |
| 3100 | 3693 | if(is_wp_error($post_id)){ |
| 3101 | - echo json_encode( array('succes'=>false) ); | |
| 3694 | + $logger = new WPStream_Logger(); | |
| 3695 | + $log_entry = new WpStream_Log_Entry([ | |
| 3696 | + 'type' => 'error', | |
| 3697 | + 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(), | |
| 3698 | + ]); | |
| 3699 | + $logger->add( $log_entry ); | |
| 3700 | + echo json_encode( array('succes'=>false) ); | |
| 3102 | 3701 | }else{ |
| 3103 | 3702 | |
| 3104 | 3703 | $product = wc_get_product($post_id); |
| 3105 | 3704 | $price = wc_format_decimal($channel_price); |
| @@ -3153,36 +3752,36 @@ | ||
| 3153 | 3752 | |
| 3154 | 3753 | // Insert the post into the database |
| 3155 | 3754 | $post_id = wp_insert_post( $my_post ); |
| 3156 | 3755 | |
| 3157 | - if(is_wp_error($post_id)){ | |
| 3158 | - echo json_encode( array('succes'=>false) ); | |
| 3159 | - }else{ | |
| 3756 | + if( is_wp_error( $post_id ) ) { | |
| 3757 | + $logger = new WPStream_Logger(); | |
| 3758 | + $log_entry = new WpStream_Log_Entry([ | |
| 3759 | + 'type' => 'error', | |
| 3760 | + 'description' => 'Couldn\'t create channel during onboarding because of error: ' . $post_id->get_error_message(), | |
| 3761 | + ]); | |
| 3762 | + $logger->add( $log_entry ); | |
| 3763 | + echo json_encode( array('succes'=>false) ); | |
| 3764 | + } else { | |
| 3160 | 3765 | $permalink = get_edit_post_link($post_id); |
| 3161 | 3766 | |
| 3162 | 3767 | $permalink= add_query_arg( 'onboard', 'yes', $permalink ); |
| 3163 | 3768 | $permalink= add_query_arg( 'branch', '1', $permalink ); |
| 3164 | - | |
| 3165 | - | |
| 3769 | + | |
| 3166 | 3770 | echo json_encode( array( |
| 3167 | - 'success'=> true, | |
| 3168 | - 'link' => ($permalink) | |
| 3771 | + 'success'=> true, | |
| 3772 | + 'link' => ($permalink) | |
| 3169 | 3773 | )); |
| 3170 | 3774 | } |
| 3171 | - | |
| 3172 | 3775 | } |
| 3173 | 3776 | die(); |
| 3174 | 3777 | } |
| 3175 | 3778 | |
| 3176 | - | |
| 3177 | - | |
| 3178 | 3779 | /* |
| 3179 | 3780 | * |
| 3180 | 3781 | * On Boarding create free vod |
| 3181 | 3782 | * |
| 3182 | 3783 | */ |
| 3183 | - | |
| 3184 | - | |
| 3185 | 3784 | public function wpstream_on_board_create_free_vod(){ |
| 3186 | 3785 | $current_user = wp_get_current_user(); |
| 3187 | 3786 | check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); |
| 3188 | 3787 | if(current_user_can('administrator')){ |
| @@ -3194,14 +3793,20 @@ | ||
| 3194 | 3793 | 'post_status' => 'publish', |
| 3195 | 3794 | 'post_type' => 'wpstream_product_vod', |
| 3196 | 3795 | 'post_author' => $current_user->ID |
| 3197 | 3796 | ); |
| 3198 | - | |
| 3199 | - // Insert the post into the database | |
| 3797 | + | |
| 3798 | + // Insert the post into the database | |
| 3200 | 3799 | $post_id = wp_insert_post( $my_post ); |
| 3201 | 3800 | |
| 3202 | 3801 | if(is_wp_error($post_id)){ |
| 3203 | - echo json_encode( array('succes'=>false) ); | |
| 3802 | + $logger = new WPStream_Logger(); | |
| 3803 | + $log_entry = new WpStream_Log_Entry([ | |
| 3804 | + 'type' => 'error', | |
| 3805 | + 'description' => 'Couldn\'t create free VOD during onboarding because of error: ' . $post_id->get_error_message(), | |
| 3806 | + ]); | |
| 3807 | + $logger->add( $log_entry ); | |
| 3808 | + echo json_encode( array('succes'=>false) ); | |
| 3204 | 3809 | }else{ |
| 3205 | 3810 | update_post_meta($post_id, 'wpstream_product_type', 2); |
| 3206 | 3811 | update_post_meta($post_id, 'wpstream_free_video', $file_name); |
| 3207 | 3812 | |
| @@ -3245,15 +3850,21 @@ | ||
| 3245 | 3850 | 'post_status' => 'publish', |
| 3246 | 3851 | 'post_type' => 'product', |
| 3247 | 3852 | 'post_author' => $current_user->ID |
| 3248 | 3853 | ); |
| 3249 | - | |
| 3854 | + | |
| 3250 | 3855 | // Insert the post into the database |
| 3251 | 3856 | $post_id = wp_insert_post( $my_post ); |
| 3252 | 3857 | |
| 3253 | - if(is_wp_error($post_id)){ | |
| 3254 | - echo json_encode( array('succes'=>false) ); | |
| 3255 | - }else{ | |
| 3858 | + if( is_wp_error( $post_id ) ) { | |
| 3859 | + $logger = new WPStream_Logger(); | |
| 3860 | + $log_entry = new WpStream_Log_Entry([ | |
| 3861 | + 'type' => 'error', | |
| 3862 | + 'description' => 'Couldn\'t create PPV VOD during onboarding because of error: ' . $post_id->get_error_message(), | |
| 3863 | + ]); | |
| 3864 | + $logger->add( $log_entry ); | |
| 3865 | + echo json_encode( array('succes'=>false) ); | |
| 3866 | + } else { | |
| 3256 | 3867 | |
| 3257 | 3868 | $product = wc_get_product($post_id); |
| 3258 | 3869 | $price = wc_format_decimal($vod_price); |
| 3259 | 3870 | |
| @@ -3295,18 +3906,31 @@ | ||
| 3295 | 3906 | check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); |
| 3296 | 3907 | |
| 3297 | 3908 | if(current_user_can('administrator')){ |
| 3298 | 3909 | $username = sanitize_text_field($_POST['api_username']); |
| 3299 | - $password = sanitize_text_field($_POST['api_password']); | |
| 3910 | + $password = $_POST['api_password']; | |
| 3300 | 3911 | update_option('wpstream_api_username',$username); |
| 3301 | 3912 | update_option('wpstream_api_password',$password); |
| 3302 | 3913 | |
| 3303 | 3914 | $token = $this->main->wpstream_live_connection->wpstream_get_token(); |
| 3304 | - | |
| 3305 | - echo json_encode( array( | |
| 3306 | - 'success'=> true, | |
| 3307 | - 'token' => ($token) | |
| 3308 | - )); | |
| 3915 | + $videos_list = $this->main->wpstream_live_connection->wpstream_get_videos(); | |
| 3916 | + // cleanup any previous echo before sending json | |
| 3917 | + ob_end_clean(); | |
| 3918 | + // !DO NOT SEND TOKEN TO THE CLIENT! | |
| 3919 | + if ($token){ | |
| 3920 | + echo json_encode( array( | |
| 3921 | + 'success'=> true | |
| 3922 | + )); | |
| 3923 | + } | |
| 3924 | + else { | |
| 3925 | + $text = get_option('wpstream_curl_failed') ? | |
| 3926 | + 'Login failed with critical error: ' . get_option('wpstream_curl_failed') : | |
| 3927 | + 'Wrong username or password!'; | |
| 3928 | + echo json_encode( array( | |
| 3929 | + 'success'=> false, | |
| 3930 | + 'error' => $text, | |
| 3931 | + )); | |
| 3932 | + } | |
| 3309 | 3933 | |
| 3310 | 3934 | }else{ |
| 3311 | 3935 | echo json_encode( array( |
| 3312 | 3936 | 'success'=> false, |
| @@ -3329,19 +3953,20 @@ | ||
| 3329 | 3953 | * On Boarding login |
| 3330 | 3954 | * |
| 3331 | 3955 | */ |
| 3332 | 3956 | public function wpstream_on_board_register(){ |
| 3333 | - | |
| 3334 | 3957 | check_ajax_referer( 'wpstream_onboarding_nonce', 'security' ); |
| 3335 | 3958 | |
| 3336 | 3959 | if(current_user_can('administrator')){ |
| 3337 | 3960 | $wpstream_register_email = sanitize_text_field($_POST['wpstream_register_email']); |
| 3338 | - $wpstream_register_password = sanitize_text_field($_POST['wpstream_register_password']); | |
| 3961 | + $wpstream_register_password = $_POST['wpstream_register_password']; | |
| 3339 | 3962 | $wpstream_register_captcha = sanitize_text_field($_POST['wpstream_register_captcha']); |
| 3340 | 3963 | $wpstream_register_captcha_id = sanitize_text_field($_POST['wpstream_register_captcha_id']); |
| 3341 | 3964 | |
| 3342 | 3965 | $validate = $this->wpstream_validate_onboard_register($wpstream_register_email,$wpstream_register_password); |
| 3343 | 3966 | if(!$validate['success']){ |
| 3967 | + // cleanup any previous echo before sending json | |
| 3968 | + ob_end_clean(); | |
| 3344 | 3969 | echo json_encode($validate); |
| 3345 | 3970 | die(); |
| 3346 | 3971 | } |
| 3347 | 3972 | |
| @@ -3354,9 +3979,9 @@ | ||
| 3354 | 3979 | ); |
| 3355 | 3980 | |
| 3356 | 3981 | |
| 3357 | 3982 | |
| 3358 | - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields); | |
| 3983 | + $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields,true); | |
| 3359 | 3984 | $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY); |
| 3360 | 3985 | |
| 3361 | 3986 | |
| 3362 | 3987 | |
| @@ -3369,8 +3994,10 @@ | ||
| 3369 | 3994 | update_option('wpstream_api_password',$wpstream_register_password); |
| 3370 | 3995 | |
| 3371 | 3996 | $token = $this->main->wpstream_live_connection->wpstream_get_token(); |
| 3372 | 3997 | |
| 3998 | + // cleanup any previous echo before sending json | |
| 3999 | + ob_end_clean(); | |
| 3373 | 4000 | echo json_encode( array( |
| 3374 | 4001 | 'success' => true, |
| 3375 | 4002 | 'token' => $token , |
| 3376 | 4003 | 'message' => esc_html__('Your Account was created. Please stand by...','wpstream'), |
| @@ -3378,8 +4005,10 @@ | ||
| 3378 | 4005 | )); |
| 3379 | 4006 | die(); |
| 3380 | 4007 | }else{ |
| 3381 | 4008 | |
| 4009 | + // cleanup any previous echo before sending json | |
| 4010 | + ob_end_clean(); | |
| 3382 | 4011 | echo json_encode( array( |
| 3383 | 4012 | 'success'=> false, |
| 3384 | 4013 | 'message'=> $curl_response_decoded['request']['message'], |
| 3385 | 4014 | 'curl'=>$curl_response_decoded, |
| @@ -3391,12 +4020,13 @@ | ||
| 3391 | 4020 | |
| 3392 | 4021 | |
| 3393 | 4022 | |
| 3394 | 4023 | }else{ |
| 3395 | - | |
| 4024 | + // cleanup any previous echo before sending json | |
| 4025 | + ob_end_clean(); | |
| 3396 | 4026 | echo json_encode( array( |
| 3397 | 4027 | 'success'=> false, |
| 3398 | - 'message'=> esc_html__('Register action could not be completed. Please register on wpstream.net','wpstream'), | |
| 4028 | + 'message'=> esc_html__('Registration could not be completed. Please try again or register on wpstream.net','wpstream'), | |
| 3399 | 4029 | |
| 3400 | 4030 | )); |
| 3401 | 4031 | die(); |
| 3402 | 4032 | } |
| @@ -3408,8 +4038,10 @@ | ||
| 3408 | 4038 | |
| 3409 | 4039 | |
| 3410 | 4040 | |
| 3411 | 4041 | }else{ |
| 4042 | + // cleanup any previous echo before sending json | |
| 4043 | + ob_end_clean(); | |
| 3412 | 4044 | echo json_encode( array( |
| 3413 | 4045 | 'success'=> false, |
| 3414 | 4046 | 'message' => esc_html('You are not an administrator','wpstream') |
| 3415 | 4047 | )); |
| @@ -3443,9 +4075,9 @@ | ||
| 3443 | 4075 | |
| 3444 | 4076 | if(filter_var($wpstream_register_email,FILTER_VALIDATE_EMAIL) === false) { |
| 3445 | 4077 | $return= array( |
| 3446 | 4078 | 'success'=> false, |
| 3447 | - 'message' => esc_html('The email doesn\'t look right !','wpstream') | |
| 4079 | + 'message' => esc_html__("The email doesn't look right !",'wpstream') | |
| 3448 | 4080 | ); |
| 3449 | 4081 | return $return;die(); |
| 3450 | 4082 | } |
| 3451 | 4083 | |
| @@ -3453,9 +4085,9 @@ | ||
| 3453 | 4085 | $domain = mb_substr(strrchr($wpstream_register_email, "@"), 1); |
| 3454 | 4086 | if( $domain!='' && !checkdnsrr ($domain) ){ |
| 3455 | 4087 | $return= array( |
| 3456 | 4088 | 'success'=> false, |
| 3457 | - 'message' => esc_html('The email doesn\'t look right !','wpstream') | |
| 4089 | + 'message' => esc_html__("The email doesn't look right !",'wpstream') | |
| 3458 | 4090 | ); |
| 3459 | 4091 | return $return;die(); |
| 3460 | 4092 | } |
| 3461 | 4093 | |
| @@ -3470,5 +4102,144 @@ | ||
| 3470 | 4102 | } |
| 3471 | 4103 | |
| 3472 | 4104 | return $return;die(); |
| 3473 | 4105 | } |
| 3474 | -} | |
| 4106 | + | |
| 4107 | + /** | |
| 4108 | + * Handle the AJAX request to initiate a multipart upload | |
| 4109 | + * | |
| 4110 | + * @since 3.0.1 | |
| 4111 | + */ | |
| 4112 | + public function handle_initiate_multipart_upload() { | |
| 4113 | + // Security check - only admins can do this | |
| 4114 | + if (!current_user_can('administrator')) { | |
| 4115 | + wp_send_json_error('Unauthorized access'); | |
| 4116 | + return; | |
| 4117 | + } | |
| 4118 | + | |
| 4119 | + // Get file details from request | |
| 4120 | + $file_name = sanitize_text_field($_POST['file_name']); | |
| 4121 | + $file_size = intval($_POST['file_size']); | |
| 4122 | + $content_type = sanitize_text_field($_POST['content_type']); | |
| 4123 | + $num_parts = intval($_POST['parts']); | |
| 4124 | + | |
| 4125 | + if (empty($file_name) || $file_size <= 0 || $num_parts <= 0) { | |
| 4126 | + wp_send_json_error('Invalid file information'); | |
| 4127 | + return; | |
| 4128 | + } | |
| 4129 | + | |
| 4130 | + // Prepare a clean filename (similar to the standard upload process) | |
| 4131 | + $file_name_array = explode(".", $file_name); | |
| 4132 | + $file_extension = $file_name_array[count($file_name_array) - 1]; | |
| 4133 | + $temp_file_name = $file_name_array[0]; | |
| 4134 | + $temp_file_name = str_replace(' ', '_', $temp_file_name); | |
| 4135 | + $temp_file_name = preg_replace('/\W/', '', $temp_file_name); | |
| 4136 | + $clean_file_name = $temp_file_name . '.' . $file_extension; | |
| 4137 | + | |
| 4138 | + // Make API call to initiate multipart upload | |
| 4139 | + $url = 'video/upload'; | |
| 4140 | + $access_token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 4141 | + | |
| 4142 | + if (!$access_token) { | |
| 4143 | + wp_send_json_error('Not connected to WPStream service'); | |
| 4144 | + return; | |
| 4145 | + } | |
| 4146 | + | |
| 4147 | + $api_params = array( | |
| 4148 | + 'access_token' => $access_token, | |
| 4149 | + 'size' => $file_size, | |
| 4150 | + 'name' => $clean_file_name, | |
| 4151 | + 'content_type' => $content_type, | |
| 4152 | + 'parts' => $num_parts | |
| 4153 | + ); | |
| 4154 | + | |
| 4155 | + $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true); | |
| 4156 | + $response_data = json_decode($response, true); | |
| 4157 | + | |
| 4158 | + if (!isset($response_data['success']) || $response_data['success'] !== true) { | |
| 4159 | + $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to initiate multipart upload'; | |
| 4160 | + wp_send_json_error($error_message); | |
| 4161 | + return; | |
| 4162 | + } | |
| 4163 | + | |
| 4164 | + // Return the upload ID and pre-signed URLs for each part | |
| 4165 | + wp_send_json_success($response_data); | |
| 4166 | + } | |
| 4167 | + | |
| 4168 | + /** | |
| 4169 | + * Handle the AJAX request to complete a multipart upload | |
| 4170 | + * | |
| 4171 | + * @since 3.0.1 | |
| 4172 | + */ | |
| 4173 | + public function handle_complete_multipart_upload() { | |
| 4174 | + // Security check - only admins can do this | |
| 4175 | + if (!current_user_can('administrator')) { | |
| 4176 | + wp_send_json_error('Unauthorized access'); | |
| 4177 | + return; | |
| 4178 | + } | |
| 4179 | + | |
| 4180 | + // Get completion details | |
| 4181 | + $parts = json_decode(stripslashes($_POST['parts']), true); | |
| 4182 | + $file_name = sanitize_text_field($_POST['file_name']); | |
| 4183 | + $handle = sanitize_text_field($_POST['handle']); | |
| 4184 | + | |
| 4185 | + if (empty($parts) || !is_numeric($parts) || empty($file_name)) { | |
| 4186 | + wp_send_json_error('Invalid completion information'); | |
| 4187 | + return; | |
| 4188 | + } | |
| 4189 | + | |
| 4190 | + // Make API call to complete the multipart upload | |
| 4191 | + $url = 'video/upload'; | |
| 4192 | + $access_token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 4193 | + | |
| 4194 | + if (!$access_token) { | |
| 4195 | + wp_send_json_error('Not connected to WPStream service'); | |
| 4196 | + return; | |
| 4197 | + } | |
| 4198 | + | |
| 4199 | + $api_params = array( | |
| 4200 | + 'access_token' => $access_token, | |
| 4201 | + 'parts' => $parts, | |
| 4202 | + 'name' => $file_name, | |
| 4203 | + 'handle' => $handle, | |
| 4204 | + 'action' => 'complete' | |
| 4205 | + ); | |
| 4206 | + | |
| 4207 | + $response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url, $api_params, true); | |
| 4208 | + $response_data = json_decode($response, true); | |
| 4209 | + | |
| 4210 | + if (!isset($response_data['success']) || $response_data['success'] !== true) { | |
| 4211 | + $error_message = isset($response_data['error']) ? $response_data['error'] : 'Failed to complete multipart upload'; | |
| 4212 | + wp_send_json_error($error_message); | |
| 4213 | + return; | |
| 4214 | + } | |
| 4215 | + | |
| 4216 | + // Return success | |
| 4217 | + wp_send_json_success(); | |
| 4218 | + } | |
| 4219 | + | |
| 4220 | + public function wpstream_settings_tab_update_plugin() { | |
| 4221 | + if ( !current_user_can( 'update_plugins' ) ) { | |
| 4222 | + wp_send_json_error( __( 'Not enough permissions to make this change', 'wpstream' ) ); | |
| 4223 | + } | |
| 4224 | + | |
| 4225 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; | |
| 4226 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; | |
| 4227 | + include_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 4228 | + | |
| 4229 | + $credentials = request_filesystem_credentials(''); | |
| 4230 | + if ( !WP_Filesystem( $credentials ) ) { | |
| 4231 | + wp_send_json_error( __( 'Failed to connect to the filesystem', 'wpstream' ) ); | |
| 4232 | + } | |
| 4233 | + | |
| 4234 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); | |
| 4235 | + $plugin_path = plugin_basename( WPSTREAM_PLUGIN_PATH . 'wpstream.php' ); | |
| 4236 | + $result = $upgrader->upgrade( $plugin_path ); | |
| 4237 | + activate_plugin( $plugin_path ); | |
| 4238 | + | |
| 4239 | + if ( is_wp_error( $result ) ) { | |
| 4240 | + wp_send_json_error( __( 'Update failed due to', 'wpstream' ) . $result->get_error_message() ); | |
| 4241 | + } | |
| 4242 | + | |
| 4243 | + wp_send_json_success(); | |
| 4244 | + } | |
| 4245 | +} | |