Limit user files in media library

function limit_media_files($file) { // Get the current user ID $current_user_id = get_current_user_id(); // Query media files for the current user $media_files = new WP_Query(array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => -1, ‘author’ => $current_user_id )); // Check if…Continue reading

Count and message according to number of user files

function count_user_media_files() { // Check if the current page is the media library $screen = get_current_screen(); if ($screen->id !== ‘upload’) { return; } // Get the current user ID $current_user_id = get_current_user_id(); // Query media files for the current user…Continue reading

change media owner

// Add a custom column in the Media Library list view function custom_media_columns($columns) { // Check if the current user is an administrator if (current_user_can(‘manage_options’)) { $columns[‘change_author’] = ‘Author’; } return $columns; } add_filter(‘manage_media_columns’, ‘custom_media_columns’); // Display the ‘Change Author’…Continue reading

Allow ICO files upload

add_filter( ‘upload_mimes’, function ( $mimes ) { // By default, only administrator users are allowed to add ICO files. // To enable more user types edit or comment the lines below but beware of // the security risks if you…Continue reading

Remove Query Strings From Static Files (exclude login)

function wpcode_snippet_remove_query_strings_split_login( $src ) { $output = preg_split( “/(&ver|?ver)/”, $src ); return $output ? $output[0] : ”; } add_action( ‘init’, function () { if ( ! is_admin() && ! is_login() ) { add_filter( ‘script_loader_src’, ‘wpcode_snippet_remove_query_strings_split_login’, 15 ); add_filter( ‘style_loader_src’, ‘wpcode_snippet_remove_query_strings_split_login’,…Continue reading