If you are working with a WordPress site and getting the dreaded “Sorry, this file type is not permitted for security reasons.” message, fret no more!
WordPress has a config that allows you to enable unfiltered uploads
define( 'ALLOW_UNFILTERED_UPLOADS', true );
This, however, does not always work. Especially on Multisite, which may only allow unfiltered uploads for super admin users. No bueno.
Filters to the rescue!
Drop this code into your project (I put it in mu-plugins) and viola! You will have unfettered uploads.
add_filter( 'user_has_cap', 'unfiltered_upload' );
function unfiltered_upload( $caps )
{
$caps['unfiltered_upload'] = 1;
return $caps;
}
See also this StackExchange message
Find and update WordPress posts with comments older than NNN days
By Ben Lobaugh (blobaugh)
On March 12, 2018
In Computing, MySQL, Programming, Web Development, WordPress
I have a use case where I need to disable comments on posts in WordPress where the last comment was more than one year, or 365 days, ago.
Posts can be found with this query:
The outer query takes the inner query as the search parameter. The inner query is finding the latest comment for each post based on the number in the WHERE condition. 365 represents 365 days, or 1 year.
Therefore, this query is getting the latest comment for post where the comment is less than 1 year old.
Now let’s say you need to update the posts to disable comments. The goal is to disable commenting for all posts that have not had a comment within the last year. It can be accomplished with the following:
Here again the number 365 represents the number of days.
Check the posts and you should see the comments have been closed.