[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
Sat Oct 5 21:08:59 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: docs
----------------------------+---------------------
Comment (by ecomzone):
In default-filters.php, you should primarily use conditionals that do not
rely on database calls or context-specific functions. Safe options include
functions and conditionals that are loaded early, typically found in wp-
includes/load.php. Avoid using functions like get_option() or
is_customize_preview() because they rely on WordPress being fully
initialized (which happens later in the boot process).
{{{#!php
<?php
This file is used to add default filters.
Safe to use functions that are loaded early, typically from wp-
includes/load.php.
Avoid using functions that depend on database access (like get_option())
or
contextual functions (like is_customize_preview()).
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38650#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list