Skip to content

Instantly share code, notes, and snippets.

@bahia0019
Created June 25, 2020 23:07
Show Gist options
  • Save bahia0019/2729f53eb70dc0ac5298688779e24128 to your computer and use it in GitHub Desktop.
Save bahia0019/2729f53eb70dc0ac5298688779e24128 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Remove Video Mimes
* Author: Flaunt Your Site
* Version: 1.0
* Author URI: http://flauntyoursite.com
* Description: Removes Video mime tyoe for all plans except Premium.
*/
function remove_mimes_by_plan_id() {
if ( is_plugin_active_for_network( 'wp-ultimo/wp-ultimo.php' ) ) {
// Get user and Premium plan ID.
$user_id = get_current_user_id();
$plan_id = 52; // Change this based on Ultimo Plan ID.
// If the plan isn't the Premium plan ID, remove all video MIME types.
// Check to see if Ultimo is active.
if ( ! wu_has_plan( $user_id, $plan_id ) || ! is_super_admin( $user_id ) ) {
function remove_video_mime( $mimes ) {
unset( $mimes['asf|asx'] );
unset( $mimes['wmv'] );
unset( $mimes['wmx'] );
unset( $mimes['wm'] );
unset( $mimes['avi'] );
unset( $mimes['divx'] );
unset( $mimes['flv'] );
unset( $mimes['mov|qt'] );
unset( $mimes['mpeg|mpg|mpe'] );
unset( $mimes['mp4|m4v'] );
unset( $mimes['ogv'] );
unset( $mimes['webm'] );
unset( $mimes['mkv'] );
unset( $mimes['3gp|3gpp'] );
unset( $mimes['3g2|3gp2'] );
unset( $mimes['mp3|m4a|m4b'] );
unset( $mimes['aac'] );
unset( $mimes['ra|ram'] );
unset( $mimes['wav'] );
unset( $mimes['ogg|oga'] );
unset( $mimes['flac'] );
unset( $mimes['mid|midi'] );
unset( $mimes['wma'] );
unset( $mimes['wax'] );
return $mimes;
}
add_filter( 'upload_mimes', 'remove_video_mime', 1, 1 );
}
}
}
add_action( 'admin_init', 'remove_mimes_by_plan_id' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment