[wp-trac] [WordPress Trac] #59000: Add a check for wp_get_current_user to current_user_can

WordPress Trac noreply at wordpress.org
Fri Aug 25 22:08:18 UTC 2023


#59000: Add a check for wp_get_current_user to current_user_can
-------------------------------------+------------------------------
 Reporter:  scruffian                |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Users                    |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  2nd-opinion needs-patch  |     Focuses:
-------------------------------------+------------------------------
Changes (by azaozz):

 * keywords:  has-patch 2nd-opinion => 2nd-opinion needs-patch


Comment:

 At first look https://github.com/WordPress/wordpress-develop/pull/5028
 makes sense: some functions defined in theme-previews.php call functions
 that are defined later, hence the fatal error.

 However this is not the "real" cause. The real cause is that
 [https://core.trac.wordpress.org/browser/tags/6.3/src/wp-includes/theme-
 previews.php#L78 there is "loose" code in theme-previews.php] that should
 not be there. Adding of actions and filters should be in `default-
 filters.php` unless there is a need for a (well documented) exception
 which also limits the use of these actions/filters.

 Moving the file to load later works because these filters and actions run
 later. So the fix here would probably be to move that loose code out of
 `theme-previews.php` and add it to `default-filters.php`. Then there will
 be no need to include that file later.

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


More information about the wp-trac mailing list