[wp-trac] [WordPress Trac] #55563: The function get_allowed_mime_types should check wp_get_current_user

WordPress Trac noreply at wordpress.org
Fri Jun 27 10:18:11 UTC 2025


#55563: The function get_allowed_mime_types should check wp_get_current_user
------------------------------------+------------------------------
 Reporter:  giuse                   |       Owner:  (none)
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Formatting              |     Version:  5.9.3
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |     Focuses:
------------------------------------+------------------------------

Comment (by callumbw95):

 Hi all,
 Just taking a look into this issue as its been sitting for a while, and at
 first glance I think it makes sense to include the check within the
 `current_user_can()` function so as to solve this issue more globally than
 opposed to within this specific edge case. For example:
 {{{#!php
 <?php
 function current_user_can( $capability, ...$args ) {
         if ( !function_exists( "wp_get_current_user" ) ) return false;
         return user_can( wp_get_current_user(), $capability, ...$args );
 }
 }}}
 However can I check where you are calling `get_allowed_mime_types()` as I
 suspect you are calling it prior to the `init` hook. Calling your function
 within this hook, or any of the hooks called post this one will ensure
 that most if not all functions are defined ready for use. @giuse if you
 can expand on where you are calling the function, or where it is failing I
 can expand on my reply here.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55563#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list