[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 07:46: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 asadwatto1):
"You're bringing up a crucial point. The nature of default-filters.php can
indeed be opaque, especially since it's loaded so early in the WordPress
initialization process. Functions like get_option() and
is_customize_preview() depend on query variables or options that aren’t
yet available at that stage, which is why they're unsafe to use there.
Instead, default-filters.php relies on lightweight, low-level functions,
often from load.php (e.g., is_admin(), wp_die(), etc.) that don't depend
on database interactions or the full theme setup.
It would be very helpful to include an inline comment clarifying which
functions are safe (those that deal with basic environment checks) and
which aren't, to prevent confusion. This would not only streamline
development but also minimize the risk of breaking functionality in the
early stages of WordPress loading. Such documentation would provide
clearer guidance on best practices for anyone working within that file.
Thanks for highlighting this issue!"
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38650#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list