can not upload file .vtt on wordpress 5.0.1

I did some debugging and was able to reproduce and solve the issue, but unfortunately I was not able to figure out the specific cause. Generally speaking, it seems that .vtt files are failing the check performed by wp_check_filetype_and_ext(). I was able to upload .vtt files (Only tested on WP 5.0.1) after creating a simple … Read more

How to force Media manager to overwrite files of same name?

Here is something i cooked up which was taken mainly from the plugin Overwrite Uploads but without the extra stuff add_filter(‘wp_handle_upload_overrides’,’noneUniqueFilename’); function noneUniqueFilename($overrides){ $overrides[‘test_form’] = false; $overrides[‘unique_filename_callback’] = ‘nonUniqueFilenameCallback’; return $overrides; } function nonUniqueFilenameCallback($directory, $name, $extension){ $filename = $name . strtolower($extension); //remove old attachment removeOldAttach($filename); return $filename; } function removeOldAttach($filename){ $arguments = array( ‘numberposts’ => … Read more

media_sideload_image file name?

When I started using media_sideload_image(), I found it pretty useless as it returned a full html tag, instead of the attachment ID, so I created my own version of it which replicates all the functionality of media_sideload_image() and adds some very useful stuff, like: saving the sideloaded file under a completely new filename making the … Read more

Turn off ms-files.php after network setup

In theory: Move images from blogs.dir/SITENUM/files/ to /uploads/SITENUM/ (or make an alias) Edit all sites so they don’t look in /files/ but in /uploads/SITENUM/ .htaccess, remove the ms-files.php line Search/replace each posts table for each site, changing /files/ to /uploads/SITENUM/ A walk-through can be found here (dumping ms-files), this is not a trivial hack! It … Read more

Set a maximum upload count for users on a specific user role

I’m not really sure which is the real problem with code you posted, however I cant understand why use 2 functions when one is enough… add_filter( ‘wp_handle_upload_prefilter’, ‘limit_uploads_for_user_roles’ ); function limit_uploads_for_user_roles( $file ) { $user = wp_get_current_user(); // add the role you want to limit in the array $limit_roles = array(‘contributor’); $filtered = apply_filters( ‘limit_uploads_for_roles’, … Read more

Creating a metabox to upload multiple images, Ignoring The Featured Image

Generally speaking, I would take the approach of querying for post attachments, but withhold the attachment that is the post thumbnail. WP provides a simple way of finding the post thumbnail ID with get_post_thumbnail_id (Codex Ref). To modify the code from the other post, I would add the following parameter to the $args array to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)