[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
Sun Sep 15 20:57:08 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 devspace):

 In the default-filters.php file, which is typically part of WordPress,
 conditionals are used to add, remove, or modify filters and actions
 dynamically, based on specific conditions.

 **
 inline code examle**
 {{{#!php
 <?php
 /**
  * default-filters.php
  *
  * This file is responsible for setting up default filters and actions
 that
  * are essential to WordPress functionality. It's loaded very early in the
  * WordPress initialization process, before many core files are fully
 loaded.
  *
  * Safe to use:
  * - Functions and conditionals defined in load.php (e.g., is_admin(),
 current_user_can())
  * - Low-level core WordPress hooks and actions that don't depend on
 options or settings.
  *
  * Unsafe to use:
  * - get_option(), get_theme_mod(), or anything relying on the options
 table.
  * - Conditional tags like is_singular(), is_page(),
 is_customize_preview(), etc.
  *   that depend on query variables, themes, or customizer data.
  *
  * Important: Use only lightweight conditionals and functions that don't
 require
  * full WordPress initialization. If in doubt, defer more complex logic to
  * later hooks (e.g., after_setup_theme or init).
  */

 }}}

-- 
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