[wp-trac] [WordPress Trac] #38650: Provide some guidance on what conditionals can/should be used in default-filters.php
WordPress Trac
noreply at wordpress.org
Mon Sep 23 06:35:02 UTC 2024
#38650: Provide some guidance on what conditionals can/should be used in default-
filters.php
----------------------------+---------------------
Reporter: helen | Owner: jorbin
Type: enhancement | Status: closed
Priority: low | Milestone: 6.7
Component: Bootstrap/Load | Version:
Severity: minor | Resolution: fixed
Keywords: has-patch | Focuses:
----------------------------+---------------------
Comment (by kamibaloch1):
This is a great recommendation! The early loading process in default-
filters.php can definitely trip up developers, especially when functions
like get_option() or is_customize_preview() are mistakenly used. Having an
inline comment that explicitly outlines what's safe and unsafe to use
would be invaluable. The distinction between functions in load.php (like
is_admin(), current_user_can()) versus those that rely on query variables
or themes is critical and often overlooked. It’s easy to assume everything
is available at this stage, but the reality is that many functions are
tied to the WordPress lifecycle, which isn't fully loaded at this point.
By adding this kind of documentation directly into the file, we can
prevent a lot of unnecessary confusion and errors. It not only helps
newcomers but also serves as a quick reference for experienced devs who
may not always remember the specifics of WordPress' loading sequence. This
should definitely be considered for a core update or at least mentioned
more prominently in the documentation!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38650#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list