Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'wcfm_form_custom_validation', function( $form_data, $screen ) {
- if( 'product_manage' == $screen ) {
- if( isset( $form_data['is_downloadable'] ) && isset( $form_data['downloadable_files'] ) ) {
- if( !class_exists( 'getID3' ) ) {
- require(ABSPATH.WPINC.'/ID3/getid3.php' );
- }
- foreach( $form_data['downloadable_files'] as $downloadable_file ) {
- $getID3 = new getID3;
- $file = $getID3->analyze( ABSPATH . str_replace( get_site_url(), '', $downloadable_file['file'] ) );
- if( is_array( $file ) && 'mp3' == $file['fileformat'] ) {
- if( isset( $file['audio'] ) && isset( $file['audio']['bitrate'] ) && $file['audio']['bitrate'] < 320*1000 ) {
- $form_data['has_error'] = true;
- $form_data['message'] = __( 'mp3 files should not be less than 320kbps', 'wc-frontend-manager' );
- }
- }
- }
- }
- }
- return $form_data;
- }, 999, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement