validate_file
doesn’t quite work the way you’re expecting it to – it checks if $file
is in the allowed files array, not just its extension/mime type.
You’re looking for wp_check_filetype
. However, all that ultimately does is check the extension (i.e. it doesn’t read the headers of the file/ascertain the mime type otherwise).
Unless you implement your own PHP library for mime checking, it’d be quicker & easier to perform a simple regex check on the filename:
return preg_match( '/\.(mpe?g4?|webm)$/', $file ); // Or similar
Related Posts:
- The the_post_thumbnail without srcset?
- after_setup_theme always runs
- WordPress API Menu/Submenu Order
- What WP folder can I use to write files to?
- Why I can’t add a CSS style in this WordPress theme?
- Allow Shortcode in Theme Customizer
- Where to post/upload the new theme for WordPress theme repository
- register_sidebar ignores ‘id’ and ‘class’
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Add colors to existing color palette without replacing it
- Single Page WordPress Theme – Using page templates
- add_theme_support( ‘custom-header’ ) does not add option menu in dashboard
- Returning Variables back into a template
- new theme permissions don’t allow me to edit
- Which theme foundry has clean coded themes, where code is poetry [closed]
- What page should I use for a contact form?
- Retrieve data using wpdb to use for customizer controls
- How can a Theme Contain no Header File or Footer File?
- Get list of months with posts
- Some translations do not work in my template class
- Does any theme support child theme?
- WordPress not registering Theme Customization Section
- How do I save a wordpress theme’s files and install them on another site?
- How to remove a file included in parent theme with locate_template() via child theme?
- “add_theme_support” for custom footer color?
- qTranslate with my own theme and settings
- Stylesheet not linking
- How to control layout of posts on page?
- Override template file i subfolders
- Theme Development for WordPress Multisite Installation
- Include Parent functions.php in Child Theme functions.php
- Internal error 500 accessing Theme > Customize
- create category on theme setup
- Theme Development: Starter Content after hook
- Is there any WordPress theme for Self Storagae just like Spacer [closed]
- Customizer: save setting/control content to post/page
- WordPress get_template_part() function not working
- Where am I doing wrong in my theme menu?
- How can my theme allow users to take advantage of advanced html tags in posts
- how to get the post attachement image in full size?
- Widget Option is Missing
- Best way to develop a new theme on a live site, with new content? [closed]
- How do I make the most minimal vanilla theme possible with nothing but raw content?
- Can I Set Up Session in WordPress Custom Page
- If you were to start using a WordPress framework today, which one would you use? [closed]
- Set a featured image as a replacement to the header image
- Is it possible to have a theme that uses only one single page?
- Custom theme: How to call archive-post.php for viewing blog posts
- underscores use of the article element on the page template
- Theme Customizer not displaying saved values in wp_head (CSS)
- Adding a gallery to my first theme
- How can I hard code my sidebar?
- Thesis -style Navigation
- How to allow certain PHP functions when using sanitize_callback in the word press customizer
- How can I wrap all blog posts image with
- Issue when posting updates/changes to wordress
- Valid SQL query not returning results
- StoreFront WordPress theme: How can i create a new Home page with Custom design same as template [closed]
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- Create theme for mobile phones and tablets only?
- Never actually adding the action? Or do I have to call the action?
- How to hide custom sidebar on mobile
- Change Image Sizes for Mobile Theme
- Recommended sidebar / content widths
- Theme Checker Text Domain
- Converting a theme to a child theme in a network
- How to copy page/post from one theme to another?
- Not sure how to debug this npm install error. This is a wordpress theme that comes with a built-in gulp/webpack task automation [closed]
- Calling a WP Plugin Function’s Variable in Theme Template [duplicate]
- Why front-page.php doesn’t show content of file instead shows loop
- How to make updatable custom WordPress theme?
- How can I access variables from theme in child theme? [closed]
- Local variable name in setup_postdata()
- How can I not disable my theme when I want to upload a new version of it?
- Are paginated comments required for publishing Themes?
- Child theme menu not appearing in Twenty Seventeen
- How can I fix my theme header for my CSS stylesheet?
- Is hand coding required at all?
- Avoiding do_shortcode() loops
- Creating a Sub Category Template
- Correct was to customise theme using get_theme_mod in scripts
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Custom theme vs theme customization?
- how can I re-utilize and class on a child theme
- Modify comments_popup_link output
- How to figure out which wordpress theme a site was using?
- Can you create a custom page with content in the center already defined?
- How to migrate the menu from the site on my own theme in WordPress?
- Incorrect search results in search.php – issue triggered by using `define(‘BodyID’, ‘search’); the_post();` in search.php
- Flexslider not working for my custom theme WordPress
- What’s the policy for building a theme that doesn’t support widgets/menus?
- RSS feed url showing page not found. How to solve it?
- How to convert that page to a wordpress template? [closed]
- Toolbox theme using printif statement – help needed understanding code block
- php file child theme directory not overriding parent theme php file [duplicate]
- How to Create a Multi Purpose Theme?
- Custom Single Page Portfolio Theme [closed]
- getting id of page
- How do I send out an update for my custom wordpress theme?