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

WordPress Trac noreply at wordpress.org
Mon Sep 11 20:55:23 UTC 2023


#59000: Add a check for wp_get_current_user to current_user_can
-------------------------------------------------+-------------------------
 Reporter:  scruffian                            |       Owner:  azaozz
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.3.2
Component:  Users                                |     Version:  6.3
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing fixed-major                            |
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Replying to [comment:27 okat]:

 > I submitted the PR trying to prevent early function calls by adding a
 notice.

 Thanks!

 I'm actually starting to have some "second thoughts" about this (yea, I
 know it was my idea, sorry). Looking at how `get_stylesheet()` is used in
 core, it's mostly to check the (active) theme, not to actually get the
 path/URI to load the theme assets. It only returns the (filtered) option
 from the options table, nothing else. Seems it should be possible to do
 that at any time.

 The problem in this ticket doesn't seem to be that the `stylesheet` and
 `template` filters may be called too early, but that it is likely they are
 not the best filters for `wp_get_theme_preview_path()` (previewing
 changes/edits to the theme should not be changing what the active theme
 is, right?).

 Thinking that the current patch: attaching the filters late (on
 plugins_loaded) seems like an okay solution, for now. Ideally the way
 `wp_get_theme_preview_path()` is implemented can be improved so it uses
 different filters/hooks.

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


More information about the wp-trac mailing list