[wp-trac] [WordPress Trac] #56849: Modify `_config_wp_home()` and `_config_wp_siteurl()` to become pre_option filters

WordPress Trac noreply at wordpress.org
Mon Jan 23 05:06:03 UTC 2023


#56849: Modify `_config_wp_home()` and `_config_wp_siteurl()` to become pre_option
filters
------------------------------------+---------------------
 Reporter:  flixos90                |       Owner:  (none)
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  6.2
Component:  Options, Meta APIs      |     Version:  2.2
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+---------------------
Changes (by costdev):

 * keywords:  has-patch commit => has-patch dev-feedback


Comment:

 > @peterwilsoncc Both site_url and home_url options are autoloaded, if the
 constants are defined during the install are the options created or left
 out of the options table?

 I applied the changes in the PR, defined both constants and ran a manual
 install (via browser). Both values are added to the options table.

 Regarding the order of operations, from what I can see:
 - `default-filters.php` is included [https://github.com/costdev/wordpress-
 develop/blob/0412d30a33b0e630d2dc4a1657c539147991c8ac/src/wp-
 settings.php#L134 here] (Line 134).
 - `ms-default-filters.php` is included [https://github.com/costdev
 /wordpress-develop/blob/0412d30a33b0e630d2dc4a1657c539147991c8ac/src/wp-
 settings.php#L359 here] (Line 359).
 - MU plugins are included [https://github.com/costdev/wordpress-
 develop/blob/0412d30a33b0e630d2dc4a1657c539147991c8ac/src/wp-
 settings.php#L372 here] (Line 372).
 - Network plugins are included [https://github.com/costdev/wordpress-
 develop/blob/0412d30a33b0e630d2dc4a1657c539147991c8ac/src/wp-
 settings.php#L392 here] (Line 392).
 - Plugins are included [https://github.com/costdev/wordpress-
 develop/blob/0412d30a33b0e630d2dc4a1657c539147991c8ac/src/wp-
 settings.php#L447 here] (Line 447).
 - Theme setup begins [https://github.com/costdev/wordpress-
 develop/blob/0412d30a33b0e630d2dc4a1657c539147991c8ac/src/wp-
 settings.php#L549 here] (Line 549).

 I created a plugin that hooks `pre_option_home` and `pre_option_siteurl`,
 and once the plugin had been loaded and the hooks added, they ran after
 the `_wp_config_home|siteurl()` hooks.

 -----

 However, and I could use a confidence check on this one, if `WP_HOME` or
 `WP_SITEURL` are defined, `get_option()` would now return after
 `pre_option`, so hooks on `option_{$home}` will never run (think
 translations with home/lang_code). That's a BC break unless we apply
 `"option_${option}"` filters for `home` and `siteurl`, right?

 Something like:
 {{{#!php
 // pre_option_{$option}
 // pre_option

 if ( false !== $pre ) {
     if ( 'home' === $option || 'siteurl' === $option ) {
         $pre = apply_filters( "option_{$option}", $value, $option );
     }

     return $pre;
 }
 }}}

 -----

 Removing `commit` while discussion continues.

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


More information about the wp-trac mailing list